summaryrefslogtreecommitdiff
path: root/Source/WebCore/platform/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/platform/graphics')
-rw-r--r--Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp31
-rw-r--r--Source/WebCore/platform/graphics/ANGLEWebKitBridge.h4
-rw-r--r--Source/WebCore/platform/graphics/AudioTrackPrivate.h90
-rw-r--r--Source/WebCore/platform/graphics/BitmapImage.cpp44
-rw-r--r--Source/WebCore/platform/graphics/BitmapImage.h42
-rw-r--r--Source/WebCore/platform/graphics/Color.h9
-rw-r--r--Source/WebCore/platform/graphics/CrossfadeGeneratedImage.cpp13
-rw-r--r--Source/WebCore/platform/graphics/CrossfadeGeneratedImage.h6
-rw-r--r--Source/WebCore/platform/graphics/Extensions3D.h48
-rw-r--r--Source/WebCore/platform/graphics/FloatPoint.cpp21
-rw-r--r--Source/WebCore/platform/graphics/FloatPoint.h29
-rw-r--r--Source/WebCore/platform/graphics/FloatPolygon.cpp234
-rw-r--r--Source/WebCore/platform/graphics/FloatPolygon.h150
-rw-r--r--Source/WebCore/platform/graphics/FloatQuad.cpp50
-rw-r--r--Source/WebCore/platform/graphics/FloatQuad.h5
-rw-r--r--Source/WebCore/platform/graphics/FloatRect.cpp5
-rw-r--r--Source/WebCore/platform/graphics/FloatRect.h38
-rw-r--r--Source/WebCore/platform/graphics/FloatSize.cpp5
-rw-r--r--Source/WebCore/platform/graphics/FloatSize.h22
-rw-r--r--Source/WebCore/platform/graphics/Font.cpp278
-rw-r--r--Source/WebCore/platform/graphics/Font.h49
-rw-r--r--Source/WebCore/platform/graphics/FontCache.cpp255
-rw-r--r--Source/WebCore/platform/graphics/FontCache.h67
-rw-r--r--Source/WebCore/platform/graphics/FontDescription.cpp4
-rw-r--r--Source/WebCore/platform/graphics/FontDescription.h41
-rw-r--r--Source/WebCore/platform/graphics/FontFallbackList.cpp125
-rw-r--r--Source/WebCore/platform/graphics/FontFamily.h86
-rw-r--r--Source/WebCore/platform/graphics/FontFastPath.cpp235
-rw-r--r--Source/WebCore/platform/graphics/FontGenericFamilies.cpp133
-rw-r--r--Source/WebCore/platform/graphics/FontGenericFamilies.h80
-rw-r--r--Source/WebCore/platform/graphics/FontGlyphs.cpp422
-rw-r--r--Source/WebCore/platform/graphics/FontGlyphs.h (renamed from Source/WebCore/platform/graphics/FontFallbackList.h)77
-rw-r--r--Source/WebCore/platform/graphics/FontMetrics.h14
-rw-r--r--Source/WebCore/platform/graphics/FontPlatformData.cpp17
-rw-r--r--Source/WebCore/platform/graphics/FontPlatformData.h66
-rw-r--r--Source/WebCore/platform/graphics/FontSelector.h4
-rw-r--r--Source/WebCore/platform/graphics/GeneratedImage.cpp7
-rw-r--r--Source/WebCore/platform/graphics/GeneratedImage.h12
-rw-r--r--Source/WebCore/platform/graphics/Generator.h47
-rw-r--r--Source/WebCore/platform/graphics/GeneratorGeneratedImage.cpp35
-rw-r--r--Source/WebCore/platform/graphics/GeneratorGeneratedImage.h31
-rw-r--r--Source/WebCore/platform/graphics/GlyphBuffer.h53
-rw-r--r--Source/WebCore/platform/graphics/GlyphMetricsMap.h13
-rw-r--r--Source/WebCore/platform/graphics/GlyphPage.h126
-rw-r--r--Source/WebCore/platform/graphics/GlyphPageTreeNode.cpp32
-rw-r--r--Source/WebCore/platform/graphics/Gradient.cpp74
-rw-r--r--Source/WebCore/platform/graphics/Gradient.h37
-rw-r--r--Source/WebCore/platform/graphics/GraphicsContext.cpp182
-rw-r--r--Source/WebCore/platform/graphics/GraphicsContext.h124
-rw-r--r--Source/WebCore/platform/graphics/GraphicsContext3D.cpp1528
-rw-r--r--Source/WebCore/platform/graphics/GraphicsContext3D.h305
-rw-r--r--Source/WebCore/platform/graphics/GraphicsLayer.cpp113
-rw-r--r--Source/WebCore/platform/graphics/GraphicsLayer.h174
-rw-r--r--Source/WebCore/platform/graphics/GraphicsLayerAnimation.cpp62
-rw-r--r--Source/WebCore/platform/graphics/GraphicsLayerAnimation.h2
-rw-r--r--Source/WebCore/platform/graphics/GraphicsLayerClient.h12
-rw-r--r--Source/WebCore/platform/graphics/GraphicsLayerTransform.cpp15
-rw-r--r--Source/WebCore/platform/graphics/GraphicsTypes.cpp44
-rw-r--r--Source/WebCore/platform/graphics/GraphicsTypes.h4
-rw-r--r--Source/WebCore/platform/graphics/GraphicsTypes3D.h1
-rw-r--r--Source/WebCore/platform/graphics/Icon.h10
-rw-r--r--Source/WebCore/platform/graphics/Image.cpp27
-rw-r--r--Source/WebCore/platform/graphics/Image.h24
-rw-r--r--Source/WebCore/platform/graphics/ImageBuffer.cpp11
-rw-r--r--Source/WebCore/platform/graphics/ImageBuffer.h26
-rw-r--r--Source/WebCore/platform/graphics/ImageBufferData.h8
-rw-r--r--Source/WebCore/platform/graphics/ImageOrientation.cpp15
-rw-r--r--Source/WebCore/platform/graphics/ImageSource.cpp35
-rw-r--r--Source/WebCore/platform/graphics/ImageSource.h18
-rw-r--r--Source/WebCore/platform/graphics/InbandTextTrackPrivate.h102
-rw-r--r--Source/WebCore/platform/graphics/InbandTextTrackPrivateClient.h151
-rw-r--r--Source/WebCore/platform/graphics/IntPoint.h31
-rw-r--r--Source/WebCore/platform/graphics/IntRect.h53
-rw-r--r--Source/WebCore/platform/graphics/IntRectExtent.h112
-rw-r--r--Source/WebCore/platform/graphics/IntSize.h17
-rw-r--r--Source/WebCore/platform/graphics/LayoutPoint.h19
-rw-r--r--Source/WebCore/platform/graphics/LayoutRect.cpp2
-rw-r--r--Source/WebCore/platform/graphics/LayoutRect.h22
-rw-r--r--Source/WebCore/platform/graphics/LayoutSize.h20
-rw-r--r--Source/WebCore/platform/graphics/MediaPlayer.cpp304
-rw-r--r--Source/WebCore/platform/graphics/MediaPlayer.h149
-rw-r--r--Source/WebCore/platform/graphics/MediaPlayerPrivate.h61
-rw-r--r--Source/WebCore/platform/graphics/MediaSourcePrivate.h (renamed from Source/WebCore/platform/graphics/blackberry/skia/ImageBufferDataSkia.h)39
-rw-r--r--Source/WebCore/platform/graphics/NativeImagePtr.h51
-rw-r--r--Source/WebCore/platform/graphics/OpenGLESShims.h2
-rw-r--r--Source/WebCore/platform/graphics/OpenGLShims.cpp13
-rw-r--r--Source/WebCore/platform/graphics/OpenGLShims.h17
-rw-r--r--Source/WebCore/platform/graphics/Path.cpp13
-rw-r--r--Source/WebCore/platform/graphics/Path.h24
-rw-r--r--Source/WebCore/platform/graphics/PathTraversalState.cpp3
-rw-r--r--Source/WebCore/platform/graphics/Pattern.cpp11
-rw-r--r--Source/WebCore/platform/graphics/Pattern.h27
-rw-r--r--Source/WebCore/platform/graphics/PlatformLayer.h19
-rw-r--r--Source/WebCore/platform/graphics/PlatformTextTrack.h112
-rw-r--r--Source/WebCore/platform/graphics/PlatformTextTrackMenu.h60
-rw-r--r--Source/WebCore/platform/graphics/Region.cpp2
-rw-r--r--Source/WebCore/platform/graphics/RoundedRect.cpp97
-rw-r--r--Source/WebCore/platform/graphics/RoundedRect.h5
-rw-r--r--Source/WebCore/platform/graphics/SVGGlyph.cpp2
-rw-r--r--Source/WebCore/platform/graphics/ShadowBlur.cpp60
-rw-r--r--Source/WebCore/platform/graphics/ShadowBlur.h6
-rw-r--r--Source/WebCore/platform/graphics/SimpleFontData.cpp37
-rw-r--r--Source/WebCore/platform/graphics/SimpleFontData.h48
-rw-r--r--Source/WebCore/platform/graphics/SourceBufferPrivate.h (renamed from Source/WebCore/platform/graphics/blackberry/skia/PlatformSupport.h)27
-rw-r--r--Source/WebCore/platform/graphics/SurrogatePairAwareTextIterator.cpp5
-rw-r--r--Source/WebCore/platform/graphics/TextRun.h6
-rw-r--r--Source/WebCore/platform/graphics/TextTrackRepresentation.cpp52
-rw-r--r--Source/WebCore/platform/graphics/TextTrackRepresentation.h67
-rw-r--r--Source/WebCore/platform/graphics/TiledBacking.h34
-rw-r--r--Source/WebCore/platform/graphics/TiledBackingStore.cpp111
-rw-r--r--Source/WebCore/platform/graphics/TiledBackingStore.h17
-rw-r--r--Source/WebCore/platform/graphics/TiledBackingStoreClient.h2
-rw-r--r--Source/WebCore/platform/graphics/VideoTrackPrivate.h90
-rw-r--r--Source/WebCore/platform/graphics/WidthCache.h52
-rw-r--r--Source/WebCore/platform/graphics/WidthIterator.cpp11
-rw-r--r--Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp470
-rw-r--r--Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.h95
-rw-r--r--Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp141
-rw-r--r--Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h82
-rw-r--r--Source/WebCore/platform/graphics/avfoundation/cf/AVFoundationCFSoftLinking.h177
-rw-r--r--Source/WebCore/platform/graphics/avfoundation/cf/CoreMediaSoftLinking.h5
-rw-r--r--Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.cpp183
-rw-r--r--Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.h71
-rw-r--r--Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateLegacyAVCF.cpp128
-rw-r--r--Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateLegacyAVCF.h72
-rw-r--r--Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp520
-rw-r--r--Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h24
-rw-r--r--Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.h72
-rw-r--r--Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.mm203
-rw-r--r--Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateLegacyAVFObjC.h73
-rw-r--r--Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateLegacyAVFObjC.mm138
-rw-r--r--Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h70
-rw-r--r--Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm541
-rw-r--r--Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.h4
-rw-r--r--Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm19
-rw-r--r--Source/WebCore/platform/graphics/blackberry/CanvasLayerWebKitThread.cpp91
-rw-r--r--Source/WebCore/platform/graphics/blackberry/CanvasLayerWebKitThread.h18
-rw-r--r--Source/WebCore/platform/graphics/blackberry/DrawingBufferBlackBerry.cpp35
-rw-r--r--Source/WebCore/platform/graphics/blackberry/EGLImageLayerCompositingThreadClient.cpp86
-rw-r--r--Source/WebCore/platform/graphics/blackberry/EGLImageLayerCompositingThreadClient.h21
-rw-r--r--Source/WebCore/platform/graphics/blackberry/EGLImageLayerWebKitThread.cpp126
-rw-r--r--Source/WebCore/platform/graphics/blackberry/EGLImageLayerWebKitThread.h17
-rw-r--r--Source/WebCore/platform/graphics/blackberry/FloatRectBlackBerry.cpp15
-rw-r--r--Source/WebCore/platform/graphics/blackberry/FontBlackBerry.cpp159
-rw-r--r--Source/WebCore/platform/graphics/blackberry/FontCacheBlackBerry.cpp339
-rw-r--r--Source/WebCore/platform/graphics/blackberry/FontCacheBlackberry.cpp120
-rw-r--r--Source/WebCore/platform/graphics/blackberry/FontCustomPlatformData.h55
-rw-r--r--Source/WebCore/platform/graphics/blackberry/FontCustomPlatformDataBlackBerry.cpp79
-rw-r--r--Source/WebCore/platform/graphics/blackberry/FontPlatformDataBlackBerry.cpp229
-rw-r--r--Source/WebCore/platform/graphics/blackberry/GlyphPageTreeNodeBlackBerry.cpp75
-rw-r--r--Source/WebCore/platform/graphics/blackberry/GradientBlackBerry.cpp134
-rw-r--r--Source/WebCore/platform/graphics/blackberry/GraphicsContext3DBlackBerry.cpp111
-rw-r--r--Source/WebCore/platform/graphics/blackberry/GraphicsContextBlackBerry.cpp460
-rw-r--r--Source/WebCore/platform/graphics/blackberry/GraphicsLayerBlackBerry.cpp78
-rw-r--r--Source/WebCore/platform/graphics/blackberry/GraphicsLayerBlackBerry.h8
-rw-r--r--Source/WebCore/platform/graphics/blackberry/ITypeUtils.h (renamed from Source/WebCore/platform/graphics/cairo/NativeImageCairo.h)29
-rw-r--r--Source/WebCore/platform/graphics/blackberry/ImageBlackBerry.cpp171
-rw-r--r--Source/WebCore/platform/graphics/blackberry/ImageBufferBlackBerry.cpp316
-rw-r--r--Source/WebCore/platform/graphics/blackberry/ImageBufferDataBlackBerry.h47
-rw-r--r--Source/WebCore/platform/graphics/blackberry/InstrumentedPlatformCanvas.h300
-rw-r--r--Source/WebCore/platform/graphics/blackberry/IntRectBlackBerry.cpp2
-rw-r--r--Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.cpp258
-rw-r--r--Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.h49
-rw-r--r--Source/WebCore/platform/graphics/blackberry/LayerCompositingThreadClient.h18
-rw-r--r--Source/WebCore/platform/graphics/blackberry/LayerData.h71
-rw-r--r--Source/WebCore/platform/graphics/blackberry/LayerFilterRenderer.cpp181
-rw-r--r--Source/WebCore/platform/graphics/blackberry/LayerFilterRenderer.h41
-rw-r--r--Source/WebCore/platform/graphics/blackberry/LayerRenderer.cpp633
-rw-r--r--Source/WebCore/platform/graphics/blackberry/LayerRenderer.h74
-rw-r--r--Source/WebCore/platform/graphics/blackberry/LayerRendererClient.h49
-rw-r--r--Source/WebCore/platform/graphics/blackberry/LayerRendererSurface.cpp33
-rw-r--r--Source/WebCore/platform/graphics/blackberry/LayerRendererSurface.h16
-rw-r--r--Source/WebCore/platform/graphics/blackberry/LayerTexture.cpp121
-rw-r--r--Source/WebCore/platform/graphics/blackberry/LayerTexture.h (renamed from Source/WebCore/platform/graphics/blackberry/Texture.h)58
-rw-r--r--Source/WebCore/platform/graphics/blackberry/LayerTile.cpp23
-rw-r--r--Source/WebCore/platform/graphics/blackberry/LayerTile.h28
-rw-r--r--Source/WebCore/platform/graphics/blackberry/LayerTileIndex.h2
-rw-r--r--Source/WebCore/platform/graphics/blackberry/LayerTiler.cpp716
-rw-r--r--Source/WebCore/platform/graphics/blackberry/LayerTiler.h83
-rw-r--r--Source/WebCore/platform/graphics/blackberry/LayerUtilities.h308
-rw-r--r--Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.cpp234
-rw-r--r--Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.h94
-rw-r--r--Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp299
-rw-r--r--Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h21
-rw-r--r--Source/WebCore/platform/graphics/blackberry/PathBlackBerry.cpp285
-rw-r--r--Source/WebCore/platform/graphics/blackberry/PatternBlackBerry.cpp60
-rw-r--r--Source/WebCore/platform/graphics/blackberry/PluginLayerWebKitThread.cpp2
-rw-r--r--Source/WebCore/platform/graphics/blackberry/SimpleFontDataBlackBerry.cpp214
-rw-r--r--Source/WebCore/platform/graphics/blackberry/Texture.cpp202
-rw-r--r--Source/WebCore/platform/graphics/blackberry/TextureCacheCompositingThread.cpp176
-rw-r--r--Source/WebCore/platform/graphics/blackberry/TextureCacheCompositingThread.h47
-rw-r--r--Source/WebCore/platform/graphics/blackberry/VideoLayerWebKitThread.cpp15
-rw-r--r--Source/WebCore/platform/graphics/blackberry/WebGLLayerWebKitThread.cpp9
-rw-r--r--Source/WebCore/platform/graphics/blackberry/WebGLLayerWebKitThread.h1
-rw-r--r--Source/WebCore/platform/graphics/blackberry/skia/PlatformSupport.cpp132
-rw-r--r--Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp536
-rw-r--r--Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h89
-rw-r--r--Source/WebCore/platform/graphics/ca/LayerFlushScheduler.h6
-rw-r--r--Source/WebCore/platform/graphics/ca/PlatformCAAnimation.h5
-rw-r--r--Source/WebCore/platform/graphics/ca/PlatformCAFilters.h (renamed from Source/WebCore/platform/graphics/clutter/PlatformClutterLayerClient.h)43
-rw-r--r--Source/WebCore/platform/graphics/ca/PlatformCALayer.h17
-rw-r--r--Source/WebCore/platform/graphics/ca/mac/LayerFlushSchedulerMac.cpp4
-rw-r--r--Source/WebCore/platform/graphics/ca/mac/LayerPool.mm2
-rw-r--r--Source/WebCore/platform/graphics/ca/mac/PlatformCAAnimationMac.mm177
-rw-r--r--Source/WebCore/platform/graphics/ca/mac/PlatformCAFiltersMac.mm681
-rw-r--r--Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm264
-rw-r--r--Source/WebCore/platform/graphics/ca/mac/TileCache.h140
-rw-r--r--Source/WebCore/platform/graphics/ca/mac/TileCache.mm570
-rw-r--r--Source/WebCore/platform/graphics/ca/mac/TileController.h217
-rw-r--r--Source/WebCore/platform/graphics/ca/mac/TileController.mm1135
-rw-r--r--Source/WebCore/platform/graphics/ca/mac/WebTileLayer.h13
-rw-r--r--Source/WebCore/platform/graphics/ca/mac/WebTileLayer.mm34
-rw-r--r--Source/WebCore/platform/graphics/ca/mac/WebTiledBackingLayer.h (renamed from Source/WebCore/platform/graphics/ca/mac/WebTileCacheLayer.h)18
-rw-r--r--Source/WebCore/platform/graphics/ca/mac/WebTiledBackingLayer.mm (renamed from Source/WebCore/platform/graphics/ca/mac/WebTileCacheLayer.mm)40
-rw-r--r--Source/WebCore/platform/graphics/ca/win/PlatformCAAnimationWin.cpp61
-rw-r--r--Source/WebCore/platform/graphics/ca/win/PlatformCAFiltersWin.cpp (renamed from Source/WebCore/platform/graphics/clutter/GraphicsLayerClutter.h)43
-rw-r--r--Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp34
-rw-r--r--Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp8
-rw-r--r--Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp2
-rw-r--r--Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp51
-rw-r--r--Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp41
-rw-r--r--Source/WebCore/platform/graphics/cairo/CairoUtilities.h1
-rw-r--r--Source/WebCore/platform/graphics/cairo/DrawErrorUnderline.h2
-rw-r--r--Source/WebCore/platform/graphics/cairo/DrawingBufferCairo.cpp58
-rw-r--r--Source/WebCore/platform/graphics/cairo/FontCairo.cpp4
-rw-r--r--Source/WebCore/platform/graphics/cairo/FontCustomPlatformData.h3
-rw-r--r--Source/WebCore/platform/graphics/cairo/GLContext.cpp74
-rw-r--r--Source/WebCore/platform/graphics/cairo/GLContext.h3
-rw-r--r--Source/WebCore/platform/graphics/cairo/GradientCairo.cpp1
-rw-r--r--Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp95
-rw-r--r--Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.cpp12
-rw-r--r--Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.h4
-rw-r--r--Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp127
-rw-r--r--Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp178
-rw-r--r--Source/WebCore/platform/graphics/cairo/ImageBufferDataCairo.h20
-rw-r--r--Source/WebCore/platform/graphics/cairo/ImageCairo.cpp9
-rw-r--r--Source/WebCore/platform/graphics/cairo/NativeImageCairo.cpp50
-rw-r--r--Source/WebCore/platform/graphics/cairo/PathCairo.cpp4
-rw-r--r--Source/WebCore/platform/graphics/cairo/PatternCairo.cpp6
-rw-r--r--Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp38
-rw-r--r--Source/WebCore/platform/graphics/cg/BitmapImageCG.cpp18
-rw-r--r--Source/WebCore/platform/graphics/cg/ColorCG.cpp2
-rw-r--r--Source/WebCore/platform/graphics/cg/FloatPointCG.cpp2
-rw-r--r--Source/WebCore/platform/graphics/cg/FloatRectCG.cpp2
-rw-r--r--Source/WebCore/platform/graphics/cg/FloatSizeCG.cpp2
-rw-r--r--Source/WebCore/platform/graphics/cg/GradientCG.cpp4
-rw-r--r--Source/WebCore/platform/graphics/cg/GraphicsContext3DCG.cpp396
-rw-r--r--Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp453
-rw-r--r--Source/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h2
-rw-r--r--Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp109
-rw-r--r--Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp24
-rw-r--r--Source/WebCore/platform/graphics/cg/ImageCG.cpp22
-rw-r--r--Source/WebCore/platform/graphics/cg/ImageSourceCG.cpp49
-rw-r--r--Source/WebCore/platform/graphics/cg/IntPointCG.cpp2
-rw-r--r--Source/WebCore/platform/graphics/cg/IntRectCG.cpp2
-rw-r--r--Source/WebCore/platform/graphics/cg/IntSizeCG.cpp2
-rw-r--r--Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp8
-rw-r--r--Source/WebCore/platform/graphics/cg/PDFDocumentImage.h7
-rw-r--r--Source/WebCore/platform/graphics/cg/PathCG.cpp15
-rw-r--r--Source/WebCore/platform/graphics/cg/PatternCG.cpp2
-rw-r--r--Source/WebCore/platform/graphics/cg/SubimageCacheWithTimer.cpp116
-rw-r--r--Source/WebCore/platform/graphics/cg/SubimageCacheWithTimer.h104
-rw-r--r--Source/WebCore/platform/graphics/chromium/AnimationTranslationUtil.cpp283
-rw-r--r--Source/WebCore/platform/graphics/chromium/AnimationTranslationUtil.h56
-rw-r--r--Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.cpp238
-rw-r--r--Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.h103
-rw-r--r--Source/WebCore/platform/graphics/chromium/Canvas2DLayerManager.cpp162
-rw-r--r--Source/WebCore/platform/graphics/chromium/Canvas2DLayerManager.h67
-rw-r--r--Source/WebCore/platform/graphics/chromium/CompositorHUDFontAtlas.cpp131
-rw-r--r--Source/WebCore/platform/graphics/chromium/CompositorHUDFontAtlas.h45
-rw-r--r--Source/WebCore/platform/graphics/chromium/CrossProcessFontLoading.h95
-rw-r--r--Source/WebCore/platform/graphics/chromium/CrossProcessFontLoading.mm207
-rw-r--r--Source/WebCore/platform/graphics/chromium/DeferredImageDecoder.cpp237
-rw-r--r--Source/WebCore/platform/graphics/chromium/DeferredImageDecoder.h90
-rw-r--r--Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp254
-rw-r--r--Source/WebCore/platform/graphics/chromium/Extensions3DChromium.h161
-rw-r--r--Source/WebCore/platform/graphics/chromium/FontCacheAndroid.cpp215
-rw-r--r--Source/WebCore/platform/graphics/chromium/FontCacheChromiumLinux.cpp48
-rw-r--r--Source/WebCore/platform/graphics/chromium/FontCacheChromiumWin.cpp636
-rw-r--r--Source/WebCore/platform/graphics/chromium/FontChromiumWin.cpp676
-rw-r--r--Source/WebCore/platform/graphics/chromium/FontPlatformData.h40
-rw-r--r--Source/WebCore/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp234
-rw-r--r--Source/WebCore/platform/graphics/chromium/FontPlatformDataChromiumWin.h160
-rw-r--r--Source/WebCore/platform/graphics/chromium/FontRenderStyle.h77
-rw-r--r--Source/WebCore/platform/graphics/chromium/FontUtilsChromiumWin.cpp453
-rw-r--r--Source/WebCore/platform/graphics/chromium/FontUtilsChromiumWin.h96
-rw-r--r--Source/WebCore/platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp258
-rw-r--r--Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp884
-rw-r--r--Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.h214
-rw-r--r--Source/WebCore/platform/graphics/chromium/IconChromium.cpp58
-rw-r--r--Source/WebCore/platform/graphics/chromium/IconChromiumAndroid.cpp49
-rw-r--r--Source/WebCore/platform/graphics/chromium/ImageBufferDataSkia.h54
-rw-r--r--Source/WebCore/platform/graphics/chromium/ImageChromium.cpp54
-rw-r--r--Source/WebCore/platform/graphics/chromium/ImageDecodingStore.cpp149
-rw-r--r--Source/WebCore/platform/graphics/chromium/ImageDecodingStore.h100
-rw-r--r--Source/WebCore/platform/graphics/chromium/ImageFrameGenerator.cpp153
-rw-r--r--Source/WebCore/platform/graphics/chromium/ImageFrameGenerator.h88
-rw-r--r--Source/WebCore/platform/graphics/chromium/LazyDecodingPixelRef.cpp93
-rw-r--r--Source/WebCore/platform/graphics/chromium/LazyDecodingPixelRef.h71
-rw-r--r--Source/WebCore/platform/graphics/chromium/MediaPlayerPrivateChromium.h49
-rw-r--r--Source/WebCore/platform/graphics/chromium/OpaqueRectTrackingContentLayerDelegate.cpp78
-rw-r--r--Source/WebCore/platform/graphics/chromium/OpaqueRectTrackingContentLayerDelegate.h67
-rw-r--r--Source/WebCore/platform/graphics/chromium/PlatformIcon.h42
-rw-r--r--Source/WebCore/platform/graphics/chromium/ScaledImageFragment.h61
-rw-r--r--Source/WebCore/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp200
-rw-r--r--Source/WebCore/platform/graphics/chromium/SkSizeHash.h86
-rw-r--r--Source/WebCore/platform/graphics/chromium/TextureUploader.h50
-rw-r--r--Source/WebCore/platform/graphics/chromium/TransparencyWin.cpp515
-rw-r--r--Source/WebCore/platform/graphics/chromium/TransparencyWin.h263
-rw-r--r--Source/WebCore/platform/graphics/chromium/UniscribeHelper.cpp1101
-rw-r--r--Source/WebCore/platform/graphics/chromium/UniscribeHelper.h441
-rw-r--r--Source/WebCore/platform/graphics/chromium/UniscribeHelperTextRun.cpp141
-rw-r--r--Source/WebCore/platform/graphics/chromium/UniscribeHelperTextRun.h96
-rw-r--r--Source/WebCore/platform/graphics/chromium/VDMXParser.cpp201
-rw-r--r--Source/WebCore/platform/graphics/chromium/VDMXParser.h40
-rw-r--r--Source/WebCore/platform/graphics/clutter/DrawingBufferClutter.cpp81
-rw-r--r--Source/WebCore/platform/graphics/clutter/GraphicsContext3DClutter.cpp103
-rw-r--r--Source/WebCore/platform/graphics/clutter/GraphicsContext3DPrivate.cpp64
-rw-r--r--Source/WebCore/platform/graphics/clutter/GraphicsContext3DPrivate.h55
-rw-r--r--Source/WebCore/platform/graphics/clutter/GraphicsLayerClutter.cpp81
-rw-r--r--Source/WebCore/platform/graphics/clutter/TransformationMatrixClutter.cpp54
-rw-r--r--Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm115
-rw-r--r--Source/WebCore/platform/graphics/cpu/arm/GraphicsContext3DNEON.h137
-rw-r--r--Source/WebCore/platform/graphics/cpu/arm/filters/FEBlendNEON.h2
-rw-r--r--Source/WebCore/platform/graphics/cpu/arm/filters/NEONHelpers.h2
-rw-r--r--Source/WebCore/platform/graphics/efl/CairoUtilitiesEfl.cpp14
-rw-r--r--Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp158
-rw-r--r--Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp234
-rw-r--r--Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.h50
-rw-r--r--Source/WebCore/platform/graphics/efl/ImageEfl.cpp4
-rw-r--r--Source/WebCore/platform/graphics/egl/GLContextEGL.cpp33
-rw-r--r--Source/WebCore/platform/graphics/egl/GLContextEGL.h3
-rw-r--r--Source/WebCore/platform/graphics/filters/CustomFilterArrayParameter.h8
-rw-r--r--Source/WebCore/platform/graphics/filters/CustomFilterColorParameter.h89
-rw-r--r--Source/WebCore/platform/graphics/filters/CustomFilterCompiledProgram.cpp2
-rw-r--r--Source/WebCore/platform/graphics/filters/CustomFilterConstants.h7
-rw-r--r--Source/WebCore/platform/graphics/filters/CustomFilterGlobalContext.cpp27
-rw-r--r--Source/WebCore/platform/graphics/filters/CustomFilterGlobalContext.h8
-rw-r--r--Source/WebCore/platform/graphics/filters/CustomFilterMeshGenerator.h1
-rw-r--r--Source/WebCore/platform/graphics/filters/CustomFilterOperation.cpp12
-rw-r--r--Source/WebCore/platform/graphics/filters/CustomFilterOperation.h17
-rw-r--r--Source/WebCore/platform/graphics/filters/CustomFilterParameter.h5
-rw-r--r--Source/WebCore/platform/graphics/filters/CustomFilterProgram.cpp12
-rw-r--r--Source/WebCore/platform/graphics/filters/CustomFilterProgram.h14
-rw-r--r--Source/WebCore/platform/graphics/filters/CustomFilterRenderer.cpp44
-rw-r--r--Source/WebCore/platform/graphics/filters/CustomFilterRenderer.h9
-rw-r--r--Source/WebCore/platform/graphics/filters/CustomFilterValidatedProgram.cpp126
-rw-r--r--Source/WebCore/platform/graphics/filters/CustomFilterValidatedProgram.h16
-rw-r--r--Source/WebCore/platform/graphics/filters/DistantLightSource.h5
-rw-r--r--Source/WebCore/platform/graphics/filters/FEBlend.h5
-rw-r--r--Source/WebCore/platform/graphics/filters/FEColorMatrix.cpp46
-rw-r--r--Source/WebCore/platform/graphics/filters/FEColorMatrix.h37
-rw-r--r--Source/WebCore/platform/graphics/filters/FEComponentTransfer.cpp7
-rw-r--r--Source/WebCore/platform/graphics/filters/FEComponentTransfer.h4
-rw-r--r--Source/WebCore/platform/graphics/filters/FEComposite.cpp26
-rw-r--r--Source/WebCore/platform/graphics/filters/FEConvolveMatrix.h1
-rw-r--r--Source/WebCore/platform/graphics/filters/FECustomFilter.cpp27
-rw-r--r--Source/WebCore/platform/graphics/filters/FECustomFilter.h4
-rw-r--r--Source/WebCore/platform/graphics/filters/FEDisplacementMap.cpp30
-rw-r--r--Source/WebCore/platform/graphics/filters/FEDisplacementMap.h3
-rw-r--r--Source/WebCore/platform/graphics/filters/FEFlood.h10
-rw-r--r--Source/WebCore/platform/graphics/filters/FEGaussianBlur.cpp2
-rw-r--r--Source/WebCore/platform/graphics/filters/FEGaussianBlur.h4
-rw-r--r--Source/WebCore/platform/graphics/filters/FELighting.h5
-rw-r--r--Source/WebCore/platform/graphics/filters/FEMerge.h3
-rw-r--r--Source/WebCore/platform/graphics/filters/FEMorphology.h5
-rw-r--r--Source/WebCore/platform/graphics/filters/FilterEffect.cpp93
-rw-r--r--Source/WebCore/platform/graphics/filters/FilterEffect.h31
-rw-r--r--Source/WebCore/platform/graphics/filters/FilterOperation.cpp22
-rw-r--r--Source/WebCore/platform/graphics/filters/FilterOperation.h19
-rw-r--r--Source/WebCore/platform/graphics/filters/FilterOperations.cpp29
-rw-r--r--Source/WebCore/platform/graphics/filters/FilterOperations.h5
-rw-r--r--Source/WebCore/platform/graphics/filters/LightSource.cpp115
-rw-r--r--Source/WebCore/platform/graphics/filters/LightSource.h20
-rw-r--r--Source/WebCore/platform/graphics/filters/PointLightSource.h6
-rw-r--r--Source/WebCore/platform/graphics/filters/SourceGraphic.h2
-rw-r--r--Source/WebCore/platform/graphics/filters/SpotLightSource.h19
-rw-r--r--Source/WebCore/platform/graphics/filters/ValidatedCustomFilterOperation.cpp4
-rw-r--r--Source/WebCore/platform/graphics/filters/ValidatedCustomFilterOperation.h9
-rw-r--r--Source/WebCore/platform/graphics/filters/skia/DropShadowImageFilter.cpp83
-rw-r--r--Source/WebCore/platform/graphics/filters/skia/DropShadowImageFilter.h47
-rw-r--r--Source/WebCore/platform/graphics/filters/skia/FEBlendSkia.cpp103
-rw-r--r--Source/WebCore/platform/graphics/filters/skia/FEColorMatrixSkia.cpp146
-rw-r--r--Source/WebCore/platform/graphics/filters/skia/FEComponentTransferSkia.cpp75
-rw-r--r--Source/WebCore/platform/graphics/filters/skia/FEGaussianBlurSkia.cpp72
-rw-r--r--Source/WebCore/platform/graphics/filters/skia/FELightingSkia.cpp113
-rw-r--r--Source/WebCore/platform/graphics/filters/skia/FEMorphologySkia.cpp77
-rw-r--r--Source/WebCore/platform/graphics/filters/skia/SkiaImageFilterBuilder.cpp266
-rw-r--r--Source/WebCore/platform/graphics/filters/skia/SkiaImageFilterBuilder.h50
-rw-r--r--Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp55
-rw-r--r--Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp2
-rw-r--r--Source/WebCore/platform/graphics/freetype/FontPlatformData.h14
-rw-r--r--Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp38
-rw-r--r--Source/WebCore/platform/graphics/freetype/GlyphPageTreeNodeFreeType.cpp13
-rw-r--r--Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp20
-rw-r--r--Source/WebCore/platform/graphics/freetype/UTF16UChar32Iterator.h (renamed from Source/WebCore/platform/graphics/chromium/LayerPainterChromium.h)52
-rw-r--r--Source/WebCore/platform/graphics/glx/GLContextGLX.cpp22
-rw-r--r--Source/WebCore/platform/graphics/glx/GLContextGLX.h2
-rw-r--r--Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp109
-rw-r--r--Source/WebCore/platform/graphics/gpu/DrawingBuffer.h14
-rw-r--r--Source/WebCore/platform/graphics/gpu/LoopBlinnMathUtils.cpp4
-rw-r--r--Source/WebCore/platform/graphics/gpu/LoopBlinnPathProcessor.cpp1236
-rw-r--r--Source/WebCore/platform/graphics/gpu/LoopBlinnShader.cpp2
-rw-r--r--Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp7
-rw-r--r--Source/WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm11
-rw-r--r--Source/WebCore/platform/graphics/gpu/opencl/FilterContextOpenCL.cpp154
-rw-r--r--Source/WebCore/platform/graphics/gpu/opencl/FilterContextOpenCL.h123
-rw-r--r--Source/WebCore/platform/graphics/gpu/opencl/OpenCLFEColorMatrix.cpp156
-rw-r--r--Source/WebCore/platform/graphics/gpu/opencl/OpenCLFEFlood.cpp (renamed from Source/WebCore/platform/graphics/FontFamily.cpp)43
-rw-r--r--Source/WebCore/platform/graphics/gpu/opencl/OpenCLFEImage.cpp (renamed from Source/WebCore/platform/graphics/chromium/ScaledImageFragment.cpp)32
-rw-r--r--Source/WebCore/platform/graphics/gpu/opencl/OpenCLFEMerge.cpp161
-rw-r--r--Source/WebCore/platform/graphics/gpu/opencl/OpenCLFETurbulence.cpp42
-rw-r--r--Source/WebCore/platform/graphics/gpu/opencl/OpenCLHandle.h34
-rw-r--r--Source/WebCore/platform/graphics/gpu/qt/DrawingBufferQt.cpp59
-rw-r--r--Source/WebCore/platform/graphics/gstreamer/FullscreenVideoControllerGStreamer.cpp156
-rw-r--r--Source/WebCore/platform/graphics/gstreamer/FullscreenVideoControllerGStreamer.h74
-rw-r--r--Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp18
-rw-r--r--Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h4
-rw-r--r--Source/WebCore/platform/graphics/gstreamer/GStreamerGWorld.cpp132
-rw-r--r--Source/WebCore/platform/graphics/gstreamer/GStreamerGWorld.h5
-rw-r--r--Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.cpp5
-rw-r--r--Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.h8
-rw-r--r--Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.cpp117
-rw-r--r--Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.h16
-rw-r--r--Source/WebCore/platform/graphics/gstreamer/ImageGStreamer.h10
-rw-r--r--Source/WebCore/platform/graphics/gstreamer/ImageGStreamerCairo.cpp22
-rw-r--r--Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp1294
-rw-r--r--Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h293
-rw-r--r--Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp669
-rw-r--r--Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h146
-rw-r--r--Source/WebCore/platform/graphics/gstreamer/PlatformVideoWindow.h4
-rw-r--r--Source/WebCore/platform/graphics/gstreamer/PlatformVideoWindowGtk.cpp7
-rw-r--r--Source/WebCore/platform/graphics/gstreamer/PlatformVideoWindowMac.mm2
-rw-r--r--Source/WebCore/platform/graphics/gstreamer/PlatformVideoWindowPrivate.h3
-rw-r--r--Source/WebCore/platform/graphics/gstreamer/PlatformVideoWindowQt.cpp4
-rw-r--r--Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp94
-rw-r--r--Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.h4
-rw-r--r--Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp638
-rw-r--r--Source/WebCore/platform/graphics/gtk/FullscreenVideoControllerGtk.cpp454
-rw-r--r--Source/WebCore/platform/graphics/gtk/FullscreenVideoControllerGtk.h84
-rw-r--r--Source/WebCore/platform/graphics/gtk/ImageBufferGtk.cpp2
-rw-r--r--Source/WebCore/platform/graphics/gtk/ImageGtk.cpp4
-rw-r--r--Source/WebCore/platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp510
-rw-r--r--Source/WebCore/platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.h133
-rw-r--r--Source/WebCore/platform/graphics/harfbuzz/FontHarfBuzz.cpp280
-rw-r--r--Source/WebCore/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.cpp371
-rw-r--r--Source/WebCore/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.h160
-rw-r--r--Source/WebCore/platform/graphics/harfbuzz/HarfBuzzFace.cpp (renamed from Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzNGFace.cpp)33
-rw-r--r--Source/WebCore/platform/graphics/harfbuzz/HarfBuzzFace.h (renamed from Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzNGFace.h)17
-rw-r--r--Source/WebCore/platform/graphics/harfbuzz/HarfBuzzFaceCairo.cpp (renamed from Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzNGFaceCairo.cpp)92
-rw-r--r--Source/WebCore/platform/graphics/harfbuzz/HarfBuzzFaceCoreText.cpp (renamed from Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzNGFaceCoreText.cpp)34
-rw-r--r--Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.cpp (renamed from Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.cpp)279
-rw-r--r--Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.h (renamed from Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.h)34
-rw-r--r--Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaperBase.cpp169
-rw-r--r--Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaperBase.h81
-rw-r--r--Source/WebCore/platform/graphics/harfbuzz/HarfBuzzSkia.cpp274
-rw-r--r--Source/WebCore/platform/graphics/harfbuzz/HarfBuzzSkia.h68
-rw-r--r--Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzNGFaceSkia.cpp197
-rw-r--r--Source/WebCore/platform/graphics/mac/ColorMac.mm12
-rw-r--r--Source/WebCore/platform/graphics/mac/ComplexTextController.cpp47
-rw-r--r--Source/WebCore/platform/graphics/mac/ComplexTextController.h5
-rw-r--r--Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm46
-rw-r--r--Source/WebCore/platform/graphics/mac/FontCacheMac.mm69
-rw-r--r--Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp48
-rw-r--r--Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp104
-rw-r--r--Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h13
-rw-r--r--Source/WebCore/platform/graphics/mac/FontMac.mm124
-rw-r--r--Source/WebCore/platform/graphics/mac/GlyphPageTreeNodeMac.cpp18
-rw-r--r--Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm14
-rw-r--r--Source/WebCore/platform/graphics/mac/GraphicsContextMac.mm4
-rw-r--r--Source/WebCore/platform/graphics/mac/ImageMac.mm6
-rw-r--r--Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h6
-rw-r--r--Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm135
-rw-r--r--Source/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp2
-rw-r--r--Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm79
-rw-r--r--Source/WebCore/platform/graphics/mac/WebGLLayer.mm3
-rw-r--r--Source/WebCore/platform/graphics/mac/WebLayer.h7
-rw-r--r--Source/WebCore/platform/graphics/mac/WebLayer.mm18
-rw-r--r--Source/WebCore/platform/graphics/mac/WebTiledLayer.mm1
-rw-r--r--Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp67
-rw-r--r--Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h5
-rw-r--r--Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp17
-rw-r--r--Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.h2
-rw-r--r--Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.cpp8
-rw-r--r--Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.h1
-rw-r--r--Source/WebCore/platform/graphics/opengl/GLDefs.h37
-rw-r--r--Source/WebCore/platform/graphics/opengl/GLPlatformContext.cpp197
-rw-r--r--Source/WebCore/platform/graphics/opengl/GLPlatformContext.h19
-rw-r--r--Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp119
-rw-r--r--Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h51
-rw-r--r--Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp33
-rw-r--r--Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp45
-rw-r--r--Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp10
-rw-r--r--Source/WebCore/platform/graphics/opentype/OpenTypeVerticalData.cpp2
-rw-r--r--Source/WebCore/platform/graphics/openvg/EGLDisplayOpenVG.cpp455
-rw-r--r--Source/WebCore/platform/graphics/openvg/EGLDisplayOpenVG.h90
-rw-r--r--Source/WebCore/platform/graphics/openvg/EGLUtils.h71
-rw-r--r--Source/WebCore/platform/graphics/openvg/GraphicsContextOpenVG.cpp538
-rw-r--r--Source/WebCore/platform/graphics/openvg/ImageOpenVG.cpp176
-rw-r--r--Source/WebCore/platform/graphics/openvg/PainterOpenVG.cpp1240
-rw-r--r--Source/WebCore/platform/graphics/openvg/PainterOpenVG.h142
-rw-r--r--Source/WebCore/platform/graphics/openvg/PathOpenVG.cpp497
-rw-r--r--Source/WebCore/platform/graphics/openvg/PlatformPathOpenVG.h53
-rw-r--r--Source/WebCore/platform/graphics/openvg/SharedResourceOpenVG.cpp45
-rw-r--r--Source/WebCore/platform/graphics/openvg/SharedResourceOpenVG.h33
-rw-r--r--Source/WebCore/platform/graphics/openvg/SurfaceOpenVG.cpp271
-rw-r--r--Source/WebCore/platform/graphics/openvg/SurfaceOpenVG.h158
-rw-r--r--Source/WebCore/platform/graphics/openvg/TiledImageOpenVG.cpp177
-rw-r--r--Source/WebCore/platform/graphics/openvg/TiledImageOpenVG.h69
-rw-r--r--Source/WebCore/platform/graphics/openvg/VGUtils.cpp235
-rw-r--r--Source/WebCore/platform/graphics/openvg/VGUtils.h115
-rw-r--r--Source/WebCore/platform/graphics/pango/FontCachePango.cpp65
-rw-r--r--Source/WebCore/platform/graphics/pango/FontCustomPlatformDataPango.cpp54
-rw-r--r--Source/WebCore/platform/graphics/pango/FontPango.cpp466
-rw-r--r--Source/WebCore/platform/graphics/pango/FontPlatformData.h106
-rw-r--r--Source/WebCore/platform/graphics/pango/FontPlatformDataPango.cpp277
-rw-r--r--Source/WebCore/platform/graphics/pango/GlyphPageTreeNodePango.cpp98
-rw-r--r--Source/WebCore/platform/graphics/pango/PangoUtilities.cpp84
-rw-r--r--Source/WebCore/platform/graphics/pango/PangoUtilities.h35
-rw-r--r--Source/WebCore/platform/graphics/pango/SimpleFontDataPango.cpp143
-rw-r--r--Source/WebCore/platform/graphics/qt/FontCacheQt.cpp17
-rw-r--r--Source/WebCore/platform/graphics/qt/FontCustomPlatformData.h3
-rw-r--r--Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp2
-rw-r--r--Source/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp5
-rw-r--r--Source/WebCore/platform/graphics/qt/FontQt.cpp48
-rw-r--r--Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp88
-rw-r--r--Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp264
-rw-r--r--Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp13
-rw-r--r--Source/WebCore/platform/graphics/qt/ImageDecoderQt.cpp2
-rw-r--r--Source/WebCore/platform/graphics/qt/ImageQt.cpp15
-rw-r--r--Source/WebCore/platform/graphics/qt/LayoutPointQt.cpp45
-rw-r--r--Source/WebCore/platform/graphics/qt/LayoutRectQt.cpp45
-rw-r--r--Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp16
-rw-r--r--Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.h4
-rw-r--r--Source/WebCore/platform/graphics/qt/SimpleFontDataQt.cpp7
-rw-r--r--Source/WebCore/platform/graphics/qt/StillImageQt.cpp21
-rw-r--r--Source/WebCore/platform/graphics/qt/StillImageQt.h6
-rw-r--r--Source/WebCore/platform/graphics/skia/BitmapImageSingleFrameSkia.cpp47
-rw-r--r--Source/WebCore/platform/graphics/skia/BitmapImageSingleFrameSkia.h86
-rw-r--r--Source/WebCore/platform/graphics/skia/FloatPointSkia.cpp51
-rw-r--r--Source/WebCore/platform/graphics/skia/FloatRectSkia.cpp50
-rw-r--r--Source/WebCore/platform/graphics/skia/FontCacheSkia.cpp189
-rw-r--r--Source/WebCore/platform/graphics/skia/FontCustomPlatformData.cpp212
-rw-r--r--Source/WebCore/platform/graphics/skia/FontCustomPlatformData.h86
-rw-r--r--Source/WebCore/platform/graphics/skia/FontSkia.cpp182
-rw-r--r--Source/WebCore/platform/graphics/skia/GlyphPageTreeNodeSkia.cpp72
-rw-r--r--Source/WebCore/platform/graphics/skia/GradientSkia.cpp191
-rw-r--r--Source/WebCore/platform/graphics/skia/GraphicsContext3DSkia.cpp101
-rw-r--r--Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp1217
-rw-r--r--Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp400
-rw-r--r--Source/WebCore/platform/graphics/skia/ImageSkia.cpp684
-rw-r--r--Source/WebCore/platform/graphics/skia/IntPointSkia.cpp56
-rw-r--r--Source/WebCore/platform/graphics/skia/IntRectSkia.cpp57
-rw-r--r--Source/WebCore/platform/graphics/skia/MemoryInstrumentationSkia.cpp59
-rw-r--r--Source/WebCore/platform/graphics/skia/MemoryInstrumentationSkia.h44
-rw-r--r--Source/WebCore/platform/graphics/skia/NativeImageSkia.cpp191
-rw-r--r--Source/WebCore/platform/graphics/skia/NativeImageSkia.h146
-rw-r--r--Source/WebCore/platform/graphics/skia/OpaqueRegionSkia.cpp439
-rw-r--r--Source/WebCore/platform/graphics/skia/OpaqueRegionSkia.h100
-rw-r--r--Source/WebCore/platform/graphics/skia/PathSkia.cpp313
-rw-r--r--Source/WebCore/platform/graphics/skia/PatternSkia.cpp122
-rw-r--r--Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp633
-rw-r--r--Source/WebCore/platform/graphics/skia/PlatformContextSkia.h464
-rw-r--r--Source/WebCore/platform/graphics/skia/PlatformGraphics.h37
-rw-r--r--Source/WebCore/platform/graphics/skia/SimpleFontDataSkia.cpp282
-rw-r--r--Source/WebCore/platform/graphics/skia/SkiaFontWin.cpp296
-rw-r--r--Source/WebCore/platform/graphics/skia/SkiaFontWin.h97
-rw-r--r--Source/WebCore/platform/graphics/skia/SkiaUtils.cpp168
-rw-r--r--Source/WebCore/platform/graphics/skia/SkiaUtils.h82
-rw-r--r--Source/WebCore/platform/graphics/skia/TransformationMatrixSkia.cpp78
-rw-r--r--Source/WebCore/platform/graphics/surfaces/GraphicsSurface.cpp8
-rw-r--r--Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h7
-rw-r--r--Source/WebCore/platform/graphics/surfaces/efl/GLTransportSurface.cpp263
-rw-r--r--Source/WebCore/platform/graphics/surfaces/efl/GLTransportSurface.h81
-rw-r--r--Source/WebCore/platform/graphics/surfaces/efl/GraphicsSurfaceCommon.cpp270
-rw-r--r--Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.cpp230
-rw-r--r--Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.h71
-rw-r--r--Source/WebCore/platform/graphics/surfaces/egl/EGLContext.cpp159
-rw-r--r--Source/WebCore/platform/graphics/surfaces/egl/EGLContext.h55
-rw-r--r--Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.cpp176
-rw-r--r--Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.h49
-rw-r--r--Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp170
-rw-r--r--Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.h71
-rw-r--r--Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.cpp333
-rw-r--r--Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.h89
-rw-r--r--Source/WebCore/platform/graphics/surfaces/glx/GLXConfigSelector.h211
-rw-r--r--Source/WebCore/platform/graphics/surfaces/glx/GLXContext.cpp52
-rw-r--r--Source/WebCore/platform/graphics/surfaces/glx/GLXContext.h27
-rw-r--r--Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp273
-rw-r--r--Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.h261
-rw-r--r--Source/WebCore/platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp (renamed from Source/WebCore/platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp)377
-rw-r--r--Source/WebCore/platform/graphics/surfaces/glx/OwnPtrX11.h66
-rw-r--r--Source/WebCore/platform/graphics/surfaces/glx/X11Helper.cpp343
-rw-r--r--Source/WebCore/platform/graphics/surfaces/glx/X11Helper.h76
-rw-r--r--Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp16
-rw-r--r--Source/WebCore/platform/graphics/surfaces/win/GraphicsSurfaceWin.cpp10
-rw-r--r--Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp431
-rw-r--r--Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h103
-rw-r--r--Source/WebCore/platform/graphics/texmap/TextureMapper.cpp6
-rw-r--r--Source/WebCore/platform/graphics/texmap/TextureMapper.h43
-rw-r--r--Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.cpp195
-rw-r--r--Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.h75
-rw-r--r--Source/WebCore/platform/graphics/texmap/TextureMapperFPSCounter.cpp67
-rw-r--r--Source/WebCore/platform/graphics/texmap/TextureMapperFPSCounter.h (renamed from Source/WebCore/platform/graphics/qt/LayoutSizeQt.cpp)48
-rw-r--r--Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp985
-rw-r--r--Source/WebCore/platform/graphics/texmap/TextureMapperGL.h92
-rw-r--r--Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.cpp47
-rw-r--r--Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.h15
-rw-r--r--Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp809
-rw-r--r--Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h226
-rw-r--r--Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayer.h27
-rw-r--r--Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.cpp533
-rw-r--r--Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.cpp382
-rw-r--r--Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.h (renamed from Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.h)85
-rw-r--r--Source/WebCore/platform/graphics/texmap/TextureMapperSurfaceBackingStore.cpp54
-rw-r--r--Source/WebCore/platform/graphics/texmap/TextureMapperSurfaceBackingStore.h55
-rw-r--r--Source/WebCore/platform/graphics/texmap/TextureMapperTile.cpp79
-rw-r--r--Source/WebCore/platform/graphics/texmap/TextureMapperTile.h60
-rw-r--r--Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.cpp162
-rw-r--r--Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.h64
-rw-r--r--Source/WebCore/platform/graphics/texmap/coordinated/AreaAllocator.cpp335
-rw-r--r--Source/WebCore/platform/graphics/texmap/coordinated/AreaAllocator.h112
-rw-r--r--Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.cpp434
-rw-r--r--Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.h168
-rw-r--r--Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedBackingStore.cpp194
-rw-r--r--Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedBackingStore.h90
-rw-r--r--Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedCustomFilterOperation.h66
-rw-r--r--Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedCustomFilterProgram.h67
-rw-r--r--Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp1255
-rw-r--r--Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h264
-rw-r--r--Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp781
-rw-r--r--Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h209
-rw-r--r--Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h212
-rw-r--r--Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedImageBacking.cpp182
-rw-r--r--Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedImageBacking.h95
-rw-r--r--Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedSurface.cpp54
-rw-r--r--Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedSurface.h76
-rw-r--r--Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedTile.cpp144
-rw-r--r--Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedTile.h99
-rw-r--r--Source/WebCore/platform/graphics/texmap/coordinated/SurfaceUpdateInfo.h51
-rw-r--r--Source/WebCore/platform/graphics/texmap/coordinated/ThreadSafeCoordinatedSurface.cpp76
-rw-r--r--Source/WebCore/platform/graphics/texmap/coordinated/ThreadSafeCoordinatedSurface.h54
-rw-r--r--Source/WebCore/platform/graphics/texmap/coordinated/UpdateAtlas.cpp116
-rw-r--r--Source/WebCore/platform/graphics/texmap/coordinated/UpdateAtlas.h78
-rw-r--r--Source/WebCore/platform/graphics/transforms/AffineTransform.cpp1
-rw-r--r--Source/WebCore/platform/graphics/transforms/AffineTransform.h18
-rw-r--r--Source/WebCore/platform/graphics/transforms/RotateTransformOperation.cpp16
-rw-r--r--Source/WebCore/platform/graphics/transforms/TransformState.cpp92
-rw-r--r--Source/WebCore/platform/graphics/transforms/TransformState.h23
-rw-r--r--Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp267
-rw-r--r--Source/WebCore/platform/graphics/transforms/TransformationMatrix.h35
-rw-r--r--Source/WebCore/platform/graphics/transforms/TranslateTransformOperation.cpp13
-rw-r--r--Source/WebCore/platform/graphics/win/DIBPixelData.cpp4
-rw-r--r--Source/WebCore/platform/graphics/win/FontCacheWin.cpp23
-rw-r--r--Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp122
-rw-r--r--Source/WebCore/platform/graphics/win/FontCustomPlatformData.h3
-rw-r--r--Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp61
-rw-r--r--Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h56
-rw-r--r--Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp7
-rw-r--r--Source/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp5
-rw-r--r--Source/WebCore/platform/graphics/win/FontPlatformDataWin.cpp1
-rw-r--r--Source/WebCore/platform/graphics/win/FontWin.cpp2
-rw-r--r--Source/WebCore/platform/graphics/win/FullScreenController.cpp3
-rw-r--r--Source/WebCore/platform/graphics/win/FullScreenControllerClient.h2
-rw-r--r--Source/WebCore/platform/graphics/win/GL/glext.h13146
-rw-r--r--Source/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp6
-rw-r--r--Source/WebCore/platform/graphics/win/IconWin.cpp2
-rw-r--r--Source/WebCore/platform/graphics/win/ImageCGWin.cpp8
-rw-r--r--Source/WebCore/platform/graphics/win/ImageCairoWin.cpp20
-rw-r--r--Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp2
-rw-r--r--Source/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp11
-rw-r--r--Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp2
-rw-r--r--Source/WebCore/platform/graphics/win/WKCAImageQueue.cpp2
-rw-r--r--Source/WebCore/platform/graphics/wince/FontCacheWinCE.cpp61
-rw-r--r--Source/WebCore/platform/graphics/wince/FontCustomPlatformData.cpp2
-rw-r--r--Source/WebCore/platform/graphics/wince/FontCustomPlatformData.h3
-rw-r--r--Source/WebCore/platform/graphics/wince/FontPlatformData.cpp2
-rw-r--r--Source/WebCore/platform/graphics/wince/FontWinCE.cpp4
-rw-r--r--Source/WebCore/platform/graphics/wince/GlyphPageTreeNodeWinCE.cpp4
-rw-r--r--Source/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp93
-rw-r--r--Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp19
-rw-r--r--Source/WebCore/platform/graphics/wince/ImageWinCE.cpp14
-rw-r--r--Source/WebCore/platform/graphics/wince/MediaPlayerProxy.cpp4
-rw-r--r--Source/WebCore/platform/graphics/wince/MediaPlayerProxy.h3
-rw-r--r--Source/WebCore/platform/graphics/wince/SharedBitmap.cpp6
-rw-r--r--Source/WebCore/platform/graphics/wince/SharedBitmap.h4
-rw-r--r--Source/WebCore/platform/graphics/wince/SimpleFontDataWinCE.cpp8
-rw-r--r--Source/WebCore/platform/graphics/wx/ColorWx.cpp44
-rw-r--r--Source/WebCore/platform/graphics/wx/FloatRectWx.cpp47
-rw-r--r--Source/WebCore/platform/graphics/wx/FontCacheWx.cpp115
-rw-r--r--Source/WebCore/platform/graphics/wx/FontCustomPlatformData.cpp49
-rw-r--r--Source/WebCore/platform/graphics/wx/FontCustomPlatformData.h50
-rw-r--r--Source/WebCore/platform/graphics/wx/FontPlatformData.h191
-rw-r--r--Source/WebCore/platform/graphics/wx/FontPlatformDataWx.cpp183
-rw-r--r--Source/WebCore/platform/graphics/wx/FontPlatformDataWxMac.mm143
-rw-r--r--Source/WebCore/platform/graphics/wx/FontWx.cpp196
-rw-r--r--Source/WebCore/platform/graphics/wx/GlyphMapWx.cpp59
-rw-r--r--Source/WebCore/platform/graphics/wx/GradientWx.cpp107
-rw-r--r--Source/WebCore/platform/graphics/wx/GraphicsContextWx.cpp828
-rw-r--r--Source/WebCore/platform/graphics/wx/IconWx.cpp47
-rw-r--r--Source/WebCore/platform/graphics/wx/ImageBufferDataWx.h54
-rw-r--r--Source/WebCore/platform/graphics/wx/ImageBufferWx.cpp179
-rw-r--r--Source/WebCore/platform/graphics/wx/ImageWx.cpp292
-rw-r--r--Source/WebCore/platform/graphics/wx/IntPointWx.cpp45
-rw-r--r--Source/WebCore/platform/graphics/wx/IntRectWx.cpp45
-rw-r--r--Source/WebCore/platform/graphics/wx/IntSizeWx.cpp45
-rw-r--r--Source/WebCore/platform/graphics/wx/PathWx.cpp255
-rw-r--r--Source/WebCore/platform/graphics/wx/SimpleFontDataWx.cpp185
-rw-r--r--Source/WebCore/platform/graphics/wx/TransformationMatrixWx.cpp70
709 files changed, 47570 insertions, 46577 deletions
diff --git a/Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp b/Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp
index 9a034bd91..9876c9f04 100644
--- a/Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp
+++ b/Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp
@@ -32,9 +32,16 @@
namespace WebCore {
-inline static int getValidationResultValue(const ShHandle compiler, ShShaderInfo shaderInfo)
+// Temporary typedef to support an incompatible change in the ANGLE API.
+#if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108
+typedef int ANGLEGetInfoType;
+#else
+typedef size_t ANGLEGetInfoType;
+#endif
+
+inline static ANGLEGetInfoType getValidationResultValue(const ShHandle compiler, ShShaderInfo shaderInfo)
{
- int value = -1;
+ ANGLEGetInfoType value = 0;
ShGetInfo(compiler, shaderInfo, &value);
return value;
}
@@ -55,15 +62,13 @@ static bool getSymbolInfo(ShHandle compiler, ShShaderInfo symbolType, Vector<ANG
return false;
}
- int numSymbols = getValidationResultValue(compiler, symbolType);
- if (numSymbols < 0)
- return false;
+ ANGLEGetInfoType numSymbols = getValidationResultValue(compiler, symbolType);
- int maxNameLength = getValidationResultValue(compiler, symbolMaxNameLengthType);
+ ANGLEGetInfoType maxNameLength = getValidationResultValue(compiler, symbolMaxNameLengthType);
if (maxNameLength <= 1)
return false;
- int maxMappedNameLength = getValidationResultValue(compiler, SH_MAPPED_NAME_MAX_LENGTH);
+ ANGLEGetInfoType maxMappedNameLength = getValidationResultValue(compiler, SH_MAPPED_NAME_MAX_LENGTH);
if (maxMappedNameLength <= 1)
return false;
@@ -71,9 +76,9 @@ static bool getSymbolInfo(ShHandle compiler, ShShaderInfo symbolType, Vector<ANG
Vector<char, 256> nameBuffer(maxNameLength);
Vector<char, 256> mappedNameBuffer(maxMappedNameLength);
- for (int i = 0; i < numSymbols; ++i) {
+ for (ANGLEGetInfoType i = 0; i < numSymbols; ++i) {
ANGLEShaderSymbol symbol;
- int nameLength = -1;
+ ANGLEGetInfoType nameLength = 0;
switch (symbolType) {
case SH_ACTIVE_ATTRIBUTES:
symbol.symbolType = SHADER_SYMBOL_TYPE_ATTRIBUTE;
@@ -87,7 +92,7 @@ static bool getSymbolInfo(ShHandle compiler, ShShaderInfo symbolType, Vector<ANG
ASSERT_NOT_REACHED();
return false;
}
- if (nameLength <= 0)
+ if (!nameLength)
return false;
// The ShGetActive* calls above are guaranteed to produce null-terminated strings for
@@ -184,12 +189,6 @@ bool ANGLEWebKitBridge::compileShaderSource(const char* shaderSource, ANGLEShade
const char* const shaderSourceStrings[] = { shaderSource };
-#if !PLATFORM(CHROMIUM)
- // Chromium does not use the ANGLE bundled in WebKit source, and thus
- // does not yet have the symbol SH_CLAMP_INDIRECT_ARRAY_BOUNDS.
- extraCompileOptions |= SH_CLAMP_INDIRECT_ARRAY_BOUNDS;
-#endif
-
bool validateSuccess = ShCompile(compiler, shaderSourceStrings, 1, SH_OBJECT_CODE | SH_ATTRIBUTES_UNIFORMS | extraCompileOptions);
if (!validateSuccess) {
int logSize = getValidationResultValue(compiler, SH_INFO_LOG_LENGTH);
diff --git a/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h b/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h
index 52f71dd3f..83c2e004c 100644
--- a/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h
+++ b/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h
@@ -29,8 +29,10 @@
#include <wtf/text/CString.h>
#include <wtf/text/WTFString.h>
-#if !PLATFORM(GTK) && !PLATFORM(EFL) && !PLATFORM(BLACKBERRY) && !PLATFORM(CHROMIUM) && !PLATFORM(QT)
+#if !PLATFORM(GTK) && !PLATFORM(EFL) && !PLATFORM(BLACKBERRY) && !PLATFORM(QT) && !PLATFORM(WIN)
#include "ANGLE/ShaderLang.h"
+#elif PLATFORM(WIN)
+#include "GLSLANG/ShaderLang.h"
#else
#include "ShaderLang.h"
#endif
diff --git a/Source/WebCore/platform/graphics/AudioTrackPrivate.h b/Source/WebCore/platform/graphics/AudioTrackPrivate.h
new file mode 100644
index 000000000..afd917a37
--- /dev/null
+++ b/Source/WebCore/platform/graphics/AudioTrackPrivate.h
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef AudioTrackPrivate_h
+#define AudioTrackPrivate_h
+
+#include <wtf/Forward.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/RefCounted.h>
+#include <wtf/text/AtomicString.h>
+
+#if ENABLE(VIDEO_TRACK)
+
+namespace WebCore {
+
+class AudioTrackPrivate;
+
+class AudioTrackPrivateClient {
+public:
+ virtual ~AudioTrackPrivateClient() { }
+ virtual void willRemoveAudioTrackPrivate(AudioTrackPrivate*) = 0;
+};
+
+class AudioTrackPrivate : public RefCounted<AudioTrackPrivate> {
+ WTF_MAKE_NONCOPYABLE(AudioTrackPrivate); WTF_MAKE_FAST_ALLOCATED;
+public:
+ static PassRefPtr<AudioTrackPrivate> create()
+ {
+ return adoptRef(new AudioTrackPrivate());
+ }
+ virtual ~AudioTrackPrivate() { }
+
+ void setClient(AudioTrackPrivateClient* client) { m_client = client; }
+ AudioTrackPrivateClient* client() { return m_client; }
+
+ virtual void setEnabled(bool enabled) { m_enabled = enabled; };
+ virtual bool enabled() const { return m_enabled; }
+
+ enum Kind { Alternative, Description, Main, MainDesc, Translation, Commentary, None };
+ virtual Kind kind() const { return None; }
+
+ virtual AtomicString id() const { return emptyAtom; }
+ virtual AtomicString label() const { return emptyAtom; }
+ virtual AtomicString language() const { return emptyAtom; }
+
+ virtual int audioTrackIndex() const { return 0; }
+
+ void willBeRemoved()
+ {
+ if (m_client)
+ m_client->willRemoveAudioTrackPrivate(this);
+ }
+
+protected:
+ AudioTrackPrivate()
+ : m_enabled(false)
+ {
+ }
+
+private:
+ AudioTrackPrivateClient* m_client;
+ bool m_enabled;
+};
+
+} // namespace WebCore
+
+#endif
+#endif
diff --git a/Source/WebCore/platform/graphics/BitmapImage.cpp b/Source/WebCore/platform/graphics/BitmapImage.cpp
index def072ee0..07610d2d8 100644
--- a/Source/WebCore/platform/graphics/BitmapImage.cpp
+++ b/Source/WebCore/platform/graphics/BitmapImage.cpp
@@ -31,10 +31,8 @@
#include "ImageObserver.h"
#include "IntRect.h"
#include "MIMETypeRegistry.h"
-#include "PlatformMemoryInstrumentation.h"
#include "Timer.h"
#include <wtf/CurrentTime.h>
-#include <wtf/MemoryInstrumentationVector.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
@@ -298,7 +296,7 @@ bool BitmapImage::ensureFrameIsCached(size_t index)
return true;
}
-NativeImagePtr BitmapImage::frameAtIndex(size_t index)
+PassNativeImagePtr BitmapImage::frameAtIndex(size_t index)
{
if (!ensureFrameIsCached(index))
return 0;
@@ -307,19 +305,19 @@ NativeImagePtr BitmapImage::frameAtIndex(size_t index)
bool BitmapImage::frameIsCompleteAtIndex(size_t index)
{
- if (!ensureFrameIsCached(index))
- return false;
- return m_frames[index].m_isComplete;
+ if (index < m_frames.size() && m_frames[index].m_haveMetadata && m_frames[index].m_isComplete)
+ return true;
+ return m_source.frameIsCompleteAtIndex(index);
}
float BitmapImage::frameDurationAtIndex(size_t index)
{
- if (!ensureFrameIsCached(index))
- return 0;
- return m_frames[index].m_duration;
+ if (index < m_frames.size() && m_frames[index].m_haveMetadata)
+ return m_frames[index].m_duration;
+ return m_source.frameDurationAtIndex(index);
}
-NativeImagePtr BitmapImage::nativeImageForCurrentFrame()
+PassNativeImagePtr BitmapImage::nativeImageForCurrentFrame()
{
return frameAtIndex(currentFrame());
}
@@ -335,9 +333,9 @@ bool BitmapImage::frameHasAlphaAtIndex(size_t index)
return m_source.frameHasAlphaAtIndex(index);
}
-bool BitmapImage::currentFrameHasAlpha()
+bool BitmapImage::currentFrameKnownToBeOpaque()
{
- return frameHasAlphaAtIndex(currentFrame());
+ return !frameHasAlphaAtIndex(currentFrame());
}
ImageOrientation BitmapImage::currentFrameOrientation()
@@ -572,26 +570,10 @@ Color BitmapImage::solidColor() const
{
return m_solidColor;
}
-
-void BitmapImage::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
-{
- MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Image);
- Image::reportMemoryUsage(memoryObjectInfo);
- info.addMember(m_source);
- info.addMember(m_frameTimer);
- info.addMember(m_frames);
-}
-
-void FrameData::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+
+bool BitmapImage::canAnimate()
{
- MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Image);
-#if OS(WINCE) && !PLATFORM(QT)
- info.addRawBuffer(m_frame.get(), m_frameBytes);
-#elif USE(SKIA)
- info.addMember(m_frame);
-#else
- info.addRawBuffer(m_frame, m_frameBytes);
-#endif
+ return shouldAnimate() && frameCount() > 1;
}
}
diff --git a/Source/WebCore/platform/graphics/BitmapImage.h b/Source/WebCore/platform/graphics/BitmapImage.h
index a9f649a60..752fe4464 100644
--- a/Source/WebCore/platform/graphics/BitmapImage.h
+++ b/Source/WebCore/platform/graphics/BitmapImage.h
@@ -43,10 +43,6 @@ OBJC_CLASS NSImage;
typedef struct HBITMAP__ *HBITMAP;
#endif
-#if PLATFORM(WX)
-class wxBitmap;
-#endif
-
namespace WebCore {
struct FrameData;
}
@@ -88,8 +84,6 @@ public:
// Returns whether there was cached image data to clear.
bool clear(bool clearMetadata);
- void reportMemoryUsage(MemoryObjectInfo*) const;
-
NativeImagePtr m_frame;
ImageOrientation m_orientation;
float m_duration;
@@ -109,7 +103,7 @@ class BitmapImage : public Image {
friend class GeneratorGeneratedImage;
friend class GraphicsContext;
public:
- static PassRefPtr<BitmapImage> create(NativeImagePtr nativeImage, ImageObserver* observer = 0)
+ static PassRefPtr<BitmapImage> create(PassNativeImagePtr nativeImage, ImageObserver* observer = 0)
{
return adoptRef(new BitmapImage(nativeImage, observer));
}
@@ -154,21 +148,11 @@ public:
#if PLATFORM(WIN) || (PLATFORM(QT) && OS(WINDOWS))
static PassRefPtr<BitmapImage> create(HBITMAP);
#endif
-#if PLATFORM(WX)
- static PassRefPtr<BitmapImage> create(const wxBitmap& bitmap)
- {
- return adoptRef(new BitmapImage(bitmap));
- }
-#endif
#if PLATFORM(WIN)
virtual bool getHBITMAP(HBITMAP);
virtual bool getHBITMAPOfSize(HBITMAP, LPSIZE);
#endif
-#if USE(CAIRO)
- static PassRefPtr<BitmapImage> create(cairo_surface_t*);
-#endif
-
#if PLATFORM(GTK)
virtual GdkPixbuf* getGdkPixbuf();
#endif
@@ -177,16 +161,17 @@ public:
virtual Evas_Object* getEvasObject(Evas*);
#endif
- virtual NativeImagePtr nativeImageForCurrentFrame();
- virtual bool currentFrameHasAlpha();
+ virtual PassNativeImagePtr nativeImageForCurrentFrame() OVERRIDE;
+
+ virtual bool currentFrameKnownToBeOpaque() OVERRIDE;
ImageOrientation currentFrameOrientation();
#if !ASSERT_DISABLED
virtual bool notSolidColor();
#endif
-
- void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
+
+ bool canAnimate();
private:
void updateSize() const;
@@ -198,28 +183,25 @@ protected:
Certain // The repetition count is known to be correct.
};
- BitmapImage(NativeImagePtr, ImageObserver* = 0);
+ BitmapImage(PassNativeImagePtr, ImageObserver* = 0);
BitmapImage(ImageObserver* = 0);
-#if PLATFORM(WX)
- BitmapImage(const wxBitmap&);
-#endif
#if PLATFORM(WIN)
virtual void drawFrameMatchingSourceSize(GraphicsContext*, const FloatRect& dstRect, const IntSize& srcSize, ColorSpace styleColorSpace, CompositeOperator);
#endif
- virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator);
-#if USE(CG) || PLATFORM(CHROMIUM) || USE(CAIRO)
- virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, RespectImageOrientationEnum) OVERRIDE;
+ virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode);
+#if USE(CG) || USE(CAIRO) || PLATFORM(BLACKBERRY)
+ virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode, RespectImageOrientationEnum) OVERRIDE;
#endif
-#if (OS(WINCE) && !PLATFORM(QT))
+#if USE(WINGDI)
virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform,
const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect);
#endif
size_t currentFrame() const { return m_currentFrame; }
virtual size_t frameCount();
- NativeImagePtr frameAtIndex(size_t);
+ PassNativeImagePtr frameAtIndex(size_t);
bool frameIsCompleteAtIndex(size_t);
float frameDurationAtIndex(size_t);
bool frameHasAlphaAtIndex(size_t);
diff --git a/Source/WebCore/platform/graphics/Color.h b/Source/WebCore/platform/graphics/Color.h
index 9e4ce8c11..8fe100a19 100644
--- a/Source/WebCore/platform/graphics/Color.h
+++ b/Source/WebCore/platform/graphics/Color.h
@@ -50,10 +50,6 @@ typedef struct _GdkRGBA GdkRGBA;
#endif
#endif
-#if PLATFORM(WX)
-class wxColour;
-#endif
-
namespace WebCore {
class Color;
@@ -147,11 +143,6 @@ public:
#endif
#endif
-#if PLATFORM(WX)
- Color(const wxColour&);
- operator wxColour() const;
-#endif
-
#if USE(CG)
Color(CGColorRef);
#endif
diff --git a/Source/WebCore/platform/graphics/CrossfadeGeneratedImage.cpp b/Source/WebCore/platform/graphics/CrossfadeGeneratedImage.cpp
index df51b32ae..1f41aa6fa 100644
--- a/Source/WebCore/platform/graphics/CrossfadeGeneratedImage.cpp
+++ b/Source/WebCore/platform/graphics/CrossfadeGeneratedImage.cpp
@@ -29,7 +29,6 @@
#include "FloatRect.h"
#include "GraphicsContext.h"
#include "ImageBuffer.h"
-#include "PlatformMemoryInstrumentation.h"
using namespace std;
@@ -81,7 +80,7 @@ void CrossfadeGeneratedImage::drawCrossfade(GraphicsContext* context)
context->endTransparencyLayer();
}
-void CrossfadeGeneratedImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace, CompositeOperator compositeOp)
+void CrossfadeGeneratedImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace, CompositeOperator compositeOp, BlendMode)
{
GraphicsContextStateSaver stateSaver(*context);
context->setCompositeOperation(compositeOp);
@@ -94,7 +93,7 @@ void CrossfadeGeneratedImage::draw(GraphicsContext* context, const FloatRect& ds
drawCrossfade(context);
}
-void CrossfadeGeneratedImage::drawPattern(GraphicsContext* context, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator compositeOp, const FloatRect& dstRect)
+void CrossfadeGeneratedImage::drawPattern(GraphicsContext* context, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator compositeOp, const FloatRect& dstRect, BlendMode)
{
OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(m_size, 1, ColorSpaceDeviceRGB, context->isAcceleratedContext() ? Accelerated : Unaccelerated);
if (!imageBuffer)
@@ -108,12 +107,4 @@ void CrossfadeGeneratedImage::drawPattern(GraphicsContext* context, const FloatR
imageBuffer->drawPattern(context, srcRect, patternTransform, phase, styleColorSpace, compositeOp, dstRect);
}
-void CrossfadeGeneratedImage::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
-{
- MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Image);
- GeneratedImage::reportMemoryUsage(memoryObjectInfo);
- info.addMember(m_fromImage);
- info.addMember(m_toImage);
-}
-
}
diff --git a/Source/WebCore/platform/graphics/CrossfadeGeneratedImage.h b/Source/WebCore/platform/graphics/CrossfadeGeneratedImage.h
index 9db9589b6..f1da2ca14 100644
--- a/Source/WebCore/platform/graphics/CrossfadeGeneratedImage.h
+++ b/Source/WebCore/platform/graphics/CrossfadeGeneratedImage.h
@@ -50,11 +50,9 @@ public:
virtual IntSize size() const { return m_crossfadeSize; }
- void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
-
protected:
- virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator);
- virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& dstRect);
+ virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode);
+ virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& dstRect, BlendMode);
CrossfadeGeneratedImage(Image* fromImage, Image* toImage, float percentage, IntSize crossfadeSize, const IntSize&);
diff --git a/Source/WebCore/platform/graphics/Extensions3D.h b/Source/WebCore/platform/graphics/Extensions3D.h
index 2f4c12c03..3bed46fd2 100644
--- a/Source/WebCore/platform/graphics/Extensions3D.h
+++ b/Source/WebCore/platform/graphics/Extensions3D.h
@@ -53,6 +53,7 @@ public:
// GL_EXT_packed_depth_stencil / GL_OES_packed_depth_stencil
// GL_ANGLE_framebuffer_blit / GL_ANGLE_framebuffer_multisample
// GL_OES_texture_float
+ // GL_OES_texture_half_float
// GL_OES_standard_derivatives
// GL_OES_rgb8_rgba8
// GL_OES_vertex_array_object
@@ -70,6 +71,7 @@ public:
// GL_EXT_debug_marker
// GL_CHROMIUM_copy_texture
// GL_CHROMIUM_flipy
+ // GL_ARB_draw_buffers / GL_EXT_draw_buffers
// Takes full name of extension; for example,
// "GL_EXT_texture_format_BGRA8888".
@@ -141,6 +143,11 @@ public:
COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02,
COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03,
+ // GL_AMD_compressed_ATC_texture
+ COMPRESSED_ATC_RGB_AMD = 0x8C92,
+ COMPRESSED_ATC_RGBA_EXPLICIT_ALPHA_AMD = 0x8C93,
+ COMPRESSED_ATC_RGBA_INTERPOLATED_ALPHA_AMD = 0x87EE,
+
// GL_EXT_texture_filter_anisotropic
TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE,
MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF,
@@ -150,7 +157,43 @@ public:
// GL_CHROMIUM_copy_texture
UNPACK_PREMULTIPLY_ALPHA_CHROMIUM = 0x9241,
- UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM = 0x9242
+ UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM = 0x9242,
+
+ // GL_ARB_draw_buffers / GL_EXT_draw_buffers
+ MAX_DRAW_BUFFERS_EXT = 0x8824,
+ DRAW_BUFFER0_EXT = 0x8825,
+ DRAW_BUFFER1_EXT = 0x8826,
+ DRAW_BUFFER2_EXT = 0x8827,
+ DRAW_BUFFER3_EXT = 0x8828,
+ DRAW_BUFFER4_EXT = 0x8829,
+ DRAW_BUFFER5_EXT = 0x882A,
+ DRAW_BUFFER6_EXT = 0x882B,
+ DRAW_BUFFER7_EXT = 0x882C,
+ DRAW_BUFFER8_EXT = 0x882D,
+ DRAW_BUFFER9_EXT = 0x882E,
+ DRAW_BUFFER10_EXT = 0x882F,
+ DRAW_BUFFER11_EXT = 0x8830,
+ DRAW_BUFFER12_EXT = 0x8831,
+ DRAW_BUFFER13_EXT = 0x8832,
+ DRAW_BUFFER14_EXT = 0x8833,
+ DRAW_BUFFER15_EXT = 0x8834,
+ MAX_COLOR_ATTACHMENTS_EXT = 0x8CDF,
+ COLOR_ATTACHMENT0_EXT = 0x8CE0,
+ COLOR_ATTACHMENT1_EXT = 0x8CE1,
+ COLOR_ATTACHMENT2_EXT = 0x8CE2,
+ COLOR_ATTACHMENT3_EXT = 0x8CE3,
+ COLOR_ATTACHMENT4_EXT = 0x8CE4,
+ COLOR_ATTACHMENT5_EXT = 0x8CE5,
+ COLOR_ATTACHMENT6_EXT = 0x8CE6,
+ COLOR_ATTACHMENT7_EXT = 0x8CE7,
+ COLOR_ATTACHMENT8_EXT = 0x8CE8,
+ COLOR_ATTACHMENT9_EXT = 0x8CE9,
+ COLOR_ATTACHMENT10_EXT = 0x8CEA,
+ COLOR_ATTACHMENT11_EXT = 0x8CEB,
+ COLOR_ATTACHMENT12_EXT = 0x8CEC,
+ COLOR_ATTACHMENT13_EXT = 0x8CED,
+ COLOR_ATTACHMENT14_EXT = 0x8CEE,
+ COLOR_ATTACHMENT15_EXT = 0x8CEF
};
// GL_ARB_robustness
@@ -190,6 +233,9 @@ public:
virtual void pushGroupMarkerEXT(const String&) = 0;
virtual void popGroupMarkerEXT(void) = 0;
+ // GL_ARB_draw_buffers / GL_EXT_draw_buffers
+ virtual void drawBuffersEXT(GC3Dsizei n, const GC3Denum* bufs) = 0;
+
virtual bool isNVIDIA() = 0;
virtual bool isAMD() = 0;
virtual bool isIntel() = 0;
diff --git a/Source/WebCore/platform/graphics/FloatPoint.cpp b/Source/WebCore/platform/graphics/FloatPoint.cpp
index d7a00ea5b..2795ab33c 100644
--- a/Source/WebCore/platform/graphics/FloatPoint.cpp
+++ b/Source/WebCore/platform/graphics/FloatPoint.cpp
@@ -30,8 +30,6 @@
#include "AffineTransform.h"
#include "FloatConversion.h"
#include "IntPoint.h"
-#include "LayoutPoint.h"
-#include "LayoutSize.h"
#include "TransformationMatrix.h"
#include <limits>
#include <math.h>
@@ -42,10 +40,6 @@ FloatPoint::FloatPoint(const IntPoint& p) : m_x(p.x()), m_y(p.y())
{
}
-FloatPoint::FloatPoint(const LayoutPoint& p) : m_x(p.x()), m_y(p.y())
-{
-}
-
void FloatPoint::normalize()
{
float tempLength = length();
@@ -56,21 +50,14 @@ void FloatPoint::normalize()
}
}
-float FloatPoint::length() const
-{
- return sqrtf(lengthSquared());
-}
-
-void FloatPoint::move(const LayoutSize& size)
+float FloatPoint::slopeAngleRadians() const
{
- m_x += size.width();
- m_y += size.height();
+ return atan2f(m_y, m_x);
}
-void FloatPoint::moveBy(const LayoutPoint& point)
+float FloatPoint::length() const
{
- m_x += point.x();
- m_y += point.y();
+ return sqrtf(lengthSquared());
}
FloatPoint FloatPoint::matrixTransform(const AffineTransform& transform) const
diff --git a/Source/WebCore/platform/graphics/FloatPoint.h b/Source/WebCore/platform/graphics/FloatPoint.h
index 70d62bbcf..a656c3a26 100644
--- a/Source/WebCore/platform/graphics/FloatPoint.h
+++ b/Source/WebCore/platform/graphics/FloatPoint.h
@@ -39,11 +39,11 @@ class FloatPoint;
}
#endif
-#if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM)
+#if USE(CG)
typedef struct CGPoint CGPoint;
#endif
-#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))
+#if PLATFORM(MAC)
#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
typedef struct CGPoint NSPoint;
#else
@@ -58,25 +58,18 @@ class QPointF;
QT_END_NAMESPACE
#endif
-#if USE(SKIA)
-struct SkPoint;
-#endif
-
namespace WebCore {
class AffineTransform;
class TransformationMatrix;
class IntPoint;
class IntSize;
-class LayoutPoint;
-class LayoutSize;
class FloatPoint {
public:
FloatPoint() : m_x(0), m_y(0) { }
FloatPoint(float x, float y) : m_x(x), m_y(y) { }
FloatPoint(const IntPoint&);
- FloatPoint(const LayoutPoint&);
explicit FloatPoint(const FloatSize& size) : m_x(size.width()), m_y(size.height()) { }
static FloatPoint zero() { return FloatPoint(); }
@@ -103,7 +96,6 @@ public:
m_x += a.width();
m_y += a.height();
}
- void move(const LayoutSize&);
void move(const FloatSize& a)
{
m_x += a.width();
@@ -114,7 +106,6 @@ public:
m_x += a.x();
m_y += a.y();
}
- void moveBy(const LayoutPoint&);
void moveBy(const FloatPoint& a)
{
m_x += a.x();
@@ -133,6 +124,7 @@ public:
return m_x * a.x() + m_y * a.y();
}
+ float slopeAngleRadians() const;
float length() const;
float lengthSquared() const
{
@@ -149,13 +141,12 @@ public:
return FloatPoint(m_y, m_x);
}
-#if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM)
+#if USE(CG)
FloatPoint(const CGPoint&);
operator CGPoint() const;
#endif
-#if (PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))) \
- && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
+#if PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
FloatPoint(const NSPoint&);
operator NSPoint() const;
#endif
@@ -170,11 +161,6 @@ public:
operator BlackBerry::Platform::FloatPoint() const;
#endif
-#if USE(SKIA)
- operator SkPoint() const;
- FloatPoint(const SkPoint&);
-#endif
-
FloatPoint matrixTransform(const TransformationMatrix&) const;
FloatPoint matrixTransform(const AffineTransform&) const;
@@ -262,6 +248,11 @@ inline IntSize flooredIntSize(const FloatPoint& p)
return IntSize(clampToInteger(floorf(p.x())), clampToInteger(floorf(p.y())));
}
+inline FloatSize toFloatSize(const FloatPoint& a)
+{
+ return FloatSize(a.x(), a.y());
+}
+
float findSlope(const FloatPoint& p1, const FloatPoint& p2, float& c);
// Find point where lines through the two pairs of points intersect. Returns false if the lines don't intersect.
diff --git a/Source/WebCore/platform/graphics/FloatPolygon.cpp b/Source/WebCore/platform/graphics/FloatPolygon.cpp
new file mode 100644
index 000000000..510684015
--- /dev/null
+++ b/Source/WebCore/platform/graphics/FloatPolygon.cpp
@@ -0,0 +1,234 @@
+/*
+ * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "FloatPolygon.h"
+
+#include <wtf/MathExtras.h>
+
+namespace WebCore {
+
+static inline float determinant(const FloatSize& a, const FloatSize& b)
+{
+ return a.width() * b.height() - a.height() * b.width();
+}
+
+static inline bool areCollinearPoints(const FloatPoint& p0, const FloatPoint& p1, const FloatPoint& p2)
+{
+ return !determinant(p1 - p0, p2 - p0);
+}
+
+static inline bool areCoincidentPoints(const FloatPoint& p0, const FloatPoint& p1)
+{
+ return p0.x() == p1.x() && p0.y() == p1.y();
+}
+
+static inline bool isPointOnLineSegment(const FloatPoint& vertex1, const FloatPoint& vertex2, const FloatPoint& point)
+{
+ return point.x() >= std::min(vertex1.x(), vertex2.x())
+ && point.x() <= std::max(vertex1.x(), vertex2.x())
+ && areCollinearPoints(vertex1, vertex2, point);
+}
+
+static inline unsigned nextVertexIndex(unsigned vertexIndex, unsigned nVertices, bool clockwise)
+{
+ return ((clockwise) ? vertexIndex + 1 : vertexIndex - 1 + nVertices) % nVertices;
+}
+
+static unsigned findNextEdgeVertexIndex(const FloatPolygon& polygon, unsigned vertexIndex1, bool clockwise)
+{
+ unsigned nVertices = polygon.numberOfVertices();
+ unsigned vertexIndex2 = nextVertexIndex(vertexIndex1, nVertices, clockwise);
+
+ while (vertexIndex2 && areCoincidentPoints(polygon.vertexAt(vertexIndex1), polygon.vertexAt(vertexIndex2)))
+ vertexIndex2 = nextVertexIndex(vertexIndex2, nVertices, clockwise);
+
+ while (vertexIndex2) {
+ unsigned vertexIndex3 = nextVertexIndex(vertexIndex2, nVertices, clockwise);
+ if (!areCollinearPoints(polygon.vertexAt(vertexIndex1), polygon.vertexAt(vertexIndex2), polygon.vertexAt(vertexIndex3)))
+ break;
+ vertexIndex2 = vertexIndex3;
+ }
+
+ return vertexIndex2;
+}
+
+FloatPolygon::FloatPolygon(PassOwnPtr<Vector<FloatPoint> > vertices, WindRule fillRule)
+ : m_vertices(vertices)
+ , m_fillRule(fillRule)
+{
+ unsigned nVertices = numberOfVertices();
+ m_edges.resize(nVertices);
+ m_empty = nVertices < 3;
+
+ if (nVertices)
+ m_boundingBox.setLocation(vertexAt(0));
+
+ if (m_empty)
+ return;
+
+ unsigned minVertexIndex = 0;
+ for (unsigned i = 1; i < nVertices; ++i) {
+ const FloatPoint& vertex = vertexAt(i);
+ if (vertex.y() < vertexAt(minVertexIndex).y() || (vertex.y() == vertexAt(minVertexIndex).y() && vertex.x() < vertexAt(minVertexIndex).x()))
+ minVertexIndex = i;
+ }
+ FloatPoint nextVertex = vertexAt((minVertexIndex + 1) % nVertices);
+ FloatPoint prevVertex = vertexAt((minVertexIndex + nVertices - 1) % nVertices);
+ bool clockwise = determinant(vertexAt(minVertexIndex) - prevVertex, nextVertex - prevVertex) > 0;
+
+ unsigned edgeIndex = 0;
+ unsigned vertexIndex1 = 0;
+ do {
+ m_boundingBox.extend(vertexAt(vertexIndex1));
+ unsigned vertexIndex2 = findNextEdgeVertexIndex(*this, vertexIndex1, clockwise);
+ m_edges[edgeIndex].m_polygon = this;
+ m_edges[edgeIndex].m_vertexIndex1 = vertexIndex1;
+ m_edges[edgeIndex].m_vertexIndex2 = vertexIndex2;
+ m_edges[edgeIndex].m_edgeIndex = edgeIndex;
+ ++edgeIndex;
+ vertexIndex1 = vertexIndex2;
+ } while (vertexIndex1);
+
+ if (edgeIndex > 3) {
+ const FloatPolygonEdge& firstEdge = m_edges[0];
+ const FloatPolygonEdge& lastEdge = m_edges[edgeIndex - 1];
+ if (areCollinearPoints(lastEdge.vertex1(), lastEdge.vertex2(), firstEdge.vertex2())) {
+ m_edges[0].m_vertexIndex1 = lastEdge.m_vertexIndex1;
+ edgeIndex--;
+ }
+ }
+
+ m_edges.resize(edgeIndex);
+ m_empty = m_edges.size() < 3;
+
+ if (m_empty)
+ return;
+
+ for (unsigned i = 0; i < m_edges.size(); ++i) {
+ FloatPolygonEdge* edge = &m_edges[i];
+ m_edgeTree.add(EdgeInterval(edge->minY(), edge->maxY(), edge));
+ }
+}
+
+bool FloatPolygon::overlappingEdges(float minY, float maxY, Vector<const FloatPolygonEdge*>& result) const
+{
+ Vector<FloatPolygon::EdgeInterval> overlappingEdgeIntervals;
+ m_edgeTree.allOverlaps(FloatPolygon::EdgeInterval(minY, maxY, 0), overlappingEdgeIntervals);
+ unsigned overlappingEdgeIntervalsSize = overlappingEdgeIntervals.size();
+ result.resize(overlappingEdgeIntervalsSize);
+ for (unsigned i = 0; i < overlappingEdgeIntervalsSize; ++i) {
+ const FloatPolygonEdge* edge = static_cast<const FloatPolygonEdge*>(overlappingEdgeIntervals[i].data());
+ ASSERT(edge);
+ result[i] = edge;
+ }
+ return overlappingEdgeIntervalsSize > 0;
+}
+
+static inline float leftSide(const FloatPoint& vertex1, const FloatPoint& vertex2, const FloatPoint& point)
+{
+ return ((point.x() - vertex1.x()) * (vertex2.y() - vertex1.y())) - ((vertex2.x() - vertex1.x()) * (point.y() - vertex1.y()));
+}
+
+bool FloatPolygon::contains(const FloatPoint& point) const
+{
+ if (!m_boundingBox.contains(point))
+ return false;
+
+ int windingNumber = 0;
+ for (unsigned i = 0; i < numberOfEdges(); ++i) {
+ const FloatPoint& vertex1 = edgeAt(i).vertex1();
+ const FloatPoint& vertex2 = edgeAt(i).vertex2();
+ if (isPointOnLineSegment(vertex1, vertex2, point))
+ return true;
+ if (vertex2.y() < point.y()) {
+ if ((vertex1.y() > point.y()) && (leftSide(vertex1, vertex2, point) > 0))
+ ++windingNumber;
+ } else if (vertex2.y() > point.y()) {
+ if ((vertex1.y() <= point.y()) && (leftSide(vertex1, vertex2, point) < 0))
+ --windingNumber;
+ }
+ }
+
+ return windingNumber;
+}
+
+bool VertexPair::overlapsRect(const FloatRect& rect) const
+{
+ bool boundsOverlap = (minX() < rect.maxX()) && (maxX() > rect.x()) && (minY() < rect.maxY()) && (maxY() > rect.y());
+ if (!boundsOverlap)
+ return false;
+
+ float leftSideValues[4] = {
+ leftSide(vertex1(), vertex2(), rect.minXMinYCorner()),
+ leftSide(vertex1(), vertex2(), rect.maxXMinYCorner()),
+ leftSide(vertex1(), vertex2(), rect.minXMaxYCorner()),
+ leftSide(vertex1(), vertex2(), rect.maxXMaxYCorner())
+ };
+
+ int currentLeftSideSign = 0;
+ for (unsigned i = 0; i < 4; ++i) {
+ if (!leftSideValues[i])
+ continue;
+ int leftSideSign = leftSideValues[i] > 0 ? 1 : -1;
+ if (!currentLeftSideSign)
+ currentLeftSideSign = leftSideSign;
+ else if (currentLeftSideSign != leftSideSign)
+ return true;
+ }
+
+ return false;
+}
+
+bool VertexPair::intersection(const VertexPair& other, FloatPoint& point) const
+{
+ // See: http://paulbourke.net/geometry/pointlineplane/, "Intersection point of two lines in 2 dimensions"
+
+ const FloatSize& thisDelta = vertex2() - vertex1();
+ const FloatSize& otherDelta = other.vertex2() - other.vertex1();
+ float denominator = determinant(thisDelta, otherDelta);
+ if (!denominator)
+ return false;
+
+ // The two line segments: "this" vertex1,vertex2 and "other" vertex1,vertex2, have been defined
+ // in parametric form. Each point on the line segment is: vertex1 + u * (vertex2 - vertex1),
+ // when 0 <= u <= 1. We're computing the values of u for each line at their intersection point.
+
+ const FloatSize& vertex1Delta = vertex1() - other.vertex1();
+ float uThisLine = determinant(otherDelta, vertex1Delta) / denominator;
+ float uOtherLine = determinant(thisDelta, vertex1Delta) / denominator;
+
+ if (uThisLine < 0 || uOtherLine < 0 || uThisLine > 1 || uOtherLine > 1)
+ return false;
+
+ point = vertex1() + uThisLine * thisDelta;
+ return true;
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/FloatPolygon.h b/Source/WebCore/platform/graphics/FloatPolygon.h
new file mode 100644
index 000000000..8defe1400
--- /dev/null
+++ b/Source/WebCore/platform/graphics/FloatPolygon.h
@@ -0,0 +1,150 @@
+/*
+ * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef FloatPolygon_h
+#define FloatPolygon_h
+
+#include "FloatPoint.h"
+#include "FloatRect.h"
+#include "PODIntervalTree.h"
+#include "WindRule.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class FloatPolygonEdge;
+
+// This class is used by PODIntervalTree for debugging.
+#ifndef NDEBUG
+template <class> struct ValueToString;
+#endif
+
+class FloatPolygon {
+public:
+ FloatPolygon(PassOwnPtr<Vector<FloatPoint> > vertices, WindRule fillRule);
+
+ const FloatPoint& vertexAt(unsigned index) const { return (*m_vertices)[index]; }
+ unsigned numberOfVertices() const { return m_vertices->size(); }
+
+ WindRule fillRule() const { return m_fillRule; }
+
+ const FloatPolygonEdge& edgeAt(unsigned index) const { return m_edges[index]; }
+ unsigned numberOfEdges() const { return m_edges.size(); }
+
+ FloatRect boundingBox() const { return m_boundingBox; }
+ bool overlappingEdges(float minY, float maxY, Vector<const FloatPolygonEdge*>& result) const;
+ bool contains(const FloatPoint&) const;
+ bool isEmpty() const { return m_empty; }
+
+private:
+ typedef PODInterval<float, FloatPolygonEdge*> EdgeInterval;
+ typedef PODIntervalTree<float, FloatPolygonEdge*> EdgeIntervalTree;
+
+ OwnPtr<Vector<FloatPoint> > m_vertices;
+ WindRule m_fillRule;
+ FloatRect m_boundingBox;
+ bool m_empty;
+ Vector<FloatPolygonEdge> m_edges;
+ EdgeIntervalTree m_edgeTree; // Each EdgeIntervalTree node stores minY, maxY, and a ("UserData") pointer to a FloatPolygonEdge.
+
+};
+
+class VertexPair {
+public:
+ virtual ~VertexPair() { }
+
+ virtual const FloatPoint& vertex1() const = 0;
+ virtual const FloatPoint& vertex2() const = 0;
+
+ float minX() const { return std::min(vertex1().x(), vertex2().x()); }
+ float minY() const { return std::min(vertex1().y(), vertex2().y()); }
+ float maxX() const { return std::max(vertex1().x(), vertex2().x()); }
+ float maxY() const { return std::max(vertex1().y(), vertex2().y()); }
+
+ bool overlapsRect(const FloatRect&) const;
+ bool intersection(const VertexPair&, FloatPoint&) const;
+};
+
+class FloatPolygonEdge : public VertexPair {
+ friend class FloatPolygon;
+public:
+ virtual const FloatPoint& vertex1() const OVERRIDE
+ {
+ ASSERT(m_polygon);
+ return m_polygon->vertexAt(m_vertexIndex1);
+ }
+
+ virtual const FloatPoint& vertex2() const OVERRIDE
+ {
+ ASSERT(m_polygon);
+ return m_polygon->vertexAt(m_vertexIndex2);
+ }
+
+ const FloatPolygonEdge& previousEdge() const
+ {
+ ASSERT(m_polygon && m_polygon->numberOfEdges() > 1);
+ return m_polygon->edgeAt((m_edgeIndex + m_polygon->numberOfEdges() - 1) % m_polygon->numberOfEdges());
+ }
+
+ const FloatPolygonEdge& nextEdge() const
+ {
+ ASSERT(m_polygon && m_polygon->numberOfEdges() > 1);
+ return m_polygon->edgeAt((m_edgeIndex + 1) % m_polygon->numberOfEdges());
+ }
+
+ const FloatPolygon* polygon() const { return m_polygon; }
+ unsigned vertexIndex1() const { return m_vertexIndex1; }
+ unsigned vertexIndex2() const { return m_vertexIndex2; }
+ unsigned edgeIndex() const { return m_edgeIndex; }
+
+private:
+ // Edge vertex index1 is less than index2, except the last edge, where index2 is 0. When a polygon edge
+ // is defined by 3 or more colinear vertices, index2 can be the the index of the last colinear vertex.
+ unsigned m_vertexIndex1;
+ unsigned m_vertexIndex2;
+ unsigned m_edgeIndex;
+ const FloatPolygon* m_polygon;
+};
+
+// These structures are used by PODIntervalTree for debugging.
+#ifndef NDEBUG
+template <> struct ValueToString<float> {
+ static String string(const float value) { return String::number(value); }
+};
+
+template<> struct ValueToString<FloatPolygonEdge*> {
+ static String string(const FloatPolygonEdge* edge) { return String::format("%p (%f,%f %f,%f)", edge, edge->vertex1().x(), edge->vertex1().y(), edge->vertex2().x(), edge->vertex2().y()); }
+};
+#endif
+
+} // namespace WebCore
+
+#endif // FloatPolygon_h
diff --git a/Source/WebCore/platform/graphics/FloatQuad.cpp b/Source/WebCore/platform/graphics/FloatQuad.cpp
index fc9d613ec..cb151119a 100644
--- a/Source/WebCore/platform/graphics/FloatQuad.cpp
+++ b/Source/WebCore/platform/graphics/FloatQuad.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2008 Apple Inc. All rights reserved.
* Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2013 Xidorn Quan (quanxunzhen@gmail.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -177,6 +178,55 @@ bool FloatQuad::intersectsRect(const FloatRect& rect) const
return true;
}
+// Tests whether the line is contained by or intersected with the circle.
+static inline bool lineIntersectsCircle(const FloatPoint& center, float radius, const FloatPoint& p0, const FloatPoint& p1)
+{
+ float x0 = p0.x() - center.x(), y0 = p0.y() - center.y();
+ float x1 = p1.x() - center.x(), y1 = p1.y() - center.y();
+ float radius2 = radius * radius;
+ if ((x0 * x0 + y0 * y0) <= radius2 || (x1 * x1 + y1 * y1) <= radius2)
+ return true;
+ if (p0 == p1)
+ return false;
+
+ float a = y0 - y1;
+ float b = x1 - x0;
+ float c = x0 * y1 - x1 * y0;
+ float distance2 = c * c / (a * a + b * b);
+ // If distance between the center point and the line > the radius,
+ // the line doesn't cross (or is contained by) the ellipse.
+ if (distance2 > radius2)
+ return false;
+
+ // The nearest point on the line is between p0 and p1?
+ float x = - a * c / (a * a + b * b);
+ float y = - b * c / (a * a + b * b);
+ return (((x0 <= x && x <= x1) || (x0 >= x && x >= x1))
+ && ((y0 <= y && y <= y1) || (y1 <= y && y <= y0)));
+}
+
+bool FloatQuad::intersectsCircle(const FloatPoint& center, float radius) const
+{
+ return containsPoint(center) // The circle may be totally contained by the quad.
+ || lineIntersectsCircle(center, radius, m_p1, m_p2)
+ || lineIntersectsCircle(center, radius, m_p2, m_p3)
+ || lineIntersectsCircle(center, radius, m_p3, m_p4)
+ || lineIntersectsCircle(center, radius, m_p4, m_p1);
+}
+
+bool FloatQuad::intersectsEllipse(const FloatPoint& center, const FloatSize& radii) const
+{
+ // Transform the ellipse to an origin-centered circle whose radius is the product of major radius and minor radius.
+ // Here we apply the same transformation to the quad.
+ FloatQuad transformedQuad(*this);
+ transformedQuad.move(-center.x(), -center.y());
+ transformedQuad.scale(radii.height(), radii.width());
+
+ FloatPoint originPoint;
+ return transformedQuad.intersectsCircle(originPoint, radii.height() * radii.width());
+
+}
+
bool FloatQuad::isCounterclockwise() const
{
// Return if the two first vectors are turning clockwise. If the quad is convex then all following vectors will turn the same way.
diff --git a/Source/WebCore/platform/graphics/FloatQuad.h b/Source/WebCore/platform/graphics/FloatQuad.h
index 44d2e9dd9..a9d9096f2 100644
--- a/Source/WebCore/platform/graphics/FloatQuad.h
+++ b/Source/WebCore/platform/graphics/FloatQuad.h
@@ -92,6 +92,11 @@ public:
// This only works for convex quads.
bool intersectsRect(const FloatRect&) const;
+ // Test whether any part of the circle/ellipse intersects with this quad.
+ // Note that these two functions only work for convex quads.
+ bool intersectsCircle(const FloatPoint& center, float radius) const;
+ bool intersectsEllipse(const FloatPoint& center, const FloatSize& radii) const;
+
// The center of the quad. If the quad is the result of a affine-transformed rectangle this is the same as the original center transformed.
FloatPoint center() const
{
diff --git a/Source/WebCore/platform/graphics/FloatRect.cpp b/Source/WebCore/platform/graphics/FloatRect.cpp
index edce8a25a..c4eb7b14e 100644
--- a/Source/WebCore/platform/graphics/FloatRect.cpp
+++ b/Source/WebCore/platform/graphics/FloatRect.cpp
@@ -29,7 +29,6 @@
#include "FloatConversion.h"
#include "IntRect.h"
-#include "LayoutRect.h"
#include <algorithm>
#include <math.h>
#include <wtf/MathExtras.h>
@@ -43,10 +42,6 @@ FloatRect::FloatRect(const IntRect& r) : m_location(r.location()), m_size(r.size
{
}
-FloatRect::FloatRect(const LayoutRect& r) : m_location(r.location()), m_size(r.size())
-{
-}
-
FloatRect FloatRect::narrowPrecision(double x, double y, double width, double height)
{
return FloatRect(narrowPrecisionToFloat(x), narrowPrecisionToFloat(y), narrowPrecisionToFloat(width), narrowPrecisionToFloat(height));
diff --git a/Source/WebCore/platform/graphics/FloatRect.h b/Source/WebCore/platform/graphics/FloatRect.h
index fcef94a29..0de7e2721 100644
--- a/Source/WebCore/platform/graphics/FloatRect.h
+++ b/Source/WebCore/platform/graphics/FloatRect.h
@@ -30,11 +30,11 @@
#include "FloatPoint.h"
#include <wtf/Vector.h>
-#if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM)
+#if USE(CG)
typedef struct CGRect CGRect;
#endif
-#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))
+#if PLATFORM(MAC)
#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
typedef struct CGRect NSRect;
#else
@@ -48,10 +48,6 @@ class QRectF;
QT_END_NAMESPACE
#endif
-#if PLATFORM(WX) && USE(WXGC)
-class wxRect2DDouble;
-#endif
-
#if PLATFORM(BLACKBERRY)
namespace BlackBerry {
namespace Platform {
@@ -60,21 +56,12 @@ class FloatRect;
}
#endif
-#if USE(SKIA)
-struct SkRect;
-#endif
-
#if USE(CAIRO)
typedef struct _cairo_rectangle cairo_rectangle_t;
#endif
namespace WebCore {
-#if PLATFORM(OPENVG)
-class VGRect;
-#endif
-
-class LayoutRect;
class IntRect;
class IntPoint;
@@ -91,7 +78,6 @@ public:
FloatRect(float x, float y, float width, float height)
: m_location(FloatPoint(x, y)), m_size(FloatSize(width, height)) { }
FloatRect(const IntRect&);
- FloatRect(const LayoutRect&);
static FloatRect narrowPrecision(double x, double y, double width, double height);
@@ -193,15 +179,15 @@ public:
#if PLATFORM(BLACKBERRY)
FloatRect(const BlackBerry::Platform::FloatRect&);
operator BlackBerry::Platform::FloatRect() const;
+ FloatRect normalized() const;
#endif
-#if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM)
+#if USE(CG)
FloatRect(const CGRect&);
operator CGRect() const;
#endif
-#if (PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))) \
- && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
+#if PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
FloatRect(const NSRect&);
operator NSRect() const;
#endif
@@ -212,20 +198,6 @@ public:
FloatRect normalized() const;
#endif
-#if PLATFORM(WX) && USE(WXGC)
- FloatRect(const wxRect2DDouble&);
- operator wxRect2DDouble() const;
-#endif
-
-#if USE(SKIA)
- FloatRect(const SkRect&);
- operator SkRect() const;
-#endif
-
-#if PLATFORM(OPENVG)
- operator VGRect() const;
-#endif
-
#if USE(CAIRO)
FloatRect(const cairo_rectangle_t&);
operator cairo_rectangle_t() const;
diff --git a/Source/WebCore/platform/graphics/FloatSize.cpp b/Source/WebCore/platform/graphics/FloatSize.cpp
index e11b828bb..25512a7f8 100644
--- a/Source/WebCore/platform/graphics/FloatSize.cpp
+++ b/Source/WebCore/platform/graphics/FloatSize.cpp
@@ -29,7 +29,6 @@
#include "FloatConversion.h"
#include "IntSize.h"
-#include "LayoutSize.h"
#include <limits>
#include <math.h>
@@ -41,10 +40,6 @@ FloatSize::FloatSize(const IntSize& size) : m_width(size.width()), m_height(size
{
}
-FloatSize::FloatSize(const LayoutSize& size) : m_width(size.width()), m_height(size.height())
-{
-}
-
float FloatSize::diagonalLength() const
{
return sqrtf(diagonalLengthSquared());
diff --git a/Source/WebCore/platform/graphics/FloatSize.h b/Source/WebCore/platform/graphics/FloatSize.h
index 2ca22cdd4..1b40851e9 100644
--- a/Source/WebCore/platform/graphics/FloatSize.h
+++ b/Source/WebCore/platform/graphics/FloatSize.h
@@ -45,11 +45,11 @@ class FloatSize;
}
#endif
-#if USE(CG) || (PLATFORM(WX) && OS(DARWIN)) || USE(SKIA_ON_MAC_CHROMIUM)
+#if USE(CG)
typedef struct CGSize CGSize;
#endif
-#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN)) || (PLATFORM(QT) && USE(QTKIT))
+#if PLATFORM(MAC)
#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
typedef struct CGSize NSSize;
#else
@@ -60,14 +60,12 @@ typedef struct _NSSize NSSize;
namespace WebCore {
class IntSize;
-class LayoutSize;
class FloatSize {
public:
FloatSize() : m_width(0), m_height(0) { }
FloatSize(float width, float height) : m_width(width), m_height(height) { }
FloatSize(const IntSize&);
- FloatSize(const LayoutSize&);
static FloatSize narrowPrecision(double width, double height);
@@ -130,14 +128,12 @@ public:
operator BlackBerry::Platform::FloatSize() const;
#endif
-#if USE(CG) || (PLATFORM(WX) && OS(DARWIN)) || USE(SKIA_ON_MAC_CHROMIUM)
+#if USE(CG)
explicit FloatSize(const CGSize&); // don't do this implicitly since it's lossy
operator CGSize() const;
#endif
-#if (PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))) \
- && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES) \
- || (PLATFORM(QT) && USE(QTKIT))
+#if (PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES))
explicit FloatSize(const NSSize &); // don't do this implicitly since it's lossy
operator NSSize() const;
#endif
@@ -175,6 +171,16 @@ inline FloatSize operator-(const FloatSize& size)
return FloatSize(-size.width(), -size.height());
}
+inline FloatSize operator*(const FloatSize& a, const float b)
+{
+ return FloatSize(a.width() * b, a.height() * b);
+}
+
+inline FloatSize operator*(const float a, const FloatSize& b)
+{
+ return FloatSize(a * b.width(), a * b.height());
+}
+
inline bool operator==(const FloatSize& a, const FloatSize& b)
{
return a.width() == b.width() && a.height() == b.height();
diff --git a/Source/WebCore/platform/graphics/Font.cpp b/Source/WebCore/platform/graphics/Font.cpp
index 42dd14a6b..64469681a 100644
--- a/Source/WebCore/platform/graphics/Font.cpp
+++ b/Source/WebCore/platform/graphics/Font.cpp
@@ -34,7 +34,6 @@
#include <wtf/MainThread.h>
#include <wtf/MathExtras.h>
#include <wtf/text/StringBuilder.h>
-#include <wtf/UnusedParam.h>
using namespace WTF;
using namespace Unicode;
@@ -73,7 +72,6 @@ TypesettingFeatures Font::s_defaultTypesettingFeatures = 0;
Font::Font()
: m_letterSpacing(0)
, m_wordSpacing(0)
- , m_isPlatformFont(false)
, m_needsTranscoding(false)
, m_typesettingFeatures(0)
{
@@ -83,31 +81,27 @@ Font::Font(const FontDescription& fd, short letterSpacing, short wordSpacing)
: m_fontDescription(fd)
, m_letterSpacing(letterSpacing)
, m_wordSpacing(wordSpacing)
- , m_isPlatformFont(false)
, m_needsTranscoding(fontTranscoder().needsTranscoding(fd))
, m_typesettingFeatures(computeTypesettingFeatures())
{
}
Font::Font(const FontPlatformData& fontData, bool isPrinterFont, FontSmoothingMode fontSmoothingMode)
- : m_fontFallbackList(FontFallbackList::create())
+ : m_glyphs(FontGlyphs::createForPlatformFont(fontData))
, m_letterSpacing(0)
, m_wordSpacing(0)
- , m_isPlatformFont(true)
, m_typesettingFeatures(computeTypesettingFeatures())
{
m_fontDescription.setUsePrinterFont(isPrinterFont);
m_fontDescription.setFontSmoothing(fontSmoothingMode);
m_needsTranscoding = fontTranscoder().needsTranscoding(fontDescription());
- m_fontFallbackList->setPlatformFont(fontData);
}
Font::Font(const Font& other)
: m_fontDescription(other.m_fontDescription)
- , m_fontFallbackList(other.m_fontFallbackList)
+ , m_glyphs(other.m_glyphs)
, m_letterSpacing(other.m_letterSpacing)
, m_wordSpacing(other.m_wordSpacing)
- , m_isPlatformFont(other.m_isPlatformFont)
, m_needsTranscoding(other.m_needsTranscoding)
, m_typesettingFeatures(computeTypesettingFeatures())
{
@@ -116,10 +110,9 @@ Font::Font(const Font& other)
Font& Font::operator=(const Font& other)
{
m_fontDescription = other.m_fontDescription;
- m_fontFallbackList = other.m_fontFallbackList;
+ m_glyphs = other.m_glyphs;
m_letterSpacing = other.m_letterSpacing;
m_wordSpacing = other.m_wordSpacing;
- m_isPlatformFont = other.m_isPlatformFont;
m_needsTranscoding = other.m_needsTranscoding;
m_typesettingFeatures = other.m_typesettingFeatures;
return *this;
@@ -131,28 +124,133 @@ bool Font::operator==(const Font& other) const
// FIXME: This does not work if the font was made with the FontPlatformData constructor.
if (loadingCustomFonts() || other.loadingCustomFonts())
return false;
-
- FontSelector* first = m_fontFallbackList ? m_fontFallbackList->fontSelector() : 0;
- FontSelector* second = other.m_fontFallbackList ? other.m_fontFallbackList->fontSelector() : 0;
- return first == second
- && m_fontDescription == other.m_fontDescription
- && m_letterSpacing == other.m_letterSpacing
- && m_wordSpacing == other.m_wordSpacing
- && (m_fontFallbackList ? m_fontFallbackList->fontSelectorVersion() : 0) == (other.m_fontFallbackList ? other.m_fontFallbackList->fontSelectorVersion() : 0)
- && (m_fontFallbackList ? m_fontFallbackList->generation() : 0) == (other.m_fontFallbackList ? other.m_fontFallbackList->generation() : 0);
+ if (m_fontDescription != other.m_fontDescription || m_letterSpacing != other.m_letterSpacing || m_wordSpacing != other.m_wordSpacing)
+ return false;
+ if (m_glyphs == other.m_glyphs)
+ return true;
+ if (!m_glyphs || !other.m_glyphs)
+ return false;
+ if (m_glyphs->fontSelector() != other.m_glyphs->fontSelector())
+ return false;
+ // Can these cases actually somehow occur? All fonts should get wiped out by full style recalc.
+ if (m_glyphs->fontSelectorVersion() != other.m_glyphs->fontSelectorVersion())
+ return false;
+ if (m_glyphs->generation() != other.m_glyphs->generation())
+ return false;
+ return true;
+}
+
+struct FontGlyphsCacheKey {
+ // This part of the key is shared with the lower level FontCache (caching FontData objects).
+ FontDescriptionFontDataCacheKey fontDescriptionCacheKey;
+ Vector<AtomicString, 3> families;
+ unsigned fontSelectorId;
+ unsigned fontSelectorVersion;
+ unsigned fontSelectorFlags;
+};
+
+struct FontGlyphsCacheEntry {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ FontGlyphsCacheKey key;
+ RefPtr<FontGlyphs> glyphs;
+};
+
+typedef HashMap<unsigned, OwnPtr<FontGlyphsCacheEntry>, AlreadyHashed> FontGlyphsCache;
+
+static bool operator==(const FontGlyphsCacheKey& a, const FontGlyphsCacheKey& b)
+{
+ if (a.fontDescriptionCacheKey != b.fontDescriptionCacheKey)
+ return false;
+ if (a.families != b.families)
+ return false;
+ if (a.fontSelectorId != b.fontSelectorId || a.fontSelectorVersion != b.fontSelectorVersion || a.fontSelectorFlags != b.fontSelectorFlags)
+ return false;
+ return true;
+}
+
+static FontGlyphsCache& fontGlyphsCache()
+{
+ DEFINE_STATIC_LOCAL(FontGlyphsCache, cache, ());
+ return cache;
+}
+
+void invalidateFontGlyphsCache()
+{
+ fontGlyphsCache().clear();
+}
+
+static unsigned makeFontSelectorFlags(const FontDescription& description)
+{
+ return static_cast<unsigned>(description.script()) << 1 | static_cast<unsigned>(description.smallCaps());
+}
+
+static void makeFontGlyphsCacheKey(FontGlyphsCacheKey& key, const FontDescription& description, FontSelector* fontSelector)
+{
+ key.fontDescriptionCacheKey = FontDescriptionFontDataCacheKey(description);
+ for (unsigned i = 0; i < description.familyCount(); ++i)
+ key.families.append(description.familyAt(i).lower());
+ key.fontSelectorId = fontSelector ? fontSelector->uniqueId() : 0;
+ key.fontSelectorVersion = fontSelector ? fontSelector->version() : 0;
+ key.fontSelectorFlags = fontSelector && fontSelector->resolvesFamilyFor(description) ? makeFontSelectorFlags(description) : 0;
+}
+
+static unsigned computeFontGlyphsCacheHash(const FontGlyphsCacheKey& key)
+{
+ unsigned hashCodes[5] = {
+ StringHasher::hashMemory(key.families.data(), key.families.size() * sizeof(key.families[0])),
+ key.fontDescriptionCacheKey.computeHash(),
+ key.fontSelectorId,
+ key.fontSelectorVersion,
+ key.fontSelectorFlags
+ };
+ return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes);
+}
+
+void pruneUnreferencedEntriesFromFontGlyphsCache()
+{
+ Vector<unsigned, 50> toRemove;
+ FontGlyphsCache::iterator end = fontGlyphsCache().end();
+ for (FontGlyphsCache::iterator it = fontGlyphsCache().begin(); it != end; ++it) {
+ if (it->value->glyphs->hasOneRef())
+ toRemove.append(it->key);
+ }
+ for (unsigned i = 0; i < toRemove.size(); ++i)
+ fontGlyphsCache().remove(toRemove[i]);
+}
+
+static PassRefPtr<FontGlyphs> retrieveOrAddCachedFontGlyphs(const FontDescription& fontDescription, PassRefPtr<FontSelector> fontSelector)
+{
+ FontGlyphsCacheKey key;
+ makeFontGlyphsCacheKey(key, fontDescription, fontSelector.get());
+
+ unsigned hash = computeFontGlyphsCacheHash(key);
+ FontGlyphsCache::AddResult addResult = fontGlyphsCache().add(hash, PassOwnPtr<FontGlyphsCacheEntry>());
+ if (!addResult.isNewEntry && addResult.iterator->value->key == key)
+ return addResult.iterator->value->glyphs;
+
+ OwnPtr<FontGlyphsCacheEntry>& newEntry = addResult.iterator->value;
+ newEntry = adoptPtr(new FontGlyphsCacheEntry);
+ newEntry->glyphs = FontGlyphs::create(fontSelector);
+ newEntry->key = key;
+ RefPtr<FontGlyphs> glyphs = newEntry->glyphs;
+
+ static const unsigned unreferencedPruneInterval = 50;
+ static const int maximumEntries = 400;
+ static unsigned pruneCounter;
+ // Referenced FontGlyphs would exist anyway so pruning them saves little memory.
+ if (!(++pruneCounter % unreferencedPruneInterval))
+ pruneUnreferencedEntriesFromFontGlyphsCache();
+ // Prevent pathological growth.
+ if (fontGlyphsCache().size() > maximumEntries)
+ fontGlyphsCache().remove(fontGlyphsCache().begin());
+ return glyphs;
}
void Font::update(PassRefPtr<FontSelector> fontSelector) const
{
- // FIXME: It is pretty crazy that we are willing to just poke into a RefPtr, but it ends up
- // being reasonably safe (because inherited fonts in the render tree pick up the new
- // style anyway. Other copies are transient, e.g., the state in the GraphicsContext, and
- // won't stick around long enough to get you in trouble). Still, this is pretty disgusting,
- // and could eventually be rectified by using RefPtrs for Fonts themselves.
- if (!m_fontFallbackList)
- m_fontFallbackList = FontFallbackList::create();
- m_fontFallbackList->invalidate(fontSelector);
+ m_glyphs = retrieveOrAddCachedFontGlyphs(m_fontDescription, fontSelector.get());
m_typesettingFeatures = computeTypesettingFeatures();
}
@@ -200,17 +298,21 @@ float Font::width(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFo
bool hasKerningOrLigatures = typesettingFeatures() & (Kerning | Ligatures);
bool hasWordSpacingOrLetterSpacing = wordSpacing() | letterSpacing();
- float* cacheEntry = m_fontFallbackList->widthCache().add(run, std::numeric_limits<float>::quiet_NaN(), hasKerningOrLigatures, hasWordSpacingOrLetterSpacing, glyphOverflow);
- if (cacheEntry && !isnan(*cacheEntry))
+ float* cacheEntry = m_glyphs->widthCache().add(run, std::numeric_limits<float>::quiet_NaN(), hasKerningOrLigatures, hasWordSpacingOrLetterSpacing, glyphOverflow);
+ if (cacheEntry && !std::isnan(*cacheEntry))
return *cacheEntry;
+ HashSet<const SimpleFontData*> localFallbackFonts;
+ if (!fallbackFonts)
+ fallbackFonts = &localFallbackFonts;
+
float result;
if (codePathToUse == Complex)
result = floatWidthForComplexText(run, fallbackFonts, glyphOverflow);
else
result = floatWidthForSimpleText(run, fallbackFonts, glyphOverflow);
- if (cacheEntry && (!fallbackFonts || fallbackFonts->isEmpty()))
+ if (cacheEntry && fallbackFonts->isEmpty())
*cacheEntry = result;
return result;
}
@@ -227,8 +329,7 @@ float Font::width(const TextRun& run, int& charsConsumed, String& glyphName) con
return width(run);
}
-#if !(PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN)))
-
+#if !PLATFORM(MAC)
PassOwnPtr<TextLayout> Font::createLayout(RenderText*, float, bool) const
{
return nullptr;
@@ -243,7 +344,6 @@ float Font::width(TextLayout&, unsigned, unsigned, HashSet<const SimpleFontData*
ASSERT_NOT_REACHED();
return 0;
}
-
#endif
FloatRect Font::selectionRectForText(const TextRun& run, const FloatPoint& point, int h, int from, int to) const
@@ -553,15 +653,88 @@ bool Font::isCJKIdeographOrSymbol(UChar32 c)
if ((c == 0x2C7) || (c == 0x2CA) || (c == 0x2CB) || (c == 0x2D9))
return true;
+ if ((c == 0x2020) || (c == 0x2021) || (c == 0x2030) || (c == 0x203B) || (c == 0x203C)
+ || (c == 0x2042) || (c == 0x2047) || (c == 0x2048) || (c == 0x2049) || (c == 0x2051)
+ || (c == 0x20DD) || (c == 0x20DE) || (c == 0x2100) || (c == 0x2103) || (c == 0x2105)
+ || (c == 0x2109) || (c == 0x210A) || (c == 0x2113) || (c == 0x2116) || (c == 0x2121)
+ || (c == 0x212B) || (c == 0x213B) || (c == 0x2150) || (c == 0x2151) || (c == 0x2152))
+ return true;
+
+ if (c >= 0x2156 && c <= 0x215A)
+ return true;
+
+ if (c >= 0x2160 && c <= 0x216B)
+ return true;
+
+ if (c >= 0x2170 && c <= 0x217B)
+ return true;
+
+ if ((c == 0x217F) || (c == 0x2189) || (c == 0x2307) || (c == 0x2312) || (c == 0x23BE) || (c == 0x23BF))
+ return true;
+
+ if (c >= 0x23C0 && c <= 0x23CC)
+ return true;
+
+ if ((c == 0x23CE) || (c == 0x2423))
+ return true;
+
+ if (c >= 0x2460 && c <= 0x2492)
+ return true;
+
+ if (c >= 0x249C && c <= 0x24FF)
+ return true;
+
+ if ((c == 0x25A0) || (c == 0x25A1) || (c == 0x25A2) || (c == 0x25AA) || (c == 0x25AB))
+ return true;
+
+ if ((c == 0x25B1) || (c == 0x25B2) || (c == 0x25B3) || (c == 0x25B6) || (c == 0x25B7) || (c == 0x25BC) || (c == 0x25BD))
+ return true;
+
+ if ((c == 0x25C0) || (c == 0x25C1) || (c == 0x25C6) || (c == 0x25C7) || (c == 0x25C9) || (c == 0x25CB) || (c == 0x25CC))
+ return true;
+
+ if (c >= 0x25CE && c <= 0x25D3)
+ return true;
+
+ if (c >= 0x25E2 && c <= 0x25E6)
+ return true;
+
+ if (c == 0x25EF)
+ return true;
+
+ if (c >= 0x2600 && c <= 0x2603)
+ return true;
+
+ if ((c == 0x2605) || (c == 0x2606) || (c == 0x260E) || (c == 0x2616) || (c == 0x2617) || (c == 0x2640) || (c == 0x2642))
+ return true;
+
+ if (c >= 0x2660 && c <= 0x266F)
+ return true;
+
+ if (c >= 0x2672 && c <= 0x267D)
+ return true;
+
+ if ((c == 0x26A0) || (c == 0x26BD) || (c == 0x26BE) || (c == 0x2713) || (c == 0x271A) || (c == 0x273F) || (c == 0x2740) || (c == 0x2756))
+ return true;
+
+ if (c >= 0x2776 && c <= 0x277F)
+ return true;
+
+ if (c == 0x2B1A)
+ return true;
+
// Ideographic Description Characters.
if (c >= 0x2FF0 && c <= 0x2FFF)
return true;
- // CJK Symbols and Punctuation.
- if (c >= 0x3000 && c <= 0x303F)
+ // CJK Symbols and Punctuation, excluding 0x3030.
+ if (c >= 0x3000 && c < 0x3030)
return true;
-
- // Hiragana
+
+ if (c > 0x3030 && c <= 0x303F)
+ return true;
+
+ // Hiragana
if (c >= 0x3040 && c <= 0x309F)
return true;
@@ -572,7 +745,10 @@ bool Font::isCJKIdeographOrSymbol(UChar32 c)
// Bopomofo
if (c >= 0x3100 && c <= 0x312F)
return true;
-
+
+ if (c >= 0x3190 && c <= 0x319F)
+ return true;
+
// Bopomofo Extended
if (c >= 0x31A0 && c <= 0x31BF)
return true;
@@ -584,17 +760,41 @@ bool Font::isCJKIdeographOrSymbol(UChar32 c)
// CJK Compatibility.
if (c >= 0x3300 && c <= 0x33FF)
return true;
-
+
+ if (c >= 0xF860 && c <= 0xF862)
+ return true;
+
// CJK Compatibility Forms.
if (c >= 0xFE30 && c <= 0xFE4F)
return true;
+ if ((c == 0xFE10) || (c == 0xFE11) || (c == 0xFE12) || (c == 0xFE19))
+ return true;
+
+ if ((c == 0xFF0D) || (c == 0xFF1B) || (c == 0xFF1C) || (c == 0xFF1E))
+ return false;
+
// Halfwidth and Fullwidth Forms
// Usually only used in CJK
if (c >= 0xFF00 && c <= 0xFFEF)
return true;
// Emoji.
+ if (c == 0x1F100)
+ return true;
+
+ if (c >= 0x1F110 && c <= 0x1F129)
+ return true;
+
+ if (c >= 0x1F130 && c <= 0x1F149)
+ return true;
+
+ if (c >= 0x1F150 && c <= 0x1F169)
+ return true;
+
+ if (c >= 0x1F170 && c <= 0x1F189)
+ return true;
+
if (c >= 0x1F200 && c <= 0x1F6F)
return true;
diff --git a/Source/WebCore/platform/graphics/Font.h b/Source/WebCore/platform/graphics/Font.h
index d6d393a16..28d49b66a 100644
--- a/Source/WebCore/platform/graphics/Font.h
+++ b/Source/WebCore/platform/graphics/Font.h
@@ -26,7 +26,7 @@
#define Font_h
#include "FontDescription.h"
-#include "FontFallbackList.h"
+#include "FontGlyphs.h"
#include "SimpleFontData.h"
#include "TextDirection.h"
#include "TypesettingFeatures.h"
@@ -128,18 +128,18 @@ public:
FontRenderingMode renderingMode() const { return m_fontDescription.renderingMode(); }
- TypesettingFeatures typesettingFeatures() const { return m_typesettingFeatures; }
+ TypesettingFeatures typesettingFeatures() const { return static_cast<TypesettingFeatures>(m_typesettingFeatures); }
- FontFamily& firstFamily() { return m_fontDescription.firstFamily(); }
- const FontFamily& family() const { return m_fontDescription.family(); }
+ const AtomicString& firstFamily() const { return m_fontDescription.firstFamily(); }
+ unsigned familyCount() const { return m_fontDescription.familyCount(); }
+ const AtomicString& familyAt(unsigned i) const { return m_fontDescription.familyAt(i); }
FontItalic italic() const { return m_fontDescription.italic(); }
FontWeight weight() const { return m_fontDescription.weight(); }
FontWidthVariant widthVariant() const { return m_fontDescription.widthVariant(); }
- bool isPlatformFont() const { return m_isPlatformFont; }
+ bool isPlatformFont() const { return m_glyphs->isForPlatformFont(); }
- // Metrics that we query the FontFallbackList for.
const FontMetrics& fontMetrics() const { return primaryFont()->fontMetrics(); }
float spaceWidth() const { return primaryFont()->spaceWidth() + m_letterSpacing; }
float tabWidth(const SimpleFontData&, unsigned tabSize, float position) const;
@@ -151,14 +151,17 @@ public:
const SimpleFontData* primaryFont() const;
const FontData* fontDataAt(unsigned) const;
- inline GlyphData glyphDataForCharacter(UChar32 c, bool mirror, FontDataVariant variant = AutoVariant) const
+ GlyphData glyphDataForCharacter(UChar32 c, bool mirror, FontDataVariant variant = AutoVariant) const
{
return glyphDataAndPageForCharacter(c, mirror, variant).first;
}
-#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))
+#if PLATFORM(MAC)
const SimpleFontData* fontDataForCombiningCharacterSequence(const UChar*, size_t length, FontDataVariant) const;
#endif
- std::pair<GlyphData, GlyphPage*> glyphDataAndPageForCharacter(UChar32, bool mirror, FontDataVariant = AutoVariant) const;
+ std::pair<GlyphData, GlyphPage*> glyphDataAndPageForCharacter(UChar32 c, bool mirror, FontDataVariant variant) const
+ {
+ return m_glyphs->glyphDataAndPageForCharacter(m_fontDescription, c, mirror, variant);
+ }
bool primaryFontHasGlyphForCharacter(UChar32) const;
static bool isCJKIdeograph(UChar32);
@@ -179,7 +182,7 @@ public:
CodePath codePath(const TextRun&) const;
static CodePath characterRangeCodePath(const LChar*, unsigned) { return Simple; }
static CodePath characterRangeCodePath(const UChar*, unsigned len);
-
+
private:
enum ForTextEmphasisOrNot { NotForTextEmphasis, ForTextEmphasis };
@@ -246,12 +249,12 @@ public:
static String normalizeSpaces(const UChar*, unsigned length);
bool needsTranscoding() const { return m_needsTranscoding; }
- FontFallbackList* fontList() const { return m_fontFallbackList.get(); }
+ FontGlyphs* glyphs() const { return m_glyphs.get(); }
private:
bool loadingCustomFonts() const
{
- return m_fontFallbackList && m_fontFallbackList->loadingCustomFonts();
+ return m_glyphs && m_glyphs->loadingCustomFonts();
}
TypesettingFeatures computeTypesettingFeatures() const
@@ -303,39 +306,41 @@ private:
static TypesettingFeatures s_defaultTypesettingFeatures;
FontDescription m_fontDescription;
- mutable RefPtr<FontFallbackList> m_fontFallbackList;
+ mutable RefPtr<FontGlyphs> m_glyphs;
short m_letterSpacing;
short m_wordSpacing;
- bool m_isPlatformFont;
bool m_needsTranscoding;
- mutable TypesettingFeatures m_typesettingFeatures; // Caches values computed from m_fontDescription.
+ mutable unsigned m_typesettingFeatures : 2; // (TypesettingFeatures) Caches values computed from m_fontDescription.
};
+void invalidateFontGlyphsCache();
+void pruneUnreferencedEntriesFromFontGlyphsCache();
+
inline Font::~Font()
{
}
inline const SimpleFontData* Font::primaryFont() const
{
- ASSERT(m_fontFallbackList);
- return m_fontFallbackList->primarySimpleFontData(this);
+ ASSERT(m_glyphs);
+ return m_glyphs->primarySimpleFontData(m_fontDescription);
}
inline const FontData* Font::fontDataAt(unsigned index) const
{
- ASSERT(m_fontFallbackList);
- return m_fontFallbackList->fontDataAt(this, index);
+ ASSERT(m_glyphs);
+ return m_glyphs->realizeFontDataAt(m_fontDescription, index);
}
inline bool Font::isFixedPitch() const
{
- ASSERT(m_fontFallbackList);
- return m_fontFallbackList->isFixedPitch(this);
+ ASSERT(m_glyphs);
+ return m_glyphs->isFixedPitch(m_fontDescription);
}
inline FontSelector* Font::fontSelector() const
{
- return m_fontFallbackList ? m_fontFallbackList->fontSelector() : 0;
+ return m_glyphs ? m_glyphs->fontSelector() : 0;
}
inline float Font::tabWidth(const SimpleFontData& fontData, unsigned tabSize, float position) const
diff --git a/Source/WebCore/platform/graphics/FontCache.cpp b/Source/WebCore/platform/graphics/FontCache.cpp
index 729b5ad12..f3f1720f7 100644
--- a/Source/WebCore/platform/graphics/FontCache.cpp
+++ b/Source/WebCore/platform/graphics/FontCache.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2008, 2013 Apple Inc. All rights reserved.
* Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
*
* Redistribution and use in source and binary forms, with or without
@@ -31,10 +31,9 @@
#include "FontCache.h"
#include "Font.h"
-#include "FontFallbackList.h"
+#include "FontGlyphs.h"
#include "FontPlatformData.h"
#include "FontSelector.h"
-#include "OpenTypeVerticalData.h"
#include "WebKitFontFamilyNames.h"
#include <wtf/HashMap.h>
#include <wtf/ListHashSet.h>
@@ -42,6 +41,10 @@
#include <wtf/text/AtomicStringHash.h>
#include <wtf/text/StringHash.h>
+#if ENABLE(OPENTYPE_VERTICAL)
+#include "OpenTypeVerticalData.h"
+#endif
+
using namespace WTF;
namespace WebCore {
@@ -60,40 +63,22 @@ FontCache::FontCache()
struct FontPlatformDataCacheKey {
WTF_MAKE_FAST_ALLOCATED;
public:
- FontPlatformDataCacheKey(const AtomicString& family = AtomicString(), unsigned size = 0, unsigned weight = 0, bool italic = false,
- bool isPrinterFont = false, FontRenderingMode renderingMode = NormalRenderingMode, FontOrientation orientation = Horizontal,
- TextOrientation textOrientation = TextOrientationVerticalRight, FontWidthVariant widthVariant = RegularWidth)
- : m_size(size)
- , m_weight(weight)
+ FontPlatformDataCacheKey() { }
+ FontPlatformDataCacheKey(const AtomicString& family, const FontDescription& description)
+ : m_fontDescriptionKey(description)
, m_family(family)
- , m_italic(italic)
- , m_printerFont(isPrinterFont)
- , m_renderingMode(renderingMode)
- , m_orientation(orientation)
- , m_textOrientation(textOrientation)
- , m_widthVariant(widthVariant)
- {
- }
+ { }
- FontPlatformDataCacheKey(HashTableDeletedValueType) : m_size(hashTableDeletedSize()) { }
- bool isHashTableDeletedValue() const { return m_size == hashTableDeletedSize(); }
+ FontPlatformDataCacheKey(HashTableDeletedValueType) : m_fontDescriptionKey(hashTableDeletedSize()) { }
+ bool isHashTableDeletedValue() const { return m_fontDescriptionKey.size == hashTableDeletedSize(); }
bool operator==(const FontPlatformDataCacheKey& other) const
{
- return equalIgnoringCase(m_family, other.m_family) && m_size == other.m_size &&
- m_weight == other.m_weight && m_italic == other.m_italic && m_printerFont == other.m_printerFont &&
- m_renderingMode == other.m_renderingMode && m_orientation == other.m_orientation && m_textOrientation == other.m_textOrientation && m_widthVariant == other.m_widthVariant;
+ return equalIgnoringCase(m_family, other.m_family) && m_fontDescriptionKey == other.m_fontDescriptionKey;
}
- unsigned m_size;
- unsigned m_weight;
+ FontDescriptionFontDataCacheKey m_fontDescriptionKey;
AtomicString m_family;
- bool m_italic;
- bool m_printerFont;
- FontRenderingMode m_renderingMode;
- FontOrientation m_orientation;
- TextOrientation m_textOrientation;
- FontWidthVariant m_widthVariant;
private:
static unsigned hashTableDeletedSize() { return 0xFFFFFFFFU; }
@@ -101,14 +86,7 @@ private:
inline unsigned computeHash(const FontPlatformDataCacheKey& fontKey)
{
- unsigned hashCodes[5] = {
- CaseFoldingHash::hash(fontKey.m_family),
- fontKey.m_size,
- fontKey.m_weight,
- fontKey.m_widthVariant,
- static_cast<unsigned>(fontKey.m_textOrientation) << 4 | static_cast<unsigned>(fontKey.m_orientation) << 3 | static_cast<unsigned>(fontKey.m_italic) << 2 | static_cast<unsigned>(fontKey.m_printerFont) << 1 | static_cast<unsigned>(fontKey.m_renderingMode)
- };
- return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes);
+ return pairIntHash(CaseFoldingHash::hash(fontKey.m_family), fontKey.m_fontDescriptionKey.computeHash());
}
struct FontPlatformDataCacheKeyHash {
@@ -127,57 +105,79 @@ struct FontPlatformDataCacheKeyHash {
struct FontPlatformDataCacheKeyTraits : WTF::SimpleClassHashTraits<FontPlatformDataCacheKey> { };
-typedef HashMap<FontPlatformDataCacheKey, FontPlatformData*, FontPlatformDataCacheKeyHash, FontPlatformDataCacheKeyTraits> FontPlatformDataCache;
+typedef HashMap<FontPlatformDataCacheKey, OwnPtr<FontPlatformData>, FontPlatformDataCacheKeyHash, FontPlatformDataCacheKeyTraits> FontPlatformDataCache;
static FontPlatformDataCache* gFontPlatformDataCache = 0;
-static const AtomicString& alternateFamilyName(const AtomicString& familyName)
+static bool familyNameEqualIgnoringCase(const AtomicString& familyName, const char* reference, unsigned length)
+{
+ ASSERT(length > 0);
+ ASSERT(familyName.length() == length);
+ ASSERT(strlen(reference) == length);
+ const AtomicStringImpl* familyNameImpl = familyName.impl();
+ if (familyNameImpl->is8Bit())
+ return equalIgnoringCase(familyNameImpl->characters8(), reinterpret_cast<const LChar*>(reference), length);
+ return equalIgnoringCase(familyNameImpl->characters16(), reinterpret_cast<const LChar*>(reference), length);
+}
+
+template<size_t length>
+static inline bool familyNameEqualIgnoringCase(const AtomicString& familyName, const char (&reference)[length])
{
- // Alias Courier <-> Courier New
- DEFINE_STATIC_LOCAL(AtomicString, courier, ("Courier", AtomicString::ConstructFromLiteral));
- DEFINE_STATIC_LOCAL(AtomicString, courierNew, ("Courier New", AtomicString::ConstructFromLiteral));
- if (equalIgnoringCase(familyName, courier))
- return courierNew;
+ return familyNameEqualIgnoringCase(familyName, reference, length - 1);
+}
+
+static const AtomicString alternateFamilyName(const AtomicString& familyName)
+{
+ // Alias Courier and Courier New.
+ // Alias Times and Times New Roman.
+ // Alias Arial and Helvetica.
+ switch (familyName.length()) {
+ case 5:
+ if (familyNameEqualIgnoringCase(familyName, "Arial"))
+ return AtomicString("Helvetica", AtomicString::ConstructFromLiteral);
+ if (familyNameEqualIgnoringCase(familyName, "Times"))
+ return AtomicString("Times New Roman", AtomicString::ConstructFromLiteral);
+ break;
+ case 7:
+ if (familyNameEqualIgnoringCase(familyName, "Courier"))
+ return AtomicString("Courier New", AtomicString::ConstructFromLiteral);
+ break;
+ case 9:
+ if (familyNameEqualIgnoringCase(familyName, "Helvetica"))
+ return AtomicString("Arial", AtomicString::ConstructFromLiteral);
+ break;
#if !OS(WINDOWS)
// On Windows, Courier New (truetype font) is always present and
// Courier is a bitmap font. So, we don't want to map Courier New to
// Courier.
- if (equalIgnoringCase(familyName, courierNew))
- return courier;
-#endif
-
- // Alias Times and Times New Roman.
- DEFINE_STATIC_LOCAL(AtomicString, times, ("Times", AtomicString::ConstructFromLiteral));
- DEFINE_STATIC_LOCAL(AtomicString, timesNewRoman, ("Times New Roman", AtomicString::ConstructFromLiteral));
- if (equalIgnoringCase(familyName, times))
- return timesNewRoman;
- if (equalIgnoringCase(familyName, timesNewRoman))
- return times;
-
- // Alias Arial and Helvetica
- DEFINE_STATIC_LOCAL(AtomicString, arial, ("Arial", AtomicString::ConstructFromLiteral));
- DEFINE_STATIC_LOCAL(AtomicString, helvetica, ("Helvetica", AtomicString::ConstructFromLiteral));
- if (equalIgnoringCase(familyName, arial))
- return helvetica;
- if (equalIgnoringCase(familyName, helvetica))
- return arial;
-
+ case 11:
+ if (familyNameEqualIgnoringCase(familyName, "Courier New"))
+ return AtomicString("Courier", AtomicString::ConstructFromLiteral);
+ break;
+#endif // !OS(WINDOWS)
+ case 15:
+ if (familyNameEqualIgnoringCase(familyName, "Times New Roman"))
+ return AtomicString("Times", AtomicString::ConstructFromLiteral);
+ break;
#if OS(WINDOWS)
// On Windows, bitmap fonts are blocked altogether so that we have to
// alias MS Sans Serif (bitmap font) -> Microsoft Sans Serif (truetype font)
- DEFINE_STATIC_LOCAL(AtomicString, msSans, ("MS Sans Serif", AtomicString::ConstructFromLiteral));
- DEFINE_STATIC_LOCAL(AtomicString, microsoftSans, ("Microsoft Sans Serif", AtomicString::ConstructFromLiteral));
- if (equalIgnoringCase(familyName, msSans))
- return microsoftSans;
+ case 13:
+ if (familyNameEqualIgnoringCase(familyName, "MS Sans Serif"))
+ return AtomicString("Microsoft Sans Serif", AtomicString::ConstructFromLiteral);
+ break;
// Alias MS Serif (bitmap) -> Times New Roman (truetype font). There's no
// 'Microsoft Sans Serif-equivalent' for Serif.
- DEFINE_STATIC_LOCAL(AtomicString, msSerif, ("MS Serif", AtomicString::ConstructFromLiteral));
- if (equalIgnoringCase(familyName, msSerif))
- return timesNewRoman;
-#endif
+ case 8:
+ if (familyNameEqualIgnoringCase(familyName, "MS Serif"))
+ return AtomicString("Times New Roman", AtomicString::ConstructFromLiteral);
+ break;
+#endif // OS(WINDOWS)
- return emptyAtom;
+ }
+
+ return nullAtom;
}
FontPlatformData* FontCache::getCachedFontPlatformData(const FontDescription& fontDescription,
@@ -199,32 +199,30 @@ FontPlatformData* FontCache::getCachedFontPlatformData(const FontDescription& fo
platformInit();
}
- FontPlatformDataCacheKey key(familyName, fontDescription.computedPixelSize(), fontDescription.weight(), fontDescription.italic(),
- fontDescription.usePrinterFont(), fontDescription.renderingMode(), fontDescription.orientation(),
- fontDescription.textOrientation(), fontDescription.widthVariant());
- FontPlatformData* result = 0;
- bool foundResult;
- FontPlatformDataCache::iterator it = gFontPlatformDataCache->find(key);
- if (it == gFontPlatformDataCache->end()) {
- result = createFontPlatformData(fontDescription, familyName);
- gFontPlatformDataCache->set(key, result);
- foundResult = result;
- } else {
- result = it->value;
- foundResult = true;
- }
-
- if (!foundResult && !checkingAlternateName) {
- // We were unable to find a font. We have a small set of fonts that we alias to other names,
- // e.g., Arial/Helvetica, Courier/Courier New, etc. Try looking up the font under the aliased name.
- const AtomicString& alternateName = alternateFamilyName(familyName);
- if (!alternateName.isEmpty())
- result = getCachedFontPlatformData(fontDescription, alternateName, true);
- if (result)
- gFontPlatformDataCache->set(key, new FontPlatformData(*result)); // Cache the result under the old name.
+ FontPlatformDataCacheKey key(familyName, fontDescription);
+
+ FontPlatformDataCache::AddResult result = gFontPlatformDataCache->add(key, nullptr);
+ FontPlatformDataCache::iterator it = result.iterator;
+ if (result.isNewEntry) {
+ it->value = createFontPlatformData(fontDescription, familyName);
+
+ if (!it->value && !checkingAlternateName) {
+ // We were unable to find a font. We have a small set of fonts that we alias to other names,
+ // e.g., Arial/Helvetica, Courier/Courier New, etc. Try looking up the font under the aliased name.
+ const AtomicString alternateName = alternateFamilyName(familyName);
+ if (!alternateName.isNull()) {
+ FontPlatformData* fontPlatformDataForAlternateName = getCachedFontPlatformData(fontDescription, alternateName, true);
+ // Lookup the key in the hash table again as the previous iterator may have
+ // been invalidated by the recursive call to getCachedFontPlatformData().
+ it = gFontPlatformDataCache->find(key);
+ ASSERT(it != gFontPlatformDataCache->end());
+ if (fontPlatformDataForAlternateName)
+ it->value = adoptPtr(new FontPlatformData(*fontPlatformDataForAlternateName));
+ }
+ }
}
- return result;
+ return it->value.get();
}
#if ENABLE(OPENTYPE_VERTICAL)
@@ -287,13 +285,8 @@ typedef HashMap<FontPlatformData, pair<RefPtr<SimpleFontData>, unsigned>, FontDa
static FontDataCache* gFontDataCache = 0;
-#if PLATFORM(CHROMIUM) && !OS(ANDROID)
-const int cMaxInactiveFontData = 250;
-const int cTargetInactiveFontData = 200;
-#else
const int cMaxInactiveFontData = 225;
const int cTargetInactiveFontData = 200;
-#endif
static ListHashSet<RefPtr<SimpleFontData> >* gInactiveFontData = 0;
PassRefPtr<SimpleFontData> FontCache::getCachedFontData(const FontDescription& fontDescription, const AtomicString& family, bool checkingAlternateName, ShouldRetain shouldRetain)
@@ -373,6 +366,8 @@ void FontCache::purgeInactiveFontDataIfNeeded()
void FontCache::purgeInactiveFontData(int count)
{
+ pruneUnreferencedEntriesFromFontGlyphsCache();
+
if (!gInactiveFontData || m_purgePreventCount)
return;
@@ -413,7 +408,7 @@ void FontCache::purgeInactiveFontData(int count)
size_t keysToRemoveCount = keysToRemove.size();
for (size_t i = 0; i < keysToRemoveCount; ++i)
- delete gFontPlatformDataCache->take(keysToRemove[i]);
+ gFontPlatformDataCache->remove(keysToRemove[i]);
}
#if ENABLE(OPENTYPE_VERTICAL)
@@ -459,48 +454,44 @@ size_t FontCache::inactiveFontDataCount()
return 0;
}
-PassRefPtr<FontData> FontCache::getFontData(const Font& font, int& familyIndex, FontSelector* fontSelector)
+PassRefPtr<FontData> FontCache::getFontData(const FontDescription& description, int& familyIndex, FontSelector* fontSelector)
{
+ ASSERT(familyIndex != cAllFamiliesScanned);
RefPtr<FontData> result;
- int startIndex = familyIndex;
- const FontFamily* startFamily = &font.fontDescription().family();
- for (int i = 0; startFamily && i < startIndex; i++)
- startFamily = startFamily->next();
- const FontFamily* currFamily = startFamily;
- while (currFamily && !result) {
- familyIndex++;
- if (currFamily->family().length()) {
- if (fontSelector)
- result = fontSelector->getFontData(font.fontDescription(), currFamily->family());
-
- if (!result)
- result = getCachedFontData(font.fontDescription(), currFamily->family());
- }
- currFamily = currFamily->next();
+ bool isFirst = !familyIndex;
+ int familyCount = description.familyCount();
+ for (;familyIndex < familyCount && !result; ++familyIndex) {
+ const AtomicString& family = description.familyAt(familyIndex);
+ if (family.isEmpty())
+ continue;
+ if (fontSelector)
+ result = fontSelector->getFontData(description, family);
+ if (!result)
+ result = getCachedFontData(description, family);
}
-
- if (!currFamily)
+ if (familyIndex == familyCount)
familyIndex = cAllFamiliesScanned;
- if (!result)
+#if PLATFORM(MAC)
+ if (!result) {
// We didn't find a font. Try to find a similar font using our own specific knowledge about our platform.
// For example on OS X, we know to map any families containing the words Arabic, Pashto, or Urdu to the
// Geeza Pro font.
- result = getSimilarFontPlatformData(font);
+ result = similarFontPlatformData(description);
+ }
+#endif
- if (!result && startIndex == 0) {
+ if (!result && isFirst) {
// If it's the primary font that we couldn't find, we try the following. In all other cases, we will
// just use per-character system fallback.
-
if (fontSelector) {
// Try the user's preferred standard font.
- if (RefPtr<FontData> data = fontSelector->getFontData(font.fontDescription(), standardFamily))
+ if (RefPtr<FontData> data = fontSelector->getFontData(description, standardFamily))
return data.release();
}
-
// Still no result. Hand back our last resort fallback font.
- result = getLastResortFallbackFont(font.fontDescription());
+ result = getLastResortFallbackFont(description);
}
return result.release();
}
@@ -538,11 +529,9 @@ void FontCache::invalidate()
return;
}
- if (gFontPlatformDataCache) {
- deleteAllValues(*gFontPlatformDataCache);
- delete gFontPlatformDataCache;
- gFontPlatformDataCache = new FontPlatformDataCache;
- }
+ if (gFontPlatformDataCache)
+ gFontPlatformDataCache->clear();
+ invalidateFontGlyphsCache();
gGeneration++;
diff --git a/Source/WebCore/platform/graphics/FontCache.h b/Source/WebCore/platform/graphics/FontCache.h
index fc7623e3a..b5cf0916c 100644
--- a/Source/WebCore/platform/graphics/FontCache.h
+++ b/Source/WebCore/platform/graphics/FontCache.h
@@ -30,6 +30,7 @@
#ifndef FontCache_h
#define FontCache_h
+#include "FontDescription.h"
#include <limits.h>
#include <wtf/Forward.h>
#include <wtf/PassRefPtr.h>
@@ -49,19 +50,55 @@ namespace WebCore {
class Font;
class FontPlatformData;
class FontData;
-class FontDescription;
class FontSelector;
class OpenTypeVerticalData;
class SimpleFontData;
#if PLATFORM(WIN)
-#if !OS(WINCE) || defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2)
+#if USE(IMLANG_FONT_LINK2)
typedef IMLangFontLink2 IMLangFontLinkType;
#else
typedef IMLangFontLink IMLangFontLinkType;
#endif
#endif
+// This key contains the FontDescription fields other than family that matter when fetching FontDatas (platform fonts).
+struct FontDescriptionFontDataCacheKey {
+ explicit FontDescriptionFontDataCacheKey(unsigned size = 0)
+ : size(size)
+ , weight(0)
+ , flags(0)
+ { }
+ FontDescriptionFontDataCacheKey(const FontDescription& description)
+ : size(description.computedPixelSize())
+ , weight(description.weight())
+ , flags(makeFlagKey(description))
+ { }
+ static unsigned makeFlagKey(const FontDescription& description)
+ {
+ return static_cast<unsigned>(description.widthVariant()) << 4
+ | static_cast<unsigned>(description.orientation()) << 3
+ | static_cast<unsigned>(description.italic()) << 2
+ | static_cast<unsigned>(description.usePrinterFont()) << 1
+ | static_cast<unsigned>(description.renderingMode());
+ }
+ bool operator==(const FontDescriptionFontDataCacheKey& other) const
+ {
+ return size == other.size && weight == other.weight && flags == other.flags;
+ }
+ bool operator!=(const FontDescriptionFontDataCacheKey& other) const
+ {
+ return !(*this == other);
+ }
+ inline unsigned computeHash() const
+ {
+ return StringHasher::hashMemory<sizeof(FontDescriptionFontDataCacheKey)>(this);
+ }
+ unsigned size;
+ unsigned weight;
+ unsigned flags;
+};
+
class FontCache {
friend class FontCachePurgePreventer;
@@ -71,23 +108,21 @@ public:
enum ShouldRetain { Retain, DoNotRetain };
- PassRefPtr<FontData> getFontData(const Font&, int& familyIndex, FontSelector*);
+ PassRefPtr<FontData> getFontData(const FontDescription&, int& familyIndex, FontSelector*);
void releaseFontData(const SimpleFontData*);
// This method is implemented by the platform.
- PassRefPtr<SimpleFontData> getFontDataForCharacters(const Font&, const UChar* characters, int length);
+ PassRefPtr<SimpleFontData> systemFallbackForCharacters(const FontDescription&, const SimpleFontData* originalFontData, bool isPlatformFont, const UChar* characters, int length);
// Also implemented by the platform.
void platformInit();
#if PLATFORM(WIN)
IMLangFontLinkType* getFontLinkInterface();
-#if OS(WINCE)
static void comInitialize();
static void comUninitialize();
static IMultiLanguage* getMultiLanguageInterface();
#endif
-#endif
void getTraitsInFamily(const AtomicString&, Vector<unsigned>&);
@@ -107,16 +142,10 @@ public:
#if PLATFORM(WIN)
PassRefPtr<SimpleFontData> fontDataFromDescriptionAndLogFont(const FontDescription&, ShouldRetain, const LOGFONT&, AtomicString& outFontFamilyName);
-#elif PLATFORM(CHROMIUM) && OS(WINDOWS)
- PassRefPtr<SimpleFontData> fontDataFromDescriptionAndLogFont(const FontDescription&, ShouldRetain, const LOGFONT&, wchar_t* outFontFamilyName);
#endif
#if ENABLE(OPENTYPE_VERTICAL)
-#if USE(SKIA)
- typedef uint32_t FontFileKey;
-#else
typedef AtomicString FontFileKey;
-#endif
PassRefPtr<OpenTypeVerticalData> getVerticalData(const FontFileKey&, const FontPlatformData&);
#endif
@@ -125,7 +154,11 @@ public:
bool isBold;
bool isItalic;
};
+#if PLATFORM(BLACKBERRY)
+ static void getFontFamilyForCharacters(const UChar* characters, size_t numCharacters, const char* preferredLocale, const FontDescription&, SimpleFontFamily*);
+#else
static void getFontFamilyForCharacters(const UChar* characters, size_t numCharacters, const char* preferredLocale, SimpleFontFamily*);
+#endif
private:
FontCache();
@@ -145,19 +178,21 @@ private:
FontPlatformData* getCachedFontPlatformData(const FontDescription&, const AtomicString& family, bool checkingAlternateName = false);
// These methods are implemented by each platform.
- PassRefPtr<SimpleFontData> getSimilarFontPlatformData(const Font&);
- FontPlatformData* createFontPlatformData(const FontDescription&, const AtomicString& family);
+ PassOwnPtr<FontPlatformData> createFontPlatformData(const FontDescription&, const AtomicString& family);
+#if PLATFORM(MAC)
+ PassRefPtr<SimpleFontData> similarFontPlatformData(const FontDescription&);
+#endif
PassRefPtr<SimpleFontData> getCachedFontData(const FontPlatformData*, ShouldRetain = Retain);
// Don't purge if this count is > 0;
int m_purgePreventCount;
-#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN)) || OS(ANDROID)
+#if PLATFORM(MAC)
friend class ComplexTextController;
#endif
friend class SimpleFontData; // For getCachedFontData(const FontPlatformData*)
- friend class FontFallbackList;
+ friend class FontGlyphs;
};
// Get the global fontCache.
diff --git a/Source/WebCore/platform/graphics/FontDescription.cpp b/Source/WebCore/platform/graphics/FontDescription.cpp
index e822c01ad..3487ff04a 100644
--- a/Source/WebCore/platform/graphics/FontDescription.cpp
+++ b/Source/WebCore/platform/graphics/FontDescription.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2007 Nicholas Shanks <contact@nickshanks.com>
- * Copyright (C) 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -33,7 +33,7 @@
namespace WebCore {
struct SameSizeAsFontDescription {
- FontFamily familyList;
+ Vector<AtomicString, 1> families;
RefPtr<FontFeatureSettings> m_featureSettings;
float sizes[2];
// FXIME: Make them fit into one word.
diff --git a/Source/WebCore/platform/graphics/FontDescription.h b/Source/WebCore/platform/graphics/FontDescription.h
index 44368759d..b1abaee77 100644
--- a/Source/WebCore/platform/graphics/FontDescription.h
+++ b/Source/WebCore/platform/graphics/FontDescription.h
@@ -2,7 +2,7 @@
* Copyright (C) 2000 Lars Knoll (knoll@kde.org)
* (C) 2000 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2013 Apple Inc. All rights reserved.
* Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
*
* This library is free software; you can redistribute it and/or
@@ -25,14 +25,13 @@
#ifndef FontDescription_h
#define FontDescription_h
-#include "FontFamily.h"
#include "FontFeatureSettings.h"
#include "FontOrientation.h"
#include "FontRenderingMode.h"
#include "FontSmoothingMode.h"
#include "FontTraitsMask.h"
#include "FontWidthVariant.h"
-#include "TextOrientation.h"
+#include "NonCJKGlyphOrientation.h"
#include "TextRenderingMode.h"
#include "WebKitFontFamilyNames.h"
#include <wtf/MathExtras.h>
@@ -77,10 +76,11 @@ public:
enum LigaturesState { NormalLigaturesState, DisabledLigaturesState, EnabledLigaturesState };
FontDescription()
- : m_specifiedSize(0)
+ : m_families(1)
+ , m_specifiedSize(0)
, m_computedSize(0)
, m_orientation(Horizontal)
- , m_textOrientation(TextOrientationVerticalRight)
+ , m_nonCJKGlyphOrientation(NonCJKGlyphOrientationVerticalRight)
, m_widthVariant(RegularWidth)
, m_italic(FontItalicOff)
, m_smallCaps(FontSmallCapsOff)
@@ -103,9 +103,12 @@ public:
bool operator==(const FontDescription&) const;
bool operator!=(const FontDescription& other) const { return !(*this == other); }
-
- const FontFamily& family() const { return m_familyList; }
- FontFamily& firstFamily() { return m_familyList; }
+
+ unsigned familyCount() const { return m_families.size(); }
+ const AtomicString& firstFamily() const { return familyAt(0); }
+ const AtomicString& familyAt(unsigned i) const { return m_families[i]; }
+ const Vector<AtomicString, 1>& families() const { return m_families; }
+
float specifiedSize() const { return m_specifiedSize; }
float computedSize() const { return m_computedSize; }
FontItalic italic() const { return static_cast<FontItalic>(m_italic); }
@@ -118,7 +121,7 @@ public:
GenericFamilyType genericFamily() const { return static_cast<GenericFamilyType>(m_genericFamily); }
bool usePrinterFont() const { return m_usePrinterFont; }
// only use fixed default size when there is only one font family, and that family is "monospace"
- bool useFixedDefaultSize() const { return genericFamily() == MonospaceFamily && !family().next() && family().family() == monospaceFamily; }
+ bool useFixedDefaultSize() const { return genericFamily() == MonospaceFamily && familyCount() == 1 && firstFamily() == monospaceFamily; }
FontRenderingMode renderingMode() const { return static_cast<FontRenderingMode>(m_renderingMode); }
Kerning kerning() const { return static_cast<Kerning>(m_kerning); }
LigaturesState commonLigaturesState() const { return static_cast<LigaturesState>(m_commonLigaturesState); }
@@ -132,12 +135,14 @@ public:
FontTraitsMask traitsMask() const;
bool isSpecifiedFont() const { return m_isSpecifiedFont; }
FontOrientation orientation() const { return static_cast<FontOrientation>(m_orientation); }
- TextOrientation textOrientation() const { return static_cast<TextOrientation>(m_textOrientation); }
+ NonCJKGlyphOrientation nonCJKGlyphOrientation() const { return static_cast<NonCJKGlyphOrientation>(m_nonCJKGlyphOrientation); }
FontWidthVariant widthVariant() const { return static_cast<FontWidthVariant>(m_widthVariant); }
FontFeatureSettings* featureSettings() const { return m_featureSettings.get(); }
FontDescription makeNormalFeatureSettings() const;
- void setFamily(const FontFamily& family) { m_familyList = family; }
+ void setOneFamily(const AtomicString& family) { ASSERT(m_families.size() == 1); m_families[0] = family; }
+ void setFamilies(const Vector<AtomicString, 1>& families) { m_families = families; }
+ void adoptFamilies(Vector<AtomicString, 1>& families) { m_families.swap(families); }
void setComputedSize(float s) { m_computedSize = clampToFloat(s); }
void setSpecifiedSize(float s) { m_specifiedSize = clampToFloat(s); }
void setItalic(FontItalic i) { m_italic = i; }
@@ -147,11 +152,7 @@ public:
void setIsAbsoluteSize(bool s) { m_isAbsoluteSize = s; }
void setWeight(FontWeight w) { m_weight = w; }
void setGenericFamily(GenericFamilyType genericFamily) { m_genericFamily = genericFamily; }
-#if PLATFORM(CHROMIUM) && OS(DARWIN)
- void setUsePrinterFont(bool) { }
-#else
void setUsePrinterFont(bool p) { m_usePrinterFont = p; }
-#endif
void setRenderingMode(FontRenderingMode mode) { m_renderingMode = mode; }
void setKerning(Kerning kerning) { m_kerning = kerning; }
void setCommonLigaturesState(LigaturesState commonLigaturesState) { m_commonLigaturesState = commonLigaturesState; }
@@ -162,13 +163,13 @@ public:
void setTextRenderingMode(TextRenderingMode rendering) { m_textRendering = rendering; }
void setIsSpecifiedFont(bool isSpecifiedFont) { m_isSpecifiedFont = isSpecifiedFont; }
void setOrientation(FontOrientation orientation) { m_orientation = orientation; }
- void setTextOrientation(TextOrientation textOrientation) { m_textOrientation = textOrientation; }
+ void setNonCJKGlyphOrientation(NonCJKGlyphOrientation orientation) { m_nonCJKGlyphOrientation = orientation; }
void setWidthVariant(FontWidthVariant widthVariant) { m_widthVariant = widthVariant; }
void setScript(UScriptCode s) { m_script = s; }
void setFeatureSettings(PassRefPtr<FontFeatureSettings> settings) { m_featureSettings = settings; }
private:
- FontFamily m_familyList; // The list of font families to be used.
+ Vector<AtomicString, 1> m_families;
RefPtr<FontFeatureSettings> m_featureSettings;
float m_specifiedSize; // Specified CSS value. Independent of rendering issues such as integer
@@ -176,7 +177,7 @@ private:
float m_computedSize; // Computed size adjusted for the minimum font size and the zoom factor.
unsigned m_orientation : 1; // FontOrientation - Whether the font is rendering on a horizontal line or a vertical line.
- unsigned m_textOrientation : 1; // TextOrientation - Only used by vertical text. Determines the default orientation for non-ideograph glyphs.
+ unsigned m_nonCJKGlyphOrientation : 1; // NonCJKGlyphOrientation - Only used by vertical text. Determines the default orientation for non-ideograph glyphs.
unsigned m_widthVariant : 2; // FontWidthVariant
@@ -207,7 +208,7 @@ private:
inline bool FontDescription::operator==(const FontDescription& other) const
{
- return m_familyList == other.m_familyList
+ return m_families == other.m_families
&& m_specifiedSize == other.m_specifiedSize
&& m_computedSize == other.m_computedSize
&& m_italic == other.m_italic
@@ -226,7 +227,7 @@ inline bool FontDescription::operator==(const FontDescription& other) const
&& m_textRendering == other.m_textRendering
&& m_isSpecifiedFont == other.m_isSpecifiedFont
&& m_orientation == other.m_orientation
- && m_textOrientation == other.m_textOrientation
+ && m_nonCJKGlyphOrientation == other.m_nonCJKGlyphOrientation
&& m_widthVariant == other.m_widthVariant
&& m_script == other.m_script
&& m_featureSettings == other.m_featureSettings;
diff --git a/Source/WebCore/platform/graphics/FontFallbackList.cpp b/Source/WebCore/platform/graphics/FontFallbackList.cpp
deleted file mode 100644
index 37417141d..000000000
--- a/Source/WebCore/platform/graphics/FontFallbackList.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FontFallbackList.h"
-
-#include "Font.h"
-#include "FontCache.h"
-#include "SegmentedFontData.h"
-
-namespace WebCore {
-
-FontFallbackList::FontFallbackList()
- : m_pageZero(0)
- , m_cachedPrimarySimpleFontData(0)
- , m_fontSelector(0)
- , m_fontSelectorVersion(0)
- , m_familyIndex(0)
- , m_generation(fontCache()->generation())
- , m_pitch(UnknownPitch)
- , m_loadingCustomFonts(false)
-{
-}
-
-void FontFallbackList::invalidate(PassRefPtr<FontSelector> fontSelector)
-{
- releaseFontData();
- m_fontList.clear();
- m_pageZero = 0;
- m_pages.clear();
- m_cachedPrimarySimpleFontData = 0;
- m_familyIndex = 0;
- m_pitch = UnknownPitch;
- m_loadingCustomFonts = false;
- m_fontSelector = fontSelector;
- m_fontSelectorVersion = m_fontSelector ? m_fontSelector->version() : 0;
- m_generation = fontCache()->generation();
- m_widthCache.clear();
-}
-
-void FontFallbackList::releaseFontData()
-{
- unsigned numFonts = m_fontList.size();
- for (unsigned i = 0; i < numFonts; ++i) {
- if (!m_fontList[i]->isCustomFont()) {
- ASSERT(!m_fontList[i]->isSegmented());
- fontCache()->releaseFontData(static_cast<const SimpleFontData*>(m_fontList[i].get()));
- }
- }
-}
-
-void FontFallbackList::determinePitch(const Font* font) const
-{
- const FontData* fontData = primaryFontData(font);
- if (!fontData->isSegmented())
- m_pitch = static_cast<const SimpleFontData*>(fontData)->pitch();
- else {
- const SegmentedFontData* segmentedFontData = static_cast<const SegmentedFontData*>(fontData);
- unsigned numRanges = segmentedFontData->numRanges();
- if (numRanges == 1)
- m_pitch = segmentedFontData->rangeAt(0).fontData()->pitch();
- else
- m_pitch = VariablePitch;
- }
-}
-
-const FontData* FontFallbackList::fontDataAt(const Font* font, unsigned realizedFontIndex) const
-{
- if (realizedFontIndex < m_fontList.size())
- return m_fontList[realizedFontIndex].get(); // This fallback font is already in our list.
-
- // Make sure we're not passing in some crazy value here.
- ASSERT(realizedFontIndex == m_fontList.size());
-
- if (m_familyIndex == cAllFamiliesScanned)
- return 0;
-
- // Ask the font cache for the font data.
- // We are obtaining this font for the first time. We keep track of the families we've looked at before
- // in |m_familyIndex|, so that we never scan the same spot in the list twice. getFontData will adjust our
- // |m_familyIndex| as it scans for the right font to make.
- ASSERT(fontCache()->generation() == m_generation);
- RefPtr<FontData> result = fontCache()->getFontData(*font, m_familyIndex, m_fontSelector.get());
- if (result) {
- m_fontList.append(result);
- if (result->isLoading())
- m_loadingCustomFonts = true;
- }
- return result.get();
-}
-
-void FontFallbackList::setPlatformFont(const FontPlatformData& platformData)
-{
- m_familyIndex = cAllFamiliesScanned;
- ASSERT(fontCache()->generation() == m_generation);
- RefPtr<FontData> fontData = fontCache()->getCachedFontData(&platformData);
- m_fontList.append(fontData);
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/FontFamily.h b/Source/WebCore/platform/graphics/FontFamily.h
deleted file mode 100644
index bd867cdde..000000000
--- a/Source/WebCore/platform/graphics/FontFamily.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef FontFamily_h
-#define FontFamily_h
-
-#include <wtf/RefCounted.h>
-#include <wtf/ListRefPtr.h>
-#include <wtf/text/AtomicString.h>
-
-namespace WebCore {
-
-class SharedFontFamily;
-
-class FontFamily {
-public:
- FontFamily() { }
-
- void setFamily(const AtomicString& family) { m_family = family; }
- const AtomicString& family() const { return m_family; }
- bool familyIsEmpty() const { return m_family.isEmpty(); }
-
- const FontFamily* next() const;
-
- void appendFamily(PassRefPtr<SharedFontFamily>);
- PassRefPtr<SharedFontFamily> releaseNext();
-
-private:
- AtomicString m_family;
- ListRefPtr<SharedFontFamily> m_next;
-};
-
-class SharedFontFamily : public FontFamily, public RefCounted<SharedFontFamily> {
-public:
- static PassRefPtr<SharedFontFamily> create()
- {
- return adoptRef(new SharedFontFamily);
- }
-
-private:
- SharedFontFamily() { }
-};
-
-bool operator==(const FontFamily&, const FontFamily&);
-inline bool operator!=(const FontFamily& a, const FontFamily& b) { return !(a == b); }
-
-inline const FontFamily* FontFamily::next() const
-{
- return m_next.get();
-}
-
-inline void FontFamily::appendFamily(PassRefPtr<SharedFontFamily> family)
-{
- m_next = family;
-}
-
-inline PassRefPtr<SharedFontFamily> FontFamily::releaseNext()
-{
- return m_next.release();
-}
-
-}
-
-#endif
diff --git a/Source/WebCore/platform/graphics/FontFastPath.cpp b/Source/WebCore/platform/graphics/FontFastPath.cpp
index d1553ea3f..40576e05c 100644
--- a/Source/WebCore/platform/graphics/FontFastPath.cpp
+++ b/Source/WebCore/platform/graphics/FontFastPath.cpp
@@ -25,7 +25,7 @@
#include "FloatRect.h"
#include "FontCache.h"
-#include "FontFallbackList.h"
+#include "FontGlyphs.h"
#include "GlyphBuffer.h"
#include "GlyphPageTreeNode.h"
#include "SimpleFontData.h"
@@ -42,208 +42,6 @@ using namespace std;
namespace WebCore {
-static inline std::pair<GlyphData, GlyphPage*> glyphDataAndPageForCharacterWithTextOrientation(UChar32 character, TextOrientation orientation, GlyphData& data, GlyphPage* page, unsigned pageNumber)
-{
- if (orientation == TextOrientationVerticalRight) {
- RefPtr<SimpleFontData> verticalRightFontData = data.fontData->verticalRightOrientationFontData();
- GlyphPageTreeNode* verticalRightNode = GlyphPageTreeNode::getRootChild(verticalRightFontData.get(), pageNumber);
- GlyphPage* verticalRightPage = verticalRightNode->page();
- if (verticalRightPage) {
- GlyphData verticalRightData = verticalRightPage->glyphDataForCharacter(character);
- // If the glyphs are distinct, we will make the assumption that the font has a vertical-right glyph baked
- // into it.
- if (data.glyph != verticalRightData.glyph)
- return make_pair(data, page);
- // The glyphs are identical, meaning that we should just use the horizontal glyph.
- if (verticalRightData.fontData)
- return make_pair(verticalRightData, verticalRightPage);
- }
- } else if (orientation == TextOrientationUpright) {
- RefPtr<SimpleFontData> uprightFontData = data.fontData->uprightOrientationFontData();
- GlyphPageTreeNode* uprightNode = GlyphPageTreeNode::getRootChild(uprightFontData.get(), pageNumber);
- GlyphPage* uprightPage = uprightNode->page();
- if (uprightPage) {
- GlyphData uprightData = uprightPage->glyphDataForCharacter(character);
- // If the glyphs are the same, then we know we can just use the horizontal glyph rotated vertically to be upright.
- if (data.glyph == uprightData.glyph)
- return make_pair(data, page);
- // The glyphs are distinct, meaning that the font has a vertical-right glyph baked into it. We can't use that
- // glyph, so we fall back to the upright data and use the horizontal glyph.
- if (uprightData.fontData)
- return make_pair(uprightData, uprightPage);
- }
- }
- return make_pair(data, page);
-}
-
-std::pair<GlyphData, GlyphPage*> Font::glyphDataAndPageForCharacter(UChar32 c, bool mirror, FontDataVariant variant) const
-{
- ASSERT(isMainThread());
-
- if (variant == AutoVariant) {
- if (m_fontDescription.smallCaps() && !primaryFont()->isSVGFont()) {
- UChar32 upperC = toUpper(c);
- if (upperC != c) {
- c = upperC;
- variant = SmallCapsVariant;
- } else
- variant = NormalVariant;
- } else
- variant = NormalVariant;
- }
-
- if (mirror)
- c = mirroredChar(c);
-
- unsigned pageNumber = (c / GlyphPage::size);
-
- GlyphPageTreeNode* node = pageNumber ? m_fontFallbackList->m_pages.get(pageNumber) : m_fontFallbackList->m_pageZero;
- if (!node) {
- node = GlyphPageTreeNode::getRootChild(fontDataAt(0), pageNumber);
- if (pageNumber)
- m_fontFallbackList->m_pages.set(pageNumber, node);
- else
- m_fontFallbackList->m_pageZero = node;
- }
-
- GlyphPage* page = 0;
- if (variant == NormalVariant) {
- // Fastest loop, for the common case (normal variant).
- while (true) {
- page = node->page();
- if (page) {
- GlyphData data = page->glyphDataForCharacter(c);
- if (data.fontData && (data.fontData->platformData().orientation() == Horizontal || data.fontData->isTextOrientationFallback()))
- return make_pair(data, page);
-
- if (data.fontData) {
- if (isCJKIdeographOrSymbol(c)) {
- if (!data.fontData->hasVerticalGlyphs()) {
- // Use the broken ideograph font data. The broken ideograph font will use the horizontal width of glyphs
- // to make sure you get a square (even for broken glyphs like symbols used for punctuation).
- variant = BrokenIdeographVariant;
- break;
- }
- } else
- return glyphDataAndPageForCharacterWithTextOrientation(c, m_fontDescription.textOrientation(), data, page, pageNumber);
-
- return make_pair(data, page);
- }
-
- if (node->isSystemFallback())
- break;
- }
-
- // Proceed with the fallback list.
- node = node->getChild(fontDataAt(node->level()), pageNumber);
- if (pageNumber)
- m_fontFallbackList->m_pages.set(pageNumber, node);
- else
- m_fontFallbackList->m_pageZero = node;
- }
- }
- if (variant != NormalVariant) {
- while (true) {
- page = node->page();
- if (page) {
- GlyphData data = page->glyphDataForCharacter(c);
- if (data.fontData) {
- // The variantFontData function should not normally return 0.
- // But if it does, we will just render the capital letter big.
- RefPtr<SimpleFontData> variantFontData = data.fontData->variantFontData(m_fontDescription, variant);
- if (!variantFontData)
- return make_pair(data, page);
-
- GlyphPageTreeNode* variantNode = GlyphPageTreeNode::getRootChild(variantFontData.get(), pageNumber);
- GlyphPage* variantPage = variantNode->page();
- if (variantPage) {
- GlyphData data = variantPage->glyphDataForCharacter(c);
- if (data.fontData)
- return make_pair(data, variantPage);
- }
-
- // Do not attempt system fallback off the variantFontData. This is the very unlikely case that
- // a font has the lowercase character but the small caps font does not have its uppercase version.
- return make_pair(variantFontData->missingGlyphData(), page);
- }
-
- if (node->isSystemFallback())
- break;
- }
-
- // Proceed with the fallback list.
- node = node->getChild(fontDataAt(node->level()), pageNumber);
- if (pageNumber)
- m_fontFallbackList->m_pages.set(pageNumber, node);
- else
- m_fontFallbackList->m_pageZero = node;
- }
- }
-
- ASSERT(page);
- ASSERT(node->isSystemFallback());
-
- // System fallback is character-dependent. When we get here, we
- // know that the character in question isn't in the system fallback
- // font's glyph page. Try to lazily create it here.
- UChar codeUnits[2];
- int codeUnitsLength;
- if (c <= 0xFFFF) {
- codeUnits[0] = Font::normalizeSpaces(c);
- codeUnitsLength = 1;
- } else {
- codeUnits[0] = U16_LEAD(c);
- codeUnits[1] = U16_TRAIL(c);
- codeUnitsLength = 2;
- }
- RefPtr<SimpleFontData> characterFontData = fontCache()->getFontDataForCharacters(*this, codeUnits, codeUnitsLength);
- if (characterFontData) {
- if (characterFontData->platformData().orientation() == Vertical && !characterFontData->hasVerticalGlyphs() && isCJKIdeographOrSymbol(c))
- variant = BrokenIdeographVariant;
- if (variant != NormalVariant)
- characterFontData = characterFontData->variantFontData(m_fontDescription, variant);
- }
- if (characterFontData) {
- // Got the fallback glyph and font.
- GlyphPage* fallbackPage = GlyphPageTreeNode::getRootChild(characterFontData.get(), pageNumber)->page();
- GlyphData data = fallbackPage && fallbackPage->fontDataForCharacter(c) ? fallbackPage->glyphDataForCharacter(c) : characterFontData->missingGlyphData();
- // Cache it so we don't have to do system fallback again next time.
- if (variant == NormalVariant) {
-#if OS(WINCE)
- // missingGlyphData returns a null character, which is not suitable for GDI to display.
- // Also, sometimes we cannot map a font for the character on WINCE, but GDI can still
- // display the character, probably because the font package is not installed correctly.
- // So we just always set the glyph to be same as the character, and let GDI solve it.
- page->setGlyphDataForCharacter(c, c, characterFontData.get());
- characterFontData->setMaxGlyphPageTreeLevel(max(characterFontData->maxGlyphPageTreeLevel(), node->level()));
- return make_pair(page->glyphDataForCharacter(c), page);
-#else
- page->setGlyphDataForCharacter(c, data.glyph, data.fontData);
- data.fontData->setMaxGlyphPageTreeLevel(max(data.fontData->maxGlyphPageTreeLevel(), node->level()));
- if (!isCJKIdeographOrSymbol(c) && data.fontData->platformData().orientation() != Horizontal && !data.fontData->isTextOrientationFallback())
- return glyphDataAndPageForCharacterWithTextOrientation(c, m_fontDescription.textOrientation(), data, fallbackPage, pageNumber);
-#endif
- }
- return make_pair(data, page);
- }
-
- // Even system fallback can fail; use the missing glyph in that case.
- // FIXME: It would be nicer to use the missing glyph from the last resort font instead.
- GlyphData data = primaryFont()->missingGlyphData();
- if (variant == NormalVariant) {
-#if OS(WINCE)
- // See comment about WINCE GDI handling near setGlyphDataForCharacter above.
- page->setGlyphDataForCharacter(c, c, data.fontData);
- data.fontData->setMaxGlyphPageTreeLevel(max(data.fontData->maxGlyphPageTreeLevel(), node->level()));
- return make_pair(page->glyphDataForCharacter(c), page);
-#else
- page->setGlyphDataForCharacter(c, data.glyph, data.fontData);
- data.fontData->setMaxGlyphPageTreeLevel(max(data.fontData->maxGlyphPageTreeLevel(), node->level()));
-#endif
- }
- return make_pair(data, page);
-}
-
bool Font::primaryFontHasGlyphForCharacter(UChar32 character) const
{
unsigned pageNumber = (character / GlyphPage::size);
@@ -283,6 +81,8 @@ bool Font::getEmphasisMarkGlyphData(const AtomicString& mark, GlyphData& glyphDa
int Font::emphasisMarkAscent(const AtomicString& mark) const
{
+ FontCachePurgePreventer purgePreventer;
+
GlyphData markGlyphData;
if (!getEmphasisMarkGlyphData(mark, markGlyphData))
return 0;
@@ -297,6 +97,8 @@ int Font::emphasisMarkAscent(const AtomicString& mark) const
int Font::emphasisMarkDescent(const AtomicString& mark) const
{
+ FontCachePurgePreventer purgePreventer;
+
GlyphData markGlyphData;
if (!getEmphasisMarkGlyphData(mark, markGlyphData))
return 0;
@@ -311,6 +113,8 @@ int Font::emphasisMarkDescent(const AtomicString& mark) const
int Font::emphasisMarkHeight(const AtomicString& mark) const
{
+ FontCachePurgePreventer purgePreventer;
+
GlyphData markGlyphData;
if (!getEmphasisMarkGlyphData(mark, markGlyphData))
return 0;
@@ -336,13 +140,13 @@ float Font::getGlyphsAndAdvancesForSimpleText(const TextRun& run, int from, int
float beforeWidth = 0;
int glyphPos = 0;
for (; glyphPos < localGlyphBuffer.size() && it.m_characterIndexOfGlyph[glyphPos] < from; ++glyphPos)
- beforeWidth += localGlyphBuffer.advanceAt(glyphPos);
+ beforeWidth += localGlyphBuffer.advanceAt(glyphPos).width();
int glyphFrom = glyphPos;
float afterWidth = totalWidth;
glyphPos = localGlyphBuffer.size() - 1;
for (; glyphPos >= glyphFrom && it.m_characterIndexOfGlyph[glyphPos] >= to; --glyphPos)
- afterWidth -= localGlyphBuffer.advanceAt(glyphPos);
+ afterWidth -= localGlyphBuffer.advanceAt(glyphPos).width();
int glyphTo = glyphPos + 1;
glyphBuffer.add(&localGlyphBuffer, glyphFrom, glyphTo - glyphFrom);
@@ -389,8 +193,9 @@ void Font::drawGlyphBuffer(GraphicsContext* context, const TextRun& run, const G
// Draw each contiguous run of glyphs that use the same font data.
const SimpleFontData* fontData = glyphBuffer.fontDataAt(0);
FloatSize offset = glyphBuffer.offsetAt(0);
- FloatPoint startPoint(point);
- float nextX = startPoint.x() + glyphBuffer.advanceAt(0);
+ FloatPoint startPoint(point.x(), point.y() - glyphBuffer.initialAdvance().height());
+ float nextX = startPoint.x() + glyphBuffer.advanceAt(0).width();
+ float nextY = startPoint.y() + glyphBuffer.advanceAt(0).height();
int lastFrom = 0;
int nextGlyph = 1;
#if ENABLE(SVG_FONTS)
@@ -412,8 +217,10 @@ void Font::drawGlyphBuffer(GraphicsContext* context, const TextRun& run, const G
fontData = nextFontData;
offset = nextOffset;
startPoint.setX(nextX);
+ startPoint.setY(nextY);
}
- nextX += glyphBuffer.advanceAt(nextGlyph);
+ nextX += glyphBuffer.advanceAt(nextGlyph).width();
+ nextY += glyphBuffer.advanceAt(nextGlyph).height();
nextGlyph++;
}
@@ -442,6 +249,8 @@ inline static float offsetToMiddleOfGlyphAtIndex(const GlyphBuffer& glyphBuffer,
void Font::drawEmphasisMarks(GraphicsContext* context, const TextRun& run, const GlyphBuffer& glyphBuffer, const AtomicString& mark, const FloatPoint& point) const
{
+ FontCachePurgePreventer purgePreventer;
+
GlyphData markGlyphData;
if (!getEmphasisMarkGlyphData(mark, markGlyphData))
return;
@@ -460,7 +269,7 @@ void Font::drawEmphasisMarks(GraphicsContext* context, const TextRun& run, const
GlyphBuffer markBuffer;
for (int i = 0; i + 1 < glyphBuffer.size(); ++i) {
float middleOfNextGlyph = offsetToMiddleOfGlyphAtIndex(glyphBuffer, i + 1);
- float advance = glyphBuffer.advanceAt(i) - middleOfLastGlyph + middleOfNextGlyph;
+ float advance = glyphBuffer.advanceAt(i).width() - middleOfLastGlyph + middleOfNextGlyph;
markBuffer.add(glyphBuffer.glyphAt(i) ? markGlyph : spaceGlyph, markFontData, advance);
middleOfLastGlyph = middleOfNextGlyph;
}
@@ -495,13 +304,13 @@ FloatRect Font::selectionRectForSimpleText(const TextRun& run, const FloatPoint&
float beforeWidth = 0;
int glyphPos = 0;
for (; glyphPos < glyphBuffer.size() && it.m_characterIndexOfGlyph[glyphPos] < from; ++glyphPos)
- beforeWidth += glyphBuffer.advanceAt(glyphPos);
+ beforeWidth += glyphBuffer.advanceAt(glyphPos).width();
int glyphFrom = glyphPos;
float afterWidth = totalWidth;
glyphPos = glyphBuffer.size() - 1;
for (; glyphPos >= glyphFrom && it.m_characterIndexOfGlyph[glyphPos] >= to; --glyphPos)
- afterWidth -= glyphBuffer.advanceAt(glyphPos);
+ afterWidth -= glyphBuffer.advanceAt(glyphPos).width();
// Using roundf() rather than ceilf() for the right edge as a compromise to ensure correct caret positioning.
if (run.rtl()) {
@@ -526,7 +335,7 @@ int Font::offsetForPositionForSimpleText(const TextRun& run, float x, bool inclu
break;
}
characterOffset = it.m_characterIndexOfGlyph[glyphPosition];
- float glyphWidth = glyphBuffer.advanceAt(glyphPosition);
+ float glyphWidth = glyphBuffer.advanceAt(glyphPosition).width();
if (includePartialGlyphs) {
if (currentX - glyphWidth / 2.0f <= x)
break;
@@ -544,7 +353,7 @@ int Font::offsetForPositionForSimpleText(const TextRun& run, float x, bool inclu
break;
}
characterOffset = it.m_characterIndexOfGlyph[glyphPosition];
- float glyphWidth = glyphBuffer.advanceAt(glyphPosition);
+ float glyphWidth = glyphBuffer.advanceAt(glyphPosition).width();
if (includePartialGlyphs) {
if (currentX + glyphWidth / 2.0f >= x)
break;
diff --git a/Source/WebCore/platform/graphics/FontGenericFamilies.cpp b/Source/WebCore/platform/graphics/FontGenericFamilies.cpp
new file mode 100644
index 000000000..e08255347
--- /dev/null
+++ b/Source/WebCore/platform/graphics/FontGenericFamilies.cpp
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "FontGenericFamilies.h"
+
+namespace WebCore {
+
+static bool setGenericFontFamilyForScript(ScriptFontFamilyMap& fontMap, const AtomicString& family, UScriptCode script)
+{
+ if (family.isEmpty()) {
+ ScriptFontFamilyMap::iterator it = fontMap.find(static_cast<int>(script));
+ if (it == fontMap.end())
+ return false;
+ fontMap.remove(it);
+ return true;
+ }
+ ScriptFontFamilyMap::AddResult addResult = fontMap.add(static_cast<int>(script), family);
+ if (addResult.isNewEntry)
+ return true;
+ if (addResult.iterator->value == family)
+ return false;
+ addResult.iterator->value = family;
+ return true;
+}
+
+static const AtomicString& genericFontFamilyForScript(const ScriptFontFamilyMap& fontMap, UScriptCode script)
+{
+ ScriptFontFamilyMap::const_iterator it = fontMap.find(static_cast<int>(script));
+ if (it != fontMap.end())
+ return it->value;
+ if (script != USCRIPT_COMMON)
+ return genericFontFamilyForScript(fontMap, USCRIPT_COMMON);
+ return emptyAtom;
+}
+
+FontGenericFamilies::FontGenericFamilies()
+{
+}
+
+const AtomicString& FontGenericFamilies::standardFontFamily(UScriptCode script) const
+{
+ return genericFontFamilyForScript(m_standardFontFamilyMap, script);
+}
+
+const AtomicString& FontGenericFamilies::fixedFontFamily(UScriptCode script) const
+{
+ return genericFontFamilyForScript(m_fixedFontFamilyMap, script);
+}
+
+const AtomicString& FontGenericFamilies::serifFontFamily(UScriptCode script) const
+{
+ return genericFontFamilyForScript(m_serifFontFamilyMap, script);
+}
+
+const AtomicString& FontGenericFamilies::sansSerifFontFamily(UScriptCode script) const
+{
+ return genericFontFamilyForScript(m_sansSerifFontFamilyMap, script);
+}
+
+const AtomicString& FontGenericFamilies::cursiveFontFamily(UScriptCode script) const
+{
+ return genericFontFamilyForScript(m_cursiveFontFamilyMap, script);
+}
+
+const AtomicString& FontGenericFamilies::fantasyFontFamily(UScriptCode script) const
+{
+ return genericFontFamilyForScript(m_fantasyFontFamilyMap, script);
+}
+
+const AtomicString& FontGenericFamilies::pictographFontFamily(UScriptCode script) const
+{
+ return genericFontFamilyForScript(m_pictographFontFamilyMap, script);
+}
+
+bool FontGenericFamilies::setStandardFontFamily(const AtomicString& family, UScriptCode script)
+{
+ return setGenericFontFamilyForScript(m_standardFontFamilyMap, family, script);
+}
+
+bool FontGenericFamilies::setFixedFontFamily(const AtomicString& family, UScriptCode script)
+{
+ return setGenericFontFamilyForScript(m_fixedFontFamilyMap, family, script);
+}
+
+bool FontGenericFamilies::setSerifFontFamily(const AtomicString& family, UScriptCode script)
+{
+ return setGenericFontFamilyForScript(m_serifFontFamilyMap, family, script);
+}
+
+bool FontGenericFamilies::setSansSerifFontFamily(const AtomicString& family, UScriptCode script)
+{
+ return setGenericFontFamilyForScript(m_sansSerifFontFamilyMap, family, script);
+}
+
+bool FontGenericFamilies::setCursiveFontFamily(const AtomicString& family, UScriptCode script)
+{
+ return setGenericFontFamilyForScript(m_cursiveFontFamilyMap, family, script);
+}
+
+bool FontGenericFamilies::setFantasyFontFamily(const AtomicString& family, UScriptCode script)
+{
+ return setGenericFontFamilyForScript(m_fantasyFontFamilyMap, family, script);
+}
+
+bool FontGenericFamilies::setPictographFontFamily(const AtomicString& family, UScriptCode script)
+{
+ return setGenericFontFamilyForScript(m_pictographFontFamilyMap, family, script);
+}
+
+}
diff --git a/Source/WebCore/platform/graphics/FontGenericFamilies.h b/Source/WebCore/platform/graphics/FontGenericFamilies.h
new file mode 100644
index 000000000..c87c28a85
--- /dev/null
+++ b/Source/WebCore/platform/graphics/FontGenericFamilies.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef FontGenericFamilies_h
+#define FontGenericFamilies_h
+
+#include <wtf/HashMap.h>
+#include <wtf/RefCounted.h>
+#include <wtf/text/AtomicString.h>
+
+namespace WebCore {
+
+// UScriptCode uses -1 and 0 for UScriptInvalidCode and UScriptCommon.
+// We need to use -2 and -3 for empty value and deleted value.
+struct UScriptCodeHashTraits : WTF::GenericHashTraits<int> {
+ static const bool emptyValueIsZero = false;
+ static int emptyValue() { return -2; }
+ static void constructDeletedValue(int& slot) { slot = -3; }
+ static bool isDeletedValue(int value) { return value == -3; }
+};
+
+typedef HashMap<int, AtomicString, DefaultHash<int>::Hash, UScriptCodeHashTraits> ScriptFontFamilyMap;
+
+class FontGenericFamilies : public RefCounted<FontGenericFamilies> {
+public:
+ static PassRefPtr<FontGenericFamilies> create() { return adoptRef(new FontGenericFamilies); }
+
+ const AtomicString& standardFontFamily(UScriptCode = USCRIPT_COMMON) const;
+ const AtomicString& fixedFontFamily(UScriptCode = USCRIPT_COMMON) const;
+ const AtomicString& serifFontFamily(UScriptCode = USCRIPT_COMMON) const;
+ const AtomicString& sansSerifFontFamily(UScriptCode = USCRIPT_COMMON) const;
+ const AtomicString& cursiveFontFamily(UScriptCode = USCRIPT_COMMON) const;
+ const AtomicString& fantasyFontFamily(UScriptCode = USCRIPT_COMMON) const;
+ const AtomicString& pictographFontFamily(UScriptCode = USCRIPT_COMMON) const;
+
+ bool setStandardFontFamily(const AtomicString&, UScriptCode);
+ bool setFixedFontFamily(const AtomicString&, UScriptCode);
+ bool setSerifFontFamily(const AtomicString&, UScriptCode);
+ bool setSansSerifFontFamily(const AtomicString&, UScriptCode);
+ bool setCursiveFontFamily(const AtomicString&, UScriptCode);
+ bool setFantasyFontFamily(const AtomicString&, UScriptCode);
+ bool setPictographFontFamily(const AtomicString&, UScriptCode);
+
+private:
+ FontGenericFamilies();
+
+ ScriptFontFamilyMap m_standardFontFamilyMap;
+ ScriptFontFamilyMap m_serifFontFamilyMap;
+ ScriptFontFamilyMap m_fixedFontFamilyMap;
+ ScriptFontFamilyMap m_sansSerifFontFamilyMap;
+ ScriptFontFamilyMap m_cursiveFontFamilyMap;
+ ScriptFontFamilyMap m_fantasyFontFamilyMap;
+ ScriptFontFamilyMap m_pictographFontFamilyMap;
+};
+
+}
+
+#endif
diff --git a/Source/WebCore/platform/graphics/FontGlyphs.cpp b/Source/WebCore/platform/graphics/FontGlyphs.cpp
new file mode 100644
index 000000000..3c2119492
--- /dev/null
+++ b/Source/WebCore/platform/graphics/FontGlyphs.cpp
@@ -0,0 +1,422 @@
+/*
+ * Copyright (C) 2006, 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "FontGlyphs.h"
+
+#include "Font.h"
+#include "FontCache.h"
+#include "SegmentedFontData.h"
+#include <wtf/unicode/Unicode.h>
+
+namespace WebCore {
+
+
+FontGlyphs::FontGlyphs(PassRefPtr<FontSelector> fontSelector)
+ : m_pageZero(0)
+ , m_cachedPrimarySimpleFontData(0)
+ , m_fontSelector(fontSelector)
+ , m_fontSelectorVersion(m_fontSelector ? m_fontSelector->version() : 0)
+ , m_familyIndex(0)
+ , m_generation(fontCache()->generation())
+ , m_pitch(UnknownPitch)
+ , m_loadingCustomFonts(false)
+ , m_isForPlatformFont(false)
+{
+}
+
+FontGlyphs::FontGlyphs(const FontPlatformData& platformData)
+ : m_pageZero(0)
+ , m_cachedPrimarySimpleFontData(0)
+ , m_fontSelector(0)
+ , m_fontSelectorVersion(0)
+ , m_familyIndex(cAllFamiliesScanned)
+ , m_generation(fontCache()->generation())
+ , m_pitch(UnknownPitch)
+ , m_loadingCustomFonts(false)
+ , m_isForPlatformFont(true)
+{
+ RefPtr<FontData> fontData = fontCache()->getCachedFontData(&platformData);
+ m_realizedFontData.append(fontData.release());
+}
+
+void FontGlyphs::releaseFontData()
+{
+ unsigned numFonts = m_realizedFontData.size();
+ for (unsigned i = 0; i < numFonts; ++i) {
+ if (m_realizedFontData[i]->isCustomFont())
+ continue;
+ ASSERT(!m_realizedFontData[i]->isSegmented());
+ fontCache()->releaseFontData(static_cast<const SimpleFontData*>(m_realizedFontData[i].get()));
+ }
+}
+
+void FontGlyphs::determinePitch(const FontDescription& description) const
+{
+ const FontData* fontData = primaryFontData(description);
+ if (!fontData->isSegmented())
+ m_pitch = static_cast<const SimpleFontData*>(fontData)->pitch();
+ else {
+ const SegmentedFontData* segmentedFontData = static_cast<const SegmentedFontData*>(fontData);
+ unsigned numRanges = segmentedFontData->numRanges();
+ if (numRanges == 1)
+ m_pitch = segmentedFontData->rangeAt(0).fontData()->pitch();
+ else
+ m_pitch = VariablePitch;
+ }
+}
+
+const FontData* FontGlyphs::realizeFontDataAt(const FontDescription& description, unsigned realizedFontIndex) const
+{
+ if (realizedFontIndex < m_realizedFontData.size())
+ return m_realizedFontData[realizedFontIndex].get(); // This fallback font is already in our list.
+
+ // Make sure we're not passing in some crazy value here.
+ ASSERT(realizedFontIndex == m_realizedFontData.size());
+
+ if (m_familyIndex == cAllFamiliesScanned)
+ return 0;
+
+ // Ask the font cache for the font data.
+ // We are obtaining this font for the first time. We keep track of the families we've looked at before
+ // in |m_familyIndex|, so that we never scan the same spot in the list twice. getFontData will adjust our
+ // |m_familyIndex| as it scans for the right font to make.
+ ASSERT(fontCache()->generation() == m_generation);
+ RefPtr<FontData> result = fontCache()->getFontData(description, m_familyIndex, m_fontSelector.get());
+ if (result) {
+ m_realizedFontData.append(result);
+ if (result->isLoading())
+ m_loadingCustomFonts = true;
+ }
+ return result.get();
+}
+
+static inline bool isInRange(UChar32 character, UChar32 lowerBound, UChar32 upperBound)
+{
+ return character >= lowerBound && character <= upperBound;
+}
+
+static bool shouldIgnoreRotation(UChar32 character)
+{
+ if (character == 0x000A7 || character == 0x000A9 || character == 0x000AE)
+ return true;
+
+ if (character == 0x000B6 || character == 0x000BC || character == 0x000BD || character == 0x000BE)
+ return true;
+
+ if (isInRange(character, 0x002E5, 0x002EB))
+ return true;
+
+ if (isInRange(character, 0x01100, 0x011FF) || isInRange(character, 0x01401, 0x0167F) || isInRange(character, 0x01800, 0x018FF))
+ return true;
+
+ if (character == 0x02016 || character == 0x02018 || character == 0x02019 || character == 0x02020 || character == 0x02021
+ || character == 0x2030 || character == 0x02031)
+ return true;
+
+ if (isInRange(character, 0x0203B, 0x0203D) || character == 0x02042 || character == 0x02044 || character == 0x02047
+ || character == 0x02048 || character == 0x02049 || character == 0x2051)
+ return true;
+
+ if (isInRange(character, 0x02065, 0x02069) || isInRange(character, 0x020DD, 0x020E0)
+ || isInRange(character, 0x020E2, 0x020E4) || isInRange(character, 0x02100, 0x02117)
+ || isInRange(character, 0x02119, 0x02131) || isInRange(character, 0x02133, 0x0213F))
+ return true;
+
+ if (isInRange(character, 0x02145, 0x0214A) || character == 0x0214C || character == 0x0214D
+ || isInRange(character, 0x0214F, 0x0218F))
+ return true;
+
+ if (isInRange(character, 0x02300, 0x02307) || isInRange(character, 0x0230C, 0x0231F)
+ || isInRange(character, 0x02322, 0x0232B) || isInRange(character, 0x0237D, 0x0239A)
+ || isInRange(character, 0x023B4, 0x023B6) || isInRange(character, 0x023BA, 0x023CF)
+ || isInRange(character, 0x023D1, 0x023DB) || isInRange(character, 0x023E2, 0x024FF))
+ return true;
+
+ if (isInRange(character, 0x025A0, 0x02619) || isInRange(character, 0x02620, 0x02767)
+ || isInRange(character, 0x02776, 0x02793) || isInRange(character, 0x02B12, 0x02B2F)
+ || isInRange(character, 0x02B4D, 0x02BFF) || isInRange(character, 0x02E80, 0x03007))
+ return true;
+
+ if (character == 0x03012 || character == 0x03013 || isInRange(character, 0x03020, 0x0302F)
+ || isInRange(character, 0x03031, 0x0309F) || isInRange(character, 0x030A1, 0x030FB)
+ || isInRange(character, 0x030FD, 0x0A4CF))
+ return true;
+
+ if (isInRange(character, 0x0A840, 0x0A87F) || isInRange(character, 0x0A960, 0x0A97F)
+ || isInRange(character, 0x0AC00, 0x0D7FF) || isInRange(character, 0x0E000, 0x0FAFF))
+ return true;
+
+ if (isInRange(character, 0x0FE10, 0x0FE1F) || isInRange(character, 0x0FE30, 0x0FE48)
+ || isInRange(character, 0x0FE50, 0x0FE57) || isInRange(character, 0x0FE5F, 0x0FE62)
+ || isInRange(character, 0x0FE67, 0x0FE6F))
+ return true;
+
+ if (isInRange(character, 0x0FF01, 0x0FF07) || isInRange(character, 0x0FF0A, 0x0FF0C)
+ || isInRange(character, 0x0FF0E, 0x0FF19) || isInRange(character, 0x0FF1F, 0x0FF3A))
+ return true;
+
+ if (character == 0x0FF3C || character == 0x0FF3E)
+ return true;
+
+ if (isInRange(character, 0x0FF40, 0x0FF5A) || isInRange(character, 0x0FFE0, 0x0FFE2)
+ || isInRange(character, 0x0FFE4, 0x0FFE7) || isInRange(character, 0x0FFF0, 0x0FFF8)
+ || character == 0x0FFFD)
+ return true;
+
+ if (isInRange(character, 0x13000, 0x1342F) || isInRange(character, 0x1B000, 0x1B0FF)
+ || isInRange(character, 0x1D000, 0x1D1FF) || isInRange(character, 0x1D300, 0x1D37F)
+ || isInRange(character, 0x1F000, 0x1F64F) || isInRange(character, 0x1F680, 0x1F77F))
+ return true;
+
+ if (isInRange(character, 0x20000, 0x2FFFD) || isInRange(character, 0x30000, 0x3FFFD))
+ return true;
+
+ return false;
+}
+
+static inline std::pair<GlyphData, GlyphPage*> glyphDataAndPageForCJKCharacterWithoutSyntheticItalic(UChar32 character, GlyphData& data, GlyphPage* page, unsigned pageNumber)
+{
+ RefPtr<SimpleFontData> nonItalicFontData = data.fontData->nonSyntheticItalicFontData();
+ GlyphPageTreeNode* nonItalicNode = GlyphPageTreeNode::getRootChild(nonItalicFontData.get(), pageNumber);
+ GlyphPage* nonItalicPage = nonItalicNode->page();
+ if (nonItalicPage) {
+ GlyphData nonItalicData = nonItalicPage->glyphDataForCharacter(character);
+ if (nonItalicData.fontData)
+ return std::make_pair(nonItalicData, nonItalicPage);
+ }
+ return std::make_pair(data, page);
+}
+
+static inline std::pair<GlyphData, GlyphPage*> glyphDataAndPageForNonCJKCharacterWithGlyphOrientation(UChar32 character, NonCJKGlyphOrientation orientation, GlyphData& data, GlyphPage* page, unsigned pageNumber)
+{
+ if (orientation == NonCJKGlyphOrientationUpright || shouldIgnoreRotation(character)) {
+ RefPtr<SimpleFontData> uprightFontData = data.fontData->uprightOrientationFontData();
+ GlyphPageTreeNode* uprightNode = GlyphPageTreeNode::getRootChild(uprightFontData.get(), pageNumber);
+ GlyphPage* uprightPage = uprightNode->page();
+ if (uprightPage) {
+ GlyphData uprightData = uprightPage->glyphDataForCharacter(character);
+ // If the glyphs are the same, then we know we can just use the horizontal glyph rotated vertically to be upright.
+ if (data.glyph == uprightData.glyph)
+ return std::make_pair(data, page);
+ // The glyphs are distinct, meaning that the font has a vertical-right glyph baked into it. We can't use that
+ // glyph, so we fall back to the upright data and use the horizontal glyph.
+ if (uprightData.fontData)
+ return std::make_pair(uprightData, uprightPage);
+ }
+ } else if (orientation == NonCJKGlyphOrientationVerticalRight) {
+ RefPtr<SimpleFontData> verticalRightFontData = data.fontData->verticalRightOrientationFontData();
+ GlyphPageTreeNode* verticalRightNode = GlyphPageTreeNode::getRootChild(verticalRightFontData.get(), pageNumber);
+ GlyphPage* verticalRightPage = verticalRightNode->page();
+ if (verticalRightPage) {
+ GlyphData verticalRightData = verticalRightPage->glyphDataForCharacter(character);
+ // If the glyphs are distinct, we will make the assumption that the font has a vertical-right glyph baked
+ // into it.
+ if (data.glyph != verticalRightData.glyph)
+ return std::make_pair(data, page);
+ // The glyphs are identical, meaning that we should just use the horizontal glyph.
+ if (verticalRightData.fontData)
+ return std::make_pair(verticalRightData, verticalRightPage);
+ }
+ }
+ return std::make_pair(data, page);
+}
+
+std::pair<GlyphData, GlyphPage*> FontGlyphs::glyphDataAndPageForCharacter(const FontDescription& description, UChar32 c, bool mirror, FontDataVariant variant) const
+{
+ ASSERT(isMainThread());
+
+ if (variant == AutoVariant) {
+ if (description.smallCaps() && !primarySimpleFontData(description)->isSVGFont()) {
+ UChar32 upperC = WTF::Unicode::toUpper(c);
+ if (upperC != c) {
+ c = upperC;
+ variant = SmallCapsVariant;
+ } else
+ variant = NormalVariant;
+ } else
+ variant = NormalVariant;
+ }
+
+ if (mirror)
+ c = WTF::Unicode::mirroredChar(c);
+
+ unsigned pageNumber = (c / GlyphPage::size);
+
+ GlyphPageTreeNode* node = pageNumber ? m_pages.get(pageNumber) : m_pageZero;
+ if (!node) {
+ node = GlyphPageTreeNode::getRootChild(realizeFontDataAt(description, 0), pageNumber);
+ if (pageNumber)
+ m_pages.set(pageNumber, node);
+ else
+ m_pageZero = node;
+ }
+
+ GlyphPage* page = 0;
+ if (variant == NormalVariant) {
+ // Fastest loop, for the common case (normal variant).
+ while (true) {
+ page = node->page();
+ if (page) {
+ GlyphData data = page->glyphDataForCharacter(c);
+ if (data.fontData && (data.fontData->platformData().orientation() == Horizontal || data.fontData->isTextOrientationFallback()))
+ return std::make_pair(data, page);
+
+ if (data.fontData) {
+ if (Font::isCJKIdeographOrSymbol(c)) {
+ if (!data.fontData->hasVerticalGlyphs()) {
+ // Use the broken ideograph font data. The broken ideograph font will use the horizontal width of glyphs
+ // to make sure you get a square (even for broken glyphs like symbols used for punctuation).
+ variant = BrokenIdeographVariant;
+ break;
+ }
+#if PLATFORM(MAC)
+ else if (data.fontData->platformData().syntheticOblique())
+ return glyphDataAndPageForCJKCharacterWithoutSyntheticItalic(c, data, page, pageNumber);
+#endif
+ } else
+ return glyphDataAndPageForNonCJKCharacterWithGlyphOrientation(c, description.nonCJKGlyphOrientation(), data, page, pageNumber);
+
+ return std::make_pair(data, page);
+ }
+
+ if (node->isSystemFallback())
+ break;
+ }
+
+ node = node->getChild(realizeFontDataAt(description, node->level()), pageNumber);
+ if (pageNumber)
+ m_pages.set(pageNumber, node);
+ else
+ m_pageZero = node;
+ }
+ }
+ if (variant != NormalVariant) {
+ while (true) {
+ page = node->page();
+ if (page) {
+ GlyphData data = page->glyphDataForCharacter(c);
+ if (data.fontData) {
+ // The variantFontData function should not normally return 0.
+ // But if it does, we will just render the capital letter big.
+ RefPtr<SimpleFontData> variantFontData = data.fontData->variantFontData(description, variant);
+ if (!variantFontData)
+ return std::make_pair(data, page);
+
+ GlyphPageTreeNode* variantNode = GlyphPageTreeNode::getRootChild(variantFontData.get(), pageNumber);
+ GlyphPage* variantPage = variantNode->page();
+ if (variantPage) {
+ GlyphData data = variantPage->glyphDataForCharacter(c);
+ if (data.fontData)
+ return std::make_pair(data, variantPage);
+ }
+
+ // Do not attempt system fallback off the variantFontData. This is the very unlikely case that
+ // a font has the lowercase character but the small caps font does not have its uppercase version.
+ return std::make_pair(variantFontData->missingGlyphData(), page);
+ }
+
+ if (node->isSystemFallback())
+ break;
+ }
+
+ node = node->getChild(realizeFontDataAt(description, node->level()), pageNumber);
+ if (pageNumber)
+ m_pages.set(pageNumber, node);
+ else
+ m_pageZero = node;
+ }
+ }
+
+ ASSERT(page);
+ ASSERT(node->isSystemFallback());
+
+ // System fallback is character-dependent. When we get here, we
+ // know that the character in question isn't in the system fallback
+ // font's glyph page. Try to lazily create it here.
+ UChar codeUnits[2];
+ int codeUnitsLength;
+ if (c <= 0xFFFF) {
+ codeUnits[0] = Font::normalizeSpaces(c);
+ codeUnitsLength = 1;
+ } else {
+ codeUnits[0] = U16_LEAD(c);
+ codeUnits[1] = U16_TRAIL(c);
+ codeUnitsLength = 2;
+ }
+ const SimpleFontData* originalFontData = primaryFontData(description)->fontDataForCharacter(c);
+ RefPtr<SimpleFontData> characterFontData = fontCache()->systemFallbackForCharacters(description, originalFontData, m_isForPlatformFont, codeUnits, codeUnitsLength);
+ if (characterFontData) {
+ if (characterFontData->platformData().orientation() == Vertical && !characterFontData->hasVerticalGlyphs() && Font::isCJKIdeographOrSymbol(c))
+ variant = BrokenIdeographVariant;
+ if (variant != NormalVariant)
+ characterFontData = characterFontData->variantFontData(description, variant);
+ }
+ if (characterFontData) {
+ // Got the fallback glyph and font.
+ GlyphPage* fallbackPage = GlyphPageTreeNode::getRootChild(characterFontData.get(), pageNumber)->page();
+ GlyphData data = fallbackPage && fallbackPage->fontDataForCharacter(c) ? fallbackPage->glyphDataForCharacter(c) : characterFontData->missingGlyphData();
+ // Cache it so we don't have to do system fallback again next time.
+ if (variant == NormalVariant) {
+#if OS(WINCE)
+ // missingGlyphData returns a null character, which is not suitable for GDI to display.
+ // Also, sometimes we cannot map a font for the character on WINCE, but GDI can still
+ // display the character, probably because the font package is not installed correctly.
+ // So we just always set the glyph to be same as the character, and let GDI solve it.
+ page->setGlyphDataForCharacter(c, c, characterFontData.get());
+ characterFontData->setMaxGlyphPageTreeLevel(std::max(characterFontData->maxGlyphPageTreeLevel(), node->level()));
+ return std::make_pair(page->glyphDataForCharacter(c), page);
+#else
+ page->setGlyphDataForCharacter(c, data.glyph, data.fontData);
+ data.fontData->setMaxGlyphPageTreeLevel(std::max(data.fontData->maxGlyphPageTreeLevel(), node->level()));
+ if (!Font::isCJKIdeographOrSymbol(c) && data.fontData->platformData().orientation() != Horizontal && !data.fontData->isTextOrientationFallback())
+ return glyphDataAndPageForNonCJKCharacterWithGlyphOrientation(c, description.nonCJKGlyphOrientation(), data, fallbackPage, pageNumber);
+#endif
+ }
+ return std::make_pair(data, page);
+ }
+
+ // Even system fallback can fail; use the missing glyph in that case.
+ // FIXME: It would be nicer to use the missing glyph from the last resort font instead.
+ GlyphData data = primarySimpleFontData(description)->missingGlyphData();
+ if (variant == NormalVariant) {
+#if OS(WINCE)
+ // See comment about WINCE GDI handling near setGlyphDataForCharacter above.
+ page->setGlyphDataForCharacter(c, c, data.fontData);
+ data.fontData->setMaxGlyphPageTreeLevel(std::max(data.fontData->maxGlyphPageTreeLevel(), node->level()));
+ return std::make_pair(page->glyphDataForCharacter(c), page);
+#else
+ page->setGlyphDataForCharacter(c, data.glyph, data.fontData);
+ data.fontData->setMaxGlyphPageTreeLevel(std::max(data.fontData->maxGlyphPageTreeLevel(), node->level()));
+#endif
+ }
+ return std::make_pair(data, page);
+}
+
+
+}
diff --git a/Source/WebCore/platform/graphics/FontFallbackList.h b/Source/WebCore/platform/graphics/FontGlyphs.h
index 004a53a72..351e64d57 100644
--- a/Source/WebCore/platform/graphics/FontFallbackList.h
+++ b/Source/WebCore/platform/graphics/FontGlyphs.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2010, 2013 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -18,8 +18,8 @@
*
*/
-#ifndef FontFallbackList_h
-#define FontFallbackList_h
+#ifndef FontGlyphs_h
+#define FontGlyphs_h
#include "FontSelector.h"
#include "SimpleFontData.h"
@@ -29,7 +29,6 @@
namespace WebCore {
-class Font;
class GlyphPageTreeNode;
class GraphicsContext;
class IntRect;
@@ -39,39 +38,43 @@ class FontSelector;
const int cAllFamiliesScanned = -1;
-class FontFallbackList : public RefCounted<FontFallbackList> {
- WTF_MAKE_NONCOPYABLE(FontFallbackList);
+class FontGlyphs : public RefCounted<FontGlyphs> {
+ WTF_MAKE_NONCOPYABLE(FontGlyphs);
public:
typedef HashMap<int, GlyphPageTreeNode*, DefaultHash<int>::Hash> GlyphPages;
class GlyphPagesStateSaver {
public:
- GlyphPagesStateSaver(FontFallbackList& fallbackList)
- : m_fallbackList(fallbackList)
- , m_pages(fallbackList.m_pages)
- , m_pageZero(fallbackList.m_pageZero)
+ GlyphPagesStateSaver(FontGlyphs& glyphs)
+ : m_glyphs(glyphs)
+ , m_pages(glyphs.m_pages)
+ , m_pageZero(glyphs.m_pageZero)
{
}
~GlyphPagesStateSaver()
{
- m_fallbackList.m_pages = m_pages;
- m_fallbackList.m_pageZero = m_pageZero;
+ m_glyphs.m_pages = m_pages;
+ m_glyphs.m_pageZero = m_pageZero;
}
private:
- FontFallbackList& m_fallbackList;
+ FontGlyphs& m_glyphs;
GlyphPages& m_pages;
GlyphPageTreeNode* m_pageZero;
};
- static PassRefPtr<FontFallbackList> create() { return adoptRef(new FontFallbackList()); }
+ static PassRefPtr<FontGlyphs> create(PassRefPtr<FontSelector> fontSelector) { return adoptRef(new FontGlyphs(fontSelector)); }
+ static PassRefPtr<FontGlyphs> createForPlatformFont(const FontPlatformData& platformData) { return adoptRef(new FontGlyphs(platformData)); }
- ~FontFallbackList() { releaseFontData(); }
- void invalidate(PassRefPtr<FontSelector>);
+ ~FontGlyphs() { releaseFontData(); }
+
+ bool isForPlatformFont() const { return m_isForPlatformFont; }
+
+ std::pair<GlyphData, GlyphPage*> glyphDataAndPageForCharacter(const FontDescription&, UChar32, bool mirror, FontDataVariant) const;
- bool isFixedPitch(const Font* f) const { if (m_pitch == UnknownPitch) determinePitch(f); return m_pitch == FixedPitch; };
- void determinePitch(const Font*) const;
+ bool isFixedPitch(const FontDescription&) const;
+ void determinePitch(const FontDescription&) const;
bool loadingCustomFonts() const { return m_loadingCustomFonts; }
@@ -82,25 +85,17 @@ public:
WidthCache& widthCache() const { return m_widthCache; }
-private:
- FontFallbackList();
-
- const SimpleFontData* primarySimpleFontData(const Font* f)
- {
- ASSERT(isMainThread());
- if (!m_cachedPrimarySimpleFontData)
- m_cachedPrimarySimpleFontData = primaryFontData(f)->fontDataForCharacter(' ');
- return m_cachedPrimarySimpleFontData;
- }
-
- const FontData* primaryFontData(const Font* f) const { return fontDataAt(f, 0); }
- const FontData* fontDataAt(const Font*, unsigned index) const;
+ const SimpleFontData* primarySimpleFontData(const FontDescription&) const;
+ const FontData* primaryFontData(const FontDescription& description) const { return realizeFontDataAt(description, 0); }
+ const FontData* realizeFontDataAt(const FontDescription&, unsigned index) const;
- void setPlatformFont(const FontPlatformData&);
+private:
+ FontGlyphs(PassRefPtr<FontSelector>);
+ FontGlyphs(const FontPlatformData&);
void releaseFontData();
- mutable Vector<RefPtr<FontData>, 1> m_fontList;
+ mutable Vector<RefPtr<FontData>, 1> m_realizedFontData;
mutable GlyphPages m_pages;
mutable GlyphPageTreeNode* m_pageZero;
mutable const SimpleFontData* m_cachedPrimarySimpleFontData;
@@ -111,10 +106,24 @@ private:
unsigned short m_generation;
mutable unsigned m_pitch : 3; // Pitch
mutable bool m_loadingCustomFonts : 1;
+ bool m_isForPlatformFont : 1;
+};
- friend class Font;
+inline bool FontGlyphs::isFixedPitch(const FontDescription& description) const
+{
+ if (m_pitch == UnknownPitch)
+ determinePitch(description);
+ return m_pitch == FixedPitch;
};
+inline const SimpleFontData* FontGlyphs::primarySimpleFontData(const FontDescription& description) const
+{
+ ASSERT(isMainThread());
+ if (!m_cachedPrimarySimpleFontData)
+ m_cachedPrimarySimpleFontData = primaryFontData(description)->fontDataForCharacter(' ');
+ return m_cachedPrimarySimpleFontData;
+}
+
}
#endif
diff --git a/Source/WebCore/platform/graphics/FontMetrics.h b/Source/WebCore/platform/graphics/FontMetrics.h
index 7981d8eea..5142ffe25 100644
--- a/Source/WebCore/platform/graphics/FontMetrics.h
+++ b/Source/WebCore/platform/graphics/FontMetrics.h
@@ -36,7 +36,9 @@ public:
, m_lineGap(0)
, m_lineSpacing(0)
, m_xHeight(0)
+ , m_zeroWidth(0)
, m_hasXHeight(false)
+ , m_hasZeroWidth(false)
{
}
@@ -110,6 +112,16 @@ public:
return ascent() == other.ascent() && descent() == other.descent() && lineGap() == other.lineGap();
}
+ float zeroWidth() const { return m_zeroWidth; }
+ void setZeroWidth(float zeroWidth)
+ {
+ m_zeroWidth = zeroWidth;
+ m_hasZeroWidth = true;
+ }
+
+ bool hasZeroWidth() const { return m_hasZeroWidth; }
+ void setHasZeroWidth(bool hasZeroWidth) { m_hasZeroWidth = hasZeroWidth; }
+
private:
friend class SimpleFontData;
@@ -130,7 +142,9 @@ private:
float m_lineGap;
float m_lineSpacing;
float m_xHeight;
+ float m_zeroWidth;
bool m_hasXHeight;
+ bool m_hasZeroWidth;
};
static inline float scaleEmToUnits(float x, unsigned unitsPerEm)
diff --git a/Source/WebCore/platform/graphics/FontPlatformData.cpp b/Source/WebCore/platform/graphics/FontPlatformData.cpp
index e2dc5f371..913ad9070 100644
--- a/Source/WebCore/platform/graphics/FontPlatformData.cpp
+++ b/Source/WebCore/platform/graphics/FontPlatformData.cpp
@@ -27,10 +27,6 @@
#include <wtf/text/StringHash.h>
#include <wtf/text/WTFString.h>
-#if PLATFORM(CHROMIUM) && OS(DARWIN)
-#include "HarfBuzzNGFace.h"
-#endif
-
using namespace std;
namespace WebCore {
@@ -39,7 +35,6 @@ FontPlatformData::FontPlatformData(WTF::HashTableDeletedValueType)
: m_syntheticBold(false)
, m_syntheticOblique(false)
, m_orientation(Horizontal)
- , m_textOrientation(TextOrientationVerticalRight)
, m_size(0)
, m_widthVariant(RegularWidth)
#if PLATFORM(WIN)
@@ -67,7 +62,6 @@ FontPlatformData::FontPlatformData()
: m_syntheticBold(false)
, m_syntheticOblique(false)
, m_orientation(Horizontal)
- , m_textOrientation(TextOrientationVerticalRight)
, m_size(0)
, m_widthVariant(RegularWidth)
#if OS(DARWIN)
@@ -89,11 +83,10 @@ FontPlatformData::FontPlatformData()
{
}
-FontPlatformData::FontPlatformData(float size, bool syntheticBold, bool syntheticOblique, FontOrientation orientation, TextOrientation textOrientation, FontWidthVariant widthVariant)
+FontPlatformData::FontPlatformData(float size, bool syntheticBold, bool syntheticOblique, FontOrientation orientation, FontWidthVariant widthVariant)
: m_syntheticBold(syntheticBold)
, m_syntheticOblique(syntheticOblique)
, m_orientation(orientation)
- , m_textOrientation(textOrientation)
, m_size(size)
, m_widthVariant(widthVariant)
#if OS(DARWIN)
@@ -115,13 +108,11 @@ FontPlatformData::FontPlatformData(float size, bool syntheticBold, bool syntheti
{
}
-#if OS(DARWIN) && (USE(CG) || USE(SKIA_ON_MAC_CHROMIUM))
-FontPlatformData::FontPlatformData(CGFontRef cgFont, float size, bool syntheticBold, bool syntheticOblique, FontOrientation orientation,
- TextOrientation textOrientation, FontWidthVariant widthVariant)
+#if OS(DARWIN) && USE(CG)
+FontPlatformData::FontPlatformData(CGFontRef cgFont, float size, bool syntheticBold, bool syntheticOblique, FontOrientation orientation, FontWidthVariant widthVariant)
: m_syntheticBold(syntheticBold)
, m_syntheticOblique(syntheticOblique)
, m_orientation(orientation)
- , m_textOrientation(textOrientation)
, m_size(size)
, m_widthVariant(widthVariant)
, m_font(0)
@@ -137,7 +128,6 @@ FontPlatformData::FontPlatformData(const FontPlatformData& source)
: m_syntheticBold(source.m_syntheticBold)
, m_syntheticOblique(source.m_syntheticOblique)
, m_orientation(source.m_orientation)
- , m_textOrientation(source.m_textOrientation)
, m_size(source.m_size)
, m_widthVariant(source.m_widthVariant)
, m_isColorBitmapFont(source.m_isColorBitmapFont)
@@ -158,7 +148,6 @@ const FontPlatformData& FontPlatformData::operator=(const FontPlatformData& othe
m_syntheticBold = other.m_syntheticBold;
m_syntheticOblique = other.m_syntheticOblique;
m_orientation = other.m_orientation;
- m_textOrientation = other.m_textOrientation;
m_size = other.m_size;
m_widthVariant = other.m_widthVariant;
m_isColorBitmapFont = other.m_isColorBitmapFont;
diff --git a/Source/WebCore/platform/graphics/FontPlatformData.h b/Source/WebCore/platform/graphics/FontPlatformData.h
index be82845ed..32969f0ad 100644
--- a/Source/WebCore/platform/graphics/FontPlatformData.h
+++ b/Source/WebCore/platform/graphics/FontPlatformData.h
@@ -23,18 +23,14 @@
*/
// FIXME: This is temporary until all ports switch to using this file.
-#if (PLATFORM(CHROMIUM) && !OS(DARWIN)) || PLATFORM(BLACKBERRY)
-#include "chromium/FontPlatformData.h"
+#if PLATFORM(BLACKBERRY)
+#include "harfbuzz/FontPlatformDataHarfBuzz.h"
#elif PLATFORM(QT)
#include "qt/FontPlatformData.h"
-#elif PLATFORM(WIN) && OS(WINCE)
+#elif USE(WINGDI)
#include "wince/FontPlatformData.h"
-#elif PLATFORM(WX)
-#include "wx/FontPlatformData.h"
-#elif (PLATFORM(EFL) || PLATFORM(GTK)) && USE(FREETYPE)
+#elif PLATFORM(EFL) || PLATFORM(GTK)
#include "freetype/FontPlatformData.h"
-#elif (PLATFORM(EFL) || PLATFORM(GTK)) && USE(PANGO)
-#include "pango/FontPlatformData.h"
#else
#ifndef FontPlatformData_h
@@ -42,7 +38,6 @@
#include "FontOrientation.h"
#include "FontWidthVariant.h"
-#include "TextOrientation.h"
#if PLATFORM(WIN)
#include "RefCountedGDIHandle.h"
@@ -58,9 +53,6 @@ OBJC_CLASS NSFont;
typedef struct CGFont* CGFontRef;
typedef const struct __CTFont* CTFontRef;
-
-#include <CoreFoundation/CFBase.h>
-#include <objc/objc-auto.h>
#endif
#include <wtf/Forward.h>
@@ -69,15 +61,11 @@ typedef const struct __CTFont* CTFontRef;
#include <wtf/RetainPtr.h>
#include <wtf/text/StringImpl.h>
-#if PLATFORM(CHROMIUM) && OS(DARWIN)
-#include "CrossProcessFontLoading.h"
-#endif
-
#if PLATFORM(WIN)
typedef struct HFONT__* HFONT;
#endif
-#if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM)
+#if USE(CG)
typedef struct CGFont* CGFontRef;
#if OS(DARWIN)
typedef const struct __CTFont* CTFontRef;
@@ -92,10 +80,6 @@ namespace WebCore {
class FontDescription;
class SharedBuffer;
-#if PLATFORM(CHROMIUM) && OS(DARWIN)
-class HarfBuzzNGFace;
-#endif
-
#if OS(DARWIN)
inline CTFontRef toCTFontRef(NSFont *nsFont) { return reinterpret_cast<CTFontRef>(nsFont); }
#endif
@@ -106,26 +90,23 @@ public:
FontPlatformData();
FontPlatformData(const FontPlatformData&);
FontPlatformData(const FontDescription&, const AtomicString& family);
- FontPlatformData(float size, bool syntheticBold, bool syntheticOblique, FontOrientation = Horizontal,
- TextOrientation = TextOrientationVerticalRight, FontWidthVariant = RegularWidth);
+ FontPlatformData(float size, bool syntheticBold, bool syntheticOblique, FontOrientation = Horizontal, FontWidthVariant = RegularWidth);
#if OS(DARWIN)
FontPlatformData(NSFont*, float size, bool isPrinterFont = false, bool syntheticBold = false, bool syntheticOblique = false,
- FontOrientation = Horizontal, TextOrientation = TextOrientationVerticalRight, FontWidthVariant = RegularWidth);
-#if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM)
- FontPlatformData(CGFontRef, float size, bool syntheticBold, bool syntheticOblique, FontOrientation,
- TextOrientation, FontWidthVariant);
+ FontOrientation = Horizontal, FontWidthVariant = RegularWidth);
+#if USE(CG)
+ FontPlatformData(CGFontRef, float size, bool syntheticBold, bool syntheticOblique, FontOrientation, FontWidthVariant);
#endif
#endif
#if PLATFORM(WIN)
FontPlatformData(HFONT, float size, bool syntheticBold, bool syntheticOblique, bool useGDI);
#if USE(CG)
FontPlatformData(HFONT, CGFontRef, float size, bool syntheticBold, bool syntheticOblique, bool useGDI);
+#elif USE(CAIRO)
+ FontPlatformData(HFONT, cairo_font_face_t*, float size, bool bold, bool italic);
#endif
#endif
-#if USE(CAIRO)
- FontPlatformData(cairo_font_face_t*, float size, bool bold, bool italic);
-#endif
~FontPlatformData();
@@ -137,7 +118,7 @@ public:
void setFont(NSFont*);
#endif
-#if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM)
+#if USE(CG)
#if OS(DARWIN)
CGFontRef cgFont() const { return m_cgFont.get(); }
CTFontRef ctFont() const;
@@ -160,7 +141,6 @@ public:
bool isPrinterFont() const { return m_isPrinterFont; }
#endif
FontOrientation orientation() const { return m_orientation; }
- TextOrientation textOrientation() const { return m_textOrientation; }
FontWidthVariant widthVariant() const { return m_widthVariant; }
void setOrientation(FontOrientation orientation) { m_orientation = orientation; }
@@ -169,19 +149,15 @@ public:
cairo_scaled_font_t* scaledFont() const { return m_scaledFont; }
#endif
-#if PLATFORM(CHROMIUM) && OS(DARWIN)
- HarfBuzzNGFace* harfbuzzFace();
-#endif
-
unsigned hash() const
{
#if PLATFORM(WIN) && !USE(CAIRO)
return m_font ? m_font->hash() : 0;
#elif OS(DARWIN)
-#if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM)
+#if USE(CG)
ASSERT(m_font || !m_cgFont);
#endif
- uintptr_t hashCodes[3] = { (uintptr_t)m_font, m_widthVariant, static_cast<uintptr_t>(m_isPrinterFont << 4 | m_textOrientation << 3 | m_orientation << 2 | m_syntheticBold << 1 | m_syntheticOblique) };
+ uintptr_t hashCodes[3] = { (uintptr_t)m_font, m_widthVariant, static_cast<uintptr_t>(m_isPrinterFont << 3 | m_orientation << 2 | m_syntheticBold << 1 | m_syntheticOblique) };
return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes);
#elif USE(CAIRO)
return PtrHash<cairo_scaled_font_t*>::hash(m_scaledFont);
@@ -202,7 +178,6 @@ public:
&& m_isPrinterFont == other.m_isPrinterFont
#endif
&& m_orientation == other.m_orientation
- && m_textOrientation == other.m_textOrientation
&& m_widthVariant == other.m_widthVariant;
}
@@ -231,11 +206,6 @@ private:
const FontPlatformData& platformDataAssign(const FontPlatformData&);
#if OS(DARWIN)
// Load various data about the font specified by |nsFont| with the size fontSize into the following output paramters:
- // Note: Callers should always take into account that for the Chromium port, |outNSFont| isn't necessarily the same
- // font as |nsFont|. This because the sandbox may block loading of the original font.
- // * outNSFont - The font that was actually loaded, for the Chromium port this may be different than nsFont.
- // The caller is responsible for calling CFRelease() on this parameter when done with it.
- // * cgFont - CGFontRef representing the input font at the specified point size.
void loadFont(NSFont*, float fontSize, NSFont*& outNSFont, CGFontRef&);
static NSFont* hashTableDeletedFontValue() { return reinterpret_cast<NSFont *>(-1); }
#elif PLATFORM(WIN)
@@ -250,7 +220,6 @@ public:
bool m_syntheticBold;
bool m_syntheticOblique;
FontOrientation m_orientation;
- TextOrientation m_textOrientation;
float m_size;
FontWidthVariant m_widthVariant;
@@ -261,7 +230,7 @@ private:
RefPtr<RefCountedGDIHandle<HFONT> > m_font;
#endif
-#if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM)
+#if USE(CG)
#if PLATFORM(WIN)
RetainPtr<CGFontRef> m_cgFont;
#else
@@ -274,11 +243,6 @@ private:
cairo_scaled_font_t* m_scaledFont;
#endif
-#if PLATFORM(CHROMIUM) && OS(DARWIN)
- RefPtr<MemoryActivatedFont> m_inMemoryFont;
- RefPtr<HarfBuzzNGFace> m_harfbuzzFace;
-#endif
-
bool m_isColorBitmapFont;
bool m_isCompositeFontReference;
#if OS(DARWIN)
diff --git a/Source/WebCore/platform/graphics/FontSelector.h b/Source/WebCore/platform/graphics/FontSelector.h
index aaaaae2d4..6571077f6 100644
--- a/Source/WebCore/platform/graphics/FontSelector.h
+++ b/Source/WebCore/platform/graphics/FontSelector.h
@@ -40,12 +40,14 @@ class FontSelector : public RefCounted<FontSelector> {
public:
virtual ~FontSelector() { }
virtual PassRefPtr<FontData> getFontData(const FontDescription&, const AtomicString& familyName) = 0;
+ virtual bool resolvesFamilyFor(const FontDescription&) const = 0;
virtual void fontCacheInvalidated() { }
virtual void registerForInvalidationCallbacks(FontSelectorClient*) = 0;
virtual void unregisterForInvalidationCallbacks(FontSelectorClient*) = 0;
-
+
+ virtual unsigned uniqueId() const = 0;
virtual unsigned version() const = 0;
};
diff --git a/Source/WebCore/platform/graphics/GeneratedImage.cpp b/Source/WebCore/platform/graphics/GeneratedImage.cpp
index c105ca616..b250cb1c2 100644
--- a/Source/WebCore/platform/graphics/GeneratedImage.cpp
+++ b/Source/WebCore/platform/graphics/GeneratedImage.cpp
@@ -32,7 +32,6 @@
#include "GeneratedImage.h"
#include "FloatSize.h"
-#include "PlatformMemoryInstrumentation.h"
namespace WebCore {
@@ -43,10 +42,4 @@ void GeneratedImage::computeIntrinsicDimensions(Length& intrinsicWidth, Length&
intrinsicRatio = FloatSize();
}
-void GeneratedImage::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
-{
- MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Image);
- Image::reportMemoryUsage(memoryObjectInfo);
-}
-
}
diff --git a/Source/WebCore/platform/graphics/GeneratedImage.h b/Source/WebCore/platform/graphics/GeneratedImage.h
index d294af77d..bd4658882 100644
--- a/Source/WebCore/platform/graphics/GeneratedImage.h
+++ b/Source/WebCore/platform/graphics/GeneratedImage.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2008, 2013 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -28,7 +28,6 @@
#include "Image.h"
-#include "Generator.h"
#include "IntSize.h"
#include <wtf/RefPtr.h>
@@ -50,12 +49,13 @@ public:
virtual void destroyDecodedData(bool /*destroyAll*/ = true) { }
virtual unsigned decodedSize() const { return 0; }
- virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
-
protected:
- virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator) = 0;
+ virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode) = 0;
virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform,
- const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect) = 0;
+ const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect, BlendMode) = 0;
+
+ // FIXME: Implement this to be less conservative.
+ virtual bool currentFrameKnownToBeOpaque() OVERRIDE { return false; }
GeneratedImage() { }
diff --git a/Source/WebCore/platform/graphics/Generator.h b/Source/WebCore/platform/graphics/Generator.h
deleted file mode 100644
index 50155028d..000000000
--- a/Source/WebCore/platform/graphics/Generator.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef Generator_h
-#define Generator_h
-
-#include <wtf/RefCounted.h>
-
-namespace WebCore {
-
-class FloatRect;
-class GraphicsContext;
-
-class Generator : public RefCounted<Generator> {
-public:
- virtual ~Generator() {};
-
- virtual void fill(GraphicsContext*, const FloatRect&) = 0;
- virtual void adjustParametersForTiledDrawing(IntSize& /* size */, FloatRect& /* srcRect */) { }
- virtual unsigned hash() const = 0;
-};
-
-} //namespace
-
-#endif
diff --git a/Source/WebCore/platform/graphics/GeneratorGeneratedImage.cpp b/Source/WebCore/platform/graphics/GeneratorGeneratedImage.cpp
index c42f880c2..a7fc565cf 100644
--- a/Source/WebCore/platform/graphics/GeneratorGeneratedImage.cpp
+++ b/Source/WebCore/platform/graphics/GeneratorGeneratedImage.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008, 2009, 2010, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -29,29 +29,28 @@
#include "FloatRect.h"
#include "GraphicsContext.h"
#include "Length.h"
-#include "PlatformMemoryInstrumentation.h"
namespace WebCore {
-void GeneratorGeneratedImage::draw(GraphicsContext* destContext, const FloatRect& destRect, const FloatRect& srcRect, ColorSpace, CompositeOperator compositeOp)
+void GeneratorGeneratedImage::draw(GraphicsContext* destContext, const FloatRect& destRect, const FloatRect& srcRect, ColorSpace, CompositeOperator compositeOp, BlendMode blendMode)
{
GraphicsContextStateSaver stateSaver(*destContext);
- destContext->setCompositeOperation(compositeOp);
+ destContext->setCompositeOperation(compositeOp, blendMode);
destContext->clip(destRect);
destContext->translate(destRect.x(), destRect.y());
if (destRect.size() != srcRect.size())
destContext->scale(FloatSize(destRect.width() / srcRect.width(), destRect.height() / srcRect.height()));
destContext->translate(-srcRect.x(), -srcRect.y());
- destContext->fillRect(FloatRect(FloatPoint(), m_size), *m_generator.get());
+ destContext->fillRect(FloatRect(FloatPoint(), m_size), *m_gradient.get());
}
void GeneratorGeneratedImage::drawPattern(GraphicsContext* destContext, const FloatRect& srcRect, const AffineTransform& patternTransform,
- const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator compositeOp, const FloatRect& destRect)
+ const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator compositeOp, const FloatRect& destRect, BlendMode)
{
// Allow the generator to provide visually-equivalent tiling parameters for better performance.
IntSize adjustedSize = m_size;
FloatRect adjustedSrcRect = srcRect;
- m_generator->adjustParametersForTiledDrawing(adjustedSize, adjustedSrcRect);
+ m_gradient->adjustParametersForTiledDrawing(adjustedSize, adjustedSrcRect);
// Factor in the destination context's scale to generate at the best resolution
AffineTransform destContextCTM = destContext->getCTM(GraphicsContext::DefinitelyIncludeDeviceScale);
@@ -61,15 +60,15 @@ void GeneratorGeneratedImage::drawPattern(GraphicsContext* destContext, const Fl
adjustedPatternCTM.scale(1.0 / xScale, 1.0 / yScale);
adjustedSrcRect.scale(xScale, yScale);
- unsigned generatorHash = m_generator->hash();
+ unsigned generatorHash = m_gradient->hash();
if (!m_cachedImageBuffer || m_cachedGeneratorHash != generatorHash || m_cachedAdjustedSize != adjustedSize || !destContext->isCompatibleWithBuffer(m_cachedImageBuffer.get())) {
- m_cachedImageBuffer = destContext->createCompatibleBuffer(adjustedSize);
+ m_cachedImageBuffer = destContext->createCompatibleBuffer(adjustedSize, m_gradient->hasAlpha());
if (!m_cachedImageBuffer)
return;
// Fill with the generated image.
- m_cachedImageBuffer->context()->fillRect(FloatRect(FloatPoint(), adjustedSize), *m_generator);
+ m_cachedImageBuffer->context()->fillRect(FloatRect(FloatPoint(), adjustedSize), *m_gradient);
m_cachedGeneratorHash = generatorHash;
m_cachedAdjustedSize = adjustedSize;
@@ -77,22 +76,6 @@ void GeneratorGeneratedImage::drawPattern(GraphicsContext* destContext, const Fl
// Tile the image buffer into the context.
m_cachedImageBuffer->drawPattern(destContext, adjustedSrcRect, adjustedPatternCTM, phase, styleColorSpace, compositeOp, destRect);
- m_cacheTimer.restart();
-}
-
-void GeneratorGeneratedImage::invalidateCacheTimerFired(DeferrableOneShotTimer<GeneratorGeneratedImage>*)
-{
- m_cachedImageBuffer.clear();
- m_cachedAdjustedSize = IntSize();
-}
-
-void GeneratorGeneratedImage::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
-{
- MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Image);
- GeneratedImage::reportMemoryUsage(memoryObjectInfo);
- info.addMember(m_generator);
- info.addMember(m_cachedImageBuffer);
- info.addMember(m_cacheTimer);
}
}
diff --git a/Source/WebCore/platform/graphics/GeneratorGeneratedImage.h b/Source/WebCore/platform/graphics/GeneratorGeneratedImage.h
index 61100973b..0b55be655 100644
--- a/Source/WebCore/platform/graphics/GeneratorGeneratedImage.h
+++ b/Source/WebCore/platform/graphics/GeneratorGeneratedImage.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008, 2012 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2008, 2012, 2013 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,49 +27,36 @@
#define GeneratorGeneratedImage_h
#include "GeneratedImage.h"
-#include "Generator.h"
+#include "Gradient.h"
#include "Image.h"
#include "ImageBuffer.h"
#include "IntSize.h"
-#include "Timer.h"
#include <wtf/RefPtr.h>
namespace WebCore {
-static const int generatedImageCacheClearDelay = 1;
-
class GeneratorGeneratedImage : public GeneratedImage {
public:
- static PassRefPtr<GeneratorGeneratedImage> create(PassRefPtr<Generator> generator, const IntSize& size)
+ static PassRefPtr<GeneratorGeneratedImage> create(PassRefPtr<Gradient> generator, const IntSize& size)
{
return adoptRef(new GeneratorGeneratedImage(generator, size));
}
- virtual ~GeneratorGeneratedImage()
- {
- m_cacheTimer.stop();
- }
-
- virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
+ virtual ~GeneratorGeneratedImage() { }
protected:
- virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator);
+ virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode);
virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform,
- const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect);
-
- void invalidateCacheTimerFired(DeferrableOneShotTimer<GeneratorGeneratedImage>*);
+ const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect, BlendMode);
- GeneratorGeneratedImage(PassRefPtr<Generator> generator, const IntSize& size)
- : m_generator(generator)
- , m_cacheTimer(this, &GeneratorGeneratedImage::invalidateCacheTimerFired, generatedImageCacheClearDelay)
+ GeneratorGeneratedImage(PassRefPtr<Gradient> generator, const IntSize& size)
+ : m_gradient(generator)
{
m_size = size;
}
- RefPtr<Generator> m_generator;
-
+ RefPtr<Gradient> m_gradient;
OwnPtr<ImageBuffer> m_cachedImageBuffer;
- DeferrableOneShotTimer<GeneratorGeneratedImage> m_cacheTimer;
IntSize m_cachedAdjustedSize;
unsigned m_cachedGeneratorHash;
};
diff --git a/Source/WebCore/platform/graphics/GlyphBuffer.h b/Source/WebCore/platform/graphics/GlyphBuffer.h
index 9d757bc20..651415851 100644
--- a/Source/WebCore/platform/graphics/GlyphBuffer.h
+++ b/Source/WebCore/platform/graphics/GlyphBuffer.h
@@ -32,18 +32,13 @@
#include "FloatSize.h"
#include "Glyph.h"
-#include <wtf/UnusedParam.h>
#include <wtf/Vector.h>
#if USE(CG)
#include <CoreGraphics/CGGeometry.h>
#endif
-#if OS(DARWIN) && (PLATFORM(WX) || PLATFORM(CHROMIUM))
-#include <ApplicationServices/ApplicationServices.h>
-#endif
-
-#if USE(CAIRO) || (PLATFORM(WX) && defined(wxUSE_CAIRO) && wxUSE_CAIRO)
+#if USE(CAIRO)
#include <cairo.h>
#endif
@@ -51,22 +46,25 @@ namespace WebCore {
class SimpleFontData;
-#if USE(CAIRO) || (PLATFORM(WX) && defined(wxUSE_CAIRO) && wxUSE_CAIRO)
+#if USE(CAIRO)
// FIXME: Why does Cairo use such a huge struct instead of just an offset into an array?
typedef cairo_glyph_t GlyphBufferGlyph;
-#elif OS(WINCE)
+#elif USE(WINGDI)
typedef wchar_t GlyphBufferGlyph;
#elif PLATFORM(QT)
typedef quint32 GlyphBufferGlyph;
+#elif PLATFORM(BLACKBERRY)
+typedef unsigned GlyphBufferGlyph;
#else
typedef Glyph GlyphBufferGlyph;
#endif
// CG uses CGSize instead of FloatSize so that the result of advances()
// can be passed directly to CGContextShowGlyphsWithAdvances in FontMac.mm
-#if USE(CG) || (OS(DARWIN) && (PLATFORM(WX) || PLATFORM(CHROMIUM)))
+#if USE(CG)
struct GlyphBufferAdvance : CGSize {
public:
+ GlyphBufferAdvance() : CGSize(CGSizeZero) { }
GlyphBufferAdvance(CGSize size) : CGSize(size)
{
}
@@ -75,25 +73,10 @@ public:
CGFloat width() const { return this->CGSize::width; }
CGFloat height() const { return this->CGSize::height; }
};
-#elif OS(WINCE)
-// There is no cross-platform code that uses the height of GlyphBufferAdvance,
-// so we can save memory space on embedded devices by storing only the width
-struct GlyphBufferAdvance {
-public:
- GlyphBufferAdvance(float width)
- : advance(width)
- {
- }
-
- void setWidth(float width) { advance = width; }
- float width() const { return advance; }
-
-private:
- float advance;
-};
#elif PLATFORM(QT)
struct GlyphBufferAdvance : public QPointF {
public:
+ GlyphBufferAdvance() : QPointF() { }
GlyphBufferAdvance(const QPointF& advance)
: QPointF(advance)
{
@@ -128,19 +111,22 @@ public:
const GlyphBufferAdvance* advances(int from) const { return m_advances.data() + from; }
const SimpleFontData* fontDataAt(int index) const { return m_fontData[index]; }
+
+ void setInitialAdvance(GlyphBufferAdvance initialAdvance) { m_initialAdvance = initialAdvance; }
+ const GlyphBufferAdvance& initialAdvance() const { return m_initialAdvance; }
Glyph glyphAt(int index) const
{
-#if USE(CAIRO) || (PLATFORM(WX) && defined(wxUSE_CAIRO) && wxUSE_CAIRO)
+#if USE(CAIRO)
return m_glyphs[index].index;
#else
return m_glyphs[index];
#endif
}
- float advanceAt(int index) const
+ GlyphBufferAdvance advanceAt(int index) const
{
- return m_advances[index].width();
+ return m_advances[index];
}
FloatSize offsetAt(int index) const
@@ -167,7 +153,7 @@ public:
{
m_fontData.append(font);
-#if USE(CAIRO) || (PLATFORM(WX) && defined(wxUSE_CAIRO) && wxUSE_CAIRO)
+#if USE(CAIRO)
cairo_glyph_t cairoGlyph;
cairoGlyph.index = glyph;
m_glyphs.append(cairoGlyph);
@@ -175,11 +161,9 @@ public:
m_glyphs.append(glyph);
#endif
-#if USE(CG) || (OS(DARWIN) && (PLATFORM(WX) || PLATFORM(CHROMIUM)))
+#if USE(CG)
CGSize advance = { width, 0 };
m_advances.append(advance);
-#elif OS(WINCE)
- m_advances.append(width);
#elif PLATFORM(QT)
m_advances.append(QPointF(width, 0));
#else
@@ -196,11 +180,11 @@ public:
#endif
}
-#if !OS(WINCE)
+#if !USE(WINGDI)
void add(Glyph glyph, const SimpleFontData* font, GlyphBufferAdvance advance)
{
m_fontData.append(font);
-#if USE(CAIRO) || (PLATFORM(WX) && defined(wxUSE_CAIRO) && wxUSE_CAIRO)
+#if USE(CAIRO)
cairo_glyph_t cairoGlyph;
cairoGlyph.index = glyph;
m_glyphs.append(cairoGlyph);
@@ -250,6 +234,7 @@ private:
Vector<const SimpleFontData*, 2048> m_fontData;
Vector<GlyphBufferGlyph, 2048> m_glyphs;
Vector<GlyphBufferAdvance, 2048> m_advances;
+ GlyphBufferAdvance m_initialAdvance;
#if PLATFORM(WIN)
Vector<FloatSize, 2048> m_offsets;
#endif
diff --git a/Source/WebCore/platform/graphics/GlyphMetricsMap.h b/Source/WebCore/platform/graphics/GlyphMetricsMap.h
index e5aa92278..34556a79b 100644
--- a/Source/WebCore/platform/graphics/GlyphMetricsMap.h
+++ b/Source/WebCore/platform/graphics/GlyphMetricsMap.h
@@ -33,6 +33,7 @@
#include <wtf/FixedArray.h>
#include <wtf/HashMap.h>
#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
#include <wtf/unicode/Unicode.h>
namespace WebCore {
@@ -43,12 +44,6 @@ template<class T> class GlyphMetricsMap {
WTF_MAKE_NONCOPYABLE(GlyphMetricsMap);
public:
GlyphMetricsMap() : m_filledPrimaryPage(false) { }
- ~GlyphMetricsMap()
- {
- if (m_pages)
- deleteAllValues(*m_pages);
- }
-
T metricsForGlyph(Glyph glyph)
{
return locatePage(glyph / GlyphMetricsPage::size)->metricsForGlyph(glyph);
@@ -88,7 +83,7 @@ private:
bool m_filledPrimaryPage;
GlyphMetricsPage m_primaryPage; // We optimize for the page that contains glyph indices 0-255.
- OwnPtr<HashMap<int, GlyphMetricsPage*> > m_pages;
+ OwnPtr<HashMap<int, OwnPtr<GlyphMetricsPage> > > m_pages;
};
template<> inline float GlyphMetricsMap<float>::unknownMetrics()
@@ -113,9 +108,9 @@ template<class T> typename GlyphMetricsMap<T>::GlyphMetricsPage* GlyphMetricsMap
if ((page = m_pages->get(pageNumber)))
return page;
} else
- m_pages = adoptPtr(new HashMap<int, GlyphMetricsPage*>);
+ m_pages = adoptPtr(new HashMap<int, OwnPtr<GlyphMetricsPage> >);
page = new GlyphMetricsPage;
- m_pages->set(pageNumber, page);
+ m_pages->set(pageNumber, adoptPtr(page));
}
// Fill in the whole page with the unknown glyph information.
diff --git a/Source/WebCore/platform/graphics/GlyphPage.h b/Source/WebCore/platform/graphics/GlyphPage.h
index 452bc306c..853eb92b7 100644
--- a/Source/WebCore/platform/graphics/GlyphPage.h
+++ b/Source/WebCore/platform/graphics/GlyphPage.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2008, 2013 Apple Inc. All rights reserved.
* Copyright (C) Research In Motion Limited 2011. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -33,6 +33,7 @@
#include "Glyph.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
#include <wtf/unicode/Unicode.h>
namespace WebCore {
@@ -52,6 +53,11 @@ struct GlyphData {
const SimpleFontData* fontData;
};
+#if COMPILER(MSVC)
+#pragma warning(push)
+#pragma warning(disable: 4200) // Disable "zero-sized array in struct/union" warning
+#endif
+
// A GlyphPage contains a fixed-size set of GlyphData mappings for a contiguous
// range of characters in the Unicode code space. GlyphPages are indexed
// starting from 0 and incrementing for each 256 glyphs.
@@ -62,35 +68,63 @@ struct GlyphData {
// to be overriding the parent's node, but provide no additional information.
class GlyphPage : public RefCounted<GlyphPage> {
public:
- static PassRefPtr<GlyphPage> create(GlyphPageTreeNode* owner)
+ static PassRefPtr<GlyphPage> createForMixedFontData(GlyphPageTreeNode* owner)
+ {
+ void* slot = fastMalloc(sizeof(GlyphPage) + sizeof(SimpleFontData*) * GlyphPage::size);
+ return adoptRef(new (NotNull, slot) GlyphPage(owner));
+ }
+
+ static PassRefPtr<GlyphPage> createForSingleFontData(GlyphPageTreeNode* owner, const SimpleFontData* fontData)
{
- return adoptRef(new GlyphPage(owner));
+ ASSERT(fontData);
+ return adoptRef(new GlyphPage(owner, fontData));
}
+ PassRefPtr<GlyphPage> createCopiedSystemFallbackPage(GlyphPageTreeNode* owner) const
+ {
+ RefPtr<GlyphPage> page = GlyphPage::createForMixedFontData(owner);
+ memcpy(page->m_glyphs, m_glyphs, sizeof(m_glyphs));
+ if (hasPerGlyphFontData())
+ memcpy(page->m_perGlyphFontData, m_perGlyphFontData, sizeof(SimpleFontData*) * GlyphPage::size);
+ else {
+ for (size_t i = 0; i < GlyphPage::size; ++i) {
+ page->m_perGlyphFontData[i] = m_glyphs[i] ? m_fontDataForAllGlyphs : 0;
+ }
+ }
+ return page.release();
+ }
+
+ ~GlyphPage() { }
+
static const size_t size = 256; // Covers Latin-1 in a single page.
+ static unsigned indexForCharacter(UChar32 c) { return c % GlyphPage::size; }
- unsigned indexForCharacter(UChar32 c) const { return c % size; }
- GlyphData glyphDataForCharacter(UChar32 c) const
+ ALWAYS_INLINE GlyphData glyphDataForCharacter(UChar32 c) const
{
- unsigned index = indexForCharacter(c);
- return GlyphData(m_glyphs[index], m_glyphFontData[index]);
+ return glyphDataForIndex(indexForCharacter(c));
}
- GlyphData glyphDataForIndex(unsigned index) const
+ ALWAYS_INLINE GlyphData glyphDataForIndex(unsigned index) const
{
- ASSERT(index < size);
- return GlyphData(m_glyphs[index], m_glyphFontData[index]);
+ ASSERT_WITH_SECURITY_IMPLICATION(index < size);
+ Glyph glyph = m_glyphs[index];
+ if (hasPerGlyphFontData())
+ return GlyphData(glyph, m_perGlyphFontData[index]);
+ return GlyphData(glyph, glyph ? m_fontDataForAllGlyphs : 0);
}
- Glyph glyphAt(unsigned index) const
+ ALWAYS_INLINE Glyph glyphAt(unsigned index) const
{
- ASSERT(index < size);
+ ASSERT_WITH_SECURITY_IMPLICATION(index < size);
return m_glyphs[index];
}
- const SimpleFontData* fontDataForCharacter(UChar32 c) const
+ ALWAYS_INLINE const SimpleFontData* fontDataForCharacter(UChar32 c) const
{
- return m_glyphFontData[indexForCharacter(c)];
+ unsigned index = indexForCharacter(c);
+ if (hasPerGlyphFontData())
+ return m_perGlyphFontData[index];
+ return m_glyphs[index] ? m_fontDataForAllGlyphs : 0;
}
void setGlyphDataForCharacter(UChar32 c, Glyph g, const SimpleFontData* f)
@@ -98,36 +132,34 @@ public:
setGlyphDataForIndex(indexForCharacter(c), g, f);
}
- void setGlyphDataForIndex(unsigned index, Glyph g, const SimpleFontData* f)
+ void setGlyphDataForIndex(unsigned index, Glyph glyph, const SimpleFontData* fontData)
{
- ASSERT(index < size);
- m_glyphs[index] = g;
- m_glyphFontData[index] = f;
+ ASSERT_WITH_SECURITY_IMPLICATION(index < size);
+ m_glyphs[index] = glyph;
+
+ // GlyphPage getters will always return a null SimpleFontData* for glyph #0 if there's no per-glyph font array.
+ if (hasPerGlyphFontData()) {
+ m_perGlyphFontData[index] = glyph ? fontData : 0;
+ return;
+ }
+
+ // A single-font GlyphPage already assigned m_fontDataForAllGlyphs in the constructor.
+ ASSERT(!glyph || fontData == m_fontDataForAllGlyphs);
}
void setGlyphDataForIndex(unsigned index, const GlyphData& glyphData)
{
setGlyphDataForIndex(index, glyphData.glyph, glyphData.fontData);
}
-
- void copyFrom(const GlyphPage& other)
- {
- memcpy(m_glyphs, other.m_glyphs, sizeof(m_glyphs));
- memcpy(m_glyphFontData, other.m_glyphFontData, sizeof(m_glyphFontData));
- }
- void clear()
- {
- memset(m_glyphs, 0, sizeof(m_glyphs));
- memset(m_glyphFontData, 0, sizeof(m_glyphFontData));
- }
-
- void clearForFontData(const SimpleFontData* fontData)
+ void removeFontDataFromSystemFallbackPage(const SimpleFontData* fontData)
{
+ // This method should only be called on the system fallback page, which is never single-font.
+ ASSERT(hasPerGlyphFontData());
for (size_t i = 0; i < size; ++i) {
- if (m_glyphFontData[i] == fontData) {
+ if (m_perGlyphFontData[i] == fontData) {
m_glyphs[i] = 0;
- m_glyphFontData[i] = 0;
+ m_perGlyphFontData[i] = 0;
}
}
}
@@ -136,20 +168,36 @@ public:
// Implemented by the platform.
bool fill(unsigned offset, unsigned length, UChar* characterBuffer, unsigned bufferLength, const SimpleFontData*);
+#if PLATFORM(MAC)
+ static bool mayUseMixedFontDataWhenFilling(const UChar* characterBuffer, unsigned bufferLength, const SimpleFontData*);
+#else
+ static bool mayUseMixedFontDataWhenFilling(const UChar*, unsigned, const SimpleFontData*) { return false; }
+#endif
private:
- GlyphPage(GlyphPageTreeNode* owner)
- : m_owner(owner)
+ explicit GlyphPage(GlyphPageTreeNode* owner, const SimpleFontData* fontDataForAllGlyphs = 0)
+ : m_fontDataForAllGlyphs(fontDataForAllGlyphs)
+ , m_owner(owner)
{
+ memset(m_glyphs, 0, sizeof(m_glyphs));
+ if (hasPerGlyphFontData())
+ memset(m_perGlyphFontData, 0, sizeof(SimpleFontData*) * GlyphPage::size);
}
- // Separate arrays, rather than array of GlyphData, to save space.
- Glyph m_glyphs[size];
- const SimpleFontData* m_glyphFontData[size];
+ bool hasPerGlyphFontData() const { return !m_fontDataForAllGlyphs; }
+ const SimpleFontData* m_fontDataForAllGlyphs;
GlyphPageTreeNode* m_owner;
+ Glyph m_glyphs[size];
+
+ // NOTE: This array has (GlyphPage::size) elements if m_fontDataForAllGlyphs is null.
+ const SimpleFontData* m_perGlyphFontData[0];
};
+#if COMPILER(MSVC)
+#pragma warning(pop)
+#endif
+
} // namespace WebCore
-#endif // GlyphPageTreeNode_h
+#endif // GlyphPage_h
diff --git a/Source/WebCore/platform/graphics/GlyphPageTreeNode.cpp b/Source/WebCore/platform/graphics/GlyphPageTreeNode.cpp
index c11657b3d..a36f33baf 100644
--- a/Source/WebCore/platform/graphics/GlyphPageTreeNode.cpp
+++ b/Source/WebCore/platform/graphics/GlyphPageTreeNode.cpp
@@ -29,7 +29,6 @@
#include "config.h"
#include "GlyphPageTreeNode.h"
-#include "OpenTypeVerticalData.h"
#include "SegmentedFontData.h"
#include "SimpleFontData.h"
#include <stdio.h>
@@ -38,6 +37,10 @@
#include <wtf/unicode/CharacterNames.h>
#include <wtf/unicode/Unicode.h>
+#if ENABLE(OPENTYPE_VERTICAL)
+#include "OpenTypeVerticalData.h"
+#endif
+
namespace WebCore {
using std::max;
@@ -200,8 +203,6 @@ void GlyphPageTreeNode::initializePage(const FontData* fontData, unsigned pageNu
buffer[i * 2 + 1] = U16_TRAIL(c);
}
}
-
- m_page = GlyphPage::create(this);
// Now that we have a buffer full of characters, we want to get back an array
// of glyph indices. This part involves calling into the platform-specific
@@ -209,7 +210,14 @@ void GlyphPageTreeNode::initializePage(const FontData* fontData, unsigned pageNu
// Success is not guaranteed. For example, Times fails to fill page 260, giving glyph data
// for only 128 out of 256 characters.
bool haveGlyphs;
- if (fontData->isSegmented()) {
+ if (!fontData->isSegmented()) {
+ if (GlyphPage::mayUseMixedFontDataWhenFilling(buffer, bufferLength, static_cast<const SimpleFontData*>(fontData)))
+ m_page = GlyphPage::createForMixedFontData(this);
+ else
+ m_page = GlyphPage::createForSingleFontData(this, static_cast<const SimpleFontData*>(fontData));
+ haveGlyphs = fill(m_page.get(), 0, GlyphPage::size, buffer, bufferLength, static_cast<const SimpleFontData*>(fontData));
+ } else {
+ m_page = GlyphPage::createForMixedFontData(this);
haveGlyphs = false;
const SegmentedFontData* segmentedFontData = static_cast<const SegmentedFontData*>(fontData);
@@ -225,7 +233,7 @@ void GlyphPageTreeNode::initializePage(const FontData* fontData, unsigned pageNu
int to = 1 + min(static_cast<int>(range.to()) - static_cast<int>(start), static_cast<int>(GlyphPage::size) - 1);
if (from < static_cast<int>(GlyphPage::size) && to > 0) {
if (haveGlyphs && !scratchPage) {
- scratchPage = GlyphPage::create(this);
+ scratchPage = GlyphPage::createForMixedFontData(this);
pageToFill = scratchPage.get();
}
@@ -238,7 +246,7 @@ void GlyphPageTreeNode::initializePage(const FontData* fontData, unsigned pageNu
}
haveGlyphs |= fill(pageToFill, from, to - from, buffer + from * (start < 0x10000 ? 1 : 2), (to - from) * (start < 0x10000 ? 1 : 2), range.fontData().get());
if (scratchPage) {
- ASSERT(to <= static_cast<int>(GlyphPage::size));
+ ASSERT_WITH_SECURITY_IMPLICATION(to <= static_cast<int>(GlyphPage::size));
for (int j = from; j < to; j++) {
if (!m_page->glyphAt(j) && pageToFill->glyphAt(j))
m_page->setGlyphDataForIndex(j, pageToFill->glyphDataForIndex(j));
@@ -246,8 +254,7 @@ void GlyphPageTreeNode::initializePage(const FontData* fontData, unsigned pageNu
}
}
}
- } else
- haveGlyphs = fill(m_page.get(), 0, GlyphPage::size, buffer, bufferLength, static_cast<const SimpleFontData*>(fontData));
+ }
if (!haveGlyphs)
m_page = 0;
@@ -279,7 +286,7 @@ void GlyphPageTreeNode::initializePage(const FontData* fontData, unsigned pageNu
m_page = parentPage;
} else {
// Combine the parent's glyphs and ours to form a new more complete page.
- m_page = GlyphPage::create(this);
+ m_page = GlyphPage::createForMixedFontData(this);
// Overlay the parent page on the fallback page. Check if the fallback font
// has added anything.
@@ -300,15 +307,14 @@ void GlyphPageTreeNode::initializePage(const FontData* fontData, unsigned pageNu
}
}
} else {
- m_page = GlyphPage::create(this);
// System fallback. Initialized with the parent's page here, as individual
// entries may use different fonts depending on character. If the Font
// ever finds it needs a glyph out of the system fallback page, it will
// ask the system for the best font to use and fill that glyph in for us.
if (parentPage)
- m_page->copyFrom(*parentPage);
+ m_page = parentPage->createCopiedSystemFallbackPage(this);
else
- m_page->clear();
+ m_page = GlyphPage::createForMixedFontData(this);
}
}
@@ -370,7 +376,7 @@ void GlyphPageTreeNode::pruneFontData(const SimpleFontData* fontData, unsigned l
// Prune fall back child (if any) of this font.
if (m_systemFallbackChild && m_systemFallbackChild->m_page)
- m_systemFallbackChild->m_page->clearForFontData(fontData);
+ m_systemFallbackChild->m_page->removeFontDataFromSystemFallbackPage(fontData);
// Prune any branch that contains this FontData.
if (OwnPtr<GlyphPageTreeNode> node = m_children.take(fontData)) {
diff --git a/Source/WebCore/platform/graphics/Gradient.cpp b/Source/WebCore/platform/graphics/Gradient.cpp
index 95d70ba25..5345e121b 100644
--- a/Source/WebCore/platform/graphics/Gradient.cpp
+++ b/Source/WebCore/platform/graphics/Gradient.cpp
@@ -31,7 +31,6 @@
#include "FloatRect.h"
#include <wtf/HashFunctions.h>
#include <wtf/StringHasher.h>
-#include <wtf/UnusedParam.h>
using WTF::pairIntHash;
@@ -45,7 +44,6 @@ Gradient::Gradient(const FloatPoint& p0, const FloatPoint& p1)
, m_r1(0)
, m_aspectRatio(1)
, m_stopsSorted(false)
- , m_lastStop(0)
, m_spreadMethod(SpreadMethodPad)
, m_cachedHash(0)
{
@@ -60,7 +58,6 @@ Gradient::Gradient(const FloatPoint& p0, float r0, const FloatPoint& p1, float r
, m_r1(r1)
, m_aspectRatio(aspectRatio)
, m_stopsSorted(false)
- , m_lastStop(0)
, m_spreadMethod(SpreadMethodPad)
, m_cachedHash(0)
{
@@ -139,73 +136,6 @@ void Gradient::sortStopsIfNecessary()
invalidateHash();
}
-void Gradient::getColor(float value, float* r, float* g, float* b, float* a) const
-{
- ASSERT(value >= 0);
- ASSERT(value <= 1);
-
- if (m_stops.isEmpty()) {
- *r = 0;
- *g = 0;
- *b = 0;
- *a = 0;
- return;
- }
- if (!m_stopsSorted) {
- if (m_stops.size())
- std::stable_sort(m_stops.begin(), m_stops.end(), compareStops);
- m_stopsSorted = true;
- }
- if (value <= 0 || value <= m_stops.first().stop) {
- *r = m_stops.first().red;
- *g = m_stops.first().green;
- *b = m_stops.first().blue;
- *a = m_stops.first().alpha;
- return;
- }
- if (value >= 1 || value >= m_stops.last().stop) {
- *r = m_stops.last().red;
- *g = m_stops.last().green;
- *b = m_stops.last().blue;
- *a = m_stops.last().alpha;
- return;
- }
-
- // Find stop before and stop after and interpolate.
- int stop = findStop(value);
- const ColorStop& lastStop = m_stops[stop];
- const ColorStop& nextStop = m_stops[stop + 1];
- float stopFraction = (value - lastStop.stop) / (nextStop.stop - lastStop.stop);
- *r = lastStop.red + (nextStop.red - lastStop.red) * stopFraction;
- *g = lastStop.green + (nextStop.green - lastStop.green) * stopFraction;
- *b = lastStop.blue + (nextStop.blue - lastStop.blue) * stopFraction;
- *a = lastStop.alpha + (nextStop.alpha - lastStop.alpha) * stopFraction;
-}
-
-int Gradient::findStop(float value) const
-{
- ASSERT(value >= 0);
- ASSERT(value <= 1);
- ASSERT(m_stopsSorted);
-
- int numStops = m_stops.size();
- ASSERT(numStops >= 2);
- ASSERT(m_lastStop < numStops - 1);
-
- int i = m_lastStop;
- if (value < m_stops[i].stop)
- i = 1;
- else
- i = m_lastStop + 1;
-
- for (; i < numStops - 1; ++i)
- if (value < m_stops[i].stop)
- break;
-
- m_lastStop = i - 1;
- return m_lastStop;
-}
-
bool Gradient::hasAlpha() const
{
for (size_t i = 0; i < m_stops.size(); i++) {
@@ -240,7 +170,7 @@ void Gradient::setGradientSpaceTransform(const AffineTransform& gradientSpaceTra
invalidateHash();
}
-#if !USE(SKIA) && !USE(CAIRO)
+#if !USE(CAIRO) && !PLATFORM(BLACKBERRY)
void Gradient::setPlatformGradientSpaceTransform(const AffineTransform&)
{
}
@@ -258,7 +188,6 @@ unsigned Gradient::hash() const
float r0;
float r1;
float aspectRatio;
- int lastStop;
GradientSpreadMethod spreadMethod;
bool radial;
} parameters;
@@ -276,7 +205,6 @@ unsigned Gradient::hash() const
parameters.r0 = m_r0;
parameters.r1 = m_r1;
parameters.aspectRatio = m_aspectRatio;
- parameters.lastStop = m_lastStop;
parameters.spreadMethod = m_spreadMethod;
parameters.radial = m_radial;
diff --git a/Source/WebCore/platform/graphics/Gradient.h b/Source/WebCore/platform/graphics/Gradient.h
index 265e9828c..fb1df9380 100644
--- a/Source/WebCore/platform/graphics/Gradient.h
+++ b/Source/WebCore/platform/graphics/Gradient.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2008, 2011, 2012, 2013 Apple Inc. All rights reserved.
* Copyright (C) 2007 Alp Toker <alp@atoker.com>
* Copyright (C) 2008 Torch Mobile, Inc.
*
@@ -30,9 +30,9 @@
#include "AffineTransform.h"
#include "FloatPoint.h"
-#include "Generator.h"
#include "GraphicsTypes.h"
#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
#if USE(CG)
@@ -50,13 +50,15 @@ typedef QGradient* PlatformGradient;
#elif USE(CAIRO)
typedef struct _cairo_pattern cairo_pattern_t;
typedef cairo_pattern_t* PlatformGradient;
-#elif USE(SKIA)
-class SkShader;
-typedef class SkShader* PlatformGradient;
-typedef class SkShader* PlatformPattern;
-#elif PLATFORM(WX)
-class wxGraphicsBrush;
-typedef wxGraphicsBrush* PlatformGradient;
+#elif PLATFORM(BLACKBERRY)
+namespace BlackBerry {
+namespace Platform {
+namespace Graphics {
+class Gradient;
+}
+}
+}
+typedef BlackBerry::Platform::Graphics::Gradient* PlatformGradient;
#else
typedef void* PlatformGradient;
#endif
@@ -64,8 +66,10 @@ typedef void* PlatformGradient;
namespace WebCore {
class Color;
+ class FloatRect;
+ class GraphicsContext;
- class Gradient : public Generator {
+ class Gradient : public RefCounted<Gradient> {
public:
static PassRefPtr<Gradient> create(const FloatPoint& p0, const FloatPoint& p1)
{
@@ -75,13 +79,12 @@ namespace WebCore {
{
return adoptRef(new Gradient(p0, r0, p1, r1, aspectRatio));
}
- virtual ~Gradient();
+ ~Gradient();
struct ColorStop;
void addColorStop(const ColorStop&);
void addColorStop(float, const Color&);
- void getColor(float value, float* r, float* g, float* b, float* a) const;
bool hasAlpha() const;
bool isRadial() const { return m_radial; }
@@ -135,7 +138,7 @@ namespace WebCore {
float aspectRatio() const { return m_aspectRatio; }
-#if OS(WINCE) && !PLATFORM(QT)
+#if USE(WINGDI)
const Vector<ColorStop, 2>& getStops() const;
#else
PlatformGradient platformGradient();
@@ -160,12 +163,12 @@ namespace WebCore {
// Qt and CG transform the gradient at draw time
AffineTransform gradientSpaceTransform() { return m_gradientSpaceTransformation; }
- virtual void fill(GraphicsContext*, const FloatRect&);
- virtual void adjustParametersForTiledDrawing(IntSize& size, FloatRect& srcRect);
+ void fill(GraphicsContext*, const FloatRect&);
+ void adjustParametersForTiledDrawing(IntSize&, FloatRect&);
void setPlatformGradientSpaceTransform(const AffineTransform& gradientSpaceTransformation);
- virtual unsigned hash() const OVERRIDE;
+ unsigned hash() const;
void invalidateHash() { m_cachedHash = 0; }
#if USE(CG)
@@ -182,7 +185,6 @@ namespace WebCore {
void platformInit() { m_gradient = 0; }
void platformDestroy();
- int findStop(float value) const;
void sortStopsIfNecessary();
// Keep any parameters relevant to rendering in sync with the structure in Gradient::hash().
@@ -194,7 +196,6 @@ namespace WebCore {
float m_aspectRatio; // For elliptical gradient, width / height.
mutable Vector<ColorStop, 2> m_stops;
mutable bool m_stopsSorted;
- mutable int m_lastStop;
GradientSpreadMethod m_spreadMethod;
AffineTransform m_gradientSpaceTransformation;
diff --git a/Source/WebCore/platform/graphics/GraphicsContext.cpp b/Source/WebCore/platform/graphics/GraphicsContext.cpp
index 4ede7da2e..26e2dbb4a 100644
--- a/Source/WebCore/platform/graphics/GraphicsContext.cpp
+++ b/Source/WebCore/platform/graphics/GraphicsContext.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2004, 2005, 2006, 2009, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -28,7 +28,7 @@
#include "BidiResolver.h"
#include "BitmapImage.h"
-#include "Generator.h"
+#include "Gradient.h"
#include "ImageBuffer.h"
#include "IntRect.h"
#include "RoundedRect.h"
@@ -184,6 +184,29 @@ bool GraphicsContext::getShadow(FloatSize& offset, float& blur, Color& color, Co
return hasShadow();
}
+bool GraphicsContext::hasBlurredShadow() const
+{
+ return m_state.shadowColor.isValid() && m_state.shadowColor.alpha() && m_state.shadowBlur;
+}
+
+#if PLATFORM(QT) || USE(CAIRO)
+bool GraphicsContext::mustUseShadowBlur() const
+{
+ // We can't avoid ShadowBlur if the shadow has blur.
+ if (hasBlurredShadow())
+ return true;
+ // We can avoid ShadowBlur and optimize, since we're not drawing on a
+ // canvas and box shadows are affected by the transformation matrix.
+ if (!m_state.shadowsIgnoreTransforms)
+ return false;
+ // We can avoid ShadowBlur, since there are no transformations to apply to the canvas.
+ if (getCTM().isIdentity())
+ return false;
+ // Otherwise, no chance avoiding ShadowBlur.
+ return true;
+}
+#endif
+
float GraphicsContext::strokeThickness() const
{
return m_state.strokeThickness;
@@ -385,7 +408,7 @@ bool GraphicsContext::paintingDisabled() const
return m_state.paintingDisabled;
}
-#if !OS(WINCE) || PLATFORM(QT)
+#if !USE(WINGDI)
void GraphicsContext::drawText(const Font& font, const TextRun& run, const FloatPoint& point, int from, int to)
{
if (paintingDisabled())
@@ -448,63 +471,54 @@ void GraphicsContext::drawHighlightForText(const Font& font, const TextRun& run,
void GraphicsContext::drawImage(Image* image, ColorSpace styleColorSpace, const IntPoint& p, CompositeOperator op, RespectImageOrientationEnum shouldRespectImageOrientation)
{
- drawImage(image, styleColorSpace, p, IntRect(0, 0, -1, -1), op, shouldRespectImageOrientation);
+ if (!image)
+ return;
+ drawImage(image, styleColorSpace, FloatRect(IntRect(p, image->size())), FloatRect(FloatPoint(), FloatSize(image->size())), op, shouldRespectImageOrientation);
}
void GraphicsContext::drawImage(Image* image, ColorSpace styleColorSpace, const IntRect& r, CompositeOperator op, RespectImageOrientationEnum shouldRespectImageOrientation, bool useLowQualityScale)
{
- drawImage(image, styleColorSpace, r, IntRect(0, 0, -1, -1), op, shouldRespectImageOrientation, useLowQualityScale);
+ if (!image)
+ return;
+ drawImage(image, styleColorSpace, FloatRect(r), FloatRect(FloatPoint(), FloatSize(image->size())), op, shouldRespectImageOrientation, useLowQualityScale);
}
void GraphicsContext::drawImage(Image* image, ColorSpace styleColorSpace, const IntPoint& dest, const IntRect& srcRect, CompositeOperator op, RespectImageOrientationEnum shouldRespectImageOrientation)
{
- drawImage(image, styleColorSpace, IntRect(dest, srcRect.size()), srcRect, op, shouldRespectImageOrientation);
+ drawImage(image, styleColorSpace, FloatRect(IntRect(dest, srcRect.size())), FloatRect(srcRect), op, shouldRespectImageOrientation);
}
-void GraphicsContext::drawImage(Image* image, ColorSpace styleColorSpace, const IntRect& dest, const IntRect& srcRect, CompositeOperator op, RespectImageOrientationEnum shouldRespectImageOrientation, bool useLowQualityScale)
+void GraphicsContext::drawImage(Image* image, ColorSpace styleColorSpace, const FloatRect& dest, const FloatRect& src, CompositeOperator op, RespectImageOrientationEnum shouldRespectImageOrientation, bool useLowQualityScale)
{
- drawImage(image, styleColorSpace, FloatRect(dest), srcRect, op, shouldRespectImageOrientation, useLowQualityScale);
+ drawImage(image, styleColorSpace, dest, src, op, BlendModeNormal, shouldRespectImageOrientation, useLowQualityScale);
}
-void GraphicsContext::drawImage(Image* image, ColorSpace styleColorSpace, const FloatRect& dest, const FloatRect& src, CompositeOperator op, RespectImageOrientationEnum shouldRespectImageOrientation, bool useLowQualityScale)
+void GraphicsContext::drawImage(Image* image, ColorSpace styleColorSpace, const FloatRect& dest)
{
- if (paintingDisabled() || !image)
+ if (!image)
return;
+ drawImage(image, styleColorSpace, dest, FloatRect(IntRect(IntPoint(), image->size())));
+}
- float tsw = src.width();
- float tsh = src.height();
- float tw = dest.width();
- float th = dest.height();
-
- if (tsw == -1)
- tsw = image->width();
- if (tsh == -1)
- tsh = image->height();
-
- if (tw == -1)
- tw = image->width();
- if (th == -1)
- th = image->height();
+void GraphicsContext::drawImage(Image* image, ColorSpace styleColorSpace, const FloatRect& dest, const FloatRect& src, CompositeOperator op, BlendMode blendMode, RespectImageOrientationEnum shouldRespectImageOrientation, bool useLowQualityScale)
+{ if (paintingDisabled() || !image)
+ return;
InterpolationQuality previousInterpolationQuality = InterpolationDefault;
if (useLowQualityScale) {
previousInterpolationQuality = imageInterpolationQuality();
-#if PLATFORM(CHROMIUM)
- setImageInterpolationQuality(InterpolationLow);
-#else
// FIXME (49002): Should be InterpolationLow
setImageInterpolationQuality(InterpolationNone);
-#endif
}
- image->draw(this, FloatRect(dest.location(), FloatSize(tw, th)), FloatRect(src.location(), FloatSize(tsw, tsh)), styleColorSpace, op, shouldRespectImageOrientation);
+ image->draw(this, dest, src, styleColorSpace, op, blendMode, shouldRespectImageOrientation);
if (useLowQualityScale)
setImageInterpolationQuality(previousInterpolationQuality);
}
-void GraphicsContext::drawTiledImage(Image* image, ColorSpace styleColorSpace, const IntRect& destRect, const IntPoint& srcPoint, const IntSize& tileSize, CompositeOperator op, bool useLowQualityScale)
+void GraphicsContext::drawTiledImage(Image* image, ColorSpace styleColorSpace, const IntRect& destRect, const IntPoint& srcPoint, const IntSize& tileSize, CompositeOperator op, bool useLowQualityScale, BlendMode blendMode)
{
if (paintingDisabled() || !image)
return;
@@ -512,10 +526,10 @@ void GraphicsContext::drawTiledImage(Image* image, ColorSpace styleColorSpace, c
if (useLowQualityScale) {
InterpolationQuality previousInterpolationQuality = imageInterpolationQuality();
setImageInterpolationQuality(InterpolationLow);
- image->drawTiled(this, destRect, srcPoint, tileSize, styleColorSpace, op);
+ image->drawTiled(this, destRect, srcPoint, tileSize, styleColorSpace, op, blendMode);
setImageInterpolationQuality(previousInterpolationQuality);
} else
- image->drawTiled(this, destRect, srcPoint, tileSize, styleColorSpace, op);
+ image->drawTiled(this, destRect, srcPoint, tileSize, styleColorSpace, op, blendMode);
}
void GraphicsContext::drawTiledImage(Image* image, ColorSpace styleColorSpace, const IntRect& dest, const IntRect& srcRect,
@@ -539,58 +553,50 @@ void GraphicsContext::drawTiledImage(Image* image, ColorSpace styleColorSpace, c
image->drawTiled(this, dest, srcRect, tileScaleFactor, hRule, vRule, styleColorSpace, op);
}
-void GraphicsContext::drawImageBuffer(ImageBuffer* image, ColorSpace styleColorSpace, const IntPoint& p, CompositeOperator op)
+void GraphicsContext::drawImageBuffer(ImageBuffer* image, ColorSpace styleColorSpace, const IntPoint& p, CompositeOperator op, BlendMode blendMode)
{
- drawImageBuffer(image, styleColorSpace, p, IntRect(0, 0, -1, -1), op);
+ if (!image)
+ return;
+ drawImageBuffer(image, styleColorSpace, FloatRect(IntRect(p, image->logicalSize())), FloatRect(FloatPoint(), FloatSize(image->logicalSize())), op, blendMode);
}
-void GraphicsContext::drawImageBuffer(ImageBuffer* image, ColorSpace styleColorSpace, const IntRect& r, CompositeOperator op, bool useLowQualityScale)
+void GraphicsContext::drawImageBuffer(ImageBuffer* image, ColorSpace styleColorSpace, const IntRect& r, CompositeOperator op, BlendMode blendMode, bool useLowQualityScale)
{
- drawImageBuffer(image, styleColorSpace, r, IntRect(0, 0, -1, -1), op, useLowQualityScale);
+ if (!image)
+ return;
+ drawImageBuffer(image, styleColorSpace, FloatRect(r), FloatRect(FloatPoint(), FloatSize(image->logicalSize())), op, blendMode, useLowQualityScale);
}
-void GraphicsContext::drawImageBuffer(ImageBuffer* image, ColorSpace styleColorSpace, const IntPoint& dest, const IntRect& srcRect, CompositeOperator op)
+void GraphicsContext::drawImageBuffer(ImageBuffer* image, ColorSpace styleColorSpace, const IntPoint& dest, const IntRect& srcRect, CompositeOperator op, BlendMode blendMode)
{
- drawImageBuffer(image, styleColorSpace, IntRect(dest, srcRect.size()), srcRect, op);
+ drawImageBuffer(image, styleColorSpace, FloatRect(IntRect(dest, srcRect.size())), FloatRect(srcRect), op, blendMode);
}
-void GraphicsContext::drawImageBuffer(ImageBuffer* image, ColorSpace styleColorSpace, const IntRect& dest, const IntRect& srcRect, CompositeOperator op, bool useLowQualityScale)
+void GraphicsContext::drawImageBuffer(ImageBuffer* image, ColorSpace styleColorSpace, const IntRect& dest, const IntRect& srcRect, CompositeOperator op, BlendMode blendMode, bool useLowQualityScale)
{
- drawImageBuffer(image, styleColorSpace, FloatRect(dest), srcRect, op, useLowQualityScale);
+ drawImageBuffer(image, styleColorSpace, FloatRect(dest), FloatRect(srcRect), op, blendMode, useLowQualityScale);
}
-void GraphicsContext::drawImageBuffer(ImageBuffer* image, ColorSpace styleColorSpace, const FloatRect& dest, const FloatRect& src, CompositeOperator op, bool useLowQualityScale)
+void GraphicsContext::drawImageBuffer(ImageBuffer* image, ColorSpace styleColorSpace, const FloatRect& dest)
{
- if (paintingDisabled() || !image)
+ if (!image)
return;
+ drawImageBuffer(image, styleColorSpace, dest, FloatRect(IntRect(IntPoint(), image->logicalSize())));
+}
- float tsw = src.width();
- float tsh = src.height();
- float tw = dest.width();
- float th = dest.height();
-
- if (tsw == -1)
- tsw = image->logicalSize().width();
- if (tsh == -1)
- tsh = image->logicalSize().height();
-
- if (tw == -1)
- tw = image->logicalSize().width();
- if (th == -1)
- th = image->logicalSize().height();
+void GraphicsContext::drawImageBuffer(ImageBuffer* image, ColorSpace styleColorSpace, const FloatRect& dest, const FloatRect& src, CompositeOperator op, BlendMode blendMode, bool useLowQualityScale)
+{
+ if (paintingDisabled() || !image)
+ return;
if (useLowQualityScale) {
InterpolationQuality previousInterpolationQuality = imageInterpolationQuality();
-#if PLATFORM(CHROMIUM)
- setImageInterpolationQuality(InterpolationLow);
-#else
// FIXME (49002): Should be InterpolationLow
setImageInterpolationQuality(InterpolationNone);
-#endif
- image->draw(this, styleColorSpace, FloatRect(dest.location(), FloatSize(tw, th)), FloatRect(src.location(), FloatSize(tsw, tsh)), op, useLowQualityScale);
+ image->draw(this, styleColorSpace, dest, src, op, blendMode, useLowQualityScale);
setImageInterpolationQuality(previousInterpolationQuality);
} else
- image->draw(this, styleColorSpace, FloatRect(dest.location(), FloatSize(tw, th)), FloatRect(src.location(), FloatSize(tsw, tsh)), op, useLowQualityScale);
+ image->draw(this, styleColorSpace, dest, src, op, blendMode, useLowQualityScale);
}
#if !PLATFORM(QT)
@@ -600,11 +606,16 @@ void GraphicsContext::clip(const IntRect& rect)
}
#endif
-void GraphicsContext::addRoundedRectClip(const RoundedRect& rect)
+void GraphicsContext::clipRoundedRect(const RoundedRect& rect)
{
if (paintingDisabled())
return;
+ if (!rect.isRounded()) {
+ clip(rect.rect());
+ return;
+ }
+
Path path;
path.addRoundedRect(rect);
clip(path);
@@ -615,6 +626,11 @@ void GraphicsContext::clipOutRoundedRect(const RoundedRect& rect)
if (paintingDisabled())
return;
+ if (!rect.isRounded()) {
+ clipOut(rect.rect());
+ return;
+ }
+
Path path;
path.addRoundedRect(rect);
clipOut(path);
@@ -648,27 +664,33 @@ void GraphicsContext::setTextDrawingMode(TextDrawingModeFlags mode)
setPlatformTextDrawingMode(mode);
}
-void GraphicsContext::fillRect(const FloatRect& rect, Generator& generator)
+void GraphicsContext::fillRect(const FloatRect& rect, Gradient& gradient)
{
if (paintingDisabled())
return;
- generator.fill(this, rect);
+ gradient.fill(this, rect);
}
-void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorSpace styleColorSpace, CompositeOperator op)
+void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorSpace styleColorSpace, CompositeOperator op, BlendMode blendMode)
{
if (paintingDisabled())
return;
CompositeOperator previousOperator = compositeOperation();
- setCompositeOperation(op);
+ setCompositeOperation(op, blendMode);
fillRect(rect, color, styleColorSpace);
setCompositeOperation(previousOperator);
}
-void GraphicsContext::fillRoundedRect(const RoundedRect& rect, const Color& color, ColorSpace colorSpace)
+void GraphicsContext::fillRoundedRect(const RoundedRect& rect, const Color& color, ColorSpace colorSpace, BlendMode blendMode)
{
- fillRoundedRect(rect.rect(), rect.radii().topLeft(), rect.radii().topRight(), rect.radii().bottomLeft(), rect.radii().bottomRight(), color, colorSpace);
+
+ if (rect.isRounded()) {
+ setCompositeOperation(compositeOperation(), blendMode);
+ fillRoundedRect(rect.rect(), rect.radii().topLeft(), rect.radii().topRight(), rect.radii().bottomLeft(), rect.radii().bottomRight(), color, colorSpace);
+ setCompositeOperation(compositeOperation());
+ } else
+ fillRect(rect.rect(), color, colorSpace, compositeOperation(), blendMode);
}
#if !USE(CG) && !PLATFORM(QT)
@@ -699,10 +721,11 @@ void GraphicsContext::fillRectWithRoundedHole(const IntRect& rect, const Rounded
}
#endif
-void GraphicsContext::setCompositeOperation(CompositeOperator compositeOperation)
+void GraphicsContext::setCompositeOperation(CompositeOperator compositeOperation, BlendMode blendMode)
{
m_state.compositeOperator = compositeOperation;
- setPlatformCompositeOperation(compositeOperation);
+ m_state.blendMode = blendMode;
+ setPlatformCompositeOperation(compositeOperation, blendMode);
}
CompositeOperator GraphicsContext::compositeOperation() const
@@ -710,7 +733,12 @@ CompositeOperator GraphicsContext::compositeOperation() const
return m_state.compositeOperator;
}
-#if !USE(CG) && !USE(SKIA)
+BlendMode GraphicsContext::blendModeOperation() const
+{
+ return m_state.blendMode;
+}
+
+#if !USE(CG)
// Implement this if you want to go ahead and push the drawing mode into your native context
// immediately.
void GraphicsContext::setPlatformTextDrawingMode(TextDrawingModeFlags)
@@ -718,7 +746,7 @@ void GraphicsContext::setPlatformTextDrawingMode(TextDrawingModeFlags)
}
#endif
-#if !PLATFORM(QT) && !USE(CAIRO) && !USE(SKIA) && !PLATFORM(OPENVG)
+#if !PLATFORM(QT) && !USE(CAIRO)
void GraphicsContext::setPlatformStrokeStyle(StrokeStyle)
{
}
@@ -730,7 +758,7 @@ void GraphicsContext::setPlatformShouldSmoothFonts(bool)
}
#endif
-#if !USE(SKIA) && !USE(CG)
+#if !USE(CG) && !USE(CAIRO)
bool GraphicsContext::isAcceleratedContext() const
{
return false;
@@ -771,7 +799,7 @@ static bool scalesMatch(AffineTransform a, AffineTransform b)
return a.xScale() == b.xScale() && a.yScale() == b.yScale();
}
-PassOwnPtr<ImageBuffer> GraphicsContext::createCompatibleBuffer(const IntSize& size) const
+PassOwnPtr<ImageBuffer> GraphicsContext::createCompatibleBuffer(const IntSize& size, bool hasAlpha) const
{
// Make the buffer larger if the context's transform is scaling it so we need a higher
// resolution than one pixel per unit. Also set up a corresponding scale factor on the
@@ -780,7 +808,7 @@ PassOwnPtr<ImageBuffer> GraphicsContext::createCompatibleBuffer(const IntSize& s
AffineTransform transform = getCTM(DefinitelyIncludeDeviceScale);
IntSize scaledSize(static_cast<int>(ceil(size.width() * transform.xScale())), static_cast<int>(ceil(size.height() * transform.yScale())));
- OwnPtr<ImageBuffer> buffer = ImageBuffer::create(scaledSize, 1, ColorSpaceDeviceRGB, isAcceleratedContext() ? Accelerated : Unaccelerated);
+ OwnPtr<ImageBuffer> buffer = ImageBuffer::createCompatibleBuffer(scaledSize, 1, ColorSpaceDeviceRGB, this, hasAlpha);
if (!buffer)
return nullptr;
@@ -833,7 +861,7 @@ void GraphicsContext::strokeEllipseAsPath(const FloatRect& ellipse)
strokePath(path);
}
-#if !USE(CG) && !USE(SKIA) // append && !USE(MYPLATFORM) here to optimize ellipses on your platform.
+#if !USE(CG)
void GraphicsContext::platformFillEllipse(const FloatRect& ellipse)
{
if (paintingDisabled())
diff --git a/Source/WebCore/platform/graphics/GraphicsContext.h b/Source/WebCore/platform/graphics/GraphicsContext.h
index 71b3a0bbd..9c5f4da19 100644
--- a/Source/WebCore/platform/graphics/GraphicsContext.h
+++ b/Source/WebCore/platform/graphics/GraphicsContext.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights reserved.
* Copyright (C) 2008-2009 Torch Mobile, Inc.
*
* Redistribution and use in source and binary forms, with or without
@@ -46,44 +46,20 @@ namespace WebCore {
class PlatformContextCairo;
}
typedef WebCore::PlatformContextCairo PlatformGraphicsContext;
-#elif PLATFORM(OPENVG)
-namespace WebCore {
-class SurfaceOpenVG;
-}
-typedef class WebCore::SurfaceOpenVG PlatformGraphicsContext;
#elif PLATFORM(QT)
#include <QPainter>
-namespace WebCore {
-class ShadowBlur;
-}
typedef QPainter PlatformGraphicsContext;
-#elif PLATFORM(WX)
-class wxGCDC;
-class wxWindowDC;
-
-// wxGraphicsContext allows us to support Path, etc.
-// but on some platforms, e.g. Linux, it requires fairly
-// new software.
-#if USE(WXGC)
-// On OS X, wxGCDC is just a typedef for wxDC, so use wxDC explicitly to make
-// the linker happy.
-#ifdef __APPLE__
- class wxDC;
- typedef wxDC PlatformGraphicsContext;
-#else
- typedef wxGCDC PlatformGraphicsContext;
-#endif
-#else
- typedef wxWindowDC PlatformGraphicsContext;
-#endif
-#elif USE(SKIA)
-namespace WebCore {
-class PlatformContextSkia;
-typedef PlatformContextSkia GraphicsContextPlatformPrivate;
-}
-typedef WebCore::PlatformContextSkia PlatformGraphicsContext;
-#elif OS(WINCE)
+#elif USE(WINGDI)
typedef struct HDC__ PlatformGraphicsContext;
+#elif PLATFORM(BLACKBERRY)
+namespace BlackBerry {
+namespace Platform {
+namespace Graphics {
+class PlatformGraphicsContext;
+}
+}
+}
+using BlackBerry::Platform::Graphics::PlatformGraphicsContext;
#else
typedef void PlatformGraphicsContext;
#endif
@@ -103,7 +79,7 @@ typedef unsigned char UInt8;
namespace WebCore {
-#if OS(WINCE) && !PLATFORM(QT)
+#if USE(WINGDI)
class SharedBitmap;
class SimpleFontData;
class GlyphBuffer;
@@ -115,10 +91,8 @@ namespace WebCore {
class AffineTransform;
class DrawingBuffer;
- class Generator;
-#if !USE(SKIA)
+ class Gradient;
class GraphicsContextPlatformPrivate;
-#endif
class ImageBuffer;
class IntRect;
class RoundedRect;
@@ -165,6 +139,7 @@ namespace WebCore {
, fillColorSpace(ColorSpaceDeviceRGB)
, shadowColorSpace(ColorSpaceDeviceRGB)
, compositeOperator(CompositeSourceOver)
+ , blendMode(BlendModeNormal)
, shouldAntialias(true)
, shouldSmoothFonts(true)
, shouldSubpixelQuantizeFonts(true)
@@ -203,6 +178,7 @@ namespace WebCore {
ColorSpace shadowColorSpace;
CompositeOperator compositeOperator;
+ BlendMode blendMode;
bool shouldAntialias : 1;
bool shouldSmoothFonts : 1;
@@ -220,9 +196,7 @@ namespace WebCore {
GraphicsContext(PlatformGraphicsContext*);
~GraphicsContext();
-#if !OS(WINCE) || PLATFORM(QT)
PlatformGraphicsContext* platformContext() const;
-#endif
float strokeThickness() const;
void setStrokeThickness(float);
@@ -271,7 +245,7 @@ namespace WebCore {
void applyFillPattern();
void drawPath(const Path&);
- void drawNativeImage(NativeImagePtr, const FloatSize& selfSize, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator = CompositeSourceOver, ImageOrientation = DefaultImageOrientation);
+ void drawNativeImage(PassNativeImagePtr, const FloatSize& selfSize, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNormal, ImageOrientation = DefaultImageOrientation);
// Allow font smoothing (LCD antialiasing). Not part of the graphics state.
void setAllowsFontSmoothing(bool);
@@ -301,15 +275,12 @@ namespace WebCore {
void fillEllipse(const FloatRect&);
void strokeEllipse(const FloatRect&);
- // Arc drawing (used by border-radius in CSS) just supports stroking at the moment.
- void strokeArc(const IntRect&, int startAngle, int angleSpan);
-
void fillRect(const FloatRect&);
void fillRect(const FloatRect&, const Color&, ColorSpace);
- void fillRect(const FloatRect&, Generator&);
- void fillRect(const FloatRect&, const Color&, ColorSpace, CompositeOperator);
+ void fillRect(const FloatRect&, Gradient&);
+ void fillRect(const FloatRect&, const Color&, ColorSpace, CompositeOperator, BlendMode = BlendModeNormal);
void fillRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color&, ColorSpace);
- void fillRoundedRect(const RoundedRect&, const Color&, ColorSpace);
+ void fillRoundedRect(const RoundedRect&, const Color&, ColorSpace, BlendMode = BlendModeNormal);
void fillRectWithRoundedHole(const IntRect&, const RoundedRect& roundedHoleRect, const Color&, ColorSpace);
void clearRect(const FloatRect&);
@@ -319,29 +290,29 @@ namespace WebCore {
void drawImage(Image*, ColorSpace styleColorSpace, const IntPoint&, CompositeOperator = CompositeSourceOver, RespectImageOrientationEnum = DoNotRespectImageOrientation);
void drawImage(Image*, ColorSpace styleColorSpace, const IntRect&, CompositeOperator = CompositeSourceOver, RespectImageOrientationEnum = DoNotRespectImageOrientation, bool useLowQualityScale = false);
void drawImage(Image*, ColorSpace styleColorSpace, const IntPoint& destPoint, const IntRect& srcRect, CompositeOperator = CompositeSourceOver, RespectImageOrientationEnum = DoNotRespectImageOrientation);
- void drawImage(Image*, ColorSpace styleColorSpace, const IntRect& destRect, const IntRect& srcRect, CompositeOperator = CompositeSourceOver, RespectImageOrientationEnum = DoNotRespectImageOrientation, bool useLowQualityScale = false);
- void drawImage(Image*, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect = FloatRect(0, 0, -1, -1),
- CompositeOperator = CompositeSourceOver, RespectImageOrientationEnum = DoNotRespectImageOrientation, bool useLowQualityScale = false);
+ void drawImage(Image*, ColorSpace styleColorSpace, const FloatRect& destRect);
+ void drawImage(Image*, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator = CompositeSourceOver, RespectImageOrientationEnum = DoNotRespectImageOrientation, bool useLowQualityScale = false);
+ void drawImage(Image*, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator, BlendMode, RespectImageOrientationEnum = DoNotRespectImageOrientation, bool useLowQualityScale = false);
+
void drawTiledImage(Image*, ColorSpace styleColorSpace, const IntRect& destRect, const IntPoint& srcPoint, const IntSize& tileSize,
- CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
+ CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false, BlendMode = BlendModeNormal);
void drawTiledImage(Image*, ColorSpace styleColorSpace, const IntRect& destRect, const IntRect& srcRect,
const FloatSize& tileScaleFactor, Image::TileRule hRule = Image::StretchTile, Image::TileRule vRule = Image::StretchTile,
CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
- void drawImageBuffer(ImageBuffer*, ColorSpace styleColorSpace, const IntPoint&, CompositeOperator = CompositeSourceOver);
- void drawImageBuffer(ImageBuffer*, ColorSpace styleColorSpace, const IntRect&, CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
- void drawImageBuffer(ImageBuffer*, ColorSpace styleColorSpace, const IntPoint& destPoint, const IntRect& srcRect, CompositeOperator = CompositeSourceOver);
- void drawImageBuffer(ImageBuffer*, ColorSpace styleColorSpace, const IntRect& destRect, const IntRect& srcRect, CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
- void drawImageBuffer(ImageBuffer*, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect = FloatRect(0, 0, -1, -1),
- CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
+ void drawImageBuffer(ImageBuffer*, ColorSpace styleColorSpace, const IntPoint&, CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNormal);
+ void drawImageBuffer(ImageBuffer*, ColorSpace styleColorSpace, const IntRect&, CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNormal, bool useLowQualityScale = false);
+ void drawImageBuffer(ImageBuffer*, ColorSpace styleColorSpace, const IntPoint& destPoint, const IntRect& srcRect, CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNormal);
+ void drawImageBuffer(ImageBuffer*, ColorSpace styleColorSpace, const IntRect& destRect, const IntRect& srcRect, CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNormal, bool useLowQualityScale = false);
+ void drawImageBuffer(ImageBuffer*, ColorSpace styleColorSpace, const FloatRect& destRect);
+ void drawImageBuffer(ImageBuffer*, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNormal, bool useLowQualityScale = false);
void setImageInterpolationQuality(InterpolationQuality);
InterpolationQuality imageInterpolationQuality() const;
void clip(const IntRect&);
void clip(const FloatRect&);
- void addRoundedRectClip(const RoundedRect&);
- void addInnerRoundedRectClip(const IntRect&, int thickness);
+ void clipRoundedRect(const RoundedRect&);
void clipOut(const IntRect&);
void clipOutRoundedRect(const RoundedRect&);
void clipPath(const Path&, WindRule);
@@ -392,6 +363,11 @@ namespace WebCore {
bool getShadow(FloatSize&, float&, Color&, ColorSpace&) const;
void clearShadow();
+ bool hasBlurredShadow() const;
+#if PLATFORM(QT) || USE(CAIRO)
+ bool mustUseShadowBlur() const;
+#endif
+
void drawFocusRing(const Vector<IntRect>&, int width, int offset, const Color&);
void drawFocusRing(const Path&, int width, int offset, const Color&);
@@ -402,15 +378,16 @@ namespace WebCore {
void setAlpha(float);
- void setCompositeOperation(CompositeOperator);
+ void setCompositeOperation(CompositeOperator, BlendMode = BlendModeNormal);
CompositeOperator compositeOperation() const;
+ BlendMode blendModeOperation() const;
- void clip(const Path&);
+ void clip(const Path&, WindRule = RULE_EVENODD);
// This clip function is used only by <canvas> code. It allows
// implementations to handle clipping on the canvas differently since
// the discipline is different.
- void canvasClip(const Path&);
+ void canvasClip(const Path&, WindRule = RULE_EVENODD);
void clipOut(const Path&);
void scale(const FloatSize&);
@@ -434,7 +411,7 @@ namespace WebCore {
#endif
// Create an image buffer compatible with this context, with suitable resolution
// for drawing into the buffer and then into this context.
- PassOwnPtr<ImageBuffer> createCompatibleBuffer(const IntSize&) const;
+ PassOwnPtr<ImageBuffer> createCompatibleBuffer(const IntSize&, bool hasAlpha = true) const;
bool isCompatibleWithBuffer(ImageBuffer*) const;
// This function applies the device scale factor to the context, making the context capable of
@@ -446,7 +423,7 @@ namespace WebCore {
HDC getWindowsContext(const IntRect&, bool supportAlphaBlend, bool mayCreateBitmap); // The passed in rect is used to create a bitmap for compositing inside transparency layers.
void releaseWindowsContext(HDC, const IntRect&, bool supportAlphaBlend, bool mayCreateBitmap); // The passed in HDC should be the one handed back by getWindowsContext.
#if PLATFORM(WIN)
-#if OS(WINCE)
+#if USE(WINGDI)
void setBitmap(PassRefPtr<SharedBitmap>);
const AffineTransform& affineTransform() const;
AffineTransform& affineTransform();
@@ -456,7 +433,7 @@ namespace WebCore {
void drawFrameControl(const IntRect& rect, unsigned type, unsigned state);
void drawFocusRect(const IntRect& rect);
void paintTextField(const IntRect& rect, unsigned state);
- void drawBitmap(SharedBitmap*, const IntRect& dstRect, const IntRect& srcRect, ColorSpace styleColorSpace, CompositeOperator compositeOp);
+ void drawBitmap(SharedBitmap*, const IntRect& dstRect, const IntRect& srcRect, ColorSpace styleColorSpace, CompositeOperator compositeOp, BlendMode blendMode);
void drawBitmapPattern(SharedBitmap*, const FloatRect& tileRectIn, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect, const IntSize& origSourceSize);
void drawIcon(HICON icon, const IntRect& dstRect, UINT flags);
void drawRoundCorner(bool newClip, RECT clipRect, RECT rectWin, HDC dc, int width, int height);
@@ -503,21 +480,11 @@ namespace WebCore {
#endif // PLATFORM(WIN)
#endif // OS(WINDOWS)
-#if PLATFORM(WX)
- // This is needed because of a bug whereby getting an HDC from a GDI+ context
- // loses the scale operations applied to the context.
- FloatSize currentScale();
-#endif
-
#if PLATFORM(QT)
void pushTransparencyLayerInternal(const QRect&, qreal, QPixmap&);
void takeOwnershipOfPlatformContext();
#endif
-#if PLATFORM(QT)
- ShadowBlur* shadowBlur();
-#endif
-
#if USE(CAIRO)
GraphicsContext(cairo_t*);
#endif
@@ -534,7 +501,7 @@ namespace WebCore {
void platformInit(PlatformGraphicsContext*);
void platformDestroy();
-#if PLATFORM(WIN) && !OS(WINCE)
+#if PLATFORM(WIN) && !USE(WINGDI)
void platformInit(HDC, bool hasAlpha = false);
#endif
@@ -542,7 +509,6 @@ namespace WebCore {
void restorePlatformState();
void setPlatformTextDrawingMode(TextDrawingModeFlags);
- void setPlatformFont(const Font& font);
void setPlatformStrokeColor(const Color&, ColorSpace);
void setPlatformStrokeStyle(StrokeStyle);
@@ -556,7 +522,7 @@ namespace WebCore {
void setPlatformShadow(const FloatSize&, float blur, const Color&, ColorSpace);
void clearPlatformShadow();
- void setPlatformCompositeOperation(CompositeOperator);
+ void setPlatformCompositeOperation(CompositeOperator, BlendMode = BlendModeNormal);
void beginPlatformTransparencyLayer(float opacity);
void endPlatformTransparencyLayer();
diff --git a/Source/WebCore/platform/graphics/GraphicsContext3D.cpp b/Source/WebCore/platform/graphics/GraphicsContext3D.cpp
index a98b546ba..5a248d0a5 100644
--- a/Source/WebCore/platform/graphics/GraphicsContext3D.cpp
+++ b/Source/WebCore/platform/graphics/GraphicsContext3D.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2010 Apple Inc. All rights reserved.
* Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2010 Mozilla Corporation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -29,15 +30,16 @@
#if USE(3D_GRAPHICS)
#include "GraphicsContext3D.h"
-#include "GraphicsContext3DNEON.h"
-#include "CheckedInt.h"
-#include "DrawingBuffer.h"
#include "Extensions3D.h"
#include "Image.h"
#include "ImageData.h"
#include "ImageObserver.h"
+#if HAVE(ARM_NEON_INTRINSICS)
+#include "GraphicsContext3DNEON.h"
+#endif
+
#include <wtf/ArrayBufferView.h>
#include <wtf/OwnArrayPtr.h>
#include <wtf/PassOwnArrayPtr.h>
@@ -46,14 +48,65 @@ namespace WebCore {
namespace {
-uint8_t convertColor16LittleTo8(uint16_t value)
-{
- return value >> 8;
-}
-
-uint8_t convertColor16BigTo8(uint16_t value)
+GraphicsContext3D::DataFormat getDataFormat(GC3Denum destinationFormat, GC3Denum destinationType)
{
- return static_cast<uint8_t>(value & 0x00FF);
+ GraphicsContext3D::DataFormat dstFormat = GraphicsContext3D::DataFormatRGBA8;
+ switch (destinationType) {
+ case GraphicsContext3D::UNSIGNED_BYTE:
+ switch (destinationFormat) {
+ case GraphicsContext3D::RGB:
+ dstFormat = GraphicsContext3D::DataFormatRGB8;
+ break;
+ case GraphicsContext3D::RGBA:
+ dstFormat = GraphicsContext3D::DataFormatRGBA8;
+ break;
+ case GraphicsContext3D::ALPHA:
+ dstFormat = GraphicsContext3D::DataFormatA8;
+ break;
+ case GraphicsContext3D::LUMINANCE:
+ dstFormat = GraphicsContext3D::DataFormatR8;
+ break;
+ case GraphicsContext3D::LUMINANCE_ALPHA:
+ dstFormat = GraphicsContext3D::DataFormatRA8;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ break;
+ case GraphicsContext3D::UNSIGNED_SHORT_4_4_4_4:
+ dstFormat = GraphicsContext3D::DataFormatRGBA4444;
+ break;
+ case GraphicsContext3D::UNSIGNED_SHORT_5_5_5_1:
+ dstFormat = GraphicsContext3D::DataFormatRGBA5551;
+ break;
+ case GraphicsContext3D::UNSIGNED_SHORT_5_6_5:
+ dstFormat = GraphicsContext3D::DataFormatRGB565;
+ break;
+ case GraphicsContext3D::FLOAT: // OES_texture_float
+ switch (destinationFormat) {
+ case GraphicsContext3D::RGB:
+ dstFormat = GraphicsContext3D::DataFormatRGB32F;
+ break;
+ case GraphicsContext3D::RGBA:
+ dstFormat = GraphicsContext3D::DataFormatRGBA32F;
+ break;
+ case GraphicsContext3D::ALPHA:
+ dstFormat = GraphicsContext3D::DataFormatA32F;
+ break;
+ case GraphicsContext3D::LUMINANCE:
+ dstFormat = GraphicsContext3D::DataFormatR32F;
+ break;
+ case GraphicsContext3D::LUMINANCE_ALPHA:
+ dstFormat = GraphicsContext3D::DataFormatRA32F;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ return dstFormat;
}
} // anonymous namespace
@@ -124,6 +177,9 @@ bool GraphicsContext3D::computeFormatAndTypeParameters(GC3Denum format,
case GraphicsContext3D::FLOAT: // OES_texture_float
*bytesPerComponent = sizeof(GC3Dfloat);
break;
+ case GraphicsContext3D::HALF_FLOAT_OES: // OES_texture_half_float
+ *bytesPerComponent = sizeof(GC3Dhalffloat);
+ break;
default:
return false;
}
@@ -146,11 +202,11 @@ GC3Denum GraphicsContext3D::computeImageSizeInBytes(GC3Denum format, GC3Denum ty
*paddingInBytes = 0;
return GraphicsContext3D::NO_ERROR;
}
- CheckedInt<uint32_t> checkedValue(bytesPerComponent * componentsPerPixel);
+ Checked<uint32_t, RecordOverflow> checkedValue = bytesPerComponent * componentsPerPixel;
checkedValue *= width;
- if (!checkedValue.isValid())
+ if (checkedValue.hasOverflowed())
return GraphicsContext3D::INVALID_VALUE;
- unsigned int validRowSize = checkedValue.value();
+ unsigned int validRowSize = checkedValue.unsafeGet();
unsigned int padding = 0;
unsigned int residual = validRowSize % alignment;
if (residual) {
@@ -160,38 +216,45 @@ GC3Denum GraphicsContext3D::computeImageSizeInBytes(GC3Denum format, GC3Denum ty
// Last row needs no padding.
checkedValue *= (height - 1);
checkedValue += validRowSize;
- if (!checkedValue.isValid())
+ if (checkedValue.hasOverflowed())
return GraphicsContext3D::INVALID_VALUE;
- *imageSizeInBytes = checkedValue.value();
+ *imageSizeInBytes = checkedValue.unsafeGet();
if (paddingInBytes)
*paddingInBytes = padding;
return GraphicsContext3D::NO_ERROR;
}
-bool GraphicsContext3D::extractImageData(Image* image,
- GC3Denum format,
- GC3Denum type,
- bool flipY,
- bool premultiplyAlpha,
- bool ignoreGammaAndColorProfile,
- Vector<uint8_t>& data)
+GraphicsContext3D::ImageExtractor::ImageExtractor(Image* image, ImageHtmlDomSource imageHtmlDomSource, bool premultiplyAlpha, bool ignoreGammaAndColorProfile)
{
- if (!image)
+ m_image = image;
+ m_imageHtmlDomSource = imageHtmlDomSource;
+ m_extractSucceeded = extractImage(premultiplyAlpha, ignoreGammaAndColorProfile);
+}
+
+bool GraphicsContext3D::packImageData(
+ Image* image,
+ const void* pixels,
+ GC3Denum format,
+ GC3Denum type,
+ bool flipY,
+ AlphaOp alphaOp,
+ DataFormat sourceFormat,
+ unsigned width,
+ unsigned height,
+ unsigned sourceUnpackAlignment,
+ Vector<uint8_t>& data)
+{
+ if (!pixels)
return false;
- if (!getImageData(image, format, type, premultiplyAlpha, ignoreGammaAndColorProfile, data))
+
+ unsigned packedSize;
+ // Output data is tightly packed (alignment == 1).
+ if (computeImageSizeInBytes(format, type, width, height, 1, &packedSize, 0) != GraphicsContext3D::NO_ERROR)
+ return false;
+ data.resize(packedSize);
+
+ if (!packPixels(reinterpret_cast<const uint8_t*>(pixels), sourceFormat, width, height, sourceUnpackAlignment, format, type, alphaOp, data.data(), flipY))
return false;
- if (flipY) {
- unsigned int componentsPerPixel, bytesPerComponent;
- if (!computeFormatAndTypeParameters(format, type,
- &componentsPerPixel,
- &bytesPerComponent))
- return false;
- // The image data is tightly packed, and we upload it as such.
- unsigned int unpackAlignment = 1;
- flipVertically(data.data(), image->width(), image->height(),
- componentsPerPixel * bytesPerComponent,
- unpackAlignment);
- }
if (ImageObserver *observer = image->imageObserver())
observer->didDraw(image);
return true;
@@ -215,28 +278,9 @@ bool GraphicsContext3D::extractImageData(ImageData* imageData,
return false;
data.resize(packedSize);
- if (!packPixels(imageData->data()->data(),
- SourceFormatRGBA8,
- width,
- height,
- 0,
- format,
- type,
- premultiplyAlpha ? AlphaDoPremultiply : AlphaDoNothing,
- data.data()))
+ if (!packPixels(imageData->data()->data(), DataFormatRGBA8, width, height, 0, format, type, premultiplyAlpha ? AlphaDoPremultiply : AlphaDoNothing, data.data(), flipY))
return false;
- if (flipY) {
- unsigned int componentsPerPixel, bytesPerComponent;
- if (!computeFormatAndTypeParameters(format, type,
- &componentsPerPixel,
- &bytesPerComponent))
- return false;
- // The image data is tightly packed, and we upload it as such.
- unsigned int unpackAlignment = 1;
- flipVertically(data.data(), width, height,
- componentsPerPixel * bytesPerComponent,
- unpackAlignment);
- }
+
return true;
}
@@ -248,62 +292,7 @@ bool GraphicsContext3D::extractTextureData(unsigned int width, unsigned int heig
Vector<uint8_t>& data)
{
// Assumes format, type, etc. have already been validated.
- SourceDataFormat sourceDataFormat = SourceFormatRGBA8;
- switch (type) {
- case UNSIGNED_BYTE:
- switch (format) {
- case RGBA:
- sourceDataFormat = SourceFormatRGBA8;
- break;
- case RGB:
- sourceDataFormat = SourceFormatRGB8;
- break;
- case ALPHA:
- sourceDataFormat = SourceFormatA8;
- break;
- case LUMINANCE:
- sourceDataFormat = SourceFormatR8;
- break;
- case LUMINANCE_ALPHA:
- sourceDataFormat = SourceFormatRA8;
- break;
- default:
- ASSERT_NOT_REACHED();
- }
- break;
- case FLOAT: // OES_texture_float
- switch (format) {
- case RGBA:
- sourceDataFormat = SourceFormatRGBA32F;
- break;
- case RGB:
- sourceDataFormat = SourceFormatRGB32F;
- break;
- case ALPHA:
- sourceDataFormat = SourceFormatA32F;
- break;
- case LUMINANCE:
- sourceDataFormat = SourceFormatR32F;
- break;
- case LUMINANCE_ALPHA:
- sourceDataFormat = SourceFormatRA32F;
- break;
- default:
- ASSERT_NOT_REACHED();
- }
- break;
- case UNSIGNED_SHORT_5_5_5_1:
- sourceDataFormat = SourceFormatRGBA5551;
- break;
- case UNSIGNED_SHORT_4_4_4_4:
- sourceDataFormat = SourceFormatRGBA4444;
- break;
- case UNSIGNED_SHORT_5_6_5:
- sourceDataFormat = SourceFormatRGB565;
- break;
- default:
- ASSERT_NOT_REACHED();
- }
+ DataFormat sourceDataFormat = getDataFormat(format, type);
// Resize the output buffer.
unsigned int componentsPerPixel, bytesPerComponent;
@@ -314,79 +303,29 @@ bool GraphicsContext3D::extractTextureData(unsigned int width, unsigned int heig
unsigned int bytesPerPixel = componentsPerPixel * bytesPerComponent;
data.resize(width * height * bytesPerPixel);
- if (!packPixels(static_cast<const uint8_t*>(pixels),
- sourceDataFormat,
- width, height, unpackAlignment,
- format, type,
- (premultiplyAlpha ? AlphaDoPremultiply : AlphaDoNothing),
- data.data()))
+ if (!packPixels(static_cast<const uint8_t*>(pixels), sourceDataFormat, width, height, unpackAlignment, format, type, (premultiplyAlpha ? AlphaDoPremultiply : AlphaDoNothing), data.data(), flipY))
return false;
- // The pixel data is now tightly packed.
- if (flipY)
- flipVertically(data.data(), width, height, bytesPerPixel, 1);
+
return true;
}
-void GraphicsContext3D::flipVertically(void* imageData,
- unsigned int width,
- unsigned int height,
- unsigned int bytesPerPixel,
- unsigned int unpackAlignment)
-{
- if (!width || !height)
- return;
- unsigned int validRowBytes = width * bytesPerPixel;
- unsigned int totalRowBytes = validRowBytes;
- unsigned int remainder = validRowBytes % unpackAlignment;
- if (remainder)
- totalRowBytes += (unpackAlignment - remainder);
- uint8_t* tempRow = new uint8_t[validRowBytes];
- uint8_t* data = static_cast<uint8_t*>(imageData);
- for (unsigned i = 0; i < height / 2; i++) {
- uint8_t* lowRow = data + (totalRowBytes * i);
- uint8_t* highRow = data + (totalRowBytes * (height - i - 1));
- memcpy(tempRow, lowRow, validRowBytes);
- memcpy(lowRow, highRow, validRowBytes);
- memcpy(highRow, tempRow, validRowBytes);
- }
- delete[] tempRow;
-}
-
-// The following packing and unpacking routines are expressed in terms
-// of line-by-line operations, and passed by function pointer rather
-// than template parameter, to achieve the majority of the speedups of
-// having them inlined while reducing code size.
-
namespace {
-//----------------------------------------------------------------------
-// Pixel unpacking routines.
+/* BEGIN CODE SHARED WITH MOZILLA FIREFOX */
-void unpackOneRowOfRGBA16LittleToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow)
-{
- for (unsigned int i = 0; i < pixelsPerRow; ++i) {
- destination[0] = convertColor16LittleTo8(source[0]);
- destination[1] = convertColor16LittleTo8(source[1]);
- destination[2] = convertColor16LittleTo8(source[2]);
- destination[3] = convertColor16LittleTo8(source[3]);
- source += 4;
- destination += 4;
- }
-}
+// The following packing and unpacking routines are expressed in terms of function templates and inline functions to achieve generality and speedup.
+// Explicit template specializations correspond to the cases that would occur.
+// Some code are merged back from Mozilla code in http://mxr.mozilla.org/mozilla-central/source/content/canvas/src/WebGLTexelConversions.h
-void unpackOneRowOfRGBA16BigToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow)
+//----------------------------------------------------------------------
+// Pixel unpacking routines.
+template<int format, typename SourceType, typename DstType>
+ALWAYS_INLINE void unpack(const SourceType*, DstType*, unsigned)
{
- for (unsigned int i = 0; i < pixelsPerRow; ++i) {
- destination[0] = convertColor16BigTo8(source[0]);
- destination[1] = convertColor16BigTo8(source[1]);
- destination[2] = convertColor16BigTo8(source[2]);
- destination[3] = convertColor16BigTo8(source[3]);
- source += 4;
- destination += 4;
- }
+ ASSERT_NOT_REACHED();
}
-void unpackOneRowOfRGB8ToRGBA8(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatRGB8, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
destination[0] = source[0];
@@ -398,31 +337,7 @@ void unpackOneRowOfRGB8ToRGBA8(const uint8_t* source, uint8_t* destination, unsi
}
}
-void unpackOneRowOfRGB16LittleToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow)
-{
- for (unsigned int i = 0; i < pixelsPerRow; ++i) {
- destination[0] = convertColor16LittleTo8(source[0]);
- destination[1] = convertColor16LittleTo8(source[1]);
- destination[2] = convertColor16LittleTo8(source[2]);
- destination[3] = 0xFF;
- source += 3;
- destination += 4;
- }
-}
-
-void unpackOneRowOfRGB16BigToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow)
-{
- for (unsigned int i = 0; i < pixelsPerRow; ++i) {
- destination[0] = convertColor16BigTo8(source[0]);
- destination[1] = convertColor16BigTo8(source[1]);
- destination[2] = convertColor16BigTo8(source[2]);
- destination[3] = 0xFF;
- source += 3;
- destination += 4;
- }
-}
-
-void unpackOneRowOfBGR8ToRGBA8(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatBGR8, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
destination[0] = source[2];
@@ -434,7 +349,7 @@ void unpackOneRowOfBGR8ToRGBA8(const uint8_t* source, uint8_t* destination, unsi
}
}
-void unpackOneRowOfARGB8ToRGBA8(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatARGB8, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
destination[0] = source[1];
@@ -446,31 +361,7 @@ void unpackOneRowOfARGB8ToRGBA8(const uint8_t* source, uint8_t* destination, uns
}
}
-void unpackOneRowOfARGB16LittleToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow)
-{
- for (unsigned int i = 0; i < pixelsPerRow; ++i) {
- destination[0] = convertColor16LittleTo8(source[1]);
- destination[1] = convertColor16LittleTo8(source[2]);
- destination[2] = convertColor16LittleTo8(source[3]);
- destination[3] = convertColor16LittleTo8(source[0]);
- source += 4;
- destination += 4;
- }
-}
-
-void unpackOneRowOfARGB16BigToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow)
-{
- for (unsigned int i = 0; i < pixelsPerRow; ++i) {
- destination[0] = convertColor16BigTo8(source[1]);
- destination[1] = convertColor16BigTo8(source[2]);
- destination[2] = convertColor16BigTo8(source[3]);
- destination[3] = convertColor16BigTo8(source[0]);
- source += 4;
- destination += 4;
- }
-}
-
-void unpackOneRowOfABGR8ToRGBA8(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatABGR8, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
destination[0] = source[3];
@@ -482,7 +373,7 @@ void unpackOneRowOfABGR8ToRGBA8(const uint8_t* source, uint8_t* destination, uns
}
}
-void unpackOneRowOfBGRA8ToRGBA8(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatBGRA8, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
{
const uint32_t* source32 = reinterpret_cast_ptr<const uint32_t*>(source);
uint32_t* destination32 = reinterpret_cast_ptr<uint32_t*>(destination);
@@ -500,41 +391,10 @@ void unpackOneRowOfBGRA8ToRGBA8(const uint8_t* source, uint8_t* destination, uns
}
}
-void unpackOneRowOfBGRA16LittleToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow)
-{
- for (unsigned int i = 0; i < pixelsPerRow; ++i) {
- destination[0] = convertColor16LittleTo8(source[2]);
- destination[1] = convertColor16LittleTo8(source[1]);
- destination[2] = convertColor16LittleTo8(source[0]);
- destination[3] = convertColor16LittleTo8(source[3]);
- source += 4;
- destination += 4;
- }
-}
-
-void unpackOneRowOfBGRA16BigToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow)
-{
- for (unsigned int i = 0; i < pixelsPerRow; ++i) {
- destination[0] = convertColor16BigTo8(source[2]);
- destination[1] = convertColor16BigTo8(source[1]);
- destination[2] = convertColor16BigTo8(source[0]);
- destination[3] = convertColor16BigTo8(source[3]);
- source += 4;
- destination += 4;
- }
-}
-
-void unpackOneRowOfRGBA5551ToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatRGBA5551, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
{
#if HAVE(ARM_NEON_INTRINSICS)
- unsigned tailPixels = pixelsPerRow % 8;
- unsigned pixelSize = pixelsPerRow - tailPixels;
-
- ARM::unpackOneRowOfRGBA5551ToRGBA8NEON(source, destination, pixelSize);
-
- source += pixelSize;
- destination += pixelSize * 4;
- pixelsPerRow = tailPixels;
+ SIMD::unpackOneRowOfRGBA5551ToRGBA8(source, destination, pixelsPerRow);
#endif
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
uint16_t packedValue = source[0];
@@ -550,17 +410,10 @@ void unpackOneRowOfRGBA5551ToRGBA8(const uint16_t* source, uint8_t* destination,
}
}
-void unpackOneRowOfRGBA4444ToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatRGBA4444, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
{
#if HAVE(ARM_NEON_INTRINSICS)
- unsigned tailPixels = pixelsPerRow % 8;
- unsigned pixelSize = pixelsPerRow - tailPixels;
-
- ARM::unpackOneRowOfRGBA4444ToRGBA8NEON(source, destination, pixelSize);
-
- source += pixelSize;
- destination += pixelSize * 4;
- pixelsPerRow = tailPixels;
+ SIMD::unpackOneRowOfRGBA4444ToRGBA8(source, destination, pixelsPerRow);
#endif
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
uint16_t packedValue = source[0];
@@ -577,17 +430,10 @@ void unpackOneRowOfRGBA4444ToRGBA8(const uint16_t* source, uint8_t* destination,
}
}
-void unpackOneRowOfRGB565ToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatRGB565, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
{
#if HAVE(ARM_NEON_INTRINSICS)
- unsigned tailPixels = pixelsPerRow % 8;
- unsigned pixelSize = pixelsPerRow - tailPixels;
-
- ARM::unpackOneRowOfRGB565ToRGBA8NEON(source, destination, pixelSize);
-
- source += pixelSize;
- destination += pixelSize * 4;
- pixelsPerRow = tailPixels;
+ SIMD::unpackOneRowOfRGB565ToRGBA8(source, destination, pixelsPerRow);
#endif
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
uint16_t packedValue = source[0];
@@ -603,7 +449,7 @@ void unpackOneRowOfRGB565ToRGBA8(const uint16_t* source, uint8_t* destination, u
}
}
-void unpackOneRowOfR8ToRGBA8(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatR8, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
destination[0] = source[0];
@@ -615,31 +461,7 @@ void unpackOneRowOfR8ToRGBA8(const uint8_t* source, uint8_t* destination, unsign
}
}
-void unpackOneRowOfR16LittleToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow)
-{
- for (unsigned int i = 0; i < pixelsPerRow; ++i) {
- destination[0] = convertColor16LittleTo8(source[0]);
- destination[1] = convertColor16LittleTo8(source[0]);
- destination[2] = convertColor16LittleTo8(source[0]);
- destination[3] = 0xFF;
- source += 1;
- destination += 4;
- }
-}
-
-void unpackOneRowOfR16BigToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow)
-{
- for (unsigned int i = 0; i < pixelsPerRow; ++i) {
- destination[0] = convertColor16BigTo8(source[0]);
- destination[1] = convertColor16BigTo8(source[0]);
- destination[2] = convertColor16BigTo8(source[0]);
- destination[3] = 0xFF;
- source += 1;
- destination += 4;
- }
-}
-
-void unpackOneRowOfRA8ToRGBA8(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatRA8, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
destination[0] = source[0];
@@ -651,31 +473,7 @@ void unpackOneRowOfRA8ToRGBA8(const uint8_t* source, uint8_t* destination, unsig
}
}
-void unpackOneRowOfRA16LittleToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow)
-{
- for (unsigned int i = 0; i < pixelsPerRow; ++i) {
- destination[0] = convertColor16LittleTo8(source[0]);
- destination[1] = convertColor16LittleTo8(source[0]);
- destination[2] = convertColor16LittleTo8(source[0]);
- destination[3] = convertColor16LittleTo8(source[1]);
- source += 2;
- destination += 4;
- }
-}
-
-void unpackOneRowOfRA16BigToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow)
-{
- for (unsigned int i = 0; i < pixelsPerRow; ++i) {
- destination[0] = convertColor16BigTo8(source[0]);
- destination[1] = convertColor16BigTo8(source[0]);
- destination[2] = convertColor16BigTo8(source[0]);
- destination[3] = convertColor16BigTo8(source[1]);
- source += 2;
- destination += 4;
- }
-}
-
-void unpackOneRowOfAR8ToRGBA8(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatAR8, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
destination[0] = source[1];
@@ -687,93 +485,97 @@ void unpackOneRowOfAR8ToRGBA8(const uint8_t* source, uint8_t* destination, unsig
}
}
-void unpackOneRowOfAR16LittleToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatA8, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
- destination[0] = convertColor16LittleTo8(source[1]);
- destination[1] = convertColor16LittleTo8(source[1]);
- destination[2] = convertColor16LittleTo8(source[1]);
- destination[3] = convertColor16LittleTo8(source[0]);
- source += 2;
+ destination[0] = 0x0;
+ destination[1] = 0x0;
+ destination[2] = 0x0;
+ destination[3] = source[0];
+ source += 1;
destination += 4;
}
}
-void unpackOneRowOfAR16BigToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatRGBA8, uint8_t, float>(const uint8_t* source, float* destination, unsigned pixelsPerRow)
{
+ const float scaleFactor = 1.0f / 255.0f;
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
- destination[0] = convertColor16BigTo8(source[1]);
- destination[1] = convertColor16BigTo8(source[1]);
- destination[2] = convertColor16BigTo8(source[1]);
- destination[3] = convertColor16BigTo8(source[0]);
- source += 2;
+ destination[0] = source[0] * scaleFactor;
+ destination[1] = source[1] * scaleFactor;
+ destination[2] = source[2] * scaleFactor;
+ destination[3] = source[3] * scaleFactor;
+ source += 4;
destination += 4;
}
}
-void unpackOneRowOfA8ToRGBA8(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatBGRA8, uint8_t, float>(const uint8_t* source, float* destination, unsigned pixelsPerRow)
{
+ const float scaleFactor = 1.0f / 255.0f;
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
- destination[0] = 0x0;
- destination[1] = 0x0;
- destination[2] = 0x0;
- destination[3] = source[0];
- source += 1;
+ destination[0] = source[2] * scaleFactor;
+ destination[1] = source[1] * scaleFactor;
+ destination[2] = source[0] * scaleFactor;
+ destination[3] = source[3] * scaleFactor;
+ source += 4;
destination += 4;
}
}
-void unpackOneRowOfA16LittleToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatABGR8, uint8_t, float>(const uint8_t* source, float* destination, unsigned pixelsPerRow)
{
- for (unsigned int i = 0; i < pixelsPerRow; ++i) {
- destination[0] = 0x0;
- destination[1] = 0x0;
- destination[2] = 0x0;
- destination[3] = convertColor16LittleTo8(source[0]);
- source += 1;
+ const float scaleFactor = 1.0f / 255.0f;
+ for (unsigned i = 0; i < pixelsPerRow; ++i) {
+ destination[0] = source[3] * scaleFactor;
+ destination[1] = source[2] * scaleFactor;
+ destination[2] = source[1] * scaleFactor;
+ destination[3] = source[0] * scaleFactor;
+ source += 4;
destination += 4;
}
}
-void unpackOneRowOfA16BigToRGBA8(const uint16_t* source, uint8_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatARGB8, uint8_t, float>(const uint8_t* source, float* destination, unsigned pixelsPerRow)
{
- for (unsigned int i = 0; i < pixelsPerRow; ++i) {
- destination[0] = 0x0;
- destination[1] = 0x0;
- destination[2] = 0x0;
- destination[3] = convertColor16BigTo8(source[0]);
- source += 1;
+ const float scaleFactor = 1.0f / 255.0f;
+ for (unsigned i = 0; i < pixelsPerRow; ++i) {
+ destination[0] = source[1] * scaleFactor;
+ destination[1] = source[2] * scaleFactor;
+ destination[2] = source[3] * scaleFactor;
+ destination[3] = source[0] * scaleFactor;
+ source += 4;
destination += 4;
}
}
-void unpackOneRowOfRGBA8ToRGBA32F(const uint8_t* source, float* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatRGB8, uint8_t, float>(const uint8_t* source, float* destination, unsigned pixelsPerRow)
{
const float scaleFactor = 1.0f / 255.0f;
- for (unsigned int i = 0; i < pixelsPerRow; ++i) {
+ for (unsigned i = 0; i < pixelsPerRow; ++i) {
destination[0] = source[0] * scaleFactor;
destination[1] = source[1] * scaleFactor;
destination[2] = source[2] * scaleFactor;
- destination[3] = source[3] * scaleFactor;
- source += 4;
+ destination[3] = 1;
+ source += 3;
destination += 4;
}
}
-void unpackOneRowOfBGRA8ToRGBA32F(const uint8_t* source, float* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatBGR8, uint8_t, float>(const uint8_t* source, float* destination, unsigned pixelsPerRow)
{
const float scaleFactor = 1.0f / 255.0f;
- for (unsigned int i = 0; i < pixelsPerRow; ++i) {
+ for (unsigned i = 0; i < pixelsPerRow; ++i) {
destination[0] = source[2] * scaleFactor;
destination[1] = source[1] * scaleFactor;
destination[2] = source[0] * scaleFactor;
- destination[3] = source[3] * scaleFactor;
- source += 4;
+ destination[3] = 1;
+ source += 3;
destination += 4;
}
}
-void unpackOneRowOfRGB32FToRGBA32F(const float* source, float* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatRGB32F, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
destination[0] = source[0];
@@ -785,7 +587,7 @@ void unpackOneRowOfRGB32FToRGBA32F(const float* source, float* destination, unsi
}
}
-void unpackOneRowOfR32FToRGBA32F(const float* source, float* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatR32F, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
destination[0] = source[0];
@@ -797,7 +599,7 @@ void unpackOneRowOfR32FToRGBA32F(const float* source, float* destination, unsign
}
}
-void unpackOneRowOfRA32FToRGBA32F(const float* source, float* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatRA32F, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
destination[0] = source[0];
@@ -809,7 +611,7 @@ void unpackOneRowOfRA32FToRGBA32F(const float* source, float* destination, unsig
}
}
-void unpackOneRowOfA32FToRGBA32F(const float* source, float* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void unpack<GraphicsContext3D::DataFormatA32F, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
destination[0] = 0;
@@ -825,7 +627,13 @@ void unpackOneRowOfA32FToRGBA32F(const float* source, float* destination, unsign
// Pixel packing routines.
//
-void packOneRowOfRGBA8ToA8(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow)
+template<int format, int alphaOp, typename SourceType, typename DstType>
+ALWAYS_INLINE void pack(const SourceType*, DstType*, unsigned)
+{
+ ASSERT_NOT_REACHED();
+}
+
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatA8, GraphicsContext3D::AlphaDoNothing, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
destination[0] = source[3];
@@ -834,7 +642,7 @@ void packOneRowOfRGBA8ToA8(const uint8_t* source, uint8_t* destination, unsigned
}
}
-void packOneRowOfRGBA8ToR8(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatR8, GraphicsContext3D::AlphaDoNothing, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
destination[0] = source[0];
@@ -843,7 +651,7 @@ void packOneRowOfRGBA8ToR8(const uint8_t* source, uint8_t* destination, unsigned
}
}
-void packOneRowOfRGBA8ToR8Premultiply(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatR8, GraphicsContext3D::AlphaDoPremultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
float scaleFactor = source[3] / 255.0f;
@@ -855,10 +663,10 @@ void packOneRowOfRGBA8ToR8Premultiply(const uint8_t* source, uint8_t* destinatio
}
// FIXME: this routine is lossy and must be removed.
-void packOneRowOfRGBA8ToR8Unmultiply(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatR8, GraphicsContext3D::AlphaDoUnmultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
- float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f);
+ float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor);
destination[0] = sourceR;
source += 4;
@@ -866,7 +674,7 @@ void packOneRowOfRGBA8ToR8Unmultiply(const uint8_t* source, uint8_t* destination
}
}
-void packOneRowOfRGBA8ToRA8(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRA8, GraphicsContext3D::AlphaDoNothing, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
destination[0] = source[0];
@@ -876,7 +684,7 @@ void packOneRowOfRGBA8ToRA8(const uint8_t* source, uint8_t* destination, unsigne
}
}
-void packOneRowOfRGBA8ToRA8Premultiply(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRA8, GraphicsContext3D::AlphaDoPremultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
float scaleFactor = source[3] / 255.0f;
@@ -889,10 +697,10 @@ void packOneRowOfRGBA8ToRA8Premultiply(const uint8_t* source, uint8_t* destinati
}
// FIXME: this routine is lossy and must be removed.
-void packOneRowOfRGBA8ToRA8Unmultiply(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRA8, GraphicsContext3D::AlphaDoUnmultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
- float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f);
+ float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor);
destination[0] = sourceR;
destination[1] = source[3];
@@ -901,7 +709,7 @@ void packOneRowOfRGBA8ToRA8Unmultiply(const uint8_t* source, uint8_t* destinatio
}
}
-void packOneRowOfRGBA8ToRGB8(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB8, GraphicsContext3D::AlphaDoNothing, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
destination[0] = source[0];
@@ -912,7 +720,7 @@ void packOneRowOfRGBA8ToRGB8(const uint8_t* source, uint8_t* destination, unsign
}
}
-void packOneRowOfRGBA8ToRGB8Premultiply(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB8, GraphicsContext3D::AlphaDoPremultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
float scaleFactor = source[3] / 255.0f;
@@ -928,10 +736,10 @@ void packOneRowOfRGBA8ToRGB8Premultiply(const uint8_t* source, uint8_t* destinat
}
// FIXME: this routine is lossy and must be removed.
-void packOneRowOfRGBA8ToRGB8Unmultiply(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB8, GraphicsContext3D::AlphaDoUnmultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
- float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f);
+ float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor);
uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor);
uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * scaleFactor);
@@ -943,7 +751,13 @@ void packOneRowOfRGBA8ToRGB8Unmultiply(const uint8_t* source, uint8_t* destinati
}
}
-void packOneRowOfRGBA8ToRGBA8Premultiply(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow)
+
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA8, GraphicsContext3D::AlphaDoNothing, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+ memcpy(destination, source, pixelsPerRow * 4);
+}
+
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA8, GraphicsContext3D::AlphaDoPremultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
float scaleFactor = source[3] / 255.0f;
@@ -960,10 +774,10 @@ void packOneRowOfRGBA8ToRGBA8Premultiply(const uint8_t* source, uint8_t* destina
}
// FIXME: this routine is lossy and must be removed.
-void packOneRowOfRGBA8ToRGBA8Unmultiply(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA8, GraphicsContext3D::AlphaDoUnmultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
- float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f);
+ float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor);
uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor);
uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * scaleFactor);
@@ -976,18 +790,10 @@ void packOneRowOfRGBA8ToRGBA8Unmultiply(const uint8_t* source, uint8_t* destinat
}
}
-void packOneRowOfRGBA8ToUnsignedShort4444(const uint8_t* source, uint16_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA4444, GraphicsContext3D::AlphaDoNothing, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
{
#if HAVE(ARM_NEON_INTRINSICS)
- unsigned componentsPerRow = pixelsPerRow * 4;
- unsigned tailComponents = componentsPerRow % 32;
- unsigned componentsSize = componentsPerRow - tailComponents;
-
- ARM::packOneRowOfRGBA8ToUnsignedShort4444NEON(source, destination, componentsSize);
-
- source += componentsSize;
- destination += componentsSize / 4;
- pixelsPerRow = tailComponents / 4;
+ SIMD::packOneRowOfRGBA8ToUnsignedShort4444(source, destination, pixelsPerRow);
#endif
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
*destination = (((source[0] & 0xF0) << 8)
@@ -999,7 +805,7 @@ void packOneRowOfRGBA8ToUnsignedShort4444(const uint8_t* source, uint16_t* desti
}
}
-void packOneRowOfRGBA8ToUnsignedShort4444Premultiply(const uint8_t* source, uint16_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA4444, GraphicsContext3D::AlphaDoPremultiply, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
float scaleFactor = source[3] / 255.0f;
@@ -1016,10 +822,10 @@ void packOneRowOfRGBA8ToUnsignedShort4444Premultiply(const uint8_t* source, uint
}
// FIXME: this routine is lossy and must be removed.
-void packOneRowOfRGBA8ToUnsignedShort4444Unmultiply(const uint8_t* source, uint16_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA4444, GraphicsContext3D::AlphaDoUnmultiply, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
- float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f);
+ float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor);
uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor);
uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * scaleFactor);
@@ -1032,18 +838,10 @@ void packOneRowOfRGBA8ToUnsignedShort4444Unmultiply(const uint8_t* source, uint1
}
}
-void packOneRowOfRGBA8ToUnsignedShort5551(const uint8_t* source, uint16_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA5551, GraphicsContext3D::AlphaDoNothing, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
{
#if HAVE(ARM_NEON_INTRINSICS)
- unsigned componentsPerRow = pixelsPerRow * 4;
- unsigned tailComponents = componentsPerRow % 32;
- unsigned componentsSize = componentsPerRow - tailComponents;
-
- ARM::packOneRowOfRGBA8ToUnsignedShort5551NEON(source, destination, componentsSize);
-
- source += componentsSize;
- destination += componentsSize / 4;
- pixelsPerRow = tailComponents / 4;
+ SIMD::packOneRowOfRGBA8ToUnsignedShort5551(source, destination, pixelsPerRow);
#endif
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
*destination = (((source[0] & 0xF8) << 8)
@@ -1055,7 +853,7 @@ void packOneRowOfRGBA8ToUnsignedShort5551(const uint8_t* source, uint16_t* desti
}
}
-void packOneRowOfRGBA8ToUnsignedShort5551Premultiply(const uint8_t* source, uint16_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA5551, GraphicsContext3D::AlphaDoPremultiply, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
float scaleFactor = source[3] / 255.0f;
@@ -1072,10 +870,10 @@ void packOneRowOfRGBA8ToUnsignedShort5551Premultiply(const uint8_t* source, uint
}
// FIXME: this routine is lossy and must be removed.
-void packOneRowOfRGBA8ToUnsignedShort5551Unmultiply(const uint8_t* source, uint16_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA5551, GraphicsContext3D::AlphaDoUnmultiply, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
- float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f);
+ float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor);
uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor);
uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * scaleFactor);
@@ -1088,18 +886,10 @@ void packOneRowOfRGBA8ToUnsignedShort5551Unmultiply(const uint8_t* source, uint1
}
}
-void packOneRowOfRGBA8ToUnsignedShort565(const uint8_t* source, uint16_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB565, GraphicsContext3D::AlphaDoNothing, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
{
#if HAVE(ARM_NEON_INTRINSICS)
- unsigned componentsPerRow = pixelsPerRow * 4;
- unsigned tailComponents = componentsPerRow % 32;
- unsigned componentsSize = componentsPerRow - tailComponents;
-
- ARM::packOneRowOfRGBA8ToUnsignedShort565NEON(source, destination, componentsSize);
-
- source += componentsSize;
- destination += componentsSize / 4;
- pixelsPerRow = tailComponents / 4;
+ SIMD::packOneRowOfRGBA8ToUnsignedShort565(source, destination, pixelsPerRow);
#endif
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
*destination = (((source[0] & 0xF8) << 8)
@@ -1110,7 +900,7 @@ void packOneRowOfRGBA8ToUnsignedShort565(const uint8_t* source, uint16_t* destin
}
}
-void packOneRowOfRGBA8ToUnsignedShort565Premultiply(const uint8_t* source, uint16_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB565, GraphicsContext3D::AlphaDoPremultiply, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
float scaleFactor = source[3] / 255.0f;
@@ -1126,10 +916,10 @@ void packOneRowOfRGBA8ToUnsignedShort565Premultiply(const uint8_t* source, uint1
}
// FIXME: this routine is lossy and must be removed.
-void packOneRowOfRGBA8ToUnsignedShort565Unmultiply(const uint8_t* source, uint16_t* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB565, GraphicsContext3D::AlphaDoUnmultiply, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
- float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f);
+ float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor);
uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor);
uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * scaleFactor);
@@ -1141,7 +931,7 @@ void packOneRowOfRGBA8ToUnsignedShort565Unmultiply(const uint8_t* source, uint16
}
}
-void packOneRowOfRGBA32FToRGB32F(const float* source, float* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB32F, GraphicsContext3D::AlphaDoNothing, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
destination[0] = source[0];
@@ -1152,7 +942,7 @@ void packOneRowOfRGBA32FToRGB32F(const float* source, float* destination, unsign
}
}
-void packOneRowOfRGBA32FToRGB32FPremultiply(const float* source, float* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB32F, GraphicsContext3D::AlphaDoPremultiply, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
float scaleFactor = source[3];
@@ -1164,7 +954,7 @@ void packOneRowOfRGBA32FToRGB32FPremultiply(const float* source, float* destinat
}
}
-void packOneRowOfRGBA32FToRGB32FUnmultiply(const float* source, float* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGB32F, GraphicsContext3D::AlphaDoUnmultiply, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f;
@@ -1177,19 +967,12 @@ void packOneRowOfRGBA32FToRGB32FUnmultiply(const float* source, float* destinati
}
// Used only during RGBA8 or BGRA8 -> floating-point uploads.
-void packOneRowOfRGBA32FToRGBA32F(const float* source, float* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA32F, GraphicsContext3D::AlphaDoNothing, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
{
- for (unsigned int i = 0; i < pixelsPerRow; ++i) {
- destination[0] = source[0];
- destination[1] = source[1];
- destination[2] = source[2];
- destination[3] = source[3];
- source += 4;
- destination += 4;
- }
+ memcpy(destination, source, pixelsPerRow * 4 * sizeof(float));
}
-void packOneRowOfRGBA32FToRGBA32FPremultiply(const float* source, float* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA32F, GraphicsContext3D::AlphaDoPremultiply, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
float scaleFactor = source[3];
@@ -1202,7 +985,7 @@ void packOneRowOfRGBA32FToRGBA32FPremultiply(const float* source, float* destina
}
}
-void packOneRowOfRGBA32FToRGBA32FUnmultiply(const float* source, float* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA32F, GraphicsContext3D::AlphaDoUnmultiply, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f;
@@ -1215,7 +998,7 @@ void packOneRowOfRGBA32FToRGBA32FUnmultiply(const float* source, float* destinat
}
}
-void packOneRowOfRGBA32FToA32F(const float* source, float* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatA32F, GraphicsContext3D::AlphaDoNothing, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
destination[0] = source[3];
@@ -1224,7 +1007,7 @@ void packOneRowOfRGBA32FToA32F(const float* source, float* destination, unsigned
}
}
-void packOneRowOfRGBA32FToR32F(const float* source, float* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatR32F, GraphicsContext3D::AlphaDoNothing, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
destination[0] = source[0];
@@ -1233,7 +1016,7 @@ void packOneRowOfRGBA32FToR32F(const float* source, float* destination, unsigned
}
}
-void packOneRowOfRGBA32FToR32FPremultiply(const float* source, float* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatR32F, GraphicsContext3D::AlphaDoPremultiply, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
float scaleFactor = source[3];
@@ -1243,7 +1026,7 @@ void packOneRowOfRGBA32FToR32FPremultiply(const float* source, float* destinatio
}
}
-void packOneRowOfRGBA32FToR32FUnmultiply(const float* source, float* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatR32F, GraphicsContext3D::AlphaDoUnmultiply, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f;
@@ -1253,7 +1036,7 @@ void packOneRowOfRGBA32FToR32FUnmultiply(const float* source, float* destination
}
}
-void packOneRowOfRGBA32FToRA32F(const float* source, float* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRA32F, GraphicsContext3D::AlphaDoNothing, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
destination[0] = source[0];
@@ -1263,7 +1046,7 @@ void packOneRowOfRGBA32FToRA32F(const float* source, float* destination, unsigne
}
}
-void packOneRowOfRGBA32FToRA32FPremultiply(const float* source, float* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRA32F, GraphicsContext3D::AlphaDoPremultiply, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
float scaleFactor = source[3];
@@ -1274,7 +1057,7 @@ void packOneRowOfRGBA32FToRA32FPremultiply(const float* source, float* destinati
}
}
-void packOneRowOfRGBA32FToRA32FUnmultiply(const float* source, float* destination, unsigned int pixelsPerRow)
+template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRA32F, GraphicsContext3D::AlphaDoUnmultiply, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
{
for (unsigned int i = 0; i < pixelsPerRow; ++i) {
float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f;
@@ -1285,545 +1068,324 @@ void packOneRowOfRGBA32FToRA32FUnmultiply(const float* source, float* destinatio
}
}
-} // anonymous namespace
+ALWAYS_INLINE bool HasAlpha(int format)
+{
+ return format == GraphicsContext3D::DataFormatA8
+ || format == GraphicsContext3D::DataFormatA32F
+ || format == GraphicsContext3D::DataFormatRA8
+ || format == GraphicsContext3D::DataFormatAR8
+ || format == GraphicsContext3D::DataFormatRA32F
+ || format == GraphicsContext3D::DataFormatRGBA8
+ || format == GraphicsContext3D::DataFormatBGRA8
+ || format == GraphicsContext3D::DataFormatARGB8
+ || format == GraphicsContext3D::DataFormatABGR8
+ || format == GraphicsContext3D::DataFormatRGBA32F
+ || format == GraphicsContext3D::DataFormatRGBA4444
+ || format == GraphicsContext3D::DataFormatRGBA5551;
+}
+
+ALWAYS_INLINE bool HasColor(int format)
+{
+ return format == GraphicsContext3D::DataFormatRGBA8
+ || format == GraphicsContext3D::DataFormatRGBA32F
+ || format == GraphicsContext3D::DataFormatRGB8
+ || format == GraphicsContext3D::DataFormatRGB32F
+ || format == GraphicsContext3D::DataFormatBGR8
+ || format == GraphicsContext3D::DataFormatBGRA8
+ || format == GraphicsContext3D::DataFormatARGB8
+ || format == GraphicsContext3D::DataFormatABGR8
+ || format == GraphicsContext3D::DataFormatRGBA5551
+ || format == GraphicsContext3D::DataFormatRGBA4444
+ || format == GraphicsContext3D::DataFormatRGB565
+ || format == GraphicsContext3D::DataFormatR8
+ || format == GraphicsContext3D::DataFormatR32F
+ || format == GraphicsContext3D::DataFormatRA8
+ || format == GraphicsContext3D::DataFormatRA32F
+ || format == GraphicsContext3D::DataFormatAR8;
+}
+
+template<int Format>
+struct IsFloatFormat {
+ static const bool Value =
+ Format == GraphicsContext3D::DataFormatRGBA32F
+ || Format == GraphicsContext3D::DataFormatRGB32F
+ || Format == GraphicsContext3D::DataFormatRA32F
+ || Format == GraphicsContext3D::DataFormatR32F
+ || Format == GraphicsContext3D::DataFormatA32F;
+};
+
+template<int Format>
+struct Is16bppFormat {
+ static const bool Value =
+ Format == GraphicsContext3D::DataFormatRGBA5551
+ || Format == GraphicsContext3D::DataFormatRGBA4444
+ || Format == GraphicsContext3D::DataFormatRGB565;
+};
+
+template<int Format, bool IsFloat = IsFloatFormat<Format>::Value, bool Is16bpp = Is16bppFormat<Format>::Value>
+struct DataTypeForFormat {
+ typedef uint8_t Type;
+};
+
+template<int Format>
+struct DataTypeForFormat<Format, true, false> {
+ typedef float Type;
+};
+
+template<int Format>
+struct DataTypeForFormat<Format, false, true> {
+ typedef uint16_t Type;
+};
+
+template<int Format>
+struct IntermediateFormat {
+ static const int Value = IsFloatFormat<Format>::Value ? GraphicsContext3D::DataFormatRGBA32F : GraphicsContext3D::DataFormatRGBA8;
+};
+
+ALWAYS_INLINE unsigned TexelBytesForFormat(GraphicsContext3D::DataFormat format)
+{
+ switch (format) {
+ case GraphicsContext3D::DataFormatR8:
+ case GraphicsContext3D::DataFormatA8:
+ return 1;
+ case GraphicsContext3D::DataFormatRA8:
+ case GraphicsContext3D::DataFormatAR8:
+ case GraphicsContext3D::DataFormatRGBA5551:
+ case GraphicsContext3D::DataFormatRGBA4444:
+ case GraphicsContext3D::DataFormatRGB565:
+ return 2;
+ case GraphicsContext3D::DataFormatRGB8:
+ case GraphicsContext3D::DataFormatBGR8:
+ return 3;
+ case GraphicsContext3D::DataFormatRGBA8:
+ case GraphicsContext3D::DataFormatARGB8:
+ case GraphicsContext3D::DataFormatABGR8:
+ case GraphicsContext3D::DataFormatBGRA8:
+ case GraphicsContext3D::DataFormatR32F:
+ case GraphicsContext3D::DataFormatA32F:
+ return 4;
+ case GraphicsContext3D::DataFormatRA32F:
+ return 8;
+ case GraphicsContext3D::DataFormatRGB32F:
+ return 12;
+ case GraphicsContext3D::DataFormatRGBA32F:
+ return 16;
+ default:
+ return 0;
+ }
+}
-// This is used whenever unpacking is necessary; i.e., the source data
-// is not in RGBA8/RGBA32F format, or the unpack alignment specifies
-// that rows are not tightly packed.
-template<typename SourceType, typename IntermediateType, typename DestType>
-static void doUnpackingAndPacking(const SourceType* sourceData,
- void (*rowUnpackingFunc)(const SourceType*, IntermediateType*, unsigned int),
- unsigned int width,
- unsigned int height,
- unsigned int sourceElementsPerRow,
- DestType* destinationData,
- void (*rowPackingFunc)(const IntermediateType*, DestType*, unsigned int),
- unsigned int destinationElementsPerPixel)
-{
- if (!rowPackingFunc) {
- // The row packing is trivial, so don't bother with a temporary buffer.
- const SourceType* endPointer = sourceData + height * sourceElementsPerRow;
- unsigned int destinationElementsPerRow = width * destinationElementsPerPixel;
- while (sourceData < endPointer) {
- rowUnpackingFunc(sourceData, reinterpret_cast<IntermediateType*>(destinationData), width);
- sourceData += sourceElementsPerRow;
- destinationData += destinationElementsPerRow;
+/* END CODE SHARED WITH MOZILLA FIREFOX */
+
+class FormatConverter {
+public:
+ FormatConverter(unsigned width, unsigned height,
+ const void* srcStart, void* dstStart, int srcStride, int dstStride)
+ : m_width(width), m_height(height), m_srcStart(srcStart), m_dstStart(dstStart), m_srcStride(srcStride), m_dstStride(dstStride), m_success(false)
+ {
+ const unsigned MaxNumberOfComponents = 4;
+ const unsigned MaxBytesPerComponent = 4;
+ m_unpackedIntermediateSrcData = adoptArrayPtr(new uint8_t[m_width * MaxNumberOfComponents *MaxBytesPerComponent]);
+ ASSERT(m_unpackedIntermediateSrcData.get());
+ }
+
+ void convert(GraphicsContext3D::DataFormat srcFormat, GraphicsContext3D::DataFormat dstFormat, GraphicsContext3D::AlphaOp);
+ bool Success() const { return m_success; }
+
+private:
+ template<GraphicsContext3D::DataFormat SrcFormat>
+ ALWAYS_INLINE void convert(GraphicsContext3D::DataFormat dstFormat, GraphicsContext3D::AlphaOp);
+
+ template<GraphicsContext3D::DataFormat SrcFormat, GraphicsContext3D::DataFormat DstFormat>
+ ALWAYS_INLINE void convert(GraphicsContext3D::AlphaOp);
+
+ template<GraphicsContext3D::DataFormat SrcFormat, GraphicsContext3D::DataFormat DstFormat, GraphicsContext3D::AlphaOp alphaOp>
+ ALWAYS_INLINE void convert();
+
+ const unsigned m_width, m_height;
+ const void* const m_srcStart;
+ void* const m_dstStart;
+ const int m_srcStride, m_dstStride;
+ bool m_success;
+ OwnArrayPtr<uint8_t> m_unpackedIntermediateSrcData;
+};
+
+void FormatConverter::convert(GraphicsContext3D::DataFormat srcFormat, GraphicsContext3D::DataFormat dstFormat, GraphicsContext3D::AlphaOp alphaOp)
+{
+#define FORMATCONVERTER_CASE_SRCFORMAT(SrcFormat) \
+ case SrcFormat: \
+ return convert<SrcFormat>(dstFormat, alphaOp);
+
+ switch (srcFormat) {
+ FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatR8)
+ FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatA8)
+ FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatR32F)
+ FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatA32F)
+ FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRA8)
+ FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRA32F)
+ FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRGB8)
+ FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatBGR8)
+ FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRGB565)
+ FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRGB32F)
+ FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRGBA8)
+ FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatARGB8)
+ FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatABGR8)
+ FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatAR8)
+ FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatBGRA8)
+ FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRGBA5551)
+ FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRGBA4444)
+ FORMATCONVERTER_CASE_SRCFORMAT(GraphicsContext3D::DataFormatRGBA32F)
+ default:
+ ASSERT_NOT_REACHED();
}
- } else {
- OwnArrayPtr<IntermediateType> temporaryRGBAData = adoptArrayPtr(new IntermediateType[width * 4]);
- const SourceType* endPointer = sourceData + height * sourceElementsPerRow;
- unsigned int destinationElementsPerRow = width * destinationElementsPerPixel;
- while (sourceData < endPointer) {
- rowUnpackingFunc(sourceData, temporaryRGBAData.get(), width);
- rowPackingFunc(temporaryRGBAData.get(), destinationData, width);
- sourceData += sourceElementsPerRow;
- destinationData += destinationElementsPerRow;
+#undef FORMATCONVERTER_CASE_SRCFORMAT
+}
+
+template<GraphicsContext3D::DataFormat SrcFormat>
+ALWAYS_INLINE void FormatConverter::convert(GraphicsContext3D::DataFormat dstFormat, GraphicsContext3D::AlphaOp alphaOp)
+{
+#define FORMATCONVERTER_CASE_DSTFORMAT(DstFormat) \
+ case DstFormat: \
+ return convert<SrcFormat, DstFormat>(alphaOp);
+
+ switch (dstFormat) {
+ FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatR8)
+ FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatA8)
+ FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatR32F)
+ FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatA32F)
+ FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRA8)
+ FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRA32F)
+ FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGB8)
+ FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGB565)
+ FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGB32F)
+ FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGBA8)
+ FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGBA5551)
+ FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGBA4444)
+ FORMATCONVERTER_CASE_DSTFORMAT(GraphicsContext3D::DataFormatRGBA32F)
+ default:
+ ASSERT_NOT_REACHED();
}
- }
+
+#undef FORMATCONVERTER_CASE_DSTFORMAT
}
-template<typename SourceType>
-static unsigned int computeSourceElementsPerRow(unsigned int width,
- unsigned int bytesPerPixel,
- unsigned int unpackAlignment)
-{
- unsigned int elementSizeInBytes = sizeof(SourceType);
- ASSERT(elementSizeInBytes <= bytesPerPixel);
- ASSERT(!(bytesPerPixel % elementSizeInBytes));
- unsigned int validRowBytes = width * bytesPerPixel;
- unsigned int totalRowBytes = validRowBytes;
- if (unpackAlignment) {
- unsigned int remainder = validRowBytes % unpackAlignment;
- if (remainder)
- totalRowBytes += (unpackAlignment - remainder);
- }
- return totalRowBytes / elementSizeInBytes;
-}
-
-// This handles all conversions with a faster path for tightly packed RGBA8 source data.
-template<typename DestType>
-static void doPacking(const void* sourceData,
- GraphicsContext3D::SourceDataFormat sourceDataFormat,
- unsigned int width,
- unsigned int height,
- unsigned int sourceUnpackAlignment,
- DestType* destinationData,
- void (*rowPackingFunc)(const uint8_t*, DestType*, unsigned int),
- unsigned int destinationElementsPerPixel)
-{
- switch (sourceDataFormat) {
- case GraphicsContext3D::SourceFormatRGBA8: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint8_t>(width, 4, sourceUnpackAlignment);
- const uint8_t* source = static_cast<const uint8_t*>(sourceData);
- const uint8_t* endPointer = source + height * sourceElementsPerRow;
- unsigned int destinationElementsPerRow = width * destinationElementsPerPixel;
- while (source < endPointer) {
- if (rowPackingFunc)
- rowPackingFunc(source, destinationData, width);
- else
- memcpy(destinationData, source, width * 4);
- source += sourceElementsPerRow;
- destinationData += destinationElementsPerRow;
+template<GraphicsContext3D::DataFormat SrcFormat, GraphicsContext3D::DataFormat DstFormat>
+ALWAYS_INLINE void FormatConverter::convert(GraphicsContext3D::AlphaOp alphaOp)
+{
+#define FORMATCONVERTER_CASE_ALPHAOP(alphaOp) \
+ case alphaOp: \
+ return convert<SrcFormat, DstFormat, alphaOp>();
+
+ switch (alphaOp) {
+ FORMATCONVERTER_CASE_ALPHAOP(GraphicsContext3D::AlphaDoNothing)
+ FORMATCONVERTER_CASE_ALPHAOP(GraphicsContext3D::AlphaDoPremultiply)
+ FORMATCONVERTER_CASE_ALPHAOP(GraphicsContext3D::AlphaDoUnmultiply)
+ default:
+ ASSERT_NOT_REACHED();
}
- break;
- }
- case GraphicsContext3D::SourceFormatRGBA16Little: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 8, sourceUnpackAlignment);
- doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfRGBA16LittleToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
- }
- case GraphicsContext3D::SourceFormatRGBA16Big: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 8, sourceUnpackAlignment);
- doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfRGBA16BigToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
- }
- case GraphicsContext3D::SourceFormatRGB8: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint8_t>(width, 3, sourceUnpackAlignment);
- doUnpackingAndPacking<uint8_t, uint8_t, DestType>(static_cast<const uint8_t*>(sourceData), unpackOneRowOfRGB8ToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
- }
- case GraphicsContext3D::SourceFormatRGB16Little: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 6, sourceUnpackAlignment);
- doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfRGB16LittleToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
- }
- case GraphicsContext3D::SourceFormatRGB16Big: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 6, sourceUnpackAlignment);
- doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfRGB16BigToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
- }
- case GraphicsContext3D::SourceFormatBGR8: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint8_t>(width, 3, sourceUnpackAlignment);
- doUnpackingAndPacking<uint8_t, uint8_t, DestType>(static_cast<const uint8_t*>(sourceData), unpackOneRowOfBGR8ToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
- }
- case GraphicsContext3D::SourceFormatARGB8: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint8_t>(width, 4, sourceUnpackAlignment);
- doUnpackingAndPacking<uint8_t, uint8_t, DestType>(static_cast<const uint8_t*>(sourceData), unpackOneRowOfARGB8ToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
- }
- case GraphicsContext3D::SourceFormatARGB16Little: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 8, sourceUnpackAlignment);
- doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfARGB16LittleToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
- }
- case GraphicsContext3D::SourceFormatARGB16Big: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 8, sourceUnpackAlignment);
- doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfARGB16BigToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
- }
- case GraphicsContext3D::SourceFormatABGR8: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint8_t>(width, 4, sourceUnpackAlignment);
- doUnpackingAndPacking<uint8_t, uint8_t, DestType>(static_cast<const uint8_t*>(sourceData), unpackOneRowOfABGR8ToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
- }
- case GraphicsContext3D::SourceFormatBGRA8: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint8_t>(width, 4, sourceUnpackAlignment);
- doUnpackingAndPacking<uint8_t, uint8_t, DestType>(static_cast<const uint8_t*>(sourceData), unpackOneRowOfBGRA8ToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
- }
- case GraphicsContext3D::SourceFormatBGRA16Little: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 8, sourceUnpackAlignment);
- doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfBGRA16LittleToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
- }
- case GraphicsContext3D::SourceFormatBGRA16Big: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 8, sourceUnpackAlignment);
- doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfBGRA16BigToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
- }
- case GraphicsContext3D::SourceFormatRGBA5551: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 2, sourceUnpackAlignment);
- doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfRGBA5551ToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
- }
- case GraphicsContext3D::SourceFormatRGBA4444: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 2, sourceUnpackAlignment);
- doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfRGBA4444ToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
- }
- case GraphicsContext3D::SourceFormatRGB565: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 2, sourceUnpackAlignment);
- doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfRGB565ToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
- }
- case GraphicsContext3D::SourceFormatR8: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint8_t>(width, 1, sourceUnpackAlignment);
- doUnpackingAndPacking<uint8_t, uint8_t, DestType>(static_cast<const uint8_t*>(sourceData), unpackOneRowOfR8ToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
- }
- case GraphicsContext3D::SourceFormatR16Little: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 2, sourceUnpackAlignment);
- doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfR16LittleToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
- }
- case GraphicsContext3D::SourceFormatR16Big: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 2, sourceUnpackAlignment);
- doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfR16BigToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
- }
- case GraphicsContext3D::SourceFormatRA8: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint8_t>(width, 2, sourceUnpackAlignment);
- doUnpackingAndPacking<uint8_t, uint8_t, DestType>(static_cast<const uint8_t*>(sourceData), unpackOneRowOfRA8ToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
- }
- case GraphicsContext3D::SourceFormatRA16Little: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 4, sourceUnpackAlignment);
- doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfRA16LittleToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
- }
- case GraphicsContext3D::SourceFormatRA16Big: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 4, sourceUnpackAlignment);
- doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfRA16BigToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
- }
- case GraphicsContext3D::SourceFormatAR8: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint8_t>(width, 2, sourceUnpackAlignment);
- doUnpackingAndPacking<uint8_t, uint8_t, DestType>(static_cast<const uint8_t*>(sourceData), unpackOneRowOfAR8ToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
- }
- case GraphicsContext3D::SourceFormatAR16Little: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 4, sourceUnpackAlignment);
- doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfAR16LittleToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
- }
- case GraphicsContext3D::SourceFormatAR16Big: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 4, sourceUnpackAlignment);
- doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfAR16BigToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
+#undef FORMATCONVERTER_CASE_ALPHAOP
+}
+
+template<GraphicsContext3D::DataFormat SrcFormat, GraphicsContext3D::DataFormat DstFormat, GraphicsContext3D::AlphaOp alphaOp>
+ALWAYS_INLINE void FormatConverter::convert()
+{
+ // Many instantiations of this template function will never be entered, so we try
+ // to return immediately in these cases to avoid the compiler to generate useless code.
+ if (SrcFormat == DstFormat && alphaOp == GraphicsContext3D::AlphaDoNothing) {
+ ASSERT_NOT_REACHED();
+ return;
}
- case GraphicsContext3D::SourceFormatA8: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint8_t>(width, 1, sourceUnpackAlignment);
- doUnpackingAndPacking<uint8_t, uint8_t, DestType>(static_cast<const uint8_t*>(sourceData), unpackOneRowOfA8ToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
+ if (!IsFloatFormat<DstFormat>::Value && IsFloatFormat<SrcFormat>::Value) {
+ ASSERT_NOT_REACHED();
+ return;
}
- case GraphicsContext3D::SourceFormatA16Little: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 2, sourceUnpackAlignment);
- doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfA16LittleToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
+
+ // Only textures uploaded from DOM elements or ImageData can allow DstFormat != SrcFormat.
+ const bool srcFormatComesFromDOMElementOrImageData = GraphicsContext3D::srcFormatComeFromDOMElementOrImageData(SrcFormat);
+ if (!srcFormatComesFromDOMElementOrImageData && SrcFormat != DstFormat) {
+ ASSERT_NOT_REACHED();
+ return;
}
- case GraphicsContext3D::SourceFormatA16Big: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint16_t>(width, 2, sourceUnpackAlignment);
- doUnpackingAndPacking<uint16_t, uint8_t, DestType>(static_cast<const uint16_t*>(sourceData), unpackOneRowOfA16BigToRGBA8, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
+ // Likewise, only textures uploaded from DOM elements or ImageData can possibly have to be unpremultiplied.
+ if (!srcFormatComesFromDOMElementOrImageData && alphaOp == GraphicsContext3D::AlphaDoUnmultiply) {
+ ASSERT_NOT_REACHED();
+ return;
}
- default:
+ if ((!HasAlpha(SrcFormat) || !HasColor(SrcFormat) || !HasColor(DstFormat)) && alphaOp != GraphicsContext3D::AlphaDoNothing) {
ASSERT_NOT_REACHED();
+ return;
}
-}
-// This specialized routine is used only for floating-point texture uploads. It
-// does not need to be as general as doPacking, above; because there are
-// currently no native floating-point image formats in WebKit, there are only a
-// few upload paths.
-static void doFloatingPointPacking(const void* sourceData,
- GraphicsContext3D::SourceDataFormat sourceDataFormat,
- unsigned int width,
- unsigned int height,
- unsigned int sourceUnpackAlignment,
- float* destinationData,
- void rowPackingFunc(const float*, float*, unsigned int),
- unsigned int destinationElementsPerPixel)
-{
- switch (sourceDataFormat) {
- case GraphicsContext3D::SourceFormatRGBA8: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint8_t>(width, 4, sourceUnpackAlignment);
- doUnpackingAndPacking<uint8_t, float, float>(static_cast<const uint8_t*>(sourceData), unpackOneRowOfRGBA8ToRGBA32F, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
- }
- case GraphicsContext3D::SourceFormatBGRA8: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<uint8_t>(width, 4, sourceUnpackAlignment);
- doUnpackingAndPacking<uint8_t, float, float>(static_cast<const uint8_t*>(sourceData), unpackOneRowOfBGRA8ToRGBA32F, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
- }
- case GraphicsContext3D::SourceFormatRGBA32F: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<float>(width, 4, sourceUnpackAlignment);
- const float* source = static_cast<const float*>(sourceData);
- const float* endPointer = source + height * sourceElementsPerRow;
- unsigned int destinationElementsPerRow = width * destinationElementsPerPixel;
- while (source < endPointer) {
- rowPackingFunc(source, destinationData, width);
- source += sourceElementsPerRow;
- destinationData += destinationElementsPerRow;
+ typedef typename DataTypeForFormat<SrcFormat>::Type SrcType;
+ typedef typename DataTypeForFormat<DstFormat>::Type DstType;
+ const int IntermediateSrcFormat = IntermediateFormat<DstFormat>::Value;
+ typedef typename DataTypeForFormat<IntermediateSrcFormat>::Type IntermediateSrcType;
+ const ptrdiff_t srcStrideInElements = m_srcStride / sizeof(SrcType);
+ const ptrdiff_t dstStrideInElements = m_dstStride / sizeof(DstType);
+ const bool trivialUnpack = (SrcFormat == GraphicsContext3D::DataFormatRGBA8 && !IsFloatFormat<DstFormat>::Value) || SrcFormat == GraphicsContext3D::DataFormatRGBA32F;
+ const bool trivialPack = (DstFormat == GraphicsContext3D::DataFormatRGBA8 || DstFormat == GraphicsContext3D::DataFormatRGBA32F) && alphaOp == GraphicsContext3D::AlphaDoNothing && m_dstStride > 0;
+ ASSERT(!trivialUnpack || !trivialPack);
+
+ const SrcType *srcRowStart = static_cast<const SrcType*>(m_srcStart);
+ DstType* dstRowStart = static_cast<DstType*>(m_dstStart);
+ if (!trivialUnpack && trivialPack) {
+ for (size_t i = 0; i < m_height; ++i) {
+ unpack<SrcFormat>(srcRowStart, dstRowStart, m_width);
+ srcRowStart += srcStrideInElements;
+ dstRowStart += dstStrideInElements;
+ }
+ } else if (!trivialUnpack && !trivialPack) {
+ for (size_t i = 0; i < m_height; ++i) {
+ unpack<SrcFormat>(srcRowStart, reinterpret_cast_ptr<IntermediateSrcType*>(m_unpackedIntermediateSrcData.get()), m_width);
+ pack<DstFormat, alphaOp>(reinterpret_cast_ptr<IntermediateSrcType*>(m_unpackedIntermediateSrcData.get()), dstRowStart, m_width);
+ srcRowStart += srcStrideInElements;
+ dstRowStart += dstStrideInElements;
+ }
+ } else {
+ for (size_t i = 0; i < m_height; ++i) {
+ pack<DstFormat, alphaOp>(srcRowStart, dstRowStart, m_width);
+ srcRowStart += srcStrideInElements;
+ dstRowStart += dstStrideInElements;
}
- break;
- }
- case GraphicsContext3D::SourceFormatRGB32F: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<float>(width, 3, sourceUnpackAlignment);
- doUnpackingAndPacking<float, float, float>(static_cast<const float*>(sourceData), unpackOneRowOfRGB32FToRGBA32F, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
- }
- case GraphicsContext3D::SourceFormatR32F: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<float>(width, 1, sourceUnpackAlignment);
- doUnpackingAndPacking<float, float, float>(static_cast<const float*>(sourceData), unpackOneRowOfR32FToRGBA32F, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
- }
- case GraphicsContext3D::SourceFormatRA32F: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<float>(width, 2, sourceUnpackAlignment);
- doUnpackingAndPacking<float, float, float>(static_cast<const float*>(sourceData), unpackOneRowOfRA32FToRGBA32F, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
- }
- case GraphicsContext3D::SourceFormatA32F: {
- unsigned int sourceElementsPerRow = computeSourceElementsPerRow<float>(width, 1, sourceUnpackAlignment);
- doUnpackingAndPacking<float, float, float>(static_cast<const float*>(sourceData), unpackOneRowOfA32FToRGBA32F, width, height, sourceElementsPerRow, destinationData, rowPackingFunc, destinationElementsPerPixel);
- break;
- }
- default:
- ASSERT_NOT_REACHED();
}
+ m_success = true;
+ return;
}
+} // anonymous namespace
-#if !ASSERT_DISABLED
-static bool isFloatingPointSource(GraphicsContext3D::SourceDataFormat format)
+bool GraphicsContext3D::packPixels(const uint8_t* sourceData, DataFormat sourceDataFormat, unsigned width, unsigned height, unsigned sourceUnpackAlignment, unsigned destinationFormat, unsigned destinationType, AlphaOp alphaOp, void* destinationData, bool flipY)
{
- switch (format) {
- case GraphicsContext3D::SourceFormatRGBA32F:
- case GraphicsContext3D::SourceFormatRGB32F:
- case GraphicsContext3D::SourceFormatRA32F:
- case GraphicsContext3D::SourceFormatR32F:
- case GraphicsContext3D::SourceFormatA32F:
- return true;
- default:
- return false;
- }
-}
-#endif
+ int validSrc = width * TexelBytesForFormat(sourceDataFormat);
+ int remainder = sourceUnpackAlignment ? (validSrc % sourceUnpackAlignment) : 0;
+ int srcStride = remainder ? (validSrc + sourceUnpackAlignment - remainder) : validSrc;
-bool GraphicsContext3D::packPixels(const uint8_t* sourceData,
- GraphicsContext3D::SourceDataFormat sourceDataFormat,
- unsigned int width,
- unsigned int height,
- unsigned int sourceUnpackAlignment,
- unsigned int destinationFormat,
- unsigned int destinationType,
- AlphaOp alphaOp,
- void* destinationData)
-{
- switch (destinationType) {
- case UNSIGNED_BYTE: {
- uint8_t* destination = static_cast<uint8_t*>(destinationData);
- if (sourceDataFormat == SourceFormatRGBA8 && destinationFormat == RGBA && sourceUnpackAlignment <= 4 && alphaOp == AlphaDoNothing) {
- // No conversion necessary.
- memcpy(destinationData, sourceData, width * height * 4);
- break;
- }
- switch (destinationFormat) {
- case RGB:
- switch (alphaOp) {
- case AlphaDoNothing:
- doPacking<uint8_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToRGB8, 3);
- break;
- case AlphaDoPremultiply:
- doPacking<uint8_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToRGB8Premultiply, 3);
- break;
- case AlphaDoUnmultiply:
- doPacking<uint8_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToRGB8Unmultiply, 3);
- break;
- }
- break;
- case RGBA:
- switch (alphaOp) {
- case AlphaDoNothing:
- ASSERT(sourceDataFormat != SourceFormatRGBA8 || sourceUnpackAlignment > 4); // Handled above with fast case.
- doPacking<uint8_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 0, 4);
- break;
- case AlphaDoPremultiply:
- doPacking<uint8_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToRGBA8Premultiply, 4);
- break;
- case AlphaDoUnmultiply:
- doPacking<uint8_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToRGBA8Unmultiply, 4);
- break;
- default:
- ASSERT_NOT_REACHED();
- }
- break;
- case ALPHA:
- // From the desktop OpenGL conversion rules (OpenGL 2.1
- // specification, Table 3.15), the alpha channel is chosen
- // from the RGBA data.
- doPacking<uint8_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToA8, 1);
- break;
- case LUMINANCE:
- // From the desktop OpenGL conversion rules (OpenGL 2.1
- // specification, Table 3.15), the red channel is chosen
- // from the RGBA data.
- switch (alphaOp) {
- case AlphaDoNothing:
- doPacking<uint8_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToR8, 1);
- break;
- case AlphaDoPremultiply:
- doPacking<uint8_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToR8Premultiply, 1);
- break;
- case AlphaDoUnmultiply:
- doPacking<uint8_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToR8Unmultiply, 1);
- break;
- }
- break;
- case LUMINANCE_ALPHA:
- // From the desktop OpenGL conversion rules (OpenGL 2.1
- // specification, Table 3.15), the red and alpha channels
- // are chosen from the RGBA data.
- switch (alphaOp) {
- case AlphaDoNothing:
- doPacking<uint8_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToRA8, 2);
- break;
- case AlphaDoPremultiply:
- doPacking<uint8_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToRA8Premultiply, 2);
- break;
- case AlphaDoUnmultiply:
- doPacking<uint8_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToRA8Unmultiply, 2);
- break;
- }
- break;
- }
- break;
- }
- case UNSIGNED_SHORT_4_4_4_4: {
- uint16_t* destination = static_cast<uint16_t*>(destinationData);
- switch (alphaOp) {
- case AlphaDoNothing:
- doPacking<uint16_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToUnsignedShort4444, 1);
- break;
- case AlphaDoPremultiply:
- doPacking<uint16_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToUnsignedShort4444Premultiply, 1);
- break;
- case AlphaDoUnmultiply:
- doPacking<uint16_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToUnsignedShort4444Unmultiply, 1);
- break;
- }
- break;
- }
- case UNSIGNED_SHORT_5_5_5_1: {
- uint16_t* destination = static_cast<uint16_t*>(destinationData);
- switch (alphaOp) {
- case AlphaDoNothing:
- doPacking<uint16_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToUnsignedShort5551, 1);
- break;
- case AlphaDoPremultiply:
- doPacking<uint16_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToUnsignedShort5551Premultiply, 1);
- break;
- case AlphaDoUnmultiply:
- doPacking<uint16_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToUnsignedShort5551Unmultiply, 1);
- break;
- }
- break;
- }
- case UNSIGNED_SHORT_5_6_5: {
- uint16_t* destination = static_cast<uint16_t*>(destinationData);
- switch (alphaOp) {
- case AlphaDoNothing:
- doPacking<uint16_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToUnsignedShort565, 1);
- break;
- case AlphaDoPremultiply:
- doPacking<uint16_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToUnsignedShort565Premultiply, 1);
- break;
- case AlphaDoUnmultiply:
- doPacking<uint16_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToUnsignedShort565Unmultiply, 1);
- break;
- }
- break;
- }
- case FLOAT: {
- // OpenGL ES, and therefore WebGL, require that the format and
- // internalformat be identical. This means that whenever the
- // developer supplies an ArrayBufferView on this code path,
- // the source data will be in a floating-point format.
- //
- // The only time the source data will not be floating-point is
- // when uploading a DOM element or ImageData as a
- // floating-point texture. Only RGBA8 and BGRA8 are handled in
- // this case.
- ASSERT(isFloatingPointSource(sourceDataFormat)
- || sourceDataFormat == SourceFormatRGBA8
- || sourceDataFormat == SourceFormatBGRA8);
- // When uploading a canvas into a floating-point texture,
- // unmultiplication may be necessary.
- ASSERT((alphaOp == AlphaDoNothing || alphaOp == AlphaDoPremultiply)
- || !isFloatingPointSource(sourceDataFormat));
- // For the source formats with an even number of channels (RGBA32F,
- // RA32F) it is guaranteed that the pixel data is tightly packed because
- // unpack alignment <= sizeof(float) * number of channels.
- float* destination = static_cast<float*>(destinationData);
- if (alphaOp == AlphaDoNothing
- && ((sourceDataFormat == SourceFormatRGBA32F && destinationFormat == RGBA)
- || (sourceDataFormat == SourceFormatRA32F && destinationFormat == LUMINANCE_ALPHA))) {
- // No conversion necessary.
- int numChannels = (sourceDataFormat == SourceFormatRGBA32F ? 4 : 2);
- memcpy(destinationData, sourceData, width * height * numChannels * sizeof(float));
- break;
- }
- switch (destinationFormat) {
- case RGB:
- switch (alphaOp) {
- case AlphaDoNothing:
- doFloatingPointPacking(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA32FToRGB32F, 3);
- break;
- case AlphaDoPremultiply:
- doFloatingPointPacking(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA32FToRGB32FPremultiply, 3);
- break;
- case AlphaDoUnmultiply:
- doFloatingPointPacking(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA32FToRGB32FUnmultiply, 3);
- break;
- }
- break;
- case RGBA:
- // AlphaDoNothing for RGBA32F -> RGBA is handled above with fast path.
- ASSERT(alphaOp != AlphaDoNothing || sourceDataFormat != SourceFormatRGBA32F);
- switch (alphaOp) {
- case AlphaDoNothing:
- doFloatingPointPacking(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA32FToRGBA32F, 4);
- break;
- case AlphaDoPremultiply:
- doFloatingPointPacking(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA32FToRGBA32FPremultiply, 4);
- break;
- case AlphaDoUnmultiply:
- doFloatingPointPacking(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA32FToRGBA32FUnmultiply, 4);
- break;
- }
- break;
- case ALPHA:
- // From the desktop OpenGL conversion rules (OpenGL 2.1
- // specification, Table 3.15), the alpha channel is chosen
- // from the RGBA data.
- doFloatingPointPacking(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA32FToA32F, 1);
- break;
- case LUMINANCE:
- // From the desktop OpenGL conversion rules (OpenGL 2.1
- // specification, Table 3.15), the red channel is chosen
- // from the RGBA data.
- switch (alphaOp) {
- case AlphaDoNothing:
- doFloatingPointPacking(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA32FToR32F, 1);
- break;
- case AlphaDoPremultiply:
- doFloatingPointPacking(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA32FToR32FPremultiply, 1);
- break;
- case AlphaDoUnmultiply:
- doFloatingPointPacking(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA32FToR32FUnmultiply, 1);
- break;
- }
- break;
- case LUMINANCE_ALPHA:
- // From the desktop OpenGL conversion rules (OpenGL 2.1
- // specification, Table 3.15), the red and alpha channels
- // are chosen from the RGBA data.
- switch (alphaOp) {
- case AlphaDoNothing:
- doFloatingPointPacking(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA32FToRA32F, 2);
- break;
- case AlphaDoPremultiply:
- doFloatingPointPacking(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA32FToRA32FPremultiply, 2);
- break;
- case AlphaDoUnmultiply:
- doFloatingPointPacking(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA32FToRA32FUnmultiply, 2);
- break;
- }
- break;
+ DataFormat dstDataFormat = getDataFormat(destinationFormat, destinationType);
+ int dstStride = width * TexelBytesForFormat(dstDataFormat);
+ if (flipY) {
+ destinationData = static_cast<uint8_t*>(destinationData) + dstStride*(height - 1);
+ dstStride = -dstStride;
+ }
+ if (!HasAlpha(sourceDataFormat) || !HasColor(sourceDataFormat) || !HasColor(dstDataFormat))
+ alphaOp = AlphaDoNothing;
+
+ if (sourceDataFormat == dstDataFormat && alphaOp == AlphaDoNothing) {
+ const uint8_t* ptr = sourceData;
+ const uint8_t* ptrEnd = sourceData + srcStride * height;
+ unsigned rowSize = (dstStride > 0) ? dstStride: -dstStride;
+ uint8_t* dst = static_cast<uint8_t*>(destinationData);
+ while (ptr < ptrEnd) {
+ memcpy(dst, ptr, rowSize);
+ ptr += srcStride;
+ dst += dstStride;
}
- break;
- }
+ return true;
}
+
+ FormatConverter converter(width, height, sourceData, destinationData, srcStride, dstStride);
+ converter.convert(sourceDataFormat, dstDataFormat, alphaOp);
+ if (!converter.Success())
+ return false;
return true;
}
@@ -1831,6 +1393,21 @@ unsigned GraphicsContext3D::getClearBitsByAttachmentType(GC3Denum attachment)
{
switch (attachment) {
case GraphicsContext3D::COLOR_ATTACHMENT0:
+ case Extensions3D::COLOR_ATTACHMENT1_EXT:
+ case Extensions3D::COLOR_ATTACHMENT2_EXT:
+ case Extensions3D::COLOR_ATTACHMENT3_EXT:
+ case Extensions3D::COLOR_ATTACHMENT4_EXT:
+ case Extensions3D::COLOR_ATTACHMENT5_EXT:
+ case Extensions3D::COLOR_ATTACHMENT6_EXT:
+ case Extensions3D::COLOR_ATTACHMENT7_EXT:
+ case Extensions3D::COLOR_ATTACHMENT8_EXT:
+ case Extensions3D::COLOR_ATTACHMENT9_EXT:
+ case Extensions3D::COLOR_ATTACHMENT10_EXT:
+ case Extensions3D::COLOR_ATTACHMENT11_EXT:
+ case Extensions3D::COLOR_ATTACHMENT12_EXT:
+ case Extensions3D::COLOR_ATTACHMENT13_EXT:
+ case Extensions3D::COLOR_ATTACHMENT14_EXT:
+ case Extensions3D::COLOR_ATTACHMENT15_EXT:
return GraphicsContext3D::COLOR_BUFFER_BIT;
case GraphicsContext3D::DEPTH_ATTACHMENT:
return GraphicsContext3D::DEPTH_BUFFER_BIT;
@@ -1895,6 +1472,25 @@ unsigned GraphicsContext3D::getChannelBitsByFormat(GC3Denum format)
}
}
+#if !PLATFORM(BLACKBERRY) && !PLATFORM(QT) && !PLATFORM(GTK) && !PLATFORM(EFL) && !PLATFORM(MAC) && !PLATFORM(WIN)
+PlatformGraphicsContext3D GraphicsContext3D::platformGraphicsContext3D() const
+{
+ return NullPlatformGraphicsContext3D;
+}
+
+Platform3DObject GraphicsContext3D::platformTexture() const
+{
+ return NullPlatform3DObject;
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+PlatformLayer* GraphicsContext3D::platformLayer() const
+{
+ return 0;
+}
+#endif
+#endif
+
} // namespace WebCore
#endif // USE(3D_GRAPHICS)
diff --git a/Source/WebCore/platform/graphics/GraphicsContext3D.h b/Source/WebCore/platform/graphics/GraphicsContext3D.h
index 4ede0f817..d6f57baf6 100644
--- a/Source/WebCore/platform/graphics/GraphicsContext3D.h
+++ b/Source/WebCore/platform/graphics/GraphicsContext3D.h
@@ -26,29 +26,31 @@
#ifndef GraphicsContext3D_h
#define GraphicsContext3D_h
-#include "IntRect.h"
#include "GraphicsTypes3D.h"
+#include "Image.h"
+#include "IntRect.h"
#include "PlatformLayer.h"
#include <wtf/HashMap.h>
#include <wtf/ListHashSet.h>
#include <wtf/Noncopyable.h>
+#include <wtf/OwnArrayPtr.h>
+#include <wtf/PassOwnArrayPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/text/WTFString.h>
// FIXME: Find a better way to avoid the name confliction for NO_ERROR.
-#if ((PLATFORM(CHROMIUM) && OS(WINDOWS)) || PLATFORM(WIN) || (PLATFORM(QT) && OS(WINDOWS)))
+#if PLATFORM(WIN) || (PLATFORM(QT) && OS(WINDOWS))
#undef NO_ERROR
#elif PLATFORM(GTK)
// This define is from the X11 headers, but it's used below, so we must undefine it.
#undef VERSION
#endif
-#if PLATFORM(MAC) || PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(EFL) || PLATFORM(BLACKBERRY)
+#if PLATFORM(MAC) || PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(EFL) || PLATFORM(BLACKBERRY) || PLATFORM(WIN)
#include "ANGLEWebKitBridge.h"
#endif
#if PLATFORM(MAC)
-#include <OpenGL/OpenGL.h>
#include <wtf/RetainPtr.h>
OBJC_CLASS CALayer;
OBJC_CLASS WebGLLayer;
@@ -56,8 +58,6 @@ OBJC_CLASS WebGLLayer;
QT_BEGIN_NAMESPACE
class QPainter;
class QRect;
-class QGLWidget;
-class QGLContext;
class QOpenGLContext;
class QSurface;
QT_END_NAMESPACE
@@ -66,6 +66,8 @@ typedef unsigned int GLuint;
#endif
#if PLATFORM(MAC)
+typedef struct _CGLContextObject *CGLContextObj;
+
typedef CGLContextObj PlatformGraphicsContext3D;
#elif PLATFORM(QT)
typedef QOpenGLContext* PlatformGraphicsContext3D;
@@ -75,18 +77,10 @@ typedef void* PlatformGraphicsContext3D;
typedef void* PlatformGraphicsSurface3D;
#endif
-#if (PLATFORM(CHROMIUM) || PLATFORM(BLACKBERRY)) && USE(SKIA)
-class GrContext;
-#endif
-
// These are currently the same among all implementations.
const PlatformGraphicsContext3D NullPlatformGraphicsContext3D = 0;
const Platform3DObject NullPlatform3DObject = 0;
-#if USE(CG)
-#include <CoreGraphics/CGContext.h>
-#endif
-
namespace WebCore {
class DrawingBuffer;
class Extensions3D;
@@ -101,6 +95,7 @@ class Extensions3DQt;
class HostWindow;
class Image;
class ImageBuffer;
+class ImageSource;
class ImageData;
class IntRect;
class IntSize;
@@ -246,6 +241,7 @@ public:
INT = 0x1404,
UNSIGNED_INT = 0x1405,
FLOAT = 0x1406,
+ HALF_FLOAT_OES = 0x8D61,
FIXED = 0x140C,
DEPTH_COMPONENT = 0x1902,
ALPHA = 0x1906,
@@ -488,43 +484,17 @@ public:
PlatformGraphicsContext3D platformGraphicsContext3D() const { return m_contextObj; }
Platform3DObject platformTexture() const { return m_compositorTexture; }
CALayer* platformLayer() const { return reinterpret_cast<CALayer*>(m_webGLLayer.get()); }
-#elif PLATFORM(CHROMIUM) || PLATFORM(BLACKBERRY)
- PlatformGraphicsContext3D platformGraphicsContext3D() const;
- Platform3DObject platformTexture() const;
-#if USE(SKIA)
- GrContext* grContext();
-#endif
-#if USE(ACCELERATED_COMPOSITING)
- PlatformLayer* platformLayer() const;
-#endif
-#elif PLATFORM(QT)
+#else
PlatformGraphicsContext3D platformGraphicsContext3D();
Platform3DObject platformTexture() const;
-#if USE(ACCELERATED_COMPOSITING)
+#if USE(ACCELERATED_COMPOSITING)
PlatformLayer* platformLayer() const;
#endif
-#elif PLATFORM(GTK)
- PlatformGraphicsContext3D platformGraphicsContext3D();
- Platform3DObject platformTexture() const { return m_texture; }
-#if USE(ACCELERATED_COMPOSITING)
- PlatformLayer* platformLayer() const;
-#endif
-#elif PLATFORM(EFL)
- PlatformGraphicsContext3D platformGraphicsContext3D();
- Platform3DObject platformTexture() const { return m_texture; }
-#if USE(ACCELERATED_COMPOSITING)
- PlatformLayer* platformLayer() const;
-#endif
-#else
- PlatformGraphicsContext3D platformGraphicsContext3D() const { return NullPlatformGraphicsContext3D; }
- Platform3DObject platformTexture() const { return NullPlatform3DObject; }
-#if USE(ACCELERATED_COMPOSITING)
- PlatformLayer* platformLayer() const { return 0; }
-#endif
#endif
+
bool makeContextCurrent();
-#if PLATFORM(MAC) || PLATFORM(CHROMIUM) || PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(EFL) || PLATFORM(BLACKBERRY)
+#if PLATFORM(MAC) || PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(EFL) || PLATFORM(BLACKBERRY) || PLATFORM(WIN)
// With multisampling on, blit from multisampleFBO to regular FBO.
void prepareTexture();
#endif
@@ -564,18 +534,6 @@ public:
unsigned int* imageSizeInBytes,
unsigned int* paddingInBytes);
- // Extracts the contents of the given Image into the passed Vector,
- // packing the pixel data according to the given format and type,
- // and obeying the flipY, premultiplyAlpha, and ignoreGammaAndColorProfile
- // flags. Returns true upon success.
- static bool extractImageData(Image*,
- GC3Denum format,
- GC3Denum type,
- bool flipY,
- bool premultiplyAlpha,
- bool ignoreGammaAndColorProfile,
- Vector<uint8_t>& data);
-
// Extracts the contents of the given ImageData into the passed Vector,
// packing the pixel data according to the given format and type,
// and obeying the flipY and premultiplyAlpha flags. Returns true
@@ -599,55 +557,68 @@ public:
const void* pixels,
Vector<uint8_t>& data);
- // Flips the given image data vertically, in-place.
- static void flipVertically(void* imageData,
- unsigned int width,
- unsigned int height,
- unsigned int bytesPerPixel,
- unsigned int unpackAlignment);
// Attempt to enumerate all possible native image formats to
// reduce the amount of temporary allocations during texture
// uploading. This enum must be public because it is accessed
// by non-member functions.
- enum SourceDataFormat {
- SourceFormatRGBA8 = 0,
- SourceFormatRGBA16Little,
- SourceFormatRGBA16Big,
- SourceFormatRGBA32F,
- SourceFormatRGB8,
- SourceFormatRGB16Little,
- SourceFormatRGB16Big,
- SourceFormatRGB32F,
- SourceFormatBGR8,
- SourceFormatBGRA8,
- SourceFormatBGRA16Little,
- SourceFormatBGRA16Big,
- SourceFormatARGB8,
- SourceFormatARGB16Little,
- SourceFormatARGB16Big,
- SourceFormatABGR8,
- SourceFormatRGBA5551,
- SourceFormatRGBA4444,
- SourceFormatRGB565,
- SourceFormatR8,
- SourceFormatR16Little,
- SourceFormatR16Big,
- SourceFormatR32F,
- SourceFormatRA8,
- SourceFormatRA16Little,
- SourceFormatRA16Big,
- SourceFormatRA32F,
- SourceFormatAR8,
- SourceFormatAR16Little,
- SourceFormatAR16Big,
- SourceFormatA8,
- SourceFormatA16Little,
- SourceFormatA16Big,
- SourceFormatA32F,
- SourceFormatNumFormats
+ enum DataFormat {
+ DataFormatRGBA8 = 0,
+ DataFormatRGBA16Little,
+ DataFormatRGBA16Big,
+ DataFormatRGBA32F,
+ DataFormatRGB8,
+ DataFormatRGB16Little,
+ DataFormatRGB16Big,
+ DataFormatRGB32F,
+ DataFormatBGR8,
+ DataFormatBGRA8,
+ DataFormatBGRA16Little,
+ DataFormatBGRA16Big,
+ DataFormatARGB8,
+ DataFormatARGB16Little,
+ DataFormatARGB16Big,
+ DataFormatABGR8,
+ DataFormatRGBA5551,
+ DataFormatRGBA4444,
+ DataFormatRGB565,
+ DataFormatR8,
+ DataFormatR16Little,
+ DataFormatR16Big,
+ DataFormatR32F,
+ DataFormatRA8,
+ DataFormatRA16Little,
+ DataFormatRA16Big,
+ DataFormatRA32F,
+ DataFormatAR8,
+ DataFormatAR16Little,
+ DataFormatAR16Big,
+ DataFormatA8,
+ DataFormatA16Little,
+ DataFormatA16Big,
+ DataFormatA32F,
+ DataFormatNumFormats
};
+ // Check if the format is one of the formats from the ImageData or DOM elements.
+ // The formats from ImageData is always RGBA8.
+ // The formats from DOM elements vary with Graphics ports. It can only be RGBA8 or BGRA8 for non-CG port while a little more for CG port.
+ static ALWAYS_INLINE bool srcFormatComeFromDOMElementOrImageData(DataFormat SrcFormat)
+ {
+#if USE(CG)
+#if CPU(BIG_ENDIAN)
+ return SrcFormat == DataFormatRGBA8 || SrcFormat == DataFormatARGB8 || SrcFormat == DataFormatRGB8;
+#else
+ // That LITTLE_ENDIAN case has more possible formats than BIG_ENDIAN case is because some decoded image data is actually big endian
+ // even on little endian architectures.
+ return SrcFormat == DataFormatBGRA8 || SrcFormat == DataFormatABGR8 || SrcFormat == DataFormatBGR8
+ || SrcFormat == DataFormatRGBA8 || SrcFormat == DataFormatARGB8 || SrcFormat == DataFormatRGB8;
+#endif
+#else
+ return SrcFormat == DataFormatBGRA8 || SrcFormat == DataFormatRGBA8;
+#endif
+ }
+
//----------------------------------------------------------------------
// Entry points for WebGL.
//
@@ -799,16 +770,13 @@ public:
void reshape(int width, int height);
-#if USE(CG)
- static void paintToCanvas(const unsigned char* imagePixels, int imageWidth, int imageHeight,
- int canvasWidth, int canvasHeight, CGContextRef);
-#elif PLATFORM(GTK) || PLATFORM(EFL)
+#if PLATFORM(GTK) || PLATFORM(EFL) || USE(CAIRO)
void paintToCanvas(const unsigned char* imagePixels, int imageWidth, int imageHeight,
int canvasWidth, int canvasHeight, PlatformContextCairo* context);
#elif PLATFORM(QT)
void paintToCanvas(const unsigned char* imagePixels, int imageWidth, int imageHeight,
int canvasWidth, int canvasHeight, QPainter* context);
-#elif PLATFORM(BLACKBERRY)
+#elif PLATFORM(BLACKBERRY) || USE(CG)
void paintToCanvas(const unsigned char* imagePixels, int imageWidth, int imageHeight,
int canvasWidth, int canvasHeight, GraphicsContext*);
#endif
@@ -874,35 +842,6 @@ public:
static unsigned getChannelBitsByFormat(GC3Denum);
- private:
- GraphicsContext3D(Attributes, HostWindow*, RenderStyle = RenderOffscreen);
-
- // Each platform must provide an implementation of this method.
- //
- // Gets the data for the given Image into outputVector in the
- // format specified by the (OpenGL-style) format and type
- // arguments. Despite the fact that the outputVector contains
- // uint8_t, if the format and type specify packed pixels, then
- // it will essentially contain uint16_t after the extraction
- // process.
- //
- // If premultiplyAlpha is true, the alpha channel, if any,
- // will be multiplied into the color channels during the
- // extraction process. This premultiplication occurs before
- // any packing of pixel data.
- //
- // If ignoreGammaAndColorProfile is true, gamma correction and ICC
- // profile won't be applied.
- //
- // No vertical flip of the image data is performed by this
- // method.
- static bool getImageData(Image*,
- GC3Denum format,
- GC3Denum type,
- bool premultiplyAlpha,
- bool ignoreGammaAndColorProfile,
- Vector<uint8_t>& outputVector);
-
// Possible alpha operations that may need to occur during
// pixel packing. FIXME: kAlphaDoUnmultiply is lossy and must
// be removed.
@@ -912,22 +851,75 @@ public:
AlphaDoUnmultiply = 2
};
- // Helper for getImageData which implements packing of pixel
+ enum ImageHtmlDomSource {
+ HtmlDomImage = 0,
+ HtmlDomCanvas = 1,
+ HtmlDomVideo = 2,
+ HtmlDomNone = 3
+ };
+
+ // Packs the contents of the given Image which is passed in |pixels| into the passed Vector
+ // according to the given format and type, and obeying the flipY and AlphaOp flags.
+ // Returns true upon success.
+ static bool packImageData(Image*, const void* pixels, GC3Denum format, GC3Denum type, bool flipY, AlphaOp, DataFormat sourceFormat, unsigned width, unsigned height, unsigned sourceUnpackAlignment, Vector<uint8_t>& data);
+
+ class ImageExtractor {
+ public:
+ ImageExtractor(Image*, ImageHtmlDomSource, bool premultiplyAlpha, bool ignoreGammaAndColorProfile);
+
+ // Each platform must provide an implementation of this method to deallocate or release resources
+ // associated with the image if needed.
+ ~ImageExtractor();
+
+ bool extractSucceeded() { return m_extractSucceeded; }
+ const void* imagePixelData() { return m_imagePixelData; }
+ unsigned imageWidth() { return m_imageWidth; }
+ unsigned imageHeight() { return m_imageHeight; }
+ DataFormat imageSourceFormat() { return m_imageSourceFormat; }
+ AlphaOp imageAlphaOp() { return m_alphaOp; }
+ unsigned imageSourceUnpackAlignment() { return m_imageSourceUnpackAlignment; }
+ ImageHtmlDomSource imageHtmlDomSource() { return m_imageHtmlDomSource; }
+ private:
+ // Each platform must provide an implementation of this method.
+ // Extracts the image and keeps track of its status, such as width, height, Source Alignment, format and AlphaOp etc,
+ // needs to lock the resources or relevant data if needed and returns true upon success
+ bool extractImage(bool premultiplyAlpha, bool ignoreGammaAndColorProfile);
+
+#if USE(CAIRO)
+ ImageSource* m_decoder;
+ RefPtr<cairo_surface_t> m_imageSurface;
+#elif USE(CG)
+ CGImageRef m_cgImage;
+ RetainPtr<CGImageRef> m_decodedImage;
+ RetainPtr<CFDataRef> m_pixelData;
+ OwnArrayPtr<uint8_t> m_formalizedRGBA8Data;
+#elif PLATFORM(QT)
+ QImage m_qtImage;
+#elif PLATFORM(BLACKBERRY)
+ Vector<unsigned> m_imageData;
+#endif
+ Image* m_image;
+ ImageHtmlDomSource m_imageHtmlDomSource;
+ bool m_extractSucceeded;
+ const void* m_imagePixelData;
+ unsigned m_imageWidth;
+ unsigned m_imageHeight;
+ DataFormat m_imageSourceFormat;
+ AlphaOp m_alphaOp;
+ unsigned m_imageSourceUnpackAlignment;
+ };
+
+private:
+ GraphicsContext3D(Attributes, HostWindow*, RenderStyle = RenderOffscreen);
+
+ // Helper for packImageData/extractImageData/extractTextureData which implement packing of pixel
// data into the specified OpenGL destination format and type.
// A sourceUnpackAlignment of zero indicates that the source
// data is tightly packed. Non-zero values may take a slow path.
// Destination data will have no gaps between rows.
- static bool packPixels(const uint8_t* sourceData,
- SourceDataFormat sourceDataFormat,
- unsigned int width,
- unsigned int height,
- unsigned int sourceUnpackAlignment,
- unsigned int destinationFormat,
- unsigned int destinationType,
- AlphaOp alphaOp,
- void* destinationData);
-
-#if PLATFORM(MAC) || PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(EFL) || PLATFORM(BLACKBERRY)
+ static bool packPixels(const uint8_t* sourceData, DataFormat sourceDataFormat, unsigned width, unsigned height, unsigned sourceUnpackAlignment, unsigned destinationFormat, unsigned destinationType, AlphaOp, void* destinationData, bool flipY);
+
+#if PLATFORM(MAC) || PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(EFL) || PLATFORM(BLACKBERRY) || PLATFORM(WIN)
// Take into account the user's requested context creation attributes,
// in particular stencil and antialias, and determine which could or
// could not be honored based on the capabilities of the OpenGL
@@ -965,7 +957,7 @@ public:
void* m_context;
#endif
-#if PLATFORM(MAC) || PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(EFL) || PLATFORM(BLACKBERRY)
+#if PLATFORM(MAC) || PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(EFL) || PLATFORM(BLACKBERRY) || PLATFORM(WIN)
struct SymbolInfo {
SymbolInfo()
: type(0)
@@ -1006,7 +998,7 @@ public:
{
}
- ShaderSymbolMap& symbolMap(ANGLEShaderSymbolType symbolType)
+ ShaderSymbolMap& symbolMap(enum ANGLEShaderSymbolType symbolType)
{
ASSERT(symbolType == SHADER_SYMBOL_TYPE_ATTRIBUTE || symbolType == SHADER_SYMBOL_TYPE_UNIFORM);
if (symbolType == SHADER_SYMBOL_TYPE_ATTRIBUTE)
@@ -1024,10 +1016,10 @@ public:
ANGLEWebKitBridge m_compiler;
#endif
-#if PLATFORM(BLACKBERRY) || (PLATFORM(QT) && defined(QT_OPENGL_ES_2)) || (PLATFORM(GTK) && USE(OPENGL_ES_2))
+#if PLATFORM(BLACKBERRY) || (PLATFORM(QT) && defined(QT_OPENGL_ES_2)) || ((PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(WIN)) && USE(OPENGL_ES_2))
friend class Extensions3DOpenGLES;
OwnPtr<Extensions3DOpenGLES> m_extensions;
-#elif !PLATFORM(CHROMIUM)
+#else
friend class Extensions3DOpenGL;
OwnPtr<Extensions3DOpenGL> m_extensions;
#endif
@@ -1052,10 +1044,19 @@ public:
bool m_layerComposited;
GC3Duint m_internalColorFormat;
- // For tracking which FBO/texture is bound
- GC3Duint m_boundFBO;
- GC3Denum m_activeTexture;
- GC3Duint m_boundTexture0;
+ struct GraphicsContext3DState {
+ GraphicsContext3DState()
+ : boundFBO(0)
+ , activeTexture(GraphicsContext3D::TEXTURE0)
+ , boundTexture0(0)
+ { }
+
+ GC3Duint boundFBO;
+ GC3Denum activeTexture;
+ GC3Duint boundTexture0;
+ };
+
+ GraphicsContext3DState m_state;
// For multisampling
GC3Duint m_multisampleFBO;
diff --git a/Source/WebCore/platform/graphics/GraphicsLayer.cpp b/Source/WebCore/platform/graphics/GraphicsLayer.cpp
index 6d1a2479a..80cc9d5d5 100644
--- a/Source/WebCore/platform/graphics/GraphicsLayer.cpp
+++ b/Source/WebCore/platform/graphics/GraphicsLayer.cpp
@@ -53,10 +53,10 @@ static RepaintMap& repaintRectMap()
return map;
}
-void KeyframeValueList::insert(const AnimationValue* value)
+void KeyframeValueList::insert(PassOwnPtr<const AnimationValue> value)
{
for (size_t i = 0; i < m_values.size(); ++i) {
- const AnimationValue* curValue = m_values[i];
+ const AnimationValue* curValue = m_values[i].get();
if (curValue->keyTime() == value->keyTime()) {
ASSERT_NOT_REACHED();
// insert after
@@ -78,11 +78,10 @@ GraphicsLayer::GraphicsLayer(GraphicsLayerClient* client)
, m_anchorPoint(0.5f, 0.5f, 0)
, m_opacity(1)
, m_zPosition(0)
- , m_backgroundColorSet(false)
, m_contentsOpaque(false)
, m_preserves3D(false)
, m_backfaceVisibility(true)
- , m_usingTiledLayer(false)
+ , m_usingTiledBacking(false)
, m_masksToBounds(false)
, m_drawsContent(false)
, m_contentsVisible(true)
@@ -311,25 +310,18 @@ void GraphicsLayer::setOffsetFromRenderer(const IntSize& offset, ShouldSetNeedsD
void GraphicsLayer::setBackgroundColor(const Color& color)
{
m_backgroundColor = color;
- m_backgroundColorSet = true;
-}
-
-void GraphicsLayer::clearBackgroundColor()
-{
- m_backgroundColor = Color();
- m_backgroundColorSet = false;
}
void GraphicsLayer::paintGraphicsLayerContents(GraphicsContext& context, const IntRect& clip)
{
if (m_client) {
- LayoutSize offset = offsetFromRenderer();
+ IntSize offset = offsetFromRenderer();
context.translate(-offset);
- LayoutRect clipRect(clip);
+ IntRect clipRect(clip);
clipRect.move(offset);
- m_client->paintContents(this, context, m_paintingPhase, pixelSnappedIntRect(clipRect));
+ m_client->paintContents(this, context, m_paintingPhase, clipRect);
}
}
@@ -338,7 +330,7 @@ String GraphicsLayer::animationNameForTransition(AnimatedPropertyID property)
// | is not a valid identifier character in CSS, so this can never conflict with a keyframe identifier.
StringBuilder id;
id.appendLiteral("-|transition");
- id.append(static_cast<char>(property));
+ id.appendNumber(static_cast<int>(property));
id.append('-');
return id.toString();
}
@@ -354,7 +346,7 @@ void GraphicsLayer::resumeAnimations()
void GraphicsLayer::getDebugBorderInfo(Color& color, float& width) const
{
if (drawsContent()) {
- if (m_usingTiledLayer) {
+ if (m_usingTiledBacking) {
color = Color(255, 128, 0, 128); // tiled layer: orange
width = 2;
return;
@@ -416,19 +408,10 @@ void GraphicsLayer::distributeOpacity(float accumulatedOpacity)
}
}
-#if PLATFORM(QT) || PLATFORM(GTK) || PLATFORM(EFL)
-GraphicsLayer::GraphicsLayerFactoryCallback* GraphicsLayer::s_graphicsLayerFactory = 0;
-
-void GraphicsLayer::setGraphicsLayerFactory(GraphicsLayer::GraphicsLayerFactoryCallback factory)
-{
- s_graphicsLayerFactory = factory;
-}
-#endif
-
#if ENABLE(CSS_FILTERS)
-static inline const FilterOperations* filterOperationsAt(const KeyframeValueList& valueList, size_t index)
+static inline const FilterOperations& filterOperationsAt(const KeyframeValueList& valueList, size_t index)
{
- return static_cast<const FilterAnimationValue*>(valueList.at(index))->value();
+ return static_cast<const FilterAnimationValue&>(valueList.at(index)).value();
}
int GraphicsLayer::validateFilterOperations(const KeyframeValueList& valueList)
@@ -441,23 +424,23 @@ int GraphicsLayer::validateFilterOperations(const KeyframeValueList& valueList)
// Empty filters match anything, so find the first non-empty entry as the reference
size_t firstIndex = 0;
for ( ; firstIndex < valueList.size(); ++firstIndex) {
- if (filterOperationsAt(valueList, firstIndex)->operations().size() > 0)
+ if (!filterOperationsAt(valueList, firstIndex).operations().isEmpty())
break;
}
if (firstIndex >= valueList.size())
return -1;
- const FilterOperations* firstVal = filterOperationsAt(valueList, firstIndex);
+ const FilterOperations& firstVal = filterOperationsAt(valueList, firstIndex);
for (size_t i = firstIndex + 1; i < valueList.size(); ++i) {
- const FilterOperations* val = filterOperationsAt(valueList, i);
+ const FilterOperations& val = filterOperationsAt(valueList, i);
// An emtpy filter list matches anything.
- if (val->operations().isEmpty())
+ if (val.operations().isEmpty())
continue;
- if (!firstVal->operationsMatch(*val))
+ if (!firstVal.operationsMatch(val))
return -1;
}
@@ -469,9 +452,9 @@ int GraphicsLayer::validateFilterOperations(const KeyframeValueList& valueList)
// The hasBigRotation flag will always return false if isValid is false. Otherwise hasBigRotation is
// true if the rotation between any two keyframes is >= 180 degrees.
-static inline const TransformOperations* operationsAt(const KeyframeValueList& valueList, size_t index)
+static inline const TransformOperations& operationsAt(const KeyframeValueList& valueList, size_t index)
{
- return static_cast<const TransformAnimationValue*>(valueList.at(index))->value();
+ return static_cast<const TransformAnimationValue&>(valueList.at(index)).value();
}
int GraphicsLayer::validateTransformOperations(const KeyframeValueList& valueList, bool& hasBigRotation)
@@ -486,24 +469,24 @@ int GraphicsLayer::validateTransformOperations(const KeyframeValueList& valueLis
// Empty transforms match anything, so find the first non-empty entry as the reference.
size_t firstIndex = 0;
for ( ; firstIndex < valueList.size(); ++firstIndex) {
- if (operationsAt(valueList, firstIndex)->operations().size() > 0)
+ if (!operationsAt(valueList, firstIndex).operations().isEmpty())
break;
}
if (firstIndex >= valueList.size())
return -1;
- const TransformOperations* firstVal = operationsAt(valueList, firstIndex);
+ const TransformOperations& firstVal = operationsAt(valueList, firstIndex);
// See if the keyframes are valid.
for (size_t i = firstIndex + 1; i < valueList.size(); ++i) {
- const TransformOperations* val = operationsAt(valueList, i);
+ const TransformOperations& val = operationsAt(valueList, i);
- // An emtpy transform list matches anything.
- if (val->operations().isEmpty())
+ // An empty transform list matches anything.
+ if (val.operations().isEmpty())
continue;
- if (!firstVal->operationsMatch(*val))
+ if (!firstVal.operationsMatch(val))
return -1;
}
@@ -511,22 +494,22 @@ int GraphicsLayer::validateTransformOperations(const KeyframeValueList& valueLis
double lastRotAngle = 0.0;
double maxRotAngle = -1.0;
- for (size_t j = 0; j < firstVal->operations().size(); ++j) {
- TransformOperation::OperationType type = firstVal->operations().at(j)->getOperationType();
+ for (size_t j = 0; j < firstVal.operations().size(); ++j) {
+ TransformOperation::OperationType type = firstVal.operations().at(j)->getOperationType();
// if this is a rotation entry, we need to see if any angle differences are >= 180 deg
if (type == TransformOperation::ROTATE_X ||
type == TransformOperation::ROTATE_Y ||
type == TransformOperation::ROTATE_Z ||
type == TransformOperation::ROTATE_3D) {
- lastRotAngle = static_cast<RotateTransformOperation*>(firstVal->operations().at(j).get())->angle();
+ lastRotAngle = static_cast<RotateTransformOperation*>(firstVal.operations().at(j).get())->angle();
if (maxRotAngle < 0)
maxRotAngle = fabs(lastRotAngle);
for (size_t i = firstIndex + 1; i < valueList.size(); ++i) {
- const TransformOperations* val = operationsAt(valueList, i);
- double rotAngle = val->operations().isEmpty() ? 0 : (static_cast<RotateTransformOperation*>(val->operations().at(j).get())->angle());
+ const TransformOperations& val = operationsAt(valueList, i);
+ double rotAngle = val.operations().isEmpty() ? 0 : (static_cast<RotateTransformOperation*>(val.operations().at(j).get())->angle());
double diffAngle = fabs(rotAngle - lastRotAngle);
if (diffAngle > maxRotAngle)
maxRotAngle = diffAngle;
@@ -620,9 +603,14 @@ void GraphicsLayer::dumpProperties(TextStream& ts, int indent, LayerTreeAsTextBe
ts << "(opacity " << m_opacity << ")\n";
}
- if (m_usingTiledLayer) {
+ if (m_usingTiledBacking) {
+ writeIndent(ts, indent + 1);
+ ts << "(usingTiledLayer " << m_usingTiledBacking << ")\n";
+ }
+
+ if (m_contentsOpaque) {
writeIndent(ts, indent + 1);
- ts << "(usingTiledLayer " << m_usingTiledLayer << ")\n";
+ ts << "(contentsOpaque " << m_contentsOpaque << ")\n";
}
if (m_preserves3D) {
@@ -655,7 +643,7 @@ void GraphicsLayer::dumpProperties(TextStream& ts, int indent, LayerTreeAsTextBe
ts << ")\n";
}
- if (m_backgroundColorSet) {
+ if (m_backgroundColor.isValid()) {
writeIndent(ts, indent + 1);
ts << "(backgroundColor " << m_backgroundColor.nameForRenderTreeAsText() << ")\n";
}
@@ -714,7 +702,34 @@ void GraphicsLayer::dumpProperties(TextStream& ts, int indent, LayerTreeAsTextBe
writeIndent(ts, indent + 1);
ts << ")\n";
}
-
+
+ if (behavior & LayerTreeAsTextIncludePaintingPhases && paintingPhase()) {
+ writeIndent(ts, indent + 1);
+ ts << "(paintingPhases\n";
+ if (paintingPhase() & GraphicsLayerPaintBackground) {
+ writeIndent(ts, indent + 2);
+ ts << "GraphicsLayerPaintBackground\n";
+ }
+ if (paintingPhase() & GraphicsLayerPaintForeground) {
+ writeIndent(ts, indent + 2);
+ ts << "GraphicsLayerPaintForeground\n";
+ }
+ if (paintingPhase() & GraphicsLayerPaintMask) {
+ writeIndent(ts, indent + 2);
+ ts << "GraphicsLayerPaintMask\n";
+ }
+ if (paintingPhase() & GraphicsLayerPaintOverflowContents) {
+ writeIndent(ts, indent + 2);
+ ts << "GraphicsLayerPaintOverflowContents\n";
+ }
+ if (paintingPhase() & GraphicsLayerPaintCompositedScroll) {
+ writeIndent(ts, indent + 2);
+ ts << "GraphicsLayerPaintCompositedScroll\n";
+ }
+ writeIndent(ts, indent + 1);
+ ts << ")\n";
+ }
+
dumpAdditionalProperties(ts, indent, behavior);
if (m_children.size()) {
diff --git a/Source/WebCore/platform/graphics/GraphicsLayer.h b/Source/WebCore/platform/graphics/GraphicsLayer.h
index 4f3954486..16dc07feb 100644
--- a/Source/WebCore/platform/graphics/GraphicsLayer.h
+++ b/Source/WebCore/platform/graphics/GraphicsLayer.h
@@ -30,32 +30,32 @@
#include "Animation.h"
#include "Color.h"
-#if ENABLE(CSS_FILTERS)
-#include "FilterOperations.h"
-#endif
#include "FloatPoint.h"
#include "FloatPoint3D.h"
#include "FloatSize.h"
#include "GraphicsLayerClient.h"
#include "IntRect.h"
#include "PlatformLayer.h"
-#include "TransformationMatrix.h"
#include "TransformOperations.h"
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
+#if ENABLE(CSS_FILTERS)
+#include "FilterOperations.h"
+#endif
+
enum LayerTreeAsTextBehaviorFlags {
LayerTreeAsTextBehaviorNormal = 0,
LayerTreeAsTextDebug = 1 << 0, // Dump extra debugging info like layer addresses.
LayerTreeAsTextIncludeVisibleRects = 1 << 1,
LayerTreeAsTextIncludeTileCaches = 1 << 2,
- LayerTreeAsTextIncludeRepaintRects = 1 << 3
+ LayerTreeAsTextIncludeRepaintRects = 1 << 3,
+ LayerTreeAsTextIncludePaintingPhases = 1 << 4
};
typedef unsigned LayerTreeAsTextBehavior;
namespace WebCore {
-class FloatPoint3D;
class FloatRect;
class GraphicsContext;
class GraphicsLayerFactory;
@@ -63,25 +63,27 @@ class Image;
class TextStream;
class TiledBacking;
class TimingFunction;
+class TransformationMatrix;
// Base class for animation values (also used for transitions). Here to
// represent values for properties being animated via the GraphicsLayer,
// without pulling in style-related data from outside of the platform directory.
+// FIXME: Should be moved to its own header file.
class AnimationValue {
WTF_MAKE_FAST_ALLOCATED;
public:
- AnimationValue(float keyTime, PassRefPtr<TimingFunction> timingFunction = 0)
- : m_keyTime(keyTime)
- {
- if (timingFunction)
- m_timingFunction = timingFunction;
- }
-
virtual ~AnimationValue() { }
float keyTime() const { return m_keyTime; }
const TimingFunction* timingFunction() const { return m_timingFunction.get(); }
- virtual AnimationValue* clone() const = 0;
+ virtual PassOwnPtr<AnimationValue> clone() const = 0;
+
+protected:
+ AnimationValue(float keyTime, PassRefPtr<TimingFunction> timingFunction = 0)
+ : m_keyTime(keyTime)
+ , m_timingFunction(timingFunction)
+ {
+ }
private:
float m_keyTime;
@@ -89,63 +91,91 @@ private:
};
// Used to store one float value of an animation.
+// FIXME: Should be moved to its own header file.
class FloatAnimationValue : public AnimationValue {
public:
- FloatAnimationValue(float keyTime, float value, PassRefPtr<TimingFunction> timingFunction = 0)
- : AnimationValue(keyTime, timingFunction)
- , m_value(value)
+ static PassOwnPtr<FloatAnimationValue> create(float keyTime, float value, PassRefPtr<TimingFunction> timingFunction = 0)
{
+ return adoptPtr(new FloatAnimationValue(keyTime, value, timingFunction));
+ }
+
+ virtual PassOwnPtr<AnimationValue> clone() const OVERRIDE
+ {
+ return adoptPtr(new FloatAnimationValue(*this));
}
- virtual AnimationValue* clone() const { return new FloatAnimationValue(*this); }
float value() const { return m_value; }
private:
+ FloatAnimationValue(float keyTime, float value, PassRefPtr<TimingFunction> timingFunction)
+ : AnimationValue(keyTime, timingFunction)
+ , m_value(value)
+ {
+ }
+
float m_value;
};
// Used to store one transform value in a keyframe list.
+// FIXME: Should be moved to its own header file.
class TransformAnimationValue : public AnimationValue {
public:
- TransformAnimationValue(float keyTime, const TransformOperations* value = 0, PassRefPtr<TimingFunction> timingFunction = 0)
- : AnimationValue(keyTime, timingFunction)
+ static PassOwnPtr<TransformAnimationValue> create(float keyTime, const TransformOperations& value, PassRefPtr<TimingFunction> timingFunction = 0)
+ {
+ return adoptPtr(new TransformAnimationValue(keyTime, value, timingFunction));
+ }
+
+ virtual PassOwnPtr<AnimationValue> clone() const OVERRIDE
{
- if (value)
- m_value = *value;
+ return adoptPtr(new TransformAnimationValue(*this));
}
- virtual AnimationValue* clone() const { return new TransformAnimationValue(*this); }
- const TransformOperations* value() const { return &m_value; }
+ const TransformOperations& value() const { return m_value; }
private:
+ TransformAnimationValue(float keyTime, const TransformOperations& value, PassRefPtr<TimingFunction> timingFunction)
+ : AnimationValue(keyTime, timingFunction)
+ , m_value(value)
+ {
+ }
+
TransformOperations m_value;
};
#if ENABLE(CSS_FILTERS)
// Used to store one filter value in a keyframe list.
+// FIXME: Should be moved to its own header file.
class FilterAnimationValue : public AnimationValue {
public:
- FilterAnimationValue(float keyTime, const FilterOperations* value = 0, PassRefPtr<TimingFunction> timingFunction = 0)
- : AnimationValue(keyTime, timingFunction)
+ static PassOwnPtr<FilterAnimationValue> create(float keyTime, const FilterOperations& value, PassRefPtr<TimingFunction> timingFunction = 0)
+ {
+ return adoptPtr(new FilterAnimationValue(keyTime, value, timingFunction));
+ }
+
+ virtual PassOwnPtr<AnimationValue> clone() const OVERRIDE
{
- if (value)
- m_value = *value;
+ return adoptPtr(new FilterAnimationValue(*this));
}
- virtual AnimationValue* clone() const { return new FilterAnimationValue(*this); }
- const FilterOperations* value() const { return &m_value; }
+ const FilterOperations& value() const { return m_value; }
private:
+ FilterAnimationValue(float keyTime, const FilterOperations& value, PassRefPtr<TimingFunction> timingFunction)
+ : AnimationValue(keyTime, timingFunction)
+ , m_value(value)
+ {
+ }
+
FilterOperations m_value;
};
#endif
-// Used to store a series of values in a keyframe list. Values will all be of the same type,
-// which can be inferred from the property.
+// Used to store a series of values in a keyframe list.
+// Values will all be of the same type, which can be inferred from the property.
+// FIXME: Should be moved to its own header file.
class KeyframeValueList {
public:
-
- KeyframeValueList(AnimatedPropertyID property)
+ explicit KeyframeValueList(AnimatedPropertyID property)
: m_property(property)
{
}
@@ -159,7 +189,6 @@ public:
~KeyframeValueList()
{
- deleteAllValues(m_values);
}
KeyframeValueList& operator=(const KeyframeValueList& other)
@@ -178,18 +207,16 @@ public:
AnimatedPropertyID property() const { return m_property; }
size_t size() const { return m_values.size(); }
- const AnimationValue* at(size_t i) const { return m_values.at(i); }
+ const AnimationValue& at(size_t i) const { return *m_values.at(i); }
- // Insert, sorted by keyTime. Takes ownership of the pointer.
- void insert(const AnimationValue*);
+ // Insert, sorted by keyTime.
+ void insert(PassOwnPtr<const AnimationValue>);
protected:
- Vector<const AnimationValue*> m_values;
+ Vector<OwnPtr<const AnimationValue> > m_values;
AnimatedPropertyID m_property;
};
-
-
// GraphicsLayer is an abstraction for a rendering surface with backing store,
// which may have associated transformation and animations.
@@ -292,11 +319,11 @@ public:
bool acceleratesDrawing() const { return m_acceleratesDrawing; }
virtual void setAcceleratesDrawing(bool b) { m_acceleratesDrawing = b; }
- // The color used to paint the layer backgrounds
+ // The color used to paint the layer background. Pass an invalid color to remove it.
+ // Note that this covers the entire layer. Use setContentsToSolidColor() if the color should
+ // only cover the contentsRect.
const Color& backgroundColor() const { return m_backgroundColor; }
virtual void setBackgroundColor(const Color&);
- virtual void clearBackgroundColor();
- bool backgroundColorSet() const { return m_backgroundColorSet; }
// opaque means that we know the layer contents have no alpha
bool contentsOpaque() const { return m_contentsOpaque; }
@@ -325,6 +352,14 @@ public:
virtual void setContentsNeedsDisplay() { };
+ // The tile phase is relative to the GraphicsLayer bounds.
+ virtual void setContentsTilePhase(const IntPoint& p) { m_contentsTilePhase = p; }
+ IntPoint contentsTilePhase() const { return m_contentsTilePhase; }
+
+ virtual void setContentsTileSize(const IntSize& s) { m_contentsTileSize = s; }
+ IntSize contentsTileSize() const { return m_contentsTileSize; }
+ bool hasContentsTiling() const { return !m_contentsTileSize.isEmpty(); }
+
// Set that the position/size of the contents (image or video).
IntRect contentsRect() const { return m_contentsRect; }
virtual void setContentsRect(const IntRect& r) { m_contentsRect = r; }
@@ -346,8 +381,12 @@ public:
virtual void setContentsToImage(Image*) { }
virtual bool shouldDirectlyCompositeImage(Image*) const { return true; }
virtual void setContentsToMedia(PlatformLayer*) { } // video or plug-in
- virtual void setContentsToBackgroundColor(const Color&) { }
+ // Pass an invalid color to remove the contents layer.
+ virtual void setContentsToSolidColor(const Color&) { }
virtual void setContentsToCanvas(PlatformLayer*) { }
+ // FIXME: webkit.org/b/109658
+ // Should unify setContentsToMedia and setContentsToCanvas
+ virtual void setContentsToPlatformLayer(PlatformLayer* layer) { setContentsToMedia(layer); }
virtual bool hasContentsLayer() const { return false; }
// Callback from the underlying graphics system to draw layer contents.
@@ -372,6 +411,7 @@ public:
virtual void setShowRepaintCounter(bool show) { m_showRepaintCounter = show; }
bool isShowingRepaintCounter() const { return m_showRepaintCounter; }
+ // FIXME: this is really a paint count.
int repaintCount() const { return m_repaintCount; }
int incrementRepaintCount() { return ++m_repaintCount; }
@@ -402,30 +442,47 @@ public:
// and descendant layers, and this layer only.
virtual void flushCompositingState(const FloatRect& /* clipRect */) { }
virtual void flushCompositingStateForThisLayerOnly() { }
-
- // Return a string with a human readable form of the layer tree, If debug is true
+
+ // If the exposed rect of this layer changes, returns true if this or descendant layers need a flush,
+ // for example to allocate new tiles.
+ virtual bool visibleRectChangeRequiresFlush(const FloatRect& /* clipRect */) const { return false; }
+
+ // Return a string with a human readable form of the layer tree, If debug is true
// pointers for the layers and timing data will be included in the returned string.
String layerTreeAsText(LayerTreeAsTextBehavior = LayerTreeAsTextBehaviorNormal) const;
// Return an estimate of the backing store memory cost (in bytes). May be incorrect for tiled layers.
virtual double backingStoreMemoryEstimate() const;
- bool usingTiledLayer() const { return m_usingTiledLayer; }
-
+ bool usingTiledBacking() const { return m_usingTiledBacking; }
virtual TiledBacking* tiledBacking() const { return 0; }
void resetTrackedRepaints();
void addRepaintRect(const FloatRect&);
-#if PLATFORM(QT) || PLATFORM(GTK) || PLATFORM(EFL)
- // This allows several alternative GraphicsLayer implementations in the same port,
- // e.g. if a different GraphicsLayer implementation is needed in WebKit1 vs. WebKit2.
- typedef PassOwnPtr<GraphicsLayer> GraphicsLayerFactoryCallback(GraphicsLayerClient*);
- static void setGraphicsLayerFactory(GraphicsLayerFactoryCallback);
+ static bool supportsBackgroundColorContent()
+ {
+#if USE(CA) || USE(TEXTURE_MAPPER)
+ return true;
+#else
+ return false;
+#endif
+ }
+
+#if USE(COORDINATED_GRAPHICS)
+ static bool supportsContentsTiling();
+#else
+ static bool supportsContentsTiling()
+ {
+ // FIXME: Enable the feature on different ports.
+ return false;
+ }
#endif
void updateDebugIndicators();
+ virtual bool canThrottleLayerFlush() const { return false; }
+
protected:
// Should be called from derived class destructors. Should call willBeDestroyed() on super.
virtual void willBeDestroyed();
@@ -485,11 +542,10 @@ protected:
FilterOperations m_filters;
#endif
- bool m_backgroundColorSet : 1;
bool m_contentsOpaque : 1;
bool m_preserves3D: 1;
bool m_backfaceVisibility : 1;
- bool m_usingTiledLayer : 1;
+ bool m_usingTiledBacking : 1;
bool m_masksToBounds : 1;
bool m_drawsContent : 1;
bool m_contentsVisible : 1;
@@ -513,12 +569,10 @@ protected:
FloatPoint m_replicatedLayerPosition; // For a replica layer, the position of the replica.
IntRect m_contentsRect;
+ IntPoint m_contentsTilePhase;
+ IntSize m_contentsTileSize;
int m_repaintCount;
-
-#if PLATFORM(QT) || PLATFORM(GTK) || PLATFORM(EFL)
- static GraphicsLayer::GraphicsLayerFactoryCallback* s_graphicsLayerFactory;
-#endif
};
diff --git a/Source/WebCore/platform/graphics/GraphicsLayerAnimation.cpp b/Source/WebCore/platform/graphics/GraphicsLayerAnimation.cpp
index 16710b629..206d707b3 100644
--- a/Source/WebCore/platform/graphics/GraphicsLayerAnimation.cpp
+++ b/Source/WebCore/platform/graphics/GraphicsLayerAnimation.cpp
@@ -39,27 +39,27 @@ static inline PassRefPtr<FilterOperation> blendFunc(FilterOperation* fromOp, Fil
}
-static FilterOperations applyFilterAnimation(const FilterOperations* from, const FilterOperations* to, double progress, const IntSize& boxSize)
+static FilterOperations applyFilterAnimation(const FilterOperations& from, const FilterOperations& to, double progress, const IntSize& boxSize)
{
// First frame of an animation.
if (!progress)
- return *from;
+ return from;
// Last frame of an animation.
if (progress == 1)
- return *to;
+ return to;
- if (!from->operationsMatch(*to))
- return *to;
+ if (!from.isEmpty() && !to.isEmpty() && !from.operationsMatch(to))
+ return to;
FilterOperations result;
- size_t fromSize = from->operations().size();
- size_t toSize = to->operations().size();
+ size_t fromSize = from.operations().size();
+ size_t toSize = to.operations().size();
size_t size = std::max(fromSize, toSize);
for (size_t i = 0; i < size; i++) {
- RefPtr<FilterOperation> fromOp = (i < fromSize) ? from->operations()[i].get() : 0;
- RefPtr<FilterOperation> toOp = (i < toSize) ? to->operations()[i].get() : 0;
+ RefPtr<FilterOperation> fromOp = (i < fromSize) ? from.operations()[i].get() : 0;
+ RefPtr<FilterOperation> toOp = (i < toSize) ? to.operations()[i].get() : 0;
RefPtr<FilterOperation> blendedOp = toOp ? blendFunc(fromOp.get(), toOp.get(), progress, boxSize) : (fromOp ? blendFunc(0, fromOp.get(), progress, boxSize, true) : 0);
if (blendedOp)
result.operations().append(blendedOp);
@@ -155,58 +155,58 @@ static inline float applyTimingFunction(const TimingFunction* timingFunction, fl
return progress;
}
-static TransformationMatrix applyTransformAnimation(const TransformOperations* from, const TransformOperations* to, double progress, const IntSize& boxSize, bool listsMatch)
+static TransformationMatrix applyTransformAnimation(const TransformOperations& from, const TransformOperations& to, double progress, const IntSize& boxSize, bool listsMatch)
{
TransformationMatrix matrix;
// First frame of an animation.
if (!progress) {
- from->apply(boxSize, matrix);
+ from.apply(boxSize, matrix);
return matrix;
}
// Last frame of an animation.
if (progress == 1) {
- to->apply(boxSize, matrix);
+ to.apply(boxSize, matrix);
return matrix;
}
// If we have incompatible operation lists, we blend the resulting matrices.
if (!listsMatch) {
TransformationMatrix fromMatrix;
- to->apply(boxSize, matrix);
- from->apply(boxSize, fromMatrix);
+ to.apply(boxSize, matrix);
+ from.apply(boxSize, fromMatrix);
matrix.blend(fromMatrix, progress);
return matrix;
}
// Animation to "-webkit-transform: none".
- if (!to->size()) {
- TransformOperations blended(*from);
+ if (!to.size()) {
+ TransformOperations blended(from);
for (size_t i = 0; i < blended.operations().size(); ++i)
blended.operations()[i]->blend(0, progress, true)->apply(matrix, boxSize);
return matrix;
}
// Animation from "-webkit-transform: none".
- if (!from->size()) {
- TransformOperations blended(*to);
+ if (!from.size()) {
+ TransformOperations blended(to);
for (size_t i = 0; i < blended.operations().size(); ++i)
blended.operations()[i]->blend(0, 1. - progress, true)->apply(matrix, boxSize);
return matrix;
}
// Normal animation with a matching operation list.
- TransformOperations blended(*to);
+ TransformOperations blended(to);
for (size_t i = 0; i < blended.operations().size(); ++i)
- blended.operations()[i]->blend(from->at(i), progress, !from->at(i))->apply(matrix, boxSize);
+ blended.operations()[i]->blend(from.at(i), progress, !from.at(i))->apply(matrix, boxSize);
return matrix;
}
-static const TimingFunction* timingFunctionForAnimationValue(const AnimationValue* animValue, const Animation* anim)
+static const TimingFunction* timingFunctionForAnimationValue(const AnimationValue& animValue, const Animation* anim)
{
- if (animValue->timingFunction())
- return animValue->timingFunction();
+ if (animValue.timingFunction())
+ return animValue.timingFunction();
if (anim->timingFunction())
return anim->timingFunction().get();
@@ -227,18 +227,18 @@ GraphicsLayerAnimation::GraphicsLayerAnimation(const String& name, const Keyfram
{
}
-void GraphicsLayerAnimation::applyInternal(Client* client, const AnimationValue* from, const AnimationValue* to, float progress)
+void GraphicsLayerAnimation::applyInternal(Client* client, const AnimationValue& from, const AnimationValue& to, float progress)
{
switch (m_keyframes.property()) {
case AnimatedPropertyOpacity:
- client->setAnimatedOpacity(applyOpacityAnimation((static_cast<const FloatAnimationValue*>(from)->value()), (static_cast<const FloatAnimationValue*>(to)->value()), progress));
+ client->setAnimatedOpacity(applyOpacityAnimation((static_cast<const FloatAnimationValue&>(from).value()), (static_cast<const FloatAnimationValue&>(to).value()), progress));
return;
case AnimatedPropertyWebkitTransform:
- client->setAnimatedTransform(applyTransformAnimation(static_cast<const TransformAnimationValue*>(from)->value(), static_cast<const TransformAnimationValue*>(to)->value(), progress, m_boxSize, m_listsMatch));
+ client->setAnimatedTransform(applyTransformAnimation(static_cast<const TransformAnimationValue&>(from).value(), static_cast<const TransformAnimationValue&>(to).value(), progress, m_boxSize, m_listsMatch));
return;
#if ENABLE(CSS_FILTERS)
case AnimatedPropertyWebkitFilter:
- client->setAnimatedFilters(applyFilterAnimation(static_cast<const FilterAnimationValue*>(from)->value(), static_cast<const FilterAnimationValue*>(to)->value(), progress, m_boxSize));
+ client->setAnimatedFilters(applyFilterAnimation(static_cast<const FilterAnimationValue&>(from).value(), static_cast<const FilterAnimationValue&>(to).value(), progress, m_boxSize));
return;
#endif
default:
@@ -304,12 +304,12 @@ void GraphicsLayerAnimation::apply(Client* client)
}
for (size_t i = 0; i < m_keyframes.size() - 1; ++i) {
- const AnimationValue* from = m_keyframes.at(i);
- const AnimationValue* to = m_keyframes.at(i + 1);
- if (from->keyTime() > normalizedValue || to->keyTime() < normalizedValue)
+ const AnimationValue& from = m_keyframes.at(i);
+ const AnimationValue& to = m_keyframes.at(i + 1);
+ if (from.keyTime() > normalizedValue || to.keyTime() < normalizedValue)
continue;
- normalizedValue = (normalizedValue - from->keyTime()) / (to->keyTime() - from->keyTime());
+ normalizedValue = (normalizedValue - from.keyTime()) / (to.keyTime() - from.keyTime());
const TimingFunction* timingFunction = timingFunctionForAnimationValue(from, m_animation.get());
normalizedValue = applyTimingFunction(timingFunction, normalizedValue, m_animation->duration());
applyInternal(client, from, to, normalizedValue);
diff --git a/Source/WebCore/platform/graphics/GraphicsLayerAnimation.h b/Source/WebCore/platform/graphics/GraphicsLayerAnimation.h
index 9f0b5c52a..2d2f68573 100644
--- a/Source/WebCore/platform/graphics/GraphicsLayerAnimation.h
+++ b/Source/WebCore/platform/graphics/GraphicsLayerAnimation.h
@@ -66,7 +66,7 @@ public:
bool listsMatch() const { return m_listsMatch; }
private:
- void applyInternal(Client*, const AnimationValue* from, const AnimationValue* to, float progress);
+ void applyInternal(Client*, const AnimationValue& from, const AnimationValue& to, float progress);
KeyframeValueList m_keyframes;
IntSize m_boxSize;
RefPtr<Animation> m_animation;
diff --git a/Source/WebCore/platform/graphics/GraphicsLayerClient.h b/Source/WebCore/platform/graphics/GraphicsLayerClient.h
index 8b6bffd19..bdf6a7ee8 100644
--- a/Source/WebCore/platform/graphics/GraphicsLayerClient.h
+++ b/Source/WebCore/platform/graphics/GraphicsLayerClient.h
@@ -42,6 +42,7 @@ enum GraphicsLayerPaintingPhaseFlags {
GraphicsLayerPaintForeground = (1 << 1),
GraphicsLayerPaintMask = (1 << 2),
GraphicsLayerPaintOverflowContents = (1 << 3),
+ GraphicsLayerPaintCompositedScroll = (1 << 4),
GraphicsLayerPaintAllWithOverflowClip = (GraphicsLayerPaintBackground | GraphicsLayerPaintForeground | GraphicsLayerPaintMask)
};
typedef unsigned GraphicsLayerPaintingPhase;
@@ -58,7 +59,8 @@ class GraphicsLayerClient {
public:
virtual ~GraphicsLayerClient() {}
- virtual bool shouldUseTileCache(const GraphicsLayer*) const { return false; }
+ virtual bool shouldUseTiledBacking(const GraphicsLayer*) const { return false; }
+ virtual void tiledBackingUsageChanged(const GraphicsLayer*, bool /*usingTiledBacking*/) { }
// Callback for when hardware-accelerated animation started.
virtual void notifyAnimationStarted(const GraphicsLayer*, double time) = 0;
@@ -77,6 +79,10 @@ public:
// initialized to identity already. Returns false if the layer has no transform.
virtual bool getCurrentTransform(const GraphicsLayer*, TransformationMatrix&) const { return false; }
+ // Allows the client to modify a layer position used during the visibleRect calculation, for example to ignore
+ // scroll overhang.
+ virtual void customPositionForVisibleRectComputation(const GraphicsLayer*, FloatPoint&) const { }
+
// Multiplier for backing store size, related to high DPI.
virtual float deviceScaleFactor() const { return 1; }
// Page scale factor.
@@ -92,10 +98,6 @@ public:
// while painting.
virtual void verifyNotPainting() { }
#endif
-
-#if PLATFORM(BLACKBERRY)
- virtual bool contentsVisible(const GraphicsLayer*, const IntRect& contentRect) const { return false; }
-#endif
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/GraphicsLayerTransform.cpp b/Source/WebCore/platform/graphics/GraphicsLayerTransform.cpp
index 77cac87d6..04363ccdc 100644
--- a/Source/WebCore/platform/graphics/GraphicsLayerTransform.cpp
+++ b/Source/WebCore/platform/graphics/GraphicsLayerTransform.cpp
@@ -23,7 +23,8 @@
namespace WebCore {
GraphicsLayerTransform::GraphicsLayerTransform()
- : m_flattening(false)
+ : m_anchorPoint(0.5, 0.5, 0)
+ , m_flattening(true)
, m_dirty(false) // false by default since all default values would be combined as the identity matrix
, m_childrenDirty(false)
{
@@ -31,36 +32,48 @@ GraphicsLayerTransform::GraphicsLayerTransform()
void GraphicsLayerTransform::setPosition(const FloatPoint& position)
{
+ if (m_position == position)
+ return;
m_position = position;
m_dirty = true;
}
void GraphicsLayerTransform::setSize(const FloatSize& size)
{
+ if (m_size == size)
+ return;
m_size = size;
m_dirty = true;
}
void GraphicsLayerTransform::setAnchorPoint(const FloatPoint3D& anchorPoint)
{
+ if (m_anchorPoint == anchorPoint)
+ return;
m_anchorPoint = anchorPoint;
m_dirty = true;
}
void GraphicsLayerTransform::setFlattening(bool flattening)
{
+ if (m_flattening == flattening)
+ return;
m_flattening = flattening;
m_dirty = true;
}
void GraphicsLayerTransform::setLocalTransform(const TransformationMatrix& transform)
{
+ if (m_local == transform)
+ return;
m_local = transform;
m_dirty = true;
}
void GraphicsLayerTransform::setChildrenTransform(const TransformationMatrix& transform)
{
+ if (m_children == transform)
+ return;
m_children = transform;
m_dirty = true;
}
diff --git a/Source/WebCore/platform/graphics/GraphicsTypes.cpp b/Source/WebCore/platform/graphics/GraphicsTypes.cpp
index f617cc5ea..8d1150194 100644
--- a/Source/WebCore/platform/graphics/GraphicsTypes.cpp
+++ b/Source/WebCore/platform/graphics/GraphicsTypes.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2012 Rik Cabanier (cabanier@adobe.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -46,22 +47,59 @@ static const char* const compositeOperatorNames[] = {
"darker",
"lighter"
};
+
+static const char* const blendOperatorNames[] = {
+ "multiply",
+ "screen",
+ "overlay",
+ "darken",
+ "lighten",
+ "color-dodge",
+ "color-burn",
+ "hard-light",
+ "soft-light",
+ "difference",
+ "exclusion",
+ "hue",
+ "saturation",
+ "color",
+ "luminosity"
+};
const int numCompositeOperatorNames = WTF_ARRAY_LENGTH(compositeOperatorNames);
+const int numBlendOperatorNames = WTF_ARRAY_LENGTH(blendOperatorNames);
-bool parseCompositeOperator(const String& s, CompositeOperator& op)
+bool parseCompositeAndBlendOperator(const String& s, CompositeOperator& op, BlendMode& blendOp)
{
- for (int i = 0; i < numCompositeOperatorNames; i++)
+ for (int i = 0; i < numCompositeOperatorNames; i++) {
if (s == compositeOperatorNames[i]) {
op = static_cast<CompositeOperator>(i);
+ blendOp = BlendModeNormal;
+ return true;
+ }
+ }
+
+ for (int i = 0; i < numBlendOperatorNames; i++) {
+ if (s == blendOperatorNames[i]) {
+ blendOp = static_cast<BlendMode>(i+1);
+ // For now, blending will always assume source-over. This will be fixed in the future
+ op = CompositeSourceOver;
return true;
}
+ }
+
return false;
}
-String compositeOperatorName(CompositeOperator op)
+// FIXME: when we support blend modes in combination with compositing other than source-over
+// this routine needs to be updated.
+String compositeOperatorName(CompositeOperator op, BlendMode blendOp)
{
ASSERT(op >= 0);
ASSERT(op < numCompositeOperatorNames);
+ ASSERT(blendOp >= 0);
+ ASSERT(blendOp <= numBlendOperatorNames);
+ if (blendOp != BlendModeNormal)
+ return blendOperatorNames[blendOp-1];
return compositeOperatorNames[op];
}
diff --git a/Source/WebCore/platform/graphics/GraphicsTypes.h b/Source/WebCore/platform/graphics/GraphicsTypes.h
index 1d1b7e09d..586f7ec69 100644
--- a/Source/WebCore/platform/graphics/GraphicsTypes.h
+++ b/Source/WebCore/platform/graphics/GraphicsTypes.h
@@ -82,8 +82,8 @@ namespace WebCore {
enum TextAlign { StartTextAlign, EndTextAlign, LeftTextAlign, CenterTextAlign, RightTextAlign };
- String compositeOperatorName(CompositeOperator);
- bool parseCompositeOperator(const String&, CompositeOperator&);
+ String compositeOperatorName(CompositeOperator, BlendMode);
+ bool parseCompositeAndBlendOperator(const String&, CompositeOperator&, BlendMode&);
String lineCapName(LineCap);
bool parseLineCap(const String&, LineCap&);
diff --git a/Source/WebCore/platform/graphics/GraphicsTypes3D.h b/Source/WebCore/platform/graphics/GraphicsTypes3D.h
index 203a3fd8a..1fa8eaab1 100644
--- a/Source/WebCore/platform/graphics/GraphicsTypes3D.h
+++ b/Source/WebCore/platform/graphics/GraphicsTypes3D.h
@@ -41,6 +41,7 @@ typedef int GC3Dint;
typedef int GC3Dsizei;
typedef unsigned int GC3Duint;
typedef float GC3Dfloat;
+typedef unsigned short GC3Dhalffloat;
typedef float GC3Dclampf;
typedef intptr_t GC3Dintptr;
typedef intptr_t GC3Dsizeiptr;
diff --git a/Source/WebCore/platform/graphics/Icon.h b/Source/WebCore/platform/graphics/Icon.h
index 781a08cb2..a78b265c8 100644
--- a/Source/WebCore/platform/graphics/Icon.h
+++ b/Source/WebCore/platform/graphics/Icon.h
@@ -35,11 +35,6 @@ typedef struct HICON__* HICON;
#include <QIcon>
#elif PLATFORM(GTK)
typedef struct _GdkPixbuf GdkPixbuf;
-#elif PLATFORM(EFL)
-typedef struct _Evas_Object Evas_Object;
-#elif PLATFORM(CHROMIUM)
-#include "Image.h"
-#include "PlatformIcon.h"
#endif
namespace WebCore {
@@ -57,8 +52,6 @@ public:
#if PLATFORM(WIN)
static PassRefPtr<Icon> create(HICON hIcon) { return adoptRef(new Icon(hIcon)); }
-#elif PLATFORM(CHROMIUM)
- static PassRefPtr<Icon> create(PassRefPtr<PlatformIcon> icon) { return adoptRef(new Icon(icon)); }
#endif
private:
@@ -77,9 +70,6 @@ private:
#elif PLATFORM(EFL)
Icon();
Evas_Object* m_icon;
-#elif PLATFORM(CHROMIUM)
- Icon(PassRefPtr<PlatformIcon>);
- RefPtr<PlatformIcon> m_icon;
#endif
};
diff --git a/Source/WebCore/platform/graphics/Image.cpp b/Source/WebCore/platform/graphics/Image.cpp
index 1cac9972b..b83bc4c50 100644
--- a/Source/WebCore/platform/graphics/Image.cpp
+++ b/Source/WebCore/platform/graphics/Image.cpp
@@ -34,7 +34,6 @@
#include "IntRect.h"
#include "Length.h"
#include "MIMETypeRegistry.h"
-#include "PlatformMemoryInstrumentation.h"
#include "SharedBuffer.h"
#include <math.h>
#include <wtf/MainThread.h>
@@ -69,11 +68,11 @@ bool Image::supportsType(const String& type)
bool Image::setData(PassRefPtr<SharedBuffer> data, bool allDataReceived)
{
- m_data = data;
- if (!m_data.get())
+ m_encodedImageData = data;
+ if (!m_encodedImageData.get())
return true;
- int length = m_data->size();
+ int length = m_encodedImageData->size();
if (!length)
return true;
@@ -91,22 +90,19 @@ void Image::fillWithSolidColor(GraphicsContext* ctxt, const FloatRect& dstRect,
ctxt->setCompositeOperation(previousOperator);
}
-void Image::draw(GraphicsContext* ctx, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator op, RespectImageOrientationEnum)
+void Image::draw(GraphicsContext* ctx, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator op, BlendMode blendMode, RespectImageOrientationEnum)
{
- draw(ctx, dstRect, srcRect, styleColorSpace, op);
+ draw(ctx, dstRect, srcRect, styleColorSpace, op, blendMode);
}
-void Image::drawTiled(GraphicsContext* ctxt, const FloatRect& destRect, const FloatPoint& srcPoint, const FloatSize& scaledTileSize, ColorSpace styleColorSpace, CompositeOperator op)
+void Image::drawTiled(GraphicsContext* ctxt, const FloatRect& destRect, const FloatPoint& srcPoint, const FloatSize& scaledTileSize, ColorSpace styleColorSpace, CompositeOperator op, BlendMode blendMode)
{
if (mayFillWithSolidColor()) {
fillWithSolidColor(ctxt, destRect, solidColor(), styleColorSpace, op);
return;
}
- // See <https://webkit.org/b/59043>.
-#if !PLATFORM(WX)
ASSERT(!isBitmapImage() || notSolidColor());
-#endif
FloatSize intrinsicTileSize = size();
if (hasRelativeWidth())
@@ -129,13 +125,13 @@ void Image::drawTiled(GraphicsContext* ctxt, const FloatRect& destRect, const Fl
visibleSrcRect.setY((destRect.y() - oneTileRect.y()) / scale.height());
visibleSrcRect.setWidth(destRect.width() / scale.width());
visibleSrcRect.setHeight(destRect.height() / scale.height());
- draw(ctxt, destRect, visibleSrcRect, styleColorSpace, op);
+ draw(ctxt, destRect, visibleSrcRect, styleColorSpace, op, blendMode);
return;
}
AffineTransform patternTransform = AffineTransform().scaleNonUniform(scale.width(), scale.height());
FloatRect tileRect(FloatPoint(), intrinsicTileSize);
- drawPattern(ctxt, tileRect, patternTransform, oneTileRect.location(), styleColorSpace, op, destRect);
+ drawPattern(ctxt, tileRect, patternTransform, oneTileRect.location(), styleColorSpace, op, destRect, blendMode);
startAnimation();
}
@@ -198,11 +194,4 @@ void Image::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsic
intrinsicHeight = Length(intrinsicRatio.height(), Fixed);
}
-void Image::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
-{
- MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Image);
- info.addMember(m_data);
- info.addWeakPointer(m_imageObserver);
-}
-
}
diff --git a/Source/WebCore/platform/graphics/Image.h b/Source/WebCore/platform/graphics/Image.h
index eab13bc5f..78912efea 100644
--- a/Source/WebCore/platform/graphics/Image.h
+++ b/Source/WebCore/platform/graphics/Image.h
@@ -62,9 +62,14 @@ typedef struct _GdkPixbuf GdkPixbuf;
#endif
#if PLATFORM(EFL)
+#if USE(EO)
+typedef struct _Eo Evas;
+typedef struct _Eo Evas_Object;
+#else
typedef struct _Evas Evas;
typedef struct _Evas_Object Evas_Object;
#endif
+#endif
namespace WebCore {
@@ -94,7 +99,7 @@ public:
virtual bool isSVGImage() const { return false; }
virtual bool isBitmapImage() const { return false; }
- virtual bool currentFrameHasAlpha() { return false; }
+ virtual bool currentFrameKnownToBeOpaque() = 0;
// Derived classes should override this if they can assure that
// the image contains only resources from its own security origin.
@@ -123,7 +128,7 @@ public:
virtual void destroyDecodedData(bool destroyAll = true) = 0;
virtual unsigned decodedSize() const = 0;
- SharedBuffer* data() { return m_data.get(); }
+ SharedBuffer* data() { return m_encodedImageData.get(); }
// Animation begins whenever someone draws the image, so startAnimation() is not normally called.
// It will automatically pause once all observers no longer want to render the image anywhere.
@@ -137,7 +142,7 @@ public:
enum TileRule { StretchTile, RoundTile, SpaceTile, RepeatTile };
- virtual NativeImagePtr nativeImageForCurrentFrame() { return 0; }
+ virtual PassNativeImagePtr nativeImageForCurrentFrame() { return 0; }
#if PLATFORM(MAC)
// Accessors for native image formats.
@@ -171,7 +176,7 @@ public:
#endif
virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform,
- const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect);
+ const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect, BlendMode = BlendModeNormal);
#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
FloatRect adjustSourceRectForDownSampling(const FloatRect& srcRect, const IntSize& scaledSize) const;
@@ -181,8 +186,6 @@ public:
virtual bool notSolidColor() { return true; }
#endif
- virtual void reportMemoryUsage(MemoryObjectInfo*) const;
-
protected:
Image(ImageObserver* = 0);
@@ -192,9 +195,10 @@ protected:
#if PLATFORM(WIN)
virtual void drawFrameMatchingSourceSize(GraphicsContext*, const FloatRect& dstRect, const IntSize& srcSize, ColorSpace styleColorSpace, CompositeOperator) { }
#endif
- virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator) = 0;
- virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, RespectImageOrientationEnum);
- void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatPoint& srcPoint, const FloatSize& tileSize, ColorSpace styleColorSpace, CompositeOperator);
+ virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode) = 0;
+ virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode, RespectImageOrientationEnum);
+ void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatPoint& srcPoint, const FloatSize& tileSize, ColorSpace styleColorSpace,
+ CompositeOperator , BlendMode);
void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, const FloatSize& tileScaleFactor, TileRule hRule, TileRule vRule, ColorSpace styleColorSpace, CompositeOperator);
// Supporting tiled drawing
@@ -202,7 +206,7 @@ protected:
virtual Color solidColor() const { return Color(); }
private:
- RefPtr<SharedBuffer> m_data; // The encoded raw data for the image.
+ RefPtr<SharedBuffer> m_encodedImageData;
ImageObserver* m_imageObserver;
};
diff --git a/Source/WebCore/platform/graphics/ImageBuffer.cpp b/Source/WebCore/platform/graphics/ImageBuffer.cpp
index 138d078cf..6cf7cca94 100644
--- a/Source/WebCore/platform/graphics/ImageBuffer.cpp
+++ b/Source/WebCore/platform/graphics/ImageBuffer.cpp
@@ -28,7 +28,6 @@
#include "ImageBuffer.h"
#include "IntRect.h"
-#include "PlatformMemoryInstrumentation.h"
#include <wtf/MathExtras.h>
namespace WebCore {
@@ -99,25 +98,21 @@ void ImageBuffer::convertToLuminanceMask()
genericConvertToLuminanceMask();
}
-#if USE(ACCELERATED_COMPOSITING) && !USE(SKIA)
+#if USE(ACCELERATED_COMPOSITING) && !USE(CAIRO) && !PLATFORM(BLACKBERRY)
PlatformLayer* ImageBuffer::platformLayer() const
{
return 0;
}
#endif
-#if !USE(SKIA)
bool ImageBuffer::copyToPlatformTexture(GraphicsContext3D&, Platform3DObject, GC3Denum, bool, bool)
{
return false;
}
-#endif
-void ImageBuffer::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+PassOwnPtr<ImageBuffer> ImageBuffer::createCompatibleBuffer(const IntSize& size, float resolutionScale, ColorSpace colorSpace, const GraphicsContext* context, bool)
{
- MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Image);
- info.addMember(m_data);
- info.addMember(m_context);
+ return create(size, resolutionScale, colorSpace, context->isAcceleratedContext() ? Accelerated : Unaccelerated);
}
}
diff --git a/Source/WebCore/platform/graphics/ImageBuffer.h b/Source/WebCore/platform/graphics/ImageBuffer.h
index 47cfeb8f0..871d7c055 100644
--- a/Source/WebCore/platform/graphics/ImageBuffer.h
+++ b/Source/WebCore/platform/graphics/ImageBuffer.h
@@ -70,11 +70,6 @@ namespace WebCore {
DontCopyBackingStore // Subsequent draws may affect the copy.
};
- enum DeferralMode {
- NonDeferred,
- Deferred
- };
-
enum ScaleBehavior {
Scaled,
Unscaled
@@ -84,15 +79,17 @@ namespace WebCore {
WTF_MAKE_NONCOPYABLE(ImageBuffer); WTF_MAKE_FAST_ALLOCATED;
public:
// Will return a null pointer on allocation failure.
- static PassOwnPtr<ImageBuffer> create(const IntSize& size, float resolutionScale = 1, ColorSpace colorSpace = ColorSpaceDeviceRGB, RenderingMode renderingMode = Unaccelerated, DeferralMode deferralMode = NonDeferred)
+ static PassOwnPtr<ImageBuffer> create(const IntSize& size, float resolutionScale = 1, ColorSpace colorSpace = ColorSpaceDeviceRGB, RenderingMode renderingMode = Unaccelerated)
{
bool success = false;
- OwnPtr<ImageBuffer> buf = adoptPtr(new ImageBuffer(size, resolutionScale, colorSpace, renderingMode, deferralMode, success));
+ OwnPtr<ImageBuffer> buf = adoptPtr(new ImageBuffer(size, resolutionScale, colorSpace, renderingMode, success));
if (!success)
return nullptr;
return buf.release();
}
+ static PassOwnPtr<ImageBuffer> createCompatibleBuffer(const IntSize&, float resolutionScale, ColorSpace, const GraphicsContext*, bool hasAlpha);
+
~ImageBuffer();
// The actual resolution of the backing store
@@ -102,6 +99,9 @@ namespace WebCore {
GraphicsContext* context() const;
PassRefPtr<Image> copyImage(BackingStoreCopy = CopyBackingStore, ScaleBehavior = Scaled) const;
+ // Give hints on the faster copyImage Mode, return DontCopyBackingStore if it supports the DontCopyBackingStore behavior
+ // or return CopyBackingStore if it doesn't.
+ static BackingStoreCopy fastCopyImageMode();
enum CoordinateSystem { LogicalCoordinateSystem, BackingStoreCoordinateSystem };
@@ -128,15 +128,15 @@ namespace WebCore {
// with textures that are RGB or RGBA format, and UNSIGNED_BYTE type.
bool copyToPlatformTexture(GraphicsContext3D&, Platform3DObject, GC3Denum, bool, bool);
- void reportMemoryUsage(MemoryObjectInfo*) const;
-
private:
#if USE(CG)
- NativeImagePtr copyNativeImage(BackingStoreCopy = CopyBackingStore) const;
+ PassNativeImagePtr copyNativeImage(BackingStoreCopy = CopyBackingStore) const;
+ void flushContext() const;
+ void flushContextIfNecessary() const;
#endif
void clip(GraphicsContext*, const FloatRect&) const;
- void draw(GraphicsContext*, ColorSpace, const FloatRect& destRect, const FloatRect& srcRect = FloatRect(0, 0, -1, -1), CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
+ void draw(GraphicsContext*, ColorSpace, const FloatRect& destRect, const FloatRect& srcRect = FloatRect(0, 0, -1, -1), CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNormal, bool useLowQualityScale = false);
void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect);
inline void genericConvertToLuminanceMask();
@@ -155,10 +155,10 @@ namespace WebCore {
// This constructor will place its success into the given out-variable
// so that create() knows when it should return failure.
- ImageBuffer(const IntSize&, float resolutionScale, ColorSpace, RenderingMode, DeferralMode, bool& success);
+ ImageBuffer(const IntSize&, float resolutionScale, ColorSpace, RenderingMode, bool& success);
};
-#if USE(CG) || USE(SKIA)
+#if USE(CG)
String ImageDataToDataURL(const ImageData&, const String& mimeType, const double* quality);
#endif
diff --git a/Source/WebCore/platform/graphics/ImageBufferData.h b/Source/WebCore/platform/graphics/ImageBufferData.h
index bacd24a0a..0f59e0273 100644
--- a/Source/WebCore/platform/graphics/ImageBufferData.h
+++ b/Source/WebCore/platform/graphics/ImageBufferData.h
@@ -29,10 +29,8 @@
#include "ImageBufferDataCairo.h"
#elif PLATFORM(QT)
#include "ImageBufferDataQt.h"
-#elif USE(SKIA)
-#include "ImageBufferDataSkia.h"
-#elif OS(WINCE)
+#elif USE(WINGDI)
#include "ImageBufferDataWince.h"
-#elif PLATFORM(WX)
-#include "ImageBufferDataWx.h"
+#elif PLATFORM(BLACKBERRY)
+#include "ImageBufferDataBlackBerry.h"
#endif
diff --git a/Source/WebCore/platform/graphics/ImageOrientation.cpp b/Source/WebCore/platform/graphics/ImageOrientation.cpp
index dc2b9782b..ab9424c37 100644
--- a/Source/WebCore/platform/graphics/ImageOrientation.cpp
+++ b/Source/WebCore/platform/graphics/ImageOrientation.cpp
@@ -28,6 +28,7 @@
#include "ImageOrientation.h"
#include "AffineTransform.h"
+#include "FloatSize.h"
namespace WebCore {
@@ -35,24 +36,26 @@ AffineTransform ImageOrientation::transformFromDefault(const FloatSize& drawnSiz
{
float w = drawnSize.width();
float h = drawnSize.height();
+
switch (m_orientation) {
case OriginTopLeft:
return AffineTransform();
- case OriginBottomRight:
- return AffineTransform(-1, 0, 0, -1, w, h);
- case OriginLeftBottom:
- return AffineTransform( 0, -1, 1, 0, 0, h);
- case OriginRightTop:
- return AffineTransform( 0, 1, -1, 0, w, 0);
case OriginTopRight:
return AffineTransform(-1, 0, 0, 1, w, 0);
+ case OriginBottomRight:
+ return AffineTransform(-1, 0, 0, -1, w, h);
case OriginBottomLeft:
return AffineTransform( 1, 0, 0, -1, 0, h);
case OriginLeftTop:
return AffineTransform( 0, 1, 1, 0, 0, 0);
+ case OriginRightTop:
+ return AffineTransform( 0, 1, -1, 0, w, 0);
case OriginRightBottom:
return AffineTransform( 0, -1, -1, 0, w, h);
+ case OriginLeftBottom:
+ return AffineTransform( 0, -1, 1, 0, 0, h);
}
+
ASSERT_NOT_REACHED();
return AffineTransform();
}
diff --git a/Source/WebCore/platform/graphics/ImageSource.cpp b/Source/WebCore/platform/graphics/ImageSource.cpp
index 0f46d703c..25c095bf8 100644
--- a/Source/WebCore/platform/graphics/ImageSource.cpp
+++ b/Source/WebCore/platform/graphics/ImageSource.cpp
@@ -33,11 +33,6 @@
#include "ImageOrientation.h"
#include "NotImplemented.h"
-#include "PlatformMemoryInstrumentation.h"
-
-#if PLATFORM(CHROMIUM)
-#include "DeferredImageDecoder.h"
-#endif
namespace WebCore {
@@ -141,7 +136,7 @@ size_t ImageSource::frameCount() const
return m_decoder ? m_decoder->frameCount() : 0;
}
-NativeImagePtr ImageSource::createFrameAtIndex(size_t index)
+PassNativeImagePtr ImageSource::createFrameAtIndex(size_t index)
{
if (!m_decoder)
return 0;
@@ -160,20 +155,16 @@ NativeImagePtr ImageSource::createFrameAtIndex(size_t index)
return buffer->asNewNativeImage();
}
-float ImageSource::frameDurationAtIndex(size_t index)
+float ImageSource::frameDurationAtIndex(size_t index) const
{
if (!m_decoder)
return 0;
- ImageFrame* buffer = m_decoder->frameBufferAtIndex(index);
- if (!buffer || buffer->status() == ImageFrame::FrameEmpty)
- return 0;
-
// Many annoying ads specify a 0 duration to make an image flash as quickly as possible.
// We follow Firefox's behavior and use a duration of 100 ms for any frames that specify
// a duration of <= 10 ms. See <rdar://problem/7689300> and <http://webkit.org/b/36082>
// for more information.
- const float duration = buffer->duration() / 1000.0f;
+ const float duration = m_decoder->frameDurationAtIndex(index) / 1000.0f;
if (duration < 0.011f)
return 0.100f;
return duration;
@@ -184,20 +175,14 @@ ImageOrientation ImageSource::orientationAtIndex(size_t) const
return m_decoder ? m_decoder->orientation() : DefaultImageOrientation;
}
-bool ImageSource::frameHasAlphaAtIndex(size_t index)
+bool ImageSource::frameHasAlphaAtIndex(size_t index) const
{
- if (!m_decoder)
- return true;
- return m_decoder->frameHasAlphaAtIndex(index);
+ return !m_decoder || m_decoder->frameHasAlphaAtIndex(index);
}
-bool ImageSource::frameIsCompleteAtIndex(size_t index)
+bool ImageSource::frameIsCompleteAtIndex(size_t index) const
{
- if (!m_decoder)
- return false;
-
- ImageFrame* buffer = m_decoder->frameBufferAtIndex(index);
- return buffer && buffer->status() == ImageFrame::FrameComplete;
+ return m_decoder && m_decoder->frameIsCompleteAtIndex(index);
}
unsigned ImageSource::frameBytesAtIndex(size_t index) const
@@ -207,10 +192,4 @@ unsigned ImageSource::frameBytesAtIndex(size_t index) const
return m_decoder->frameBytesAtIndex(index);
}
-void ImageSource::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
-{
- MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Image);
- info.addMember(m_decoder);
-}
-
}
diff --git a/Source/WebCore/platform/graphics/ImageSource.h b/Source/WebCore/platform/graphics/ImageSource.h
index 66a8a0a51..cd0d2b7f2 100644
--- a/Source/WebCore/platform/graphics/ImageSource.h
+++ b/Source/WebCore/platform/graphics/ImageSource.h
@@ -48,16 +48,12 @@ class SharedBuffer;
#if USE(CG)
typedef CGImageSourceRef NativeImageDecoderPtr;
-#elif !PLATFORM(CHROMIUM)
+#else
class ImageDecoder;
typedef ImageDecoder* NativeImageDecoderPtr;
#endif
-#if PLATFORM(CHROMIUM)
-class DeferredImageDecoder;
-typedef DeferredImageDecoder NativeImageDecoder;
-typedef DeferredImageDecoder* NativeImageDecoderPtr;
-#elif USE(CG)
+#if USE(CG)
#define NativeImageDecoder ImageDecoder
#else
typedef ImageDecoder NativeImageDecoder;
@@ -149,11 +145,11 @@ public:
// Callers should not call this after calling clear() with a higher index;
// see comments on clear() above.
- NativeImagePtr createFrameAtIndex(size_t);
+ PassNativeImagePtr createFrameAtIndex(size_t);
- float frameDurationAtIndex(size_t);
- bool frameHasAlphaAtIndex(size_t); // Whether or not the frame actually used any alpha.
- bool frameIsCompleteAtIndex(size_t); // Whether or not the frame is completely decoded.
+ float frameDurationAtIndex(size_t) const;
+ bool frameHasAlphaAtIndex(size_t) const; // Whether or not the frame actually used any alpha.
+ bool frameIsCompleteAtIndex(size_t) const; // Whether or not the frame is completely decoded.
ImageOrientation orientationAtIndex(size_t) const; // EXIF image orientation
// Return the number of bytes in the decoded frame. If the frame is not yet
@@ -165,8 +161,6 @@ public:
static void setMaxPixelsPerDecodedImage(unsigned maxPixels) { s_maxPixelsPerDecodedImage = maxPixels; }
#endif
- void reportMemoryUsage(MemoryObjectInfo*) const;
-
private:
NativeImageDecoderPtr m_decoder;
diff --git a/Source/WebCore/platform/graphics/InbandTextTrackPrivate.h b/Source/WebCore/platform/graphics/InbandTextTrackPrivate.h
new file mode 100644
index 000000000..91066eaa3
--- /dev/null
+++ b/Source/WebCore/platform/graphics/InbandTextTrackPrivate.h
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef InbandTextTrackPrivate_h
+#define InbandTextTrackPrivate_h
+
+#if ENABLE(VIDEO_TRACK)
+
+#include "InbandTextTrackPrivateClient.h"
+#include <wtf/Forward.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/RefCounted.h>
+#include <wtf/text/AtomicString.h>
+
+namespace WebCore {
+
+class InbandTextTrackPrivate : public RefCounted<InbandTextTrackPrivate> {
+ WTF_MAKE_NONCOPYABLE(InbandTextTrackPrivate); WTF_MAKE_FAST_ALLOCATED;
+public:
+ static PassRefPtr<InbandTextTrackPrivate> create()
+ {
+ return adoptRef(new InbandTextTrackPrivate());
+ }
+ virtual ~InbandTextTrackPrivate() { }
+
+ void setClient(InbandTextTrackPrivateClient* client) { m_client = client; }
+ InbandTextTrackPrivateClient* client() { return m_client; }
+
+ enum Mode {
+ Disabled,
+ Hidden,
+ Showing
+ };
+ virtual void setMode(Mode mode) { m_mode = mode; };
+ virtual InbandTextTrackPrivate::Mode mode() const { return m_mode; }
+
+ enum Kind {
+ Subtitles,
+ Captions,
+ Descriptions,
+ Chapters,
+ Metadata,
+ Forced,
+ None
+ };
+ virtual Kind kind() const { return Subtitles; }
+ virtual bool isClosedCaptions() const { return false; }
+ virtual bool isSDH() const { return false; }
+ virtual bool containsOnlyForcedSubtitles() const { return false; }
+ virtual bool isMainProgramContent() const { return true; }
+ virtual bool isEasyToRead() const { return false; }
+
+ virtual AtomicString label() const { return emptyAtom; }
+ virtual AtomicString language() const { return emptyAtom; }
+ virtual bool isDefault() const { return false; }
+
+ virtual int textTrackIndex() const { return 0; }
+
+ void willBeRemoved()
+ {
+ if (m_client)
+ m_client->willRemoveTextTrackPrivate(this);
+ }
+
+protected:
+ InbandTextTrackPrivate()
+ : m_client(0)
+ , m_mode(Disabled)
+ {
+ }
+
+private:
+ InbandTextTrackPrivateClient* m_client;
+ Mode m_mode;
+};
+
+} // namespace WebCore
+
+#endif
+#endif
diff --git a/Source/WebCore/platform/graphics/InbandTextTrackPrivateClient.h b/Source/WebCore/platform/graphics/InbandTextTrackPrivateClient.h
new file mode 100644
index 000000000..a0478fff0
--- /dev/null
+++ b/Source/WebCore/platform/graphics/InbandTextTrackPrivateClient.h
@@ -0,0 +1,151 @@
+/*
+ * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef InbandTextTrackPrivateClient_h
+#define InbandTextTrackPrivateClient_h
+
+#include "Color.h"
+#include <wtf/RefCounted.h>
+#include <wtf/text/WTFString.h>
+
+#if ENABLE(VIDEO_TRACK)
+
+namespace WebCore {
+
+class InbandTextTrackPrivate;
+
+class GenericCueData : public RefCounted<GenericCueData> {
+public:
+
+ static PassRefPtr<GenericCueData> create() { return adoptRef(new GenericCueData()); }
+ virtual ~GenericCueData() { }
+
+ double startTime() const { return m_startTime; }
+ void setStartTime(double startTime) { m_startTime = startTime; }
+
+ double endTime() const { return m_endTime; }
+ void setEndTime(double endTime) { m_endTime = endTime; }
+
+ String id() const { return m_id; }
+ void setId(String id) { m_id = id; }
+
+ String content() const { return m_content; }
+ void setContent(String content) { m_content = content; }
+
+ double line() const { return m_line; }
+ void setLine(double line) { m_line = line; }
+
+ double position() const { return m_position; }
+ void setPosition(double position) { m_position = position; }
+
+ double size() const { return m_size; }
+ void setSize(double size) { m_size = size; }
+
+ enum Alignment {
+ None,
+ Start,
+ Middle,
+ End
+ };
+ Alignment align() const { return m_align; }
+ void setAlign(Alignment align) { m_align = align; }
+
+ String fontName() const { return m_fontName; }
+ void setFontName(String fontName) { m_fontName = fontName; }
+
+ double baseFontSize() const { return m_baseFontSize; }
+ void setBaseFontSize(double baseFontSize) { m_baseFontSize = baseFontSize; }
+
+ double relativeFontSize() const { return m_relativeFontSize; }
+ void setRelativeFontSize(double relativeFontSize) { m_relativeFontSize = relativeFontSize; }
+
+ Color foregroundColor() const { return m_foregroundColor; }
+ void setForegroundColor(RGBA32 color) { m_foregroundColor.setRGB(color); }
+
+ Color backgroundColor() const { return m_backgroundColor; }
+ void setBackgroundColor(RGBA32 color) { m_backgroundColor.setRGB(color); }
+
+ Color highlightColor() const { return m_highlightColor; }
+ void setHighlightColor(RGBA32 color) { m_highlightColor.setRGB(color); }
+
+ enum Status {
+ Uninitialized,
+ Partial,
+ Complete,
+ };
+ Status status() { return m_status; }
+ void setStatus(Status status) { m_status = status; }
+
+private:
+ GenericCueData()
+ : m_startTime(0)
+ , m_endTime(0)
+ , m_line(-1)
+ , m_position(-1)
+ , m_size(-1)
+ , m_align(None)
+ , m_baseFontSize(0)
+ , m_relativeFontSize(0)
+ , m_status(Uninitialized)
+ {
+ }
+
+ double m_startTime;
+ double m_endTime;
+ String m_id;
+ String m_content;
+ double m_line;
+ double m_position;
+ double m_size;
+ Alignment m_align;
+ String m_fontName;
+ double m_baseFontSize;
+ double m_relativeFontSize;
+ Color m_foregroundColor;
+ Color m_backgroundColor;
+ Color m_highlightColor;
+ Status m_status;
+};
+
+class WebVTTCueData;
+
+class InbandTextTrackPrivateClient {
+public:
+ virtual ~InbandTextTrackPrivateClient() { }
+
+ virtual void addGenericCue(InbandTextTrackPrivate*, PassRefPtr<GenericCueData>) = 0;
+ virtual void updateGenericCue(InbandTextTrackPrivate*, GenericCueData*) = 0;
+ virtual void removeGenericCue(InbandTextTrackPrivate*, GenericCueData*) = 0;
+
+ virtual void addWebVTTCue(InbandTextTrackPrivate*, PassRefPtr<WebVTTCueData>) = 0;
+ virtual void removeWebVTTCue(InbandTextTrackPrivate*, WebVTTCueData*) = 0;
+
+ virtual void willRemoveTextTrackPrivate(InbandTextTrackPrivate*) = 0;
+};
+
+} // namespace WebCore
+
+#endif
+#endif
diff --git a/Source/WebCore/platform/graphics/IntPoint.h b/Source/WebCore/platform/graphics/IntPoint.h
index 0dd1daab1..619734eb2 100644
--- a/Source/WebCore/platform/graphics/IntPoint.h
+++ b/Source/WebCore/platform/graphics/IntPoint.h
@@ -29,7 +29,7 @@
#include "IntSize.h"
#include <wtf/MathExtras.h>
-#if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM)
+#if USE(CG)
typedef struct CGPoint CGPoint;
#endif
@@ -61,15 +61,6 @@ class IntPoint;
typedef struct _Evas_Point Evas_Point;
#endif
-#if PLATFORM(WX)
-class wxPoint;
-#endif
-
-#if USE(SKIA)
-struct SkPoint;
-struct SkIPoint;
-#endif
-
namespace WebCore {
class IntPoint {
@@ -119,7 +110,7 @@ public:
return IntPoint(m_y, m_x);
}
-#if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM)
+#if USE(CG)
explicit IntPoint(const CGPoint&); // don't do this implicitly since it's lossy
operator CGPoint() const;
#endif
@@ -148,17 +139,6 @@ public:
operator Evas_Point() const;
#endif
-#if PLATFORM(WX)
- IntPoint(const wxPoint&);
- operator wxPoint() const;
-#endif
-
-#if USE(SKIA)
- IntPoint(const SkIPoint&);
- operator SkIPoint() const;
- operator SkPoint() const;
-#endif
-
private:
int m_x, m_y;
};
@@ -210,12 +190,7 @@ inline bool operator!=(const IntPoint& a, const IntPoint& b)
return a.x() != b.x() || a.y() != b.y();
}
-inline IntPoint toPoint(const IntSize& size)
-{
- return IntPoint(size.width(), size.height());
-}
-
-inline IntSize toSize(const IntPoint& a)
+inline IntSize toIntSize(const IntPoint& a)
{
return IntSize(a.x(), a.y());
}
diff --git a/Source/WebCore/platform/graphics/IntRect.h b/Source/WebCore/platform/graphics/IntRect.h
index 70f2cc3d0..0e33bbf95 100644
--- a/Source/WebCore/platform/graphics/IntRect.h
+++ b/Source/WebCore/platform/graphics/IntRect.h
@@ -29,11 +29,11 @@
#include "IntPoint.h"
#include <wtf/Vector.h>
-#if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM)
+#if USE(CG)
typedef struct CGRect CGRect;
#endif
-#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN)) || (PLATFORM(QT) && USE(QTKIT))
+#if PLATFORM(MAC)
#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
typedef struct CGRect NSRect;
#else
@@ -65,15 +65,6 @@ class IntRect;
typedef struct _cairo_rectangle_int cairo_rectangle_int_t;
#endif
-#if PLATFORM(WX)
-class wxRect;
-#endif
-
-#if USE(SKIA)
-struct SkRect;
-struct SkIRect;
-#endif
-
namespace WebCore {
class FloatRect;
@@ -104,17 +95,6 @@ public:
int width() const { return m_size.width(); }
int height() const { return m_size.height(); }
- // FIXME: These methods are here only to ease the transition to sub-pixel layout. They should
- // be removed when we close http://webkit.org/b/60318
- int pixelSnappedX() const { return m_location.x(); }
- int pixelSnappedY() const { return m_location.y(); }
- int pixelSnappedMaxX() const { return x() + width(); }
- int pixelSnappedMaxY() const { return y() + height(); }
- int pixelSnappedWidth() const { return m_size.width(); }
- int pixelSnappedHeight() const { return m_size.height(); }
- IntPoint pixelSnappedLocation() const { return location(); }
- IntSize pixelSnappedSize() const { return size(); }
-
void setX(int x) { m_location.setX(x); }
void setY(int y) { m_location.setY(y); }
void setWidth(int width) { m_size.setWidth(width); }
@@ -194,11 +174,6 @@ public:
IntRect transposedRect() const { return IntRect(m_location.transposedPoint(), m_size.transposedSize()); }
-#if PLATFORM(WX)
- IntRect(const wxRect&);
- operator wxRect() const;
-#endif
-
#if PLATFORM(WIN)
IntRect(const RECT&);
operator RECT() const;
@@ -220,19 +195,11 @@ public:
operator cairo_rectangle_int_t() const;
#endif
-#if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM)
+#if USE(CG)
operator CGRect() const;
#endif
-#if USE(SKIA)
- IntRect(const SkIRect&);
- operator SkRect() const;
- operator SkIRect() const;
-#endif
-
-#if (PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))) \
- && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES) \
- || (PLATFORM(QT) && USE(QTKIT))
+#if (PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES))
operator NSRect() const;
#endif
@@ -272,19 +239,11 @@ inline bool operator!=(const IntRect& a, const IntRect& b)
return a.location() != b.location() || a.size() != b.size();
}
-// FIXME: This method is here only to ease the transition to sub-pixel layout. It should
-// be removed when we close http://webkit.org/b/60318
-inline IntRect enclosingIntRect(const IntRect& rect)
-{
- return rect;
-}
-
-#if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM)
+#if USE(CG)
IntRect enclosingIntRect(const CGRect&);
#endif
-#if (PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)) \
- || (PLATFORM(CHROMIUM) && OS(DARWIN)) || (PLATFORM(QT) && USE(QTKIT))
+#if (PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES))
IntRect enclosingIntRect(const NSRect&);
#endif
diff --git a/Source/WebCore/platform/graphics/IntRectExtent.h b/Source/WebCore/platform/graphics/IntRectExtent.h
new file mode 100644
index 000000000..6517f8ae0
--- /dev/null
+++ b/Source/WebCore/platform/graphics/IntRectExtent.h
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef IntRectExtent_h
+#define IntRectExtent_h
+
+#if ENABLE(CSS_FILTERS)
+
+#include "LayoutRect.h"
+
+namespace WebCore {
+
+class IntRectExtent {
+public:
+ IntRectExtent()
+ : m_top(0)
+ , m_right(0)
+ , m_bottom(0)
+ , m_left(0)
+ {
+ }
+
+ IntRectExtent(int top, int right, int bottom, int left)
+ : m_top(top)
+ , m_right(right)
+ , m_bottom(bottom)
+ , m_left(left)
+ {
+ }
+
+ int top() const { return m_top; }
+ void setTop(int top) { m_top = top; }
+
+ int right() const { return m_right; }
+ void setRight(int right) { m_right = right; }
+
+ int bottom() const { return m_bottom; }
+ void setBottom(int bottom) { m_bottom = bottom; }
+
+ int left() const { return m_left; }
+ void setLeft(int left) { m_left = left; }
+
+ void expandRect(LayoutRect& rect) const
+ {
+ if (isZero())
+ return;
+
+ rect.move(-left(), -top());
+ rect.expand(left() + right(), top() + bottom());
+ }
+
+private:
+ bool isZero() const { return !left() && !right() && !top() && !bottom(); }
+
+ int m_top;
+ int m_right;
+ int m_bottom;
+ int m_left;
+};
+
+inline bool operator==(const IntRectExtent& a, const IntRectExtent& b)
+{
+ return a.top() == b.top()
+ && a.right() == b.right()
+ && a.bottom() == b.bottom()
+ && a.left() == b.left();
+}
+
+inline bool operator!=(const IntRectExtent& a, const IntRectExtent& b)
+{
+ return !(a == b);
+}
+
+inline void operator+=(IntRectExtent& a, const IntRectExtent& b)
+{
+ a.setTop(a.top() + b.top());
+ a.setRight(a.right() + b.right());
+ a.setBottom(a.bottom() + b.bottom());
+ a.setLeft(a.left() + b.left());
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(CSS_FILTERS)
+
+#endif // IntRectExtent_h
diff --git a/Source/WebCore/platform/graphics/IntSize.h b/Source/WebCore/platform/graphics/IntSize.h
index c8a549dd7..b843507ac 100644
--- a/Source/WebCore/platform/graphics/IntSize.h
+++ b/Source/WebCore/platform/graphics/IntSize.h
@@ -26,11 +26,11 @@
#ifndef IntSize_h
#define IntSize_h
-#if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM)
+#if USE(CG)
typedef struct CGSize CGSize;
#endif
-#if PLATFORM(MAC) || (PLATFORM(QT) && USE(QTKIT))
+#if PLATFORM(MAC)
#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
typedef struct CGSize NSSize;
#else
@@ -53,10 +53,6 @@ class IntSize;
}
#endif
-#if PLATFORM(WX)
-class wxSize;
-#endif
-
namespace WebCore {
class IntSize {
@@ -132,12 +128,12 @@ public:
return IntSize(m_height, m_width);
}
-#if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM)
+#if USE(CG)
explicit IntSize(const CGSize&); // don't do this implicitly since it's lossy
operator CGSize() const;
#endif
-#if (PLATFORM(MAC) || (PLATFORM(QT) && USE(QTKIT))) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
+#if PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
explicit IntSize(const NSSize &); // don't do this implicitly since it's lossy
operator NSSize() const;
#endif
@@ -152,11 +148,6 @@ public:
operator QSize() const;
#endif
-#if PLATFORM(WX)
- IntSize(const wxSize&);
- operator wxSize() const;
-#endif
-
#if PLATFORM(BLACKBERRY)
IntSize(const BlackBerry::Platform::IntSize&);
operator BlackBerry::Platform::IntSize() const;
diff --git a/Source/WebCore/platform/graphics/LayoutPoint.h b/Source/WebCore/platform/graphics/LayoutPoint.h
index 647a651be..78ecd922e 100644
--- a/Source/WebCore/platform/graphics/LayoutPoint.h
+++ b/Source/WebCore/platform/graphics/LayoutPoint.h
@@ -35,14 +35,6 @@
#include "LayoutSize.h"
#include <wtf/MathExtras.h>
-#if PLATFORM(QT)
-#include <qglobal.h>
-QT_BEGIN_NAMESPACE
-class QPoint;
-class QPointF;
-QT_END_NAMESPACE
-#endif
-
namespace WebCore {
class LayoutPoint {
@@ -90,11 +82,12 @@ public:
return LayoutPoint(m_y, m_x);
}
-#if PLATFORM(QT)
- explicit LayoutPoint(const QPoint&);
- explicit LayoutPoint(const QPointF&);
- operator QPointF() const;
-#endif
+ LayoutPoint fraction() const
+ {
+ return LayoutPoint(m_x.fraction(), m_y.fraction());
+ }
+
+ operator FloatPoint() const { return FloatPoint(m_x, m_y); }
private:
LayoutUnit m_x, m_y;
diff --git a/Source/WebCore/platform/graphics/LayoutRect.cpp b/Source/WebCore/platform/graphics/LayoutRect.cpp
index ad772825d..42566aacb 100644
--- a/Source/WebCore/platform/graphics/LayoutRect.cpp
+++ b/Source/WebCore/platform/graphics/LayoutRect.cpp
@@ -31,8 +31,6 @@
#include "config.h"
#include "LayoutRect.h"
-#include "FloatRect.h"
-#include "LayoutUnit.h"
#include <algorithm>
using std::max;
diff --git a/Source/WebCore/platform/graphics/LayoutRect.h b/Source/WebCore/platform/graphics/LayoutRect.h
index 9c32e707d..38fb1f018 100644
--- a/Source/WebCore/platform/graphics/LayoutRect.h
+++ b/Source/WebCore/platform/graphics/LayoutRect.h
@@ -31,19 +31,12 @@
#ifndef LayoutRect_h
#define LayoutRect_h
+#include "FloatRect.h"
#include "IntRect.h"
#include "LayoutBoxExtent.h"
#include "LayoutPoint.h"
#include <wtf/Vector.h>
-#if PLATFORM(QT)
-#include <qglobal.h>
-QT_BEGIN_NAMESPACE
-class QRect;
-class QRectF;
-QT_END_NAMESPACE
-#endif
-
namespace WebCore {
class FloatRect;
@@ -107,6 +100,11 @@ public:
}
void expand(LayoutUnit dw, LayoutUnit dh) { m_size.expand(dw, dh); }
void contract(const LayoutSize& size) { m_size -= size; }
+ void contract(const LayoutBoxExtent& box)
+ {
+ m_location.move(box.left(), box.top());
+ m_size.shrink(box.left() + box.right(), box.top() + box.bottom());
+ }
void contract(LayoutUnit dw, LayoutUnit dh) { m_size.expand(-dw, -dh); }
void shiftXEdgeTo(LayoutUnit edge)
@@ -170,12 +168,8 @@ public:
// Return a rect that is slightly smaller than the true max rect to allow pixelSnapping to round up to the nearest IntRect without overflowing.
return LayoutRect(LayoutUnit::nearlyMin() / 2, LayoutUnit::nearlyMin() / 2, LayoutUnit::nearlyMax(), LayoutUnit::nearlyMax());
}
-
-#if PLATFORM(QT)
- explicit LayoutRect(const QRect&);
- explicit LayoutRect(const QRectF&);
- operator QRectF() const;
-#endif
+
+ operator FloatRect() const { return FloatRect(m_location, m_size); }
private:
LayoutPoint m_location;
diff --git a/Source/WebCore/platform/graphics/LayoutSize.h b/Source/WebCore/platform/graphics/LayoutSize.h
index 6ff187e62..2e45f9d26 100644
--- a/Source/WebCore/platform/graphics/LayoutSize.h
+++ b/Source/WebCore/platform/graphics/LayoutSize.h
@@ -35,14 +35,6 @@
#include "IntSize.h"
#include "LayoutUnit.h"
-#if PLATFORM(QT)
-#include <qglobal.h>
-QT_BEGIN_NAMESPACE
-class QSize;
-class QSizeF;
-QT_END_NAMESPACE
-#endif
-
namespace WebCore {
class LayoutPoint;
@@ -72,6 +64,12 @@ public:
m_height += height;
}
+ void shrink(LayoutUnit width, LayoutUnit height)
+ {
+ m_width -= width;
+ m_height -= height;
+ }
+
void scale(float scale)
{
m_width *= scale;
@@ -114,11 +112,7 @@ public:
return LayoutSize(m_height, m_width);
}
-#if PLATFORM(QT)
- explicit LayoutSize(const QSize&);
- explicit LayoutSize(const QSizeF&);
- operator QSizeF() const;
-#endif
+ operator FloatSize() const { return FloatSize(m_width, m_height); }
private:
LayoutUnit m_width, m_height;
diff --git a/Source/WebCore/platform/graphics/MediaPlayer.cpp b/Source/WebCore/platform/graphics/MediaPlayer.cpp
index d643223b0..3b0d63f7e 100644
--- a/Source/WebCore/platform/graphics/MediaPlayer.cpp
+++ b/Source/WebCore/platform/graphics/MediaPlayer.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -44,6 +44,10 @@
#include "InbandTextTrackPrivate.h"
#endif
+#if ENABLE(MEDIA_SOURCE)
+#include "MediaSource.h"
+#endif
+
#if PLATFORM(QT)
#include <QtGlobal>
#endif
@@ -53,12 +57,11 @@
#define PlatformMediaEngineClassName MediaPlayerPrivateGStreamer
#endif
-#if PLATFORM(MAC) || (PLATFORM(QT) && USE(QTKIT))
+#if PLATFORM(MAC)
#include "MediaPlayerPrivateQTKit.h"
#if USE(AVFOUNDATION)
#include "MediaPlayerPrivateAVFoundationObjC.h"
#endif
-#define PlatformMediaEngineClassName MediaPlayerPrivateQTKit
#elif OS(WINCE) && !PLATFORM(QT)
#include "MediaPlayerPrivateWinCE.h"
#define PlatformMediaEngineClassName MediaPlayerPrivate
@@ -73,9 +76,6 @@
#include "MediaPlayerPrivateQt.h"
#define PlatformMediaEngineClassName MediaPlayerPrivateQt
#endif
-#elif PLATFORM(CHROMIUM)
-#include "MediaPlayerPrivateChromium.h"
-#define PlatformMediaEngineClassName MediaPlayerPrivate
#elif PLATFORM(BLACKBERRY)
#include "MediaPlayerPrivateBlackBerry.h"
#define PlatformMediaEngineClassName MediaPlayerPrivate
@@ -92,6 +92,9 @@ public:
NullMediaPlayerPrivate(MediaPlayer*) { }
virtual void load(const String&) { }
+#if ENABLE(MEDIA_SOURCE)
+ virtual void load(const String&, PassRefPtr<MediaSource>) { }
+#endif
virtual void cancelLoad() { }
virtual void prepareToPlay() { }
@@ -110,17 +113,17 @@ public:
virtual void setVisible(bool) { }
- virtual float duration() const { return 0; }
+ virtual double durationDouble() const { return 0; }
- virtual float currentTime() const { return 0; }
- virtual void seek(float) { }
+ virtual double currentTimeDouble() const { return 0; }
+ virtual void seekDouble(double) { }
virtual bool seeking() const { return false; }
- virtual void setRate(float) { }
+ virtual void setRateDouble(double) { }
virtual void setPreservesPitch(bool) { }
virtual bool paused() const { return false; }
- virtual void setVolume(float) { }
+ virtual void setVolumeDouble(double) { }
virtual bool supportsMuting() const { return false; }
virtual void setMuted(bool) { }
@@ -131,7 +134,8 @@ public:
virtual MediaPlayer::NetworkState networkState() const { return MediaPlayer::Empty; }
virtual MediaPlayer::ReadyState readyState() const { return MediaPlayer::HaveNothing; }
- virtual float maxTimeSeekable() const { return 0; }
+ virtual double maxTimeSeekableDouble() const { return 0; }
+ virtual double minTimeSeekable() const { return 0; }
virtual PassRefPtr<TimeRanges> buffered() const { return TimeRanges::create(); }
virtual unsigned totalBytes() const { return 0; }
@@ -152,17 +156,6 @@ public:
virtual bool hasSingleSecurityOrigin() const { return true; }
-#if ENABLE(MEDIA_SOURCE)
- virtual MediaPlayer::AddIdStatus sourceAddId(const String& id, const String& type, const Vector<String>& codecs) { return MediaPlayer::NotSupported; }
- virtual PassRefPtr<TimeRanges> sourceBuffered(const String&) { return TimeRanges::create(); }
- virtual bool sourceRemoveId(const String&) { return false; }
- virtual bool sourceAppend(const String&, const unsigned char*, unsigned) { return false; }
- virtual bool sourceAbort(const String&) { return false; }
- virtual void sourceSetDuration(double) { }
- virtual void sourceEndOfStream(MediaPlayer::EndOfStreamStatus) { }
- virtual bool sourceSetTimestampOffset(const String&, double) { return false; }
-#endif
-
#if ENABLE(ENCRYPTED_MEDIA)
virtual MediaPlayer::MediaKeyException generateKeyRequest(const String&, const unsigned char*, unsigned) OVERRIDE { return MediaPlayer::InvalidPlayerState; }
virtual MediaPlayer::MediaKeyException addKey(const String&, const unsigned char*, unsigned, const unsigned char*, unsigned, const String&) OVERRIDE { return MediaPlayer::InvalidPlayerState; }
@@ -205,11 +198,18 @@ static void addMediaEngine(CreateMediaEnginePlayer, MediaEngineSupportedTypes, M
static MediaPlayerFactory* bestMediaEngineForTypeAndCodecs(const String& type, const String& codecs, const String& keySystem, const KURL&, MediaPlayerFactory* current = 0);
static MediaPlayerFactory* nextMediaEngine(MediaPlayerFactory* current);
-static Vector<MediaPlayerFactory*>& installedMediaEngines()
+enum RequeryEngineOptions { DoNotResetEngines, ResetEngines };
+static Vector<MediaPlayerFactory*>& installedMediaEngines(RequeryEngineOptions requeryFlags = DoNotResetEngines )
{
DEFINE_STATIC_LOCAL(Vector<MediaPlayerFactory*>, installedEngines, ());
static bool enginesQueried = false;
+ if (requeryFlags == ResetEngines) {
+ installedEngines.clear();
+ enginesQueried = false;
+ return installedEngines;
+ }
+
if (!enginesQueried) {
enginesQueried = true;
@@ -223,6 +223,11 @@ static Vector<MediaPlayerFactory*>& installedMediaEngines()
}
#endif
+#if PLATFORM(MAC)
+ if (Settings::isQTKitEnabled())
+ MediaPlayerPrivateQTKit::registerMediaEngine(addMediaEngine);
+#endif
+
#if defined(PlatformMediaEngineClassName)
PlatformMediaEngineClassName::registerMediaEngine(addMediaEngine);
#endif
@@ -285,7 +290,7 @@ static MediaPlayerFactory* bestMediaEngineForTypeAndCodecs(const String& type, c
current = 0;
continue;
}
-#if ENABLE(ENCRYPTED_MEDIA)
+#if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2)
MediaPlayer::SupportsType engineSupport = engines[ndx]->supportsTypeAndCodecs(type, codecs, keySystem, url);
#else
UNUSED_PARAM(keySystem);
@@ -362,6 +367,10 @@ bool MediaPlayer::load(const KURL& url, const ContentType& contentType, const St
m_keySystem = keySystem.lower();
m_contentMIMETypeWasInferredFromExtension = false;
+#if ENABLE(MEDIA_SOURCE)
+ m_mediaSource = 0;
+#endif
+
// If the MIME type is missing or is not meaningful, try to figure it out from the URL.
if (m_contentMIMEType.isEmpty() || m_contentMIMEType == applicationOctetStream() || m_contentMIMEType == textPlain()) {
if (m_url.protocolIsData())
@@ -384,6 +393,20 @@ bool MediaPlayer::load(const KURL& url, const ContentType& contentType, const St
return m_currentMediaEngine;
}
+#if ENABLE(MEDIA_SOURCE)
+bool MediaPlayer::load(const KURL& url, PassRefPtr<MediaSource> mediaSource)
+{
+ m_mediaSource = mediaSource;
+ m_contentMIMEType = "";
+ m_contentTypeCodecs = "";
+ m_url = url;
+ m_keySystem = "";
+ m_contentMIMETypeWasInferredFromExtension = false;
+ loadWithNextMediaEngine(0);
+ return m_currentMediaEngine;
+}
+#endif
+
void MediaPlayer::loadWithNextMediaEngine(MediaPlayerFactory* current)
{
MediaPlayerFactory* engine = 0;
@@ -415,9 +438,14 @@ void MediaPlayer::loadWithNextMediaEngine(MediaPlayerFactory* current)
m_private->prepareForRendering();
}
- if (m_private)
+ if (m_private) {
+#if ENABLE(MEDIA_SOURCE)
+ if (m_mediaSource)
+ m_private->load(m_url.string(), m_mediaSource);
+ else
+#endif
m_private->load(m_url.string());
- else {
+ } else {
m_private = createNullMediaPlayer(this);
if (m_mediaPlayerClient) {
m_mediaPlayerClient->mediaPlayerEngineUpdated(this);
@@ -467,49 +495,6 @@ void MediaPlayer::pause()
m_private->pause();
}
-#if ENABLE(MEDIA_SOURCE)
-
-MediaPlayer::AddIdStatus MediaPlayer::sourceAddId(const String& id, const String& type, const Vector<String>& codecs)
-{
- return m_private->sourceAddId(id, type, codecs);
-}
-
-PassRefPtr<TimeRanges> MediaPlayer::sourceBuffered(const String& id)
-{
- return m_private->sourceBuffered(id);
-}
-
-bool MediaPlayer::sourceRemoveId(const String& id)
-{
- return m_private->sourceRemoveId(id);
-}
-
-bool MediaPlayer::sourceAppend(const String& id, const unsigned char* data, unsigned length)
-{
- return m_private->sourceAppend(id, data, length);
-}
-
-bool MediaPlayer::sourceAbort(const String& id)
-{
- return m_private->sourceAbort(id);
-}
-
-void MediaPlayer::sourceSetDuration(double duration)
-{
- m_private->sourceSetDuration(duration);
-}
-
-void MediaPlayer::sourceEndOfStream(MediaPlayer::EndOfStreamStatus status)
-{
- return m_private->sourceEndOfStream(status);
-}
-
-bool MediaPlayer::sourceSetTimestampOffset(const String& id, double offset)
-{
- return m_private->sourceSetTimestampOffset(id, offset);
-}
-#endif
-
#if ENABLE(ENCRYPTED_MEDIA)
MediaPlayer::MediaKeyException MediaPlayer::generateKeyRequest(const String& keySystem, const unsigned char* initData, unsigned initDataLength)
{
@@ -527,14 +512,14 @@ MediaPlayer::MediaKeyException MediaPlayer::cancelKeyRequest(const String& keySy
}
#endif
-float MediaPlayer::duration() const
+double MediaPlayer::duration() const
{
- return m_private->duration();
+ return m_private->durationDouble();
}
-float MediaPlayer::startTime() const
+double MediaPlayer::startTime() const
{
- return m_private->startTime();
+ return m_private->startTimeDouble();
}
double MediaPlayer::initialTime() const
@@ -542,14 +527,14 @@ double MediaPlayer::initialTime() const
return m_private->initialTime();
}
-float MediaPlayer::currentTime() const
+double MediaPlayer::currentTime() const
{
- return m_private->currentTime();
+ return m_private->currentTimeDouble();
}
-void MediaPlayer::seek(float time)
+void MediaPlayer::seek(double time)
{
- m_private->seek(time);
+ m_private->seekDouble(time);
}
bool MediaPlayer::paused() const
@@ -622,17 +607,17 @@ MediaPlayer::ReadyState MediaPlayer::readyState()
return m_private->readyState();
}
-float MediaPlayer::volume() const
+double MediaPlayer::volume() const
{
return m_volume;
}
-void MediaPlayer::setVolume(float volume)
+void MediaPlayer::setVolume(double volume)
{
m_volume = volume;
if (m_private->supportsMuting() || !m_muted)
- m_private->setVolume(volume);
+ m_private->setVolumeDouble(volume);
}
bool MediaPlayer::muted() const
@@ -660,15 +645,15 @@ void MediaPlayer::setClosedCaptionsVisible(bool closedCaptionsVisible)
m_private->setClosedCaptionsVisible(closedCaptionsVisible);
}
-float MediaPlayer::rate() const
+double MediaPlayer::rate() const
{
return m_rate;
}
-void MediaPlayer::setRate(float rate)
+void MediaPlayer::setRate(double rate)
{
m_rate = rate;
- m_private->setRate(rate);
+ m_private->setRateDouble(rate);
}
bool MediaPlayer::preservesPitch() const
@@ -692,9 +677,14 @@ PassRefPtr<TimeRanges> MediaPlayer::seekable()
return m_private->seekable();
}
-float MediaPlayer::maxTimeSeekable()
+double MediaPlayer::maxTimeSeekable()
{
- return m_private->maxTimeSeekable();
+ return m_private->maxTimeSeekableDouble();
+}
+
+double MediaPlayer::minTimeSeekable()
+{
+ return m_private->minTimeSeekable();
}
bool MediaPlayer::didLoadingProgress()
@@ -740,6 +730,11 @@ void MediaPlayer::paintCurrentFrameInContext(GraphicsContext* p, const IntRect&
m_private->paintCurrentFrameInContext(p, r);
}
+bool MediaPlayer::copyVideoTextureToPlatformTexture(GraphicsContext3D* context, Platform3DObject texture, GC3Dint level, GC3Denum type, GC3Denum internalFormat, bool premultiplyAlpha, bool flipY)
+{
+ return m_private->copyVideoTextureToPlatformTexture(context, texture, level, type, internalFormat, premultiplyAlpha, flipY);
+}
+
MediaPlayer::SupportsType MediaPlayer::supportsType(const ContentType& contentType, const String& keySystem, const KURL& url, const MediaPlayerSupportsTypeClient* client)
{
String type = contentType.type().lower();
@@ -774,7 +769,7 @@ MediaPlayer::SupportsType MediaPlayer::supportsType(const ContentType& contentTy
UNUSED_PARAM(client);
#endif
-#if ENABLE(ENCRYPTED_MEDIA)
+#if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2)
return engine->supportsTypeAndCodecs(type, typeCodecs, system, url);
#else
ASSERT(system.isEmpty());
@@ -862,9 +857,9 @@ MediaPlayer::MovieLoadType MediaPlayer::movieLoadType() const
return m_private->movieLoadType();
}
-float MediaPlayer::mediaTimeForTimeValue(float timeValue) const
+double MediaPlayer::mediaTimeForTimeValue(double timeValue) const
{
- return m_private->mediaTimeForTimeValue(timeValue);
+ return m_private->mediaTimeForTimeValueDouble(timeValue);
}
double MediaPlayer::maximumDurationToCacheMediaTime() const
@@ -907,7 +902,7 @@ void MediaPlayer::getSitesInMediaCache(Vector<String>& sites)
continue;
Vector<String> engineSites;
engines[i]->getSitesInMediaCache(engineSites);
- sites.append(engineSites);
+ sites.appendVector(engineSites);
}
}
@@ -937,21 +932,6 @@ void MediaPlayer::setPrivateBrowsingMode(bool privateBrowsingMode)
m_private->setPrivateBrowsingMode(m_privateBrowsing);
}
-#if ENABLE(MEDIA_SOURCE)
-void MediaPlayer::sourceOpened()
-{
- if (m_mediaPlayerClient)
- m_mediaPlayerClient->mediaPlayerSourceOpened();
-}
-
-String MediaPlayer::sourceURL() const
-{
- if (m_mediaPlayerClient)
- return m_mediaPlayerClient->mediaPlayerSourceURL();
- return String();
-}
-#endif
-
// Client callbacks.
void MediaPlayer::networkStateChanged()
{
@@ -975,7 +955,7 @@ void MediaPlayer::readyStateChanged()
m_mediaPlayerClient->mediaPlayerReadyStateChanged(this);
}
-void MediaPlayer::volumeChanged(float newVolume)
+void MediaPlayer::volumeChanged(double newVolume)
{
m_volume = newVolume;
if (m_mediaPlayerClient)
@@ -1057,10 +1037,10 @@ void MediaPlayer::keyError(const String& keySystem, const String& sessionId, Med
m_mediaPlayerClient->mediaPlayerKeyError(this, keySystem, sessionId, errorCode, systemCode);
}
-void MediaPlayer::keyMessage(const String& keySystem, const String& sessionId, const unsigned char* message, unsigned messageLength)
+void MediaPlayer::keyMessage(const String& keySystem, const String& sessionId, const unsigned char* message, unsigned messageLength, const KURL& defaultURL)
{
if (m_mediaPlayerClient)
- m_mediaPlayerClient->mediaPlayerKeyMessage(this, keySystem, sessionId, message, messageLength);
+ m_mediaPlayerClient->mediaPlayerKeyMessage(this, keySystem, sessionId, message, messageLength, defaultURL);
}
bool MediaPlayer::keyNeeded(const String& keySystem, const String& sessionId, const unsigned char* initData, unsigned initDataLength)
@@ -1071,6 +1051,15 @@ bool MediaPlayer::keyNeeded(const String& keySystem, const String& sessionId, co
}
#endif
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+bool MediaPlayer::keyNeeded(Uint8Array* initData)
+{
+ if (m_mediaPlayerClient)
+ return m_mediaPlayerClient->mediaPlayerKeyNeeded(this, initData);
+ return false;
+}
+#endif
+
String MediaPlayer::referrer() const
{
if (!m_mediaPlayerClient)
@@ -1114,17 +1103,108 @@ CachedResourceLoader* MediaPlayer::cachedResourceLoader()
}
#if ENABLE(VIDEO_TRACK)
-void MediaPlayer::getTextTracks(Vector<RefPtr<InbandTextTrackPrivate> >& tracks)
+void MediaPlayer::addAudioTrack(PassRefPtr<AudioTrackPrivate> track)
+{
+ if (!m_mediaPlayerClient)
+ return;
+
+ m_mediaPlayerClient->mediaPlayerDidAddAudioTrack(track);
+}
+
+void MediaPlayer::removeAudioTrack(PassRefPtr<AudioTrackPrivate> track)
+{
+ if (!m_mediaPlayerClient)
+ return;
+
+ m_mediaPlayerClient->mediaPlayerDidRemoveAudioTrack(track);
+}
+
+void MediaPlayer::addTextTrack(PassRefPtr<InbandTextTrackPrivate> track)
{
- m_private->getTextTracks(tracks);
+ if (!m_mediaPlayerClient)
+ return;
+
+ m_mediaPlayerClient->mediaPlayerDidAddTextTrack(track);
+}
+
+void MediaPlayer::removeTextTrack(PassRefPtr<InbandTextTrackPrivate> track)
+{
+ if (!m_mediaPlayerClient)
+ return;
+
+ m_mediaPlayerClient->mediaPlayerDidRemoveTextTrack(track);
}
-void MediaPlayer::setTextTrackClient(TextTrackClient* client)
+void MediaPlayer::addVideoTrack(PassRefPtr<VideoTrackPrivate> track)
{
- m_private->setTextTrackClient(client);
+ if (!m_mediaPlayerClient)
+ return;
+
+ m_mediaPlayerClient->mediaPlayerDidAddVideoTrack(track);
+}
+
+void MediaPlayer::removeVideoTrack(PassRefPtr<VideoTrackPrivate> track)
+{
+ if (!m_mediaPlayerClient)
+ return;
+
+ m_mediaPlayerClient->mediaPlayerDidRemoveVideoTrack(track);
+}
+
+bool MediaPlayer::requiresTextTrackRepresentation() const
+{
+ return m_private->requiresTextTrackRepresentation();
+}
+
+void MediaPlayer::setTextTrackRepresentation(TextTrackRepresentation* representation)
+{
+ m_private->setTextTrackRepresentation(representation);
+}
+#endif // ENABLE(VIDEO_TRACK)
+
+#if USE(PLATFORM_TEXT_TRACK_MENU)
+bool MediaPlayer::implementsTextTrackControls() const
+{
+ return m_private->implementsTextTrackControls();
+}
+
+PassRefPtr<PlatformTextTrackMenuInterface> MediaPlayer::textTrackMenu()
+{
+ return m_private->textTrackMenu();
+}
+#endif // USE(PLATFORM_TEXT_TRACK_MENU)
+
+void MediaPlayer::resetMediaEngines()
+{
+ installedMediaEngines(ResetEngines);
+}
+
+#if USE(GSTREAMER)
+void MediaPlayer::simulateAudioInterruption()
+{
+ if (!m_private)
+ return;
+
+ m_private->simulateAudioInterruption();
}
#endif
+String MediaPlayer::languageOfPrimaryAudioTrack() const
+{
+ if (!m_private)
+ return emptyString();
+
+ return m_private->languageOfPrimaryAudioTrack();
+}
+
+size_t MediaPlayer::extraMemoryCost() const
+{
+ if (!m_private)
+ return 0;
+
+ return m_private->extraMemoryCost();
+}
+
}
#endif
diff --git a/Source/WebCore/platform/graphics/MediaPlayer.h b/Source/WebCore/platform/graphics/MediaPlayer.h
index 3dd00f561..92734cab5 100644
--- a/Source/WebCore/platform/graphics/MediaPlayer.h
+++ b/Source/WebCore/platform/graphics/MediaPlayer.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,15 +27,18 @@
#define MediaPlayer_h
#if ENABLE(VIDEO)
-
+#include "GraphicsTypes3D.h"
#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
#include "MediaPlayerProxy.h"
#endif
+#include "AudioTrackPrivate.h"
+#include "InbandTextTrackPrivate.h"
#include "IntRect.h"
#include "KURL.h"
#include "LayoutRect.h"
#include "Timer.h"
+#include "VideoTrackPrivate.h"
#include <wtf/Forward.h>
#include <wtf/HashSet.h>
#include <wtf/OwnPtr.h>
@@ -47,6 +50,10 @@
#include "PlatformLayer.h"
#endif
+#if USE(PLATFORM_TEXT_TRACK_MENU)
+#include "PlatformTextTrackMenu.h"
+#endif
+
OBJC_CLASS AVPlayer;
OBJC_CLASS QTMovie;
@@ -59,10 +66,11 @@ namespace WebCore {
class AudioSourceProvider;
class Document;
class GStreamerGWorld;
-class InbandTextTrackPrivate;
class MediaPlayerPrivateInterface;
+#if ENABLE(MEDIA_SOURCE)
class MediaSource;
-class TextTrackClient;
+#endif
+class TextTrackRepresentation;
// Structure that will hold every native
// types supported by the current media player.
@@ -99,6 +107,7 @@ class CachedResourceLoader;
class ContentType;
class FrameView;
class GraphicsContext;
+class GraphicsContext3D;
class IntRect;
class IntSize;
class MediaPlayer;
@@ -180,19 +189,18 @@ public:
virtual GraphicsDeviceAdapter* mediaPlayerGraphicsDeviceAdapter(const MediaPlayer*) const { return 0; }
#endif
-#if ENABLE(MEDIA_SOURCE)
- virtual void mediaPlayerSourceOpened() { }
- virtual String mediaPlayerSourceURL() const { return "x-media-source-unsupported:"; }
-#endif
-
#if ENABLE(ENCRYPTED_MEDIA)
enum MediaKeyErrorCode { UnknownError = 1, ClientError, ServiceError, OutputError, HardwareChangeError, DomainError };
- virtual void mediaPlayerKeyAdded(MediaPlayer*, const String&, const String&) { }
- virtual void mediaPlayerKeyError(MediaPlayer*, const String&, const String&, MediaKeyErrorCode, unsigned short) { }
- virtual void mediaPlayerKeyMessage(MediaPlayer*, const String&, const String&, const unsigned char*, unsigned) { }
- virtual bool mediaPlayerKeyNeeded(MediaPlayer*, const String&, const String&, const unsigned char*, unsigned) { return false; }
+ virtual void mediaPlayerKeyAdded(MediaPlayer*, const String& /* keySystem */, const String& /* sessionId */) { }
+ virtual void mediaPlayerKeyError(MediaPlayer*, const String& /* keySystem */, const String& /* sessionId */, MediaKeyErrorCode, unsigned short /* systemCode */) { }
+ virtual void mediaPlayerKeyMessage(MediaPlayer*, const String& /* keySystem */, const String& /* sessionId */, const unsigned char* /* message */, unsigned /* messageLength */, const KURL& /* defaultURL */) { }
+ virtual bool mediaPlayerKeyNeeded(MediaPlayer*, const String& /* keySystem */, const String& /* sessionId */, const unsigned char* /* initData */, unsigned /* initDataLength */) { return false; }
#endif
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+ virtual bool mediaPlayerKeyNeeded(MediaPlayer*, Uint8Array*) { return false; }
+#endif
+
virtual String mediaPlayerReferrer() const { return String(); }
virtual String mediaPlayerUserAgent() const { return String(); }
virtual CORSMode mediaPlayerCORSMode() const { return Unspecified; }
@@ -210,6 +218,17 @@ public:
virtual HostWindow* mediaPlayerHostWindow() { return 0; }
virtual IntRect mediaPlayerWindowClipRect() { return IntRect(); }
virtual CachedResourceLoader* mediaPlayerCachedResourceLoader() { return 0; }
+
+#if ENABLE(VIDEO_TRACK)
+ virtual void mediaPlayerDidAddAudioTrack(PassRefPtr<AudioTrackPrivate>) { }
+ virtual void mediaPlayerDidAddTextTrack(PassRefPtr<InbandTextTrackPrivate>) { }
+ virtual void mediaPlayerDidAddVideoTrack(PassRefPtr<VideoTrackPrivate>) { }
+ virtual void mediaPlayerDidRemoveAudioTrack(PassRefPtr<AudioTrackPrivate>) { }
+ virtual void mediaPlayerDidRemoveTextTrack(PassRefPtr<InbandTextTrackPrivate>) { }
+ virtual void mediaPlayerDidRemoveVideoTrack(PassRefPtr<VideoTrackPrivate>) { }
+
+ virtual void textTrackRepresentationBoundsChanged(const IntRect&) { }
+#endif
};
class MediaPlayerSupportsTypeClient {
@@ -259,6 +278,9 @@ public:
void setSize(const IntSize& size);
bool load(const KURL&, const ContentType&, const String& keySystem);
+#if ENABLE(MEDIA_SOURCE)
+ bool load(const KURL&, PassRefPtr<MediaSource>);
+#endif
void cancelLoad();
bool visible() const;
@@ -268,19 +290,6 @@ public:
void play();
void pause();
-#if ENABLE(MEDIA_SOURCE)
- enum AddIdStatus { Ok, NotSupported, ReachedIdLimit };
- AddIdStatus sourceAddId(const String& id, const String& type, const Vector<String>& codecs);
- bool sourceRemoveId(const String& id);
- PassRefPtr<TimeRanges> sourceBuffered(const String& id);
- bool sourceAppend(const String& id, const unsigned char* data, unsigned length);
- void sourceSetDuration(double);
- bool sourceAbort(const String& id);
- enum EndOfStreamStatus { EosNoError, EosNetworkError, EosDecodeError };
- void sourceEndOfStream(EndOfStreamStatus);
- bool sourceSetTimestampOffset(const String& id, double offset);
-#endif
-
#if ENABLE(ENCRYPTED_MEDIA)
// Represents synchronous exceptions that can be thrown from the Encrypted Media methods.
// This is different from the asynchronous MediaKeyError.
@@ -294,29 +303,30 @@ public:
bool paused() const;
bool seeking() const;
- static float invalidTime() { return -1.0f;}
- float duration() const;
- float currentTime() const;
- void seek(float time);
+ static double invalidTime() { return -1.0;}
+ double duration() const;
+ double currentTime() const;
+ void seek(double time);
- float startTime() const;
+ double startTime() const;
double initialTime() const;
- float rate() const;
- void setRate(float);
+ double rate() const;
+ void setRate(double);
bool preservesPitch() const;
void setPreservesPitch(bool);
PassRefPtr<TimeRanges> buffered();
PassRefPtr<TimeRanges> seekable();
- float maxTimeSeekable();
+ double minTimeSeekable();
+ double maxTimeSeekable();
bool didLoadingProgress();
- float volume() const;
- void setVolume(float);
+ double volume() const;
+ void setVolume(double);
bool muted() const;
void setMuted(bool);
@@ -330,6 +340,21 @@ public:
void paint(GraphicsContext*, const IntRect&);
void paintCurrentFrameInContext(GraphicsContext*, const IntRect&);
+ // copyVideoTextureToPlatformTexture() is used to do the GPU-GPU textures copy without a readback to system memory.
+ // The first five parameters denote the corresponding GraphicsContext, destination texture, requested level, requested type and the required internalFormat for destination texture.
+ // The last two parameters premultiplyAlpha and flipY denote whether addtional premultiplyAlpha and flip operation are required during the copy.
+ // It returns true on success and false on failure.
+
+ // In the GPU-GPU textures copy, the source texture(Video texture) should have valid target, internalFormat and size, etc.
+ // The destination texture may need to be resized to to the dimensions of the source texture or re-defined to the required internalFormat.
+ // The current restrictions require that format shoud be RGB or RGBA, type should be UNSIGNED_BYTE and level should be 0. It may be lifted in the future.
+
+ // Each platform port can have its own implementation on this function. The default implementation for it is a single "return false" in MediaPlayerPrivate.h.
+ // In chromium, the implementation is based on GL_CHROMIUM_copy_texture extension which is documented at
+ // http://src.chromium.org/viewvc/chrome/trunk/src/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_copy_texture.txt and implemented at
+ // http://src.chromium.org/viewvc/chrome/trunk/src/gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc via shaders.
+ bool copyVideoTextureToPlatformTexture(GraphicsContext3D*, Platform3DObject texture, GC3Dint level, GC3Denum type, GC3Denum internalFormat, bool premultiplyAlpha, bool flipY);
+
enum NetworkState { Empty, Idle, Loading, Loaded, FormatError, NetworkError, DecodeError };
NetworkState networkState();
@@ -345,7 +370,7 @@ public:
void networkStateChanged();
void readyStateChanged();
- void volumeChanged(float);
+ void volumeChanged(double);
void muteChanged(bool);
void timeChanged();
void sizeChanged();
@@ -358,6 +383,7 @@ public:
void repaint();
MediaPlayerClient* mediaPlayerClient() const { return m_mediaPlayerClient; }
+ void clearMediaPlayerClient() { m_mediaPlayerClient = 0; }
bool hasAvailableVideoFrame() const;
void prepareForRendering();
@@ -395,7 +421,7 @@ public:
bool didPassCORSAccessCheck() const;
- float mediaTimeForTimeValue(float) const;
+ double mediaTimeForTimeValue(double) const;
double maximumDurationToCacheMediaTime() const;
@@ -410,18 +436,17 @@ public:
AudioSourceProvider* audioSourceProvider();
#endif
-#if ENABLE(MEDIA_SOURCE)
- void sourceOpened();
- String sourceURL() const;
-#endif
-
#if ENABLE(ENCRYPTED_MEDIA)
void keyAdded(const String& keySystem, const String& sessionId);
void keyError(const String& keySystem, const String& sessionId, MediaPlayerClient::MediaKeyErrorCode, unsigned short systemCode);
- void keyMessage(const String& keySystem, const String& sessionId, const unsigned char* message, unsigned messageLength);
+ void keyMessage(const String& keySystem, const String& sessionId, const unsigned char* message, unsigned messageLength, const KURL& defaultURL);
bool keyNeeded(const String& keySystem, const String& sessionId, const unsigned char* initData, unsigned initDataLength);
#endif
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+ bool keyNeeded(Uint8Array* initData);
+#endif
+
String referrer() const;
String userAgent() const;
@@ -430,10 +455,32 @@ public:
CachedResourceLoader* cachedResourceLoader();
#if ENABLE(VIDEO_TRACK)
- void getTextTracks(Vector<RefPtr<InbandTextTrackPrivate> >&);
- void setTextTrackClient(TextTrackClient*);
+ void addAudioTrack(PassRefPtr<AudioTrackPrivate>);
+ void addTextTrack(PassRefPtr<InbandTextTrackPrivate>);
+ void addVideoTrack(PassRefPtr<VideoTrackPrivate>);
+ void removeAudioTrack(PassRefPtr<AudioTrackPrivate>);
+ void removeTextTrack(PassRefPtr<InbandTextTrackPrivate>);
+ void removeVideoTrack(PassRefPtr<VideoTrackPrivate>);
+
+ bool requiresTextTrackRepresentation() const;
+ void setTextTrackRepresentation(TextTrackRepresentation*);
+#endif
+
+ static void resetMediaEngines();
+
+#if USE(PLATFORM_TEXT_TRACK_MENU)
+ bool implementsTextTrackControls() const;
+ PassRefPtr<PlatformTextTrackMenuInterface> textTrackMenu();
+#endif
+
+#if USE(GSTREAMER)
+ void simulateAudioInterruption();
#endif
+ String languageOfPrimaryAudioTrack() const;
+
+ size_t extraMemoryCost() const;
+
private:
MediaPlayer(MediaPlayerClient*);
void loadWithNextMediaEngine(MediaPlayerFactory*);
@@ -453,8 +500,8 @@ private:
IntSize m_size;
Preload m_preload;
bool m_visible;
- float m_rate;
- float m_volume;
+ double m_rate;
+ double m_volume;
bool m_muted;
bool m_preservesPitch;
bool m_privateBrowsing;
@@ -463,11 +510,15 @@ private:
#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
WebMediaPlayerProxy* m_playerProxy; // not owned or used, passed to m_private
#endif
+
+#if ENABLE(MEDIA_SOURCE)
+ RefPtr<MediaSource> m_mediaSource;
+#endif
};
typedef PassOwnPtr<MediaPlayerPrivateInterface> (*CreateMediaEnginePlayer)(MediaPlayer*);
typedef void (*MediaEngineSupportedTypes)(HashSet<String>& types);
-#if ENABLE(ENCRYPTED_MEDIA)
+#if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2)
typedef MediaPlayer::SupportsType (*MediaEngineSupportsType)(const String& type, const String& codecs, const String& keySystem, const KURL& url);
#else
typedef MediaPlayer::SupportsType (*MediaEngineSupportsType)(const String& type, const String& codecs, const KURL& url);
diff --git a/Source/WebCore/platform/graphics/MediaPlayerPrivate.h b/Source/WebCore/platform/graphics/MediaPlayerPrivate.h
index 30e80142f..cbe80e6c2 100644
--- a/Source/WebCore/platform/graphics/MediaPlayerPrivate.h
+++ b/Source/WebCore/platform/graphics/MediaPlayerPrivate.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -36,6 +36,7 @@ namespace WebCore {
class IntRect;
class IntSize;
+class PlatformTextTrack;
class MediaPlayerPrivateInterface {
WTF_MAKE_NONCOPYABLE(MediaPlayerPrivateInterface); WTF_MAKE_FAST_ALLOCATED;
@@ -44,6 +45,9 @@ public:
virtual ~MediaPlayerPrivateInterface() { }
virtual void load(const String& url) = 0;
+#if ENABLE(MEDIA_SOURCE)
+ virtual void load(const String& url, PassRefPtr<MediaSource>) = 0;
+#endif
virtual void cancelLoad() = 0;
virtual void prepareToPlay() { }
@@ -66,22 +70,31 @@ public:
virtual void setVisible(bool) = 0;
- virtual float duration() const = 0;
+ virtual float duration() const { return 0; }
+ virtual double durationDouble() const { return duration(); }
+
+ virtual float currentTime() const { return 0; }
+ virtual double currentTimeDouble() const { return currentTime(); }
+
+ virtual void seek(float) { }
+ virtual void seekDouble(double time) { seek(time); }
- virtual float currentTime() const = 0;
- virtual void seek(float time) = 0;
virtual bool seeking() const = 0;
virtual float startTime() const { return 0; }
+ virtual double startTimeDouble() const { return startTime(); }
virtual double initialTime() const { return 0; }
- virtual void setRate(float) = 0;
+ virtual void setRate(float) { }
+ virtual void setRateDouble(double rate) { setRate(rate); }
+
virtual void setPreservesPitch(bool) { }
virtual bool paused() const = 0;
- virtual void setVolume(float) = 0;
+ virtual void setVolume(float) { }
+ virtual void setVolumeDouble(double volume) { return setVolume(volume); }
virtual bool supportsMuting() const { return false; }
virtual void setMuted(bool) { }
@@ -92,8 +105,10 @@ public:
virtual MediaPlayer::NetworkState networkState() const = 0;
virtual MediaPlayer::ReadyState readyState() const = 0;
- virtual PassRefPtr<TimeRanges> seekable() const { return maxTimeSeekable() ? TimeRanges::create(0, maxTimeSeekable()) : TimeRanges::create(); }
- virtual float maxTimeSeekable() const = 0;
+ virtual PassRefPtr<TimeRanges> seekable() const { return maxTimeSeekableDouble() ? TimeRanges::create(minTimeSeekable(), maxTimeSeekableDouble()) : TimeRanges::create(); }
+ virtual float maxTimeSeekable() const { return 0; }
+ virtual double maxTimeSeekableDouble() const { return maxTimeSeekable(); }
+ virtual double minTimeSeekable() const { return 0; }
virtual PassRefPtr<TimeRanges> buffered() const = 0;
virtual bool didLoadingProgress() const = 0;
@@ -103,6 +118,7 @@ public:
virtual void paint(GraphicsContext*, const IntRect&) = 0;
virtual void paintCurrentFrameInContext(GraphicsContext* c, const IntRect& r) { paint(c, r); }
+ virtual bool copyVideoTextureToPlatformTexture(GraphicsContext3D*, Platform3DObject, GC3Dint, GC3Denum, GC3Denum, bool, bool) { return false; }
virtual void setPreload(MediaPlayer::Preload) { }
@@ -144,6 +160,7 @@ public:
// Time value in the movie's time scale. It is only necessary to override this if the media
// engine uses rational numbers to represent media time.
virtual float mediaTimeForTimeValue(float timeValue) const { return timeValue; }
+ virtual double mediaTimeForTimeValueDouble(double timeValue) const { return timeValue; }
// Overide this if it is safe for HTMLMediaElement to cache movie time and report
// 'currentTime' as [cached time + elapsed wall time]. Returns the maximum wall time
@@ -167,17 +184,6 @@ public:
virtual AudioSourceProvider* audioSourceProvider() { return 0; }
#endif
-#if ENABLE(MEDIA_SOURCE)
- virtual MediaPlayer::AddIdStatus sourceAddId(const String& id, const String& type, const Vector<String>& codecs) { return MediaPlayer::NotSupported; }
- virtual PassRefPtr<TimeRanges> sourceBuffered(const String& id) { return TimeRanges::create(); }
- virtual bool sourceRemoveId(const String& id) { return false; }
- virtual bool sourceAppend(const String& id, const unsigned char* data, unsigned length) { return false; }
- virtual bool sourceAbort(const String& id) { return false; }
- virtual void sourceSetDuration(double) { }
- virtual void sourceEndOfStream(MediaPlayer::EndOfStreamStatus) { }
- virtual bool sourceSetTimestampOffset(const String& id, double offset) { return false; }
-#endif
-
#if ENABLE(ENCRYPTED_MEDIA)
virtual MediaPlayer::MediaKeyException addKey(const String&, const unsigned char*, unsigned, const unsigned char*, unsigned, const String&) { return MediaPlayer::KeySystemNotSupported; }
virtual MediaPlayer::MediaKeyException generateKeyRequest(const String&, const unsigned char*, unsigned) { return MediaPlayer::KeySystemNotSupported; }
@@ -185,9 +191,22 @@ public:
#endif
#if ENABLE(VIDEO_TRACK)
- virtual void getTextTracks(Vector<RefPtr<InbandTextTrackPrivate> >&) { }
- virtual void setTextTrackClient(TextTrackClient*) { }
+ virtual bool requiresTextTrackRepresentation() const { return false; }
+ virtual void setTextTrackRepresentation(TextTrackRepresentation*) { }
+#endif
+
+#if USE(PLATFORM_TEXT_TRACK_MENU)
+ virtual bool implementsTextTrackControls() const { return false; }
+ virtual PassRefPtr<PlatformTextTrackMenuInterface> textTrackMenu() { return 0; }
#endif
+
+#if USE(GSTREAMER)
+ virtual void simulateAudioInterruption() { }
+#endif
+
+ virtual String languageOfPrimaryAudioTrack() const { return emptyString(); }
+
+ virtual size_t extraMemoryCost() const { return 0; }
};
}
diff --git a/Source/WebCore/platform/graphics/blackberry/skia/ImageBufferDataSkia.h b/Source/WebCore/platform/graphics/MediaSourcePrivate.h
index d2246c09d..2b1074fbc 100644
--- a/Source/WebCore/platform/graphics/blackberry/skia/ImageBufferDataSkia.h
+++ b/Source/WebCore/platform/graphics/MediaSourcePrivate.h
@@ -1,6 +1,5 @@
/*
- * Copyright (c) 2008, 2009, Google Inc. All rights reserved.
- * Copyright (c) 2011, Research In Motion. All rights reserved.
+ * Copyright (C) 2013 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -28,29 +27,33 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef MediaSourcePrivate_h
+#define MediaSourcePrivate_h
-#ifndef ImageBufferDataSkia_h
-#define ImageBufferDataSkia_h
+#if ENABLE(MEDIA_SOURCE)
-#include "BlackBerryPlatformGraphics.h"
-#include "PlatformContextSkia.h"
-#if USE(ACCELERATED_COMPOSITING)
-#include "CanvasLayerWebKitThread.h"
-#endif
+#include <wtf/Forward.h>
namespace WebCore {
-class ImageBufferData {
+class SourceBufferPrivate;
+
+class MediaSourcePrivate {
public:
- ImageBufferData(const IntSize&);
+ typedef Vector<String, 0> CodecsArray;
- OwnPtr<SkCanvas> m_canvas;
- PlatformContextSkia m_platformContext;
-#if USE(ACCELERATED_COMPOSITING)
- RefPtr<CanvasLayerWebKitThread> m_platformLayer;
-#endif
+ MediaSourcePrivate() { }
+ virtual ~MediaSourcePrivate() { }
+
+ enum AddStatus { Ok, NotSupported, ReachedIdLimit };
+ virtual AddStatus addSourceBuffer(const String& type, const CodecsArray&, OwnPtr<SourceBufferPrivate>*) = 0;
+ virtual double duration() = 0;
+ virtual void setDuration(double) = 0;
+ enum EndOfStreamStatus { EosNoError, EosNetworkError, EosDecodeError };
+ virtual void endOfStream(EndOfStreamStatus) = 0;
};
-} // namespace WebCore
+}
-#endif // ImageBufferDataSkia_h
+#endif
+#endif
diff --git a/Source/WebCore/platform/graphics/NativeImagePtr.h b/Source/WebCore/platform/graphics/NativeImagePtr.h
index c98f8c25a..37540bc4d 100644
--- a/Source/WebCore/platform/graphics/NativeImagePtr.h
+++ b/Source/WebCore/platform/graphics/NativeImagePtr.h
@@ -28,54 +28,47 @@
#ifndef NativeImagePtr_h
#define NativeImagePtr_h
-#if PLATFORM(WX)
-class wxBitmap;
-class wxGraphicsBitmap;
-#elif USE(CG)
+#if USE(CG)
typedef struct CGImage* CGImageRef;
#elif PLATFORM(QT)
+#include "NativeImageQt.h"
#include <qglobal.h>
QT_BEGIN_NAMESPACE
class QPixmap;
QT_END_NAMESPACE
#elif USE(CAIRO)
-#include "NativeImageCairo.h"
-#elif USE(SKIA)
-namespace WebCore {
-class NativeImageSkia;
-}
-#elif OS(WINCE)
+#include "RefPtrCairo.h"
+#elif USE(WINGDI)
#include "SharedBitmap.h"
-#endif
-
-namespace WTF {
-class MemoryObjectInfo;
+#elif PLATFORM(BLACKBERRY)
+namespace BlackBerry {
+namespace Platform {
+namespace Graphics {
+class TiledImage;
}
+}
+}
+#endif
namespace WebCore {
+// FIXME: NativeImagePtr and PassNativeImagePtr should be smart
+// pointers (see SVGImage::nativeImageForCurrentFrame()).
#if USE(CG)
typedef CGImageRef NativeImagePtr;
#elif PLATFORM(QT)
typedef QPixmap* NativeImagePtr;
-#elif PLATFORM(OPENVG)
-class TiledImageOpenVG;
-typedef TiledImageOpenVG* NativeImagePtr;
-#elif PLATFORM(WX)
-#if USE(WXGC)
-typedef wxGraphicsBitmap* NativeImagePtr;
-#else
-typedef wxBitmap* NativeImagePtr;
-#endif
#elif USE(CAIRO)
-typedef WebCore::NativeImageCairo* NativeImagePtr;
-#elif USE(SKIA)
-typedef WebCore::NativeImageSkia* NativeImagePtr;
-void reportMemoryUsage(const NativeImageSkia* const&, WTF::MemoryObjectInfo*);
-#elif OS(WINCE)
+typedef RefPtr<cairo_surface_t> NativeImagePtr;
+typedef PassRefPtr<cairo_surface_t> PassNativeImagePtr;
+#elif USE(WINGDI)
typedef RefPtr<SharedBitmap> NativeImagePtr;
#elif PLATFORM(BLACKBERRY)
-typedef void* NativeImagePtr;
+typedef BlackBerry::Platform::Graphics::TiledImage* NativeImagePtr;
+#endif
+
+#if !USE(CAIRO)
+typedef NativeImagePtr PassNativeImagePtr;
#endif
}
diff --git a/Source/WebCore/platform/graphics/OpenGLESShims.h b/Source/WebCore/platform/graphics/OpenGLESShims.h
index bcaf855ea..c06b67c68 100644
--- a/Source/WebCore/platform/graphics/OpenGLESShims.h
+++ b/Source/WebCore/platform/graphics/OpenGLESShims.h
@@ -26,7 +26,7 @@
#ifndef OpenGLESShims_h
#define OpenGLESShims_h
-#if PLATFORM(BLACKBERRY) || PLATFORM(QT) || PLATFORM(GTK)
+#if PLATFORM(BLACKBERRY) || PLATFORM(QT) || PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(WIN)
#define glBindFramebufferEXT glBindFramebuffer
#define glFramebufferTexture2DEXT glFramebufferTexture2D
#define glBindRenderbufferEXT glBindRenderbuffer
diff --git a/Source/WebCore/platform/graphics/OpenGLShims.cpp b/Source/WebCore/platform/graphics/OpenGLShims.cpp
index 772a8f25c..13947ae06 100644
--- a/Source/WebCore/platform/graphics/OpenGLShims.cpp
+++ b/Source/WebCore/platform/graphics/OpenGLShims.cpp
@@ -22,7 +22,7 @@
#define DISABLE_SHIMS
#include "OpenGLShims.h"
-#if !PLATFORM(QT)
+#if !PLATFORM(QT) && !PLATFORM(WIN)
#include <dlfcn.h>
#endif
@@ -44,6 +44,11 @@ static void* getProcAddress(const char* procName)
return reinterpret_cast<void*>(context->getProcAddress(procName));
return 0;
}
+#elif PLATFORM(WIN)
+static void* getProcAddress(const char* procName)
+{
+ return GetProcAddress(GetModuleHandleA("libGLESv2"), procName);
+}
#else
typedef void* (*glGetProcAddressType) (const char* procName);
static void* getProcAddress(const char* procName)
@@ -86,6 +91,8 @@ static void* lookupOpenGLFunctionAddress(const char* functionName, bool* success
fullFunctionName = functionName;
fullFunctionName.append("ANGLE");
target = getProcAddress(fullFunctionName.utf8().data());
+ if (target)
+ return target;
fullFunctionName = functionName;
fullFunctionName.append("APPLE");
@@ -129,6 +136,7 @@ bool initializeOpenGLShims()
ASSIGN_FUNCTION_TABLE_ENTRY(glBindBuffer, success);
ASSIGN_FUNCTION_TABLE_ENTRY(glBindFramebuffer, success);
ASSIGN_FUNCTION_TABLE_ENTRY(glBindRenderbuffer, success);
+ ASSIGN_FUNCTION_TABLE_ENTRY_EXT(glBindVertexArray);
ASSIGN_FUNCTION_TABLE_ENTRY(glBlendColor, success);
ASSIGN_FUNCTION_TABLE_ENTRY(glBlendEquation, success);
ASSIGN_FUNCTION_TABLE_ENTRY(glBlendEquationSeparate, success);
@@ -152,6 +160,7 @@ bool initializeOpenGLShims()
ASSIGN_FUNCTION_TABLE_ENTRY(glDeleteProgram, success);
ASSIGN_FUNCTION_TABLE_ENTRY(glDeleteRenderbuffers, success);
ASSIGN_FUNCTION_TABLE_ENTRY(glDeleteShader, success);
+ ASSIGN_FUNCTION_TABLE_ENTRY_EXT(glDeleteVertexArrays);
ASSIGN_FUNCTION_TABLE_ENTRY(glDetachShader, success);
ASSIGN_FUNCTION_TABLE_ENTRY(glDisableVertexAttribArray, success);
ASSIGN_FUNCTION_TABLE_ENTRY(glEnableVertexAttribArray, success);
@@ -161,6 +170,7 @@ bool initializeOpenGLShims()
ASSIGN_FUNCTION_TABLE_ENTRY(glGenerateMipmap, success);
ASSIGN_FUNCTION_TABLE_ENTRY(glGenFramebuffers, success);
ASSIGN_FUNCTION_TABLE_ENTRY(glGenRenderbuffers, success);
+ ASSIGN_FUNCTION_TABLE_ENTRY_EXT(glGenVertexArrays);
ASSIGN_FUNCTION_TABLE_ENTRY(glGetActiveAttrib, success);
ASSIGN_FUNCTION_TABLE_ENTRY(glGetActiveUniform, success);
ASSIGN_FUNCTION_TABLE_ENTRY(glGetAttachedShaders, success);
@@ -184,6 +194,7 @@ bool initializeOpenGLShims()
ASSIGN_FUNCTION_TABLE_ENTRY(glIsProgram, success);
ASSIGN_FUNCTION_TABLE_ENTRY(glIsRenderbuffer, success);
ASSIGN_FUNCTION_TABLE_ENTRY(glIsShader, success);
+ ASSIGN_FUNCTION_TABLE_ENTRY_EXT(glIsVertexArray);
ASSIGN_FUNCTION_TABLE_ENTRY(glLinkProgram, success);
ASSIGN_FUNCTION_TABLE_ENTRY(glRenderbufferStorage, success);
// In GLES2 there are optional ANGLE and APPLE extensions for glRenderbufferStorageMultisample.
diff --git a/Source/WebCore/platform/graphics/OpenGLShims.h b/Source/WebCore/platform/graphics/OpenGLShims.h
index 5d71ae20e..8f794211f 100644
--- a/Source/WebCore/platform/graphics/OpenGLShims.h
+++ b/Source/WebCore/platform/graphics/OpenGLShims.h
@@ -27,6 +27,7 @@
#include <QSurface>
#else
#include <GL/gl.h>
+#include <GL/glext.h>
#endif
#if defined(GL_ES_VERSION_2_0)
@@ -53,6 +54,7 @@ typedef void (GLAPIENTRY *glBindAttribLocationType) (GLuint, GLuint, const char*
typedef void (GLAPIENTRY *glBindBufferType) (GLenum, GLuint);
typedef void (GLAPIENTRY *glBindFramebufferType) (GLenum, GLuint);
typedef void (GLAPIENTRY *glBindRenderbufferType) (GLenum, GLuint);
+typedef void (GLAPIENTRY *glBindVertexArrayType) (GLuint);
typedef void (GLAPIENTRY *glBlendColorType) (GLclampf, GLclampf, GLclampf, GLclampf);
typedef void (GLAPIENTRY *glBlendEquationType) (GLenum);
typedef void (GLAPIENTRY *glBlendEquationSeparateType)(GLenum, GLenum);
@@ -71,6 +73,7 @@ typedef void (GLAPIENTRY *glDeleteFramebuffersType) (GLsizei n, const GLuint*);
typedef void (GLAPIENTRY *glDeleteProgramType) (GLuint);
typedef void (GLAPIENTRY *glDeleteRenderbuffersType) (GLsizei n, const GLuint*);
typedef void (GLAPIENTRY *glDeleteShaderType) (GLuint);
+typedef void (GLAPIENTRY *glDeleteVertexArraysType) (GLsizei, const GLuint*);
typedef void (GLAPIENTRY *glDetachShaderType) (GLuint, GLuint);
typedef void (GLAPIENTRY *glDisableVertexAttribArrayType) (GLuint);
typedef void (GLAPIENTRY *glEnableVertexAttribArrayType) (GLuint);
@@ -80,6 +83,7 @@ typedef void (GLAPIENTRY *glGenBuffersType) (GLsizei, GLuint*);
typedef void (GLAPIENTRY *glGenerateMipmapType) (GLenum target);
typedef void (GLAPIENTRY *glGenFramebuffersType) (GLsizei, GLuint*);
typedef void (GLAPIENTRY *glGenRenderbuffersType) (GLsizei, GLuint*);
+typedef void (GLAPIENTRY *glGenVertexArraysType) (GLsizei, GLuint*);
typedef void (GLAPIENTRY *glGetActiveAttribType) (GLuint, GLuint, GLsizei, GLsizei*, GLint*, GLenum*, GLchar*);
typedef void (GLAPIENTRY *glGetActiveUniformType) (GLuint, GLuint, GLsizei, GLsizei*, GLint*, GLenum*, GLchar*);
typedef void (GLAPIENTRY *glGetAttachedShadersType) (GLuint, GLsizei, GLsizei*, GLuint*);
@@ -103,6 +107,7 @@ typedef GLboolean (GLAPIENTRY *glIsFramebufferType) (GLuint);
typedef GLboolean (GLAPIENTRY *glIsProgramType) (GLuint);
typedef GLboolean (GLAPIENTRY *glIsRenderbufferType) (GLuint);
typedef GLboolean (GLAPIENTRY *glIsShaderType) (GLuint);
+typedef GLboolean (GLAPIENTRY *glIsVertexArrayType) (GLuint);
typedef void (GLAPIENTRY *glLinkProgramType) (GLuint);
typedef void (GLAPIENTRY *glRenderbufferStorageType) (GLenum, GLenum, GLsizei, GLsizei);
typedef void (GLAPIENTRY *glRenderbufferStorageMultisampleType) (GLenum, GLsizei, GLenum, GLsizei, GLsizei);
@@ -151,6 +156,7 @@ typedef struct _OpenGLFunctionTable {
FUNCTION_TABLE_ENTRY(glBindBuffer);
FUNCTION_TABLE_ENTRY(glBindFramebuffer);
FUNCTION_TABLE_ENTRY(glBindRenderbuffer);
+ FUNCTION_TABLE_ENTRY(glBindVertexArray);
FUNCTION_TABLE_ENTRY(glBlendColor);
FUNCTION_TABLE_ENTRY(glBlendEquation);
FUNCTION_TABLE_ENTRY(glBlendEquationSeparate);
@@ -169,6 +175,7 @@ typedef struct _OpenGLFunctionTable {
FUNCTION_TABLE_ENTRY(glDeleteProgram);
FUNCTION_TABLE_ENTRY(glDeleteRenderbuffers);
FUNCTION_TABLE_ENTRY(glDeleteShader);
+ FUNCTION_TABLE_ENTRY(glDeleteVertexArrays);
FUNCTION_TABLE_ENTRY(glDetachShader);
FUNCTION_TABLE_ENTRY(glDisableVertexAttribArray);
FUNCTION_TABLE_ENTRY(glEnableVertexAttribArray);
@@ -178,6 +185,7 @@ typedef struct _OpenGLFunctionTable {
FUNCTION_TABLE_ENTRY(glGenerateMipmap);
FUNCTION_TABLE_ENTRY(glGenFramebuffers);
FUNCTION_TABLE_ENTRY(glGenRenderbuffers);
+ FUNCTION_TABLE_ENTRY(glGenVertexArrays);
FUNCTION_TABLE_ENTRY(glGetActiveAttrib);
FUNCTION_TABLE_ENTRY(glGetActiveUniform);
FUNCTION_TABLE_ENTRY(glGetAttachedShaders);
@@ -201,6 +209,7 @@ typedef struct _OpenGLFunctionTable {
FUNCTION_TABLE_ENTRY(glIsProgram);
FUNCTION_TABLE_ENTRY(glIsRenderbuffer);
FUNCTION_TABLE_ENTRY(glIsShader);
+ FUNCTION_TABLE_ENTRY(glIsVertexArray);
FUNCTION_TABLE_ENTRY(glLinkProgram);
FUNCTION_TABLE_ENTRY(glRenderbufferStorage);
FUNCTION_TABLE_ENTRY(glRenderbufferStorageMultisample);
@@ -252,6 +261,8 @@ typedef struct _OpenGLFunctionTable {
#define glBindFramebuffer LOOKUP_GL_FUNCTION(glBindFramebuffer)
#define glBindRenderbufferEXT glBindRenderbuffer
#define glBindRenderbuffer LOOKUP_GL_FUNCTION(glBindRenderbuffer)
+#define glBindVertexArrayOES glBindVertexArray
+#define glBindVertexArray LOOKUP_GL_FUNCTION(glBindVertexArray)
#define glBlendColor LOOKUP_GL_FUNCTION(glBlendColor)
#define glBlendEquation LOOKUP_GL_FUNCTION(glBlendEquation)
#define glBlendEquationSeparate LOOKUP_GL_FUNCTION(glBlendEquationSeparate)
@@ -274,6 +285,8 @@ typedef struct _OpenGLFunctionTable {
#define glDeleteRenderbuffersEXT glDeleteRenderbuffers
#define glDeleteRenderbuffers LOOKUP_GL_FUNCTION(glDeleteRenderbuffers)
#define glDeleteShader LOOKUP_GL_FUNCTION(glDeleteShader)
+#define glDeleteVertexArraysOES glDeleteVertexArrays
+#define glDeleteVertexArrays LOOKUP_GL_FUNCTION(glDeleteVertexArrays)
#define glDetachShader LOOKUP_GL_FUNCTION(glDetachShader)
#define glDisableVertexAttribArray LOOKUP_GL_FUNCTION(glDisableVertexAttribArray)
#define glEnableVertexAttribArray LOOKUP_GL_FUNCTION(glEnableVertexAttribArray)
@@ -288,6 +301,8 @@ typedef struct _OpenGLFunctionTable {
#define glGenFramebuffers LOOKUP_GL_FUNCTION(glGenFramebuffers)
#define glGenRenderbuffersEXT glGenRenderbuffers
#define glGenRenderbuffers LOOKUP_GL_FUNCTION(glGenRenderbuffers)
+#define glGenVertexArraysOES glGenVertexArrays;
+#define glGenVertexArrays LOOKUP_GL_FUNCTION(glGenVertexArrays)
#define glGetActiveAttrib LOOKUP_GL_FUNCTION(glGetActiveAttrib)
#define glGetActiveUniform LOOKUP_GL_FUNCTION(glGetActiveUniform)
#define glGetAttachedShaders LOOKUP_GL_FUNCTION(glGetAttachedShaders)
@@ -316,6 +331,8 @@ typedef struct _OpenGLFunctionTable {
#define glIsRenderbufferEXT glIsRenderbuffer
#define glIsRenderbuffer LOOKUP_GL_FUNCTION(glIsRenderbuffer)
#define glIsShader LOOKUP_GL_FUNCTION(glIsShader)
+#define glIsVertexArrayOES glIsVertexArray;
+#define glIsVertexArray LOOKUP_GL_FUNCTION(glIsVertexArray)
#define glLinkProgram LOOKUP_GL_FUNCTION(glLinkProgram)
#define glRenderbufferStorageEXT glRenderbufferStorage
#define glRenderbufferStorage LOOKUP_GL_FUNCTION(glRenderbufferStorage)
diff --git a/Source/WebCore/platform/graphics/Path.cpp b/Source/WebCore/platform/graphics/Path.cpp
index e3bee07ff..d66ad5277 100644
--- a/Source/WebCore/platform/graphics/Path.cpp
+++ b/Source/WebCore/platform/graphics/Path.cpp
@@ -32,12 +32,13 @@
#include "FloatPoint.h"
#include "FloatRect.h"
#include "PathTraversalState.h"
+#include "RoundedRect.h"
#include <math.h>
#include <wtf/MathExtras.h>
namespace WebCore {
-#if !PLATFORM(OPENVG) && !PLATFORM(QT)
+#if !PLATFORM(QT)
static void pathLengthApplierFunction(void* info, const PathElement* element)
{
PathTraversalState& traversalState = *static_cast<PathTraversalState*>(info);
@@ -144,16 +145,14 @@ void Path::addRoundedRect(const FloatRect& rect, const FloatSize& topLeftRadius,
void Path::addPathForRoundedRect(const FloatRect& rect, const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius, RoundedRectStrategy strategy)
{
- if (strategy == PreferBezierRoundedRect) {
- addBeziersForRoundedRect(rect, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius);
+ if (strategy == PreferNativeRoundedRect) {
+#if USE(CG) || PLATFORM(BLACKBERRY)
+ platformAddPathForRoundedRect(rect, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius);
return;
+#endif
}
-#if USE(CG)
- platformAddPathForRoundedRect(rect, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius);
-#else
addBeziersForRoundedRect(rect, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius);
-#endif
}
// Approximation of control point positions on a bezier to simulate a quarter of a circle.
diff --git a/Source/WebCore/platform/graphics/Path.h b/Source/WebCore/platform/graphics/Path.h
index 0e58d3399..1b6250d9d 100644
--- a/Source/WebCore/platform/graphics/Path.h
+++ b/Source/WebCore/platform/graphics/Path.h
@@ -28,37 +28,30 @@
#ifndef Path_h
#define Path_h
-#include "RoundedRect.h"
#include "WindRule.h"
#include <wtf/FastAllocBase.h>
#include <wtf/Forward.h>
#if USE(CG)
typedef struct CGPath PlatformPath;
-#elif PLATFORM(OPENVG)
-namespace WebCore {
-class PlatformPathOpenVG;
-}
-typedef WebCore::PlatformPathOpenVG PlatformPath;
#elif PLATFORM(QT)
#include <qpainterpath.h>
typedef QPainterPath PlatformPath;
-#elif PLATFORM(WX) && USE(WXGC)
-class wxGraphicsPath;
-typedef wxGraphicsPath PlatformPath;
#elif USE(CAIRO)
namespace WebCore {
class CairoPath;
}
typedef WebCore::CairoPath PlatformPath;
-#elif USE(SKIA)
-class SkPath;
-typedef SkPath PlatformPath;
-#elif OS(WINCE)
+#elif USE(WINGDI)
namespace WebCore {
class PlatformPath;
}
typedef WebCore::PlatformPath PlatformPath;
+#elif PLATFORM(BLACKBERRY)
+namespace BlackBerry { namespace Platform { namespace Graphics {
+ class Path;
+} } }
+typedef BlackBerry::Platform::Graphics::Path PlatformPath;
#else
typedef void PlatformPath;
#endif
@@ -77,6 +70,7 @@ namespace WebCore {
class FloatRect;
class FloatSize;
class GraphicsContext;
+ class RoundedRect;
class StrokeStyleApplier;
enum PathElementType {
@@ -168,12 +162,12 @@ namespace WebCore {
void addPathForRoundedRect(const FloatRect&, const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius, RoundedRectStrategy = PreferNativeRoundedRect);
void addBeziersForRoundedRect(const FloatRect&, const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius);
-#if USE(CG)
+#if USE(CG) || PLATFORM(BLACKBERRY)
void platformAddPathForRoundedRect(const FloatRect&, const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius);
#endif
#if PLATFORM(BLACKBERRY)
- Path(const SkPath&);
+ Path(const PlatformPath&);
#endif
private:
diff --git a/Source/WebCore/platform/graphics/PathTraversalState.cpp b/Source/WebCore/platform/graphics/PathTraversalState.cpp
index 139c5adf1..cf5371727 100644
--- a/Source/WebCore/platform/graphics/PathTraversalState.cpp
+++ b/Source/WebCore/platform/graphics/PathTraversalState.cpp
@@ -209,8 +209,7 @@ void PathTraversalState::processSegment()
m_success = true;
if ((m_action == TraversalPointAtLength || m_action == TraversalNormalAngleAtLength) && m_totalLength >= m_desiredLength) {
- FloatSize change = m_current - m_previous;
- float slope = atan2f(change.height(), change.width());
+ float slope = FloatPoint(m_current - m_previous).slopeAngleRadians();
if (m_action == TraversalPointAtLength) {
float offset = m_desiredLength - m_totalLength;
m_current.move(offset * cosf(slope), offset * sinf(slope));
diff --git a/Source/WebCore/platform/graphics/Pattern.cpp b/Source/WebCore/platform/graphics/Pattern.cpp
index 43f1507d2..3b32ebbb8 100644
--- a/Source/WebCore/platform/graphics/Pattern.cpp
+++ b/Source/WebCore/platform/graphics/Pattern.cpp
@@ -31,14 +31,15 @@
namespace WebCore {
+PassRefPtr<Pattern> Pattern::create(PassRefPtr<Image> tileImage, bool repeatX, bool repeatY)
+{
+ return adoptRef(new Pattern(tileImage, repeatX, repeatY));
+}
+
Pattern::Pattern(PassRefPtr<Image> image, bool repeatX, bool repeatY)
: m_tileImage(image)
, m_repeatX(repeatX)
, m_repeatY(repeatY)
-#if USE(SKIA)
- , m_pattern(0)
- , m_externalMemoryAllocated(0)
-#endif
{
ASSERT(m_tileImage);
}
@@ -54,7 +55,6 @@ void Pattern::setPatternSpaceTransform(const AffineTransform& patternSpaceTransf
setPlatformPatternSpaceTransform();
}
-#if !USE(SKIA)
void Pattern::platformDestroy()
{
}
@@ -62,6 +62,5 @@ void Pattern::platformDestroy()
void Pattern::setPlatformPatternSpaceTransform()
{
}
-#endif
}
diff --git a/Source/WebCore/platform/graphics/Pattern.h b/Source/WebCore/platform/graphics/Pattern.h
index 3d5300555..ef347d607 100644
--- a/Source/WebCore/platform/graphics/Pattern.h
+++ b/Source/WebCore/platform/graphics/Pattern.h
@@ -29,7 +29,6 @@
#define Pattern_h
#include "AffineTransform.h"
-#include "Image.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
@@ -41,34 +40,21 @@ typedef CGPatternRef PlatformPatternPtr;
#elif USE(CAIRO)
#include <cairo.h>
typedef cairo_pattern_t* PlatformPatternPtr;
-#elif USE(SKIA)
-class SkShader;
-typedef SkShader* PlatformPatternPtr;
#elif PLATFORM(QT)
#include <QBrush>
typedef QBrush PlatformPatternPtr;
-#elif PLATFORM(WX)
-#if USE(WXGC)
-class wxGraphicsBrush;
-typedef wxGraphicsBrush* PlatformPatternPtr;
-#else
-class wxBrush;
-typedef wxBrush* PlatformPatternPtr;
-#endif // USE(WXGC)
-#elif OS(WINCE)
+#elif USE(WINGDI)
typedef void* PlatformPatternPtr;
#endif
namespace WebCore {
class AffineTransform;
+class Image;
class Pattern : public RefCounted<Pattern> {
public:
- static PassRefPtr<Pattern> create(PassRefPtr<Image> tileImage, bool repeatX, bool repeatY)
- {
- return adoptRef(new Pattern(tileImage, repeatX, repeatY));
- }
+ static PassRefPtr<Pattern> create(PassRefPtr<Image> tileImage, bool repeatX, bool repeatY);
virtual ~Pattern();
Image* tileImage() const { return m_tileImage.get(); }
@@ -76,9 +62,7 @@ public:
void platformDestroy();
// Pattern space is an abstract space that maps to the default user space by the transformation 'userSpaceTransformation'
-#if USE(SKIA)
- PlatformPatternPtr platformPattern(const AffineTransform& userSpaceTransformation);
-#elif PLATFORM(QT)
+#if PLATFORM(QT)
// Qt ignores user space transformation and uses pattern's instead
PlatformPatternPtr createPlatformPattern() const;
#else
@@ -99,9 +83,6 @@ private:
bool m_repeatY;
AffineTransform m_patternSpaceTransformation;
PlatformPatternPtr m_pattern;
-#if USE(SKIA)
- int m_externalMemoryAllocated;
-#endif
};
} //namespace
diff --git a/Source/WebCore/platform/graphics/PlatformLayer.h b/Source/WebCore/platform/graphics/PlatformLayer.h
index b2a2505ce..a17c19edf 100644
--- a/Source/WebCore/platform/graphics/PlatformLayer.h
+++ b/Source/WebCore/platform/graphics/PlatformLayer.h
@@ -38,24 +38,12 @@ namespace WebCore {
class TextureMapperPlatformLayer;
typedef TextureMapperPlatformLayer PlatformLayer;
};
-#elif PLATFORM(CHROMIUM)
-namespace WebKit {
-class WebLayer;
-}
-namespace WebCore {
-typedef WebKit::WebLayer PlatformLayer;
-}
#elif PLATFORM(GTK)
-#if USE(TEXTURE_MAPPER_CAIRO) || USE(TEXTURE_MAPPER_GL)
+#if USE(TEXTURE_MAPPER_GL)
namespace WebCore {
class TextureMapperPlatformLayer;
typedef TextureMapperPlatformLayer PlatformLayer;
};
-#elif USE(CLUTTER)
-typedef struct _ClutterActor ClutterActor;
-namespace WebCore {
-typedef ClutterActor PlatformLayer;
-};
#endif
#elif PLATFORM(EFL)
#if USE(TEXTURE_MAPPER)
@@ -64,6 +52,11 @@ class TextureMapperPlatformLayer;
typedef TextureMapperPlatformLayer PlatformLayer;
};
#endif
+#elif PLATFORM(BLACKBERRY)
+namespace WebCore {
+class LayerWebKitThread;
+typedef LayerWebKitThread PlatformLayer;
+}
#else
typedef void* PlatformLayer;
#endif
diff --git a/Source/WebCore/platform/graphics/PlatformTextTrack.h b/Source/WebCore/platform/graphics/PlatformTextTrack.h
new file mode 100644
index 000000000..c2b845011
--- /dev/null
+++ b/Source/WebCore/platform/graphics/PlatformTextTrack.h
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PlatformTextTrack_h
+#define PlatformTextTrack_h
+
+#if USE(PLATFORM_TEXT_TRACK_MENU)
+
+#include <wtf/RefCounted.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class TextTrack;
+class InbandTextTrackPrivate;
+
+class PlatformTextTrackClient {
+public:
+ virtual ~PlatformTextTrackClient() { }
+
+ virtual TextTrack* publicTrack() = 0;
+ virtual InbandTextTrackPrivate* privateTrack() { return 0; }
+};
+
+class PlatformTextTrack : public RefCounted<PlatformTextTrack> {
+public:
+ enum TrackKind {
+ Subtitle = 0,
+ Caption = 1,
+ Description = 2,
+ Chapter = 3,
+ MetaData = 4,
+ Forced = 5,
+ };
+ enum TrackType {
+ InBand = 0,
+ OutOfBand = 1,
+ Script = 2
+ };
+
+ static PassRefPtr<PlatformTextTrack> create(PlatformTextTrackClient* client, const String& label, const String& language, TrackKind kind, TrackType type, int uniqueId)
+ {
+ return adoptRef(new PlatformTextTrack(client, label, language, kind, type, uniqueId));
+ }
+
+ virtual ~PlatformTextTrack() { }
+
+ TrackType type() const { return m_type; }
+ TrackKind kind() const { return m_kind; }
+ String label() const { return m_label; }
+ String language() const { return m_language; }
+ PlatformTextTrackClient* client() const { return m_client; }
+ int uniqueId() const { return m_uniqueId; }
+
+ static PlatformTextTrack* captionMenuOffItem()
+ {
+ DEFINE_STATIC_LOCAL(RefPtr<PlatformTextTrack>, off, (PlatformTextTrack::create(0, "off menu item", "", Subtitle, InBand, 0)));
+ return off.get();
+ }
+
+ static PlatformTextTrack* captionMenuAutomaticItem()
+ {
+ DEFINE_STATIC_LOCAL(RefPtr<PlatformTextTrack>, automatic, (PlatformTextTrack::create(0, "automatic menu item", "", Subtitle, InBand, 0)));
+ return automatic.get();
+ }
+
+protected:
+ PlatformTextTrack(PlatformTextTrackClient* client, const String& label, const String& language, TrackKind kind, TrackType type, int uniqueId)
+ : m_label(label)
+ , m_language(language)
+ , m_kind(kind)
+ , m_type(type)
+ , m_client(client)
+ , m_uniqueId(uniqueId)
+ {
+ }
+
+ String m_label;
+ String m_language;
+ TrackKind m_kind;
+ TrackType m_type;
+ PlatformTextTrackClient* m_client;
+ int m_uniqueId;
+};
+
+}
+
+#endif
+
+#endif // PlatformTextTrack_h
diff --git a/Source/WebCore/platform/graphics/PlatformTextTrackMenu.h b/Source/WebCore/platform/graphics/PlatformTextTrackMenu.h
new file mode 100644
index 000000000..0c528ea34
--- /dev/null
+++ b/Source/WebCore/platform/graphics/PlatformTextTrackMenu.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PlatformTextTrackMenu_h
+#define PlatformTextTrackMenu_h
+
+#if USE(PLATFORM_TEXT_TRACK_MENU)
+
+#include "PlatformTextTrack.h"
+#include <wtf/Noncopyable.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class PlatformTextTrack;
+
+class PlatformTextTrackMenuClient {
+public:
+ virtual ~PlatformTextTrackMenuClient() { }
+
+ virtual void setSelectedTextTrack(PassRefPtr<PlatformTextTrack>) = 0;
+ virtual Vector<RefPtr<PlatformTextTrack> > platformTextTracks() = 0;
+};
+
+class PlatformTextTrackMenuInterface : public RefCounted<PlatformTextTrackMenuInterface> {
+public:
+ explicit PlatformTextTrackMenuInterface() { }
+ virtual ~PlatformTextTrackMenuInterface() { }
+
+ virtual void tracksDidChange() = 0;
+ virtual void trackWasSelected(PassRefPtr<PlatformTextTrack>) = 0;
+ virtual void setClient(PlatformTextTrackMenuClient*) = 0;
+};
+
+}
+
+#endif // USE(PLATFORM_TEXT_TRACK_MENU)
+#endif // PlatformTextTrackMenu_h
diff --git a/Source/WebCore/platform/graphics/Region.cpp b/Source/WebCore/platform/graphics/Region.cpp
index 5e4c046c3..465a37cde 100644
--- a/Source/WebCore/platform/graphics/Region.cpp
+++ b/Source/WebCore/platform/graphics/Region.cpp
@@ -312,7 +312,7 @@ Region::Shape::SegmentIterator Region::Shape::segments_end(SpanIterator it) cons
ASSERT(it + 1 < m_spans.data() + m_spans.size());
size_t segmentIndex = (it + 1)->segmentIndex;
- ASSERT(segmentIndex <= m_segments.size());
+ ASSERT_WITH_SECURITY_IMPLICATION(segmentIndex <= m_segments.size());
return m_segments.data() + segmentIndex;
}
diff --git a/Source/WebCore/platform/graphics/RoundedRect.cpp b/Source/WebCore/platform/graphics/RoundedRect.cpp
index 99ab8aaa9..e8d31be64 100644
--- a/Source/WebCore/platform/graphics/RoundedRect.cpp
+++ b/Source/WebCore/platform/graphics/RoundedRect.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2003, 2006, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2013 Xidorn Quan (quanxunzhen@gmail.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -61,17 +62,22 @@ void RoundedRect::Radii::scale(float factor)
void RoundedRect::Radii::expand(int topWidth, int bottomWidth, int leftWidth, int rightWidth)
{
- m_topLeft.setWidth(max<int>(0, m_topLeft.width() + leftWidth));
- m_topLeft.setHeight(max<int>(0, m_topLeft.height() + topWidth));
-
- m_topRight.setWidth(max<int>(0, m_topRight.width() + rightWidth));
- m_topRight.setHeight(max<int>(0, m_topRight.height() + topWidth));
-
- m_bottomLeft.setWidth(max<int>(0, m_bottomLeft.width() + leftWidth));
- m_bottomLeft.setHeight(max<int>(0, m_bottomLeft.height() + bottomWidth));
-
- m_bottomRight.setWidth(max<int>(0, m_bottomRight.width() + rightWidth));
- m_bottomRight.setHeight(max<int>(0, m_bottomRight.height() + bottomWidth));
+ if (m_topLeft.width() > 0 && m_topLeft.height() > 0) {
+ m_topLeft.setWidth(max<int>(0, m_topLeft.width() + leftWidth));
+ m_topLeft.setHeight(max<int>(0, m_topLeft.height() + topWidth));
+ }
+ if (m_topRight.width() > 0 && m_topRight.height() > 0) {
+ m_topRight.setWidth(max<int>(0, m_topRight.width() + rightWidth));
+ m_topRight.setHeight(max<int>(0, m_topRight.height() + topWidth));
+ }
+ if (m_bottomLeft.width() > 0 && m_bottomLeft.height() > 0) {
+ m_bottomLeft.setWidth(max<int>(0, m_bottomLeft.width() + leftWidth));
+ m_bottomLeft.setHeight(max<int>(0, m_bottomLeft.height() + bottomWidth));
+ }
+ if (m_bottomRight.width() > 0 && m_bottomRight.height() > 0) {
+ m_bottomRight.setWidth(max<int>(0, m_bottomRight.width() + rightWidth));
+ m_bottomRight.setHeight(max<int>(0, m_bottomRight.height() + bottomWidth));
+ }
}
void RoundedRect::inflateWithRadii(int size)
@@ -158,18 +164,75 @@ bool RoundedRect::isRenderable() const
{
return m_radii.topLeft().width() + m_radii.topRight().width() <= m_rect.width()
&& m_radii.bottomLeft().width() + m_radii.bottomRight().width() <= m_rect.width()
- && m_radii.topLeft().height() + m_radii.topRight().height() <= m_rect.height()
- && m_radii.bottomLeft().height() + m_radii.bottomRight().height() <= m_rect.height();
+ && m_radii.topLeft().height() + m_radii.bottomLeft().height() <= m_rect.height()
+ && m_radii.topRight().height() + m_radii.bottomRight().height() <= m_rect.height();
}
void RoundedRect::adjustRadii()
{
int maxRadiusWidth = std::max(m_radii.topLeft().width() + m_radii.topRight().width(), m_radii.bottomLeft().width() + m_radii.bottomRight().width());
int maxRadiusHeight = std::max(m_radii.topLeft().height() + m_radii.bottomLeft().height(), m_radii.topRight().height() + m_radii.bottomRight().height());
- if (maxRadiusWidth > maxRadiusHeight)
- m_radii.scale(static_cast<float>(m_rect.width()) / maxRadiusWidth);
- else
- m_radii.scale(static_cast<float>(m_rect.height()) / maxRadiusHeight);
+
+ if (maxRadiusWidth <= 0 || maxRadiusHeight <= 0) {
+ m_radii.scale(0.0f);
+ return;
+ }
+ float widthRatio = static_cast<float>(m_rect.width()) / maxRadiusWidth;
+ float heightRatio = static_cast<float>(m_rect.height()) / maxRadiusHeight;
+ m_radii.scale(widthRatio < heightRatio ? widthRatio : heightRatio);
+}
+
+bool RoundedRect::intersectsQuad(const FloatQuad& quad) const
+{
+ FloatRect rect(m_rect);
+ if (!quad.intersectsRect(rect))
+ return false;
+
+ const IntSize& topLeft = m_radii.topLeft();
+ if (!topLeft.isEmpty()) {
+ FloatRect rect(m_rect.x(), m_rect.y(), topLeft.width(), topLeft.height());
+ if (quad.intersectsRect(rect)) {
+ FloatPoint center(m_rect.x() + topLeft.width(), m_rect.y() + topLeft.height());
+ FloatSize size(topLeft.width(), topLeft.height());
+ if (!quad.intersectsEllipse(center, size))
+ return false;
+ }
+ }
+
+ const IntSize& topRight = m_radii.topRight();
+ if (!topRight.isEmpty()) {
+ FloatRect rect(m_rect.maxX() - topRight.width(), m_rect.y(), topRight.width(), topRight.height());
+ if (quad.intersectsRect(rect)) {
+ FloatPoint center(m_rect.maxX() - topRight.width(), m_rect.y() + topRight.height());
+ FloatSize size(topRight.width(), topRight.height());
+ if (!quad.intersectsEllipse(center, size))
+ return false;
+ }
+ }
+
+ const IntSize& bottomLeft = m_radii.bottomLeft();
+ if (!bottomLeft.isEmpty()) {
+ FloatRect rect(m_rect.x(), m_rect.maxY() - bottomLeft.height(), bottomLeft.width(), bottomLeft.height());
+ if (quad.intersectsRect(rect)) {
+ FloatPoint center(m_rect.x() + bottomLeft.width(), m_rect.maxY() - bottomLeft.height());
+ FloatSize size(bottomLeft.width(), bottomLeft.height());
+ if (!quad.intersectsEllipse(center, size))
+ return false;
+ }
+ }
+
+ const IntSize& bottomRight = m_radii.bottomRight();
+ if (!bottomRight.isEmpty()) {
+ FloatRect rect(m_rect.maxX() - bottomRight.width(), m_rect.maxY() - bottomRight.height(), bottomRight.width(), bottomRight.height());
+ if (quad.intersectsRect(rect)) {
+ FloatPoint center(m_rect.maxX() - bottomRight.width(), m_rect.maxY() - bottomRight.height());
+ FloatSize size(bottomRight.width(), bottomRight.height());
+ if (!quad.intersectsEllipse(center, size))
+ return false;
+ }
+ }
+
+ return true;
}
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/RoundedRect.h b/Source/WebCore/platform/graphics/RoundedRect.h
index 0fd082d44..d923e353f 100644
--- a/Source/WebCore/platform/graphics/RoundedRect.h
+++ b/Source/WebCore/platform/graphics/RoundedRect.h
@@ -27,6 +27,7 @@
#ifndef RoundedRect_h
#define RoundedRect_h
+#include "FloatQuad.h"
#include "IntRect.h"
namespace WebCore {
@@ -96,6 +97,10 @@ public:
bool isRenderable() const;
void adjustRadii();
+ // Tests whether the quad intersects any part of this rounded rectangle.
+ // This only works for convex quads.
+ bool intersectsQuad(const FloatQuad&) const;
+
private:
IntRect m_rect;
Radii m_radii;
diff --git a/Source/WebCore/platform/graphics/SVGGlyph.cpp b/Source/WebCore/platform/graphics/SVGGlyph.cpp
index 668134409..e2820e496 100644
--- a/Source/WebCore/platform/graphics/SVGGlyph.cpp
+++ b/Source/WebCore/platform/graphics/SVGGlyph.cpp
@@ -101,7 +101,7 @@ Vector<SVGGlyph::ArabicForm> charactersWithArabicForm(const String& input, bool
// Start identifying arabic forms
if (rtl) {
for (int i = length - 1; i >= 0; --i)
- forms.prepend(processArabicFormDetection(input[i], lastCharShapesRight, forms.isEmpty() ? 0 : &forms.first()));
+ forms.insert(0, processArabicFormDetection(input[i], lastCharShapesRight, forms.isEmpty() ? 0 : &forms.first()));
} else {
for (unsigned i = 0; i < length; ++i)
forms.append(processArabicFormDetection(input[i], lastCharShapesRight, forms.isEmpty() ? 0 : &forms.last()));
diff --git a/Source/WebCore/platform/graphics/ShadowBlur.cpp b/Source/WebCore/platform/graphics/ShadowBlur.cpp
index 5c92612d2..7458ea899 100644
--- a/Source/WebCore/platform/graphics/ShadowBlur.cpp
+++ b/Source/WebCore/platform/graphics/ShadowBlur.cpp
@@ -3,6 +3,7 @@
* Copyright (C) 2010 Sencha, Inc. All rights reserved.
* Copyright (C) 2010 Igalia S.L. All rights reserved.
* Copyright (C) Research In Motion Limited 2011. All rights reserved.
+ * Copyright (C) 2013 Digia Plc. and/or its subsidiary(-ies).
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -36,7 +37,6 @@
#include "Timer.h"
#include <wtf/MathExtras.h>
#include <wtf/Noncopyable.h>
-#include <wtf/UnusedParam.h>
using namespace std;
@@ -168,6 +168,13 @@ ScratchBuffer& ScratchBuffer::shared()
static const int templateSideLength = 1;
+#if USE(CG)
+static float radiusToLegacyRadius(float radius)
+{
+ return radius > 8 ? 8 + 4 * sqrt((radius - 8) / 2) : radius;
+}
+#endif
+
ShadowBlur::ShadowBlur(const FloatSize& radius, const FloatSize& offset, const Color& color, ColorSpace colorSpace)
: m_color(color)
, m_colorSpace(colorSpace)
@@ -179,6 +186,23 @@ ShadowBlur::ShadowBlur(const FloatSize& radius, const FloatSize& offset, const C
updateShadowBlurValues();
}
+ShadowBlur::ShadowBlur(const GraphicsContextState& state)
+ : m_color(state.shadowColor)
+ , m_colorSpace(state.shadowColorSpace)
+ , m_blurRadius(state.shadowBlur, state.shadowBlur)
+ , m_offset(state.shadowOffset)
+ , m_layerImage(0)
+ , m_shadowsIgnoreTransforms(state.shadowsIgnoreTransforms)
+{
+#if USE(CG)
+ if (state.shadowsUseLegacyRadius) {
+ float shadowBlur = radiusToLegacyRadius(state.shadowBlur);
+ m_blurRadius = FloatSize(shadowBlur, shadowBlur);
+ }
+#endif
+ updateShadowBlurValues();
+}
+
ShadowBlur::ShadowBlur()
: m_type(NoShadow)
, m_blurRadius(0, 0)
@@ -679,12 +703,17 @@ void ShadowBlur::drawInsetShadowWithTiling(GraphicsContext* graphicsContext, con
blurAndColorShadowBuffer(templateSize);
}
+ FloatSize offset = m_offset;
+ if (shadowsIgnoreTransforms()) {
+ AffineTransform transform = graphicsContext->getCTM();
+ offset.scale(1 / transform.xScale(), 1 / transform.yScale());
+ }
FloatRect boundingRect = rect;
- boundingRect.move(m_offset);
+ boundingRect.move(offset);
FloatRect destHoleRect = holeRect;
- destHoleRect.move(m_offset);
+ destHoleRect.move(offset);
FloatRect destHoleBounds = destHoleRect;
destHoleBounds.inflateX(edgeSize.width());
destHoleBounds.inflateY(edgeSize.height());
@@ -736,9 +765,14 @@ void ShadowBlur::drawRectShadowWithTiling(GraphicsContext* graphicsContext, cons
blurAndColorShadowBuffer(templateSize);
}
+ FloatSize offset = m_offset;
+ if (shadowsIgnoreTransforms()) {
+ AffineTransform transform = graphicsContext->getCTM();
+ offset.scale(1 / transform.xScale(), 1 / transform.yScale());
+ }
FloatRect shadowBounds = shadowedRect;
- shadowBounds.move(m_offset.width(), m_offset.height());
+ shadowBounds.move(offset);
shadowBounds.inflateX(edgeSize.width());
shadowBounds.inflateY(edgeSize.height());
@@ -887,22 +921,4 @@ void ShadowBlur::endShadowLayer(GraphicsContext* context)
ScratchBuffer::shared().scheduleScratchBufferPurge();
}
-#if PLATFORM(QT) || USE(CAIRO)
-bool ShadowBlur::mustUseShadowBlur(GraphicsContext* context) const
-{
- // We can't avoid ShadowBlur, since the shadow has blur.
- if (type() == BlurShadow)
- return true;
- // We can avoid ShadowBlur and optimize, since we're not drawing on a
- // canvas and box shadows are affected by the transformation matrix.
- if (!shadowsIgnoreTransforms())
- return false;
- // We can avoid ShadowBlur, since there are no transformations to apply to the canvas.
- if (context->getCTM().isIdentity())
- return false;
- // Otherwise, no chance avoiding ShadowBlur.
- return true;
-}
-#endif
-
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/ShadowBlur.h b/Source/WebCore/platform/graphics/ShadowBlur.h
index e88a66607..32ff60b6c 100644
--- a/Source/WebCore/platform/graphics/ShadowBlur.h
+++ b/Source/WebCore/platform/graphics/ShadowBlur.h
@@ -39,6 +39,7 @@ namespace WebCore {
class AffineTransform;
class GraphicsContext;
+struct GraphicsContextState;
class ImageBuffer;
class ShadowBlur {
@@ -51,6 +52,7 @@ public:
};
ShadowBlur(const FloatSize& radius, const FloatSize& offset, const Color&, ColorSpace);
+ ShadowBlur(const GraphicsContextState&);
ShadowBlur();
void setShadowValues(const FloatSize&, const FloatSize& , const Color&, ColorSpace, bool ignoreTransforms = false);
@@ -70,10 +72,6 @@ public:
ShadowType type() const { return m_type; }
-#if PLATFORM(QT) || USE(CAIRO)
- bool mustUseShadowBlur(GraphicsContext*) const;
-#endif
-
private:
void updateShadowBlurValues();
diff --git a/Source/WebCore/platform/graphics/SimpleFontData.cpp b/Source/WebCore/platform/graphics/SimpleFontData.cpp
index 65194f012..fe0fb981c 100644
--- a/Source/WebCore/platform/graphics/SimpleFontData.cpp
+++ b/Source/WebCore/platform/graphics/SimpleFontData.cpp
@@ -32,10 +32,11 @@
#include "Font.h"
#include "FontCache.h"
-#include "OpenTypeVerticalData.h"
-
#include <wtf/MathExtras.h>
-#include <wtf/UnusedParam.h>
+
+#if ENABLE(OPENTYPE_VERTICAL)
+#include "OpenTypeVerticalData.h"
+#endif
using namespace std;
@@ -113,6 +114,7 @@ void SimpleFontData::platformGlyphInit()
LOG_ERROR("Failed to get glyph page zero.");
m_spaceGlyph = 0;
m_spaceWidth = 0;
+ m_zeroGlyph = 0;
m_adjustedSpaceWidth = 0;
determinePitch();
m_zeroWidthSpaceGlyph = 0;
@@ -129,6 +131,8 @@ void SimpleFontData::platformGlyphInit()
m_spaceGlyph = glyphPageZero->glyphDataForCharacter(' ').glyph;
float width = widthForGlyph(m_spaceGlyph);
m_spaceWidth = width;
+ m_zeroGlyph = glyphPageZero->glyphDataForCharacter('0').glyph;
+ m_fontMetrics.setZeroWidth(widthForGlyph(m_zeroGlyph));
determinePitch();
m_adjustedSpaceWidth = m_treatAsFixedPitch ? ceilf(width) : roundf(width);
@@ -148,9 +152,7 @@ void SimpleFontData::platformGlyphInit()
SimpleFontData::~SimpleFontData()
{
-#if ENABLE(SVG_FONTS)
if (!m_fontData)
-#endif
platformDestroy();
if (isCustomFont())
@@ -227,6 +229,20 @@ PassRefPtr<SimpleFontData> SimpleFontData::brokenIdeographFontData() const
return m_derivedFontData->brokenIdeograph;
}
+PassRefPtr<SimpleFontData> SimpleFontData::nonSyntheticItalicFontData() const
+{
+ if (!m_derivedFontData)
+ m_derivedFontData = DerivedFontData::create(isCustomFont());
+ if (!m_derivedFontData->nonSyntheticItalic) {
+ FontPlatformData nonSyntheticItalicFontPlatformData(m_platformData);
+#if PLATFORM(MAC)
+ nonSyntheticItalicFontPlatformData.m_syntheticOblique = false;
+#endif
+ m_derivedFontData->nonSyntheticItalic = create(nonSyntheticItalicFontPlatformData, isCustomFont(), false, true);
+ }
+ return m_derivedFontData->nonSyntheticItalic;
+}
+
#ifndef NDEBUG
String SimpleFontData::description() const
{
@@ -268,7 +284,7 @@ SimpleFontData::DerivedFontData::~DerivedFontData()
SimpleFontData** fonts = stash.data();
CFDictionaryGetKeysAndValues(dictionary, 0, (const void **)fonts);
while (count-- > 0 && *fonts) {
- OwnPtr<SimpleFontData> afont = adoptPtr(*fonts++);
+ RefPtr<SimpleFontData> afont = adoptRef(*fonts++);
GlyphPageTreeNode::pruneTreeCustomFontData(afont.get());
}
}
@@ -276,4 +292,13 @@ SimpleFontData::DerivedFontData::~DerivedFontData()
#endif
}
+PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
+{
+ // FIXME: Support scaled fonts that used AdditionalFontData.
+ if (m_fontData)
+ return 0;
+
+ return platformCreateScaledFontData(fontDescription, scaleFactor);
+}
+
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/SimpleFontData.h b/Source/WebCore/platform/graphics/SimpleFontData.h
index a99482404..637b77f85 100644
--- a/Source/WebCore/platform/graphics/SimpleFontData.h
+++ b/Source/WebCore/platform/graphics/SimpleFontData.h
@@ -38,19 +38,17 @@
#include "TypesettingFeatures.h"
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
-#include <wtf/UnusedParam.h>
#include <wtf/text/StringHash.h>
#if PLATFORM(MAC)
#include "WebCoreSystemInterface.h"
#endif
-#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN)) || (PLATFORM(WX) && OS(DARWIN))
+#if PLATFORM(MAC)
#include <wtf/RetainPtr.h>
#endif
-#if (PLATFORM(WIN) && !OS(WINCE)) \
- || (OS(WINDOWS) && PLATFORM(WX))
+#if (PLATFORM(WIN) && !OS(WINCE))
#include <usp10.h>
#endif
@@ -108,6 +106,7 @@ public:
PassRefPtr<SimpleFontData> smallCapsFontData(const FontDescription&) const;
PassRefPtr<SimpleFontData> emphasisMarkFontData(const FontDescription&) const;
PassRefPtr<SimpleFontData> brokenIdeographFontData() const;
+ PassRefPtr<SimpleFontData> nonSyntheticItalicFontData() const;
PassRefPtr<SimpleFontData> variantFontData(const FontDescription& description, FontDataVariant variant) const
{
@@ -151,14 +150,17 @@ public:
float adjustedSpaceWidth() const { return m_adjustedSpaceWidth; }
void setSpaceWidth(float spaceWidth) { m_spaceWidth = spaceWidth; }
-#if USE(CG) || USE(CAIRO) || PLATFORM(WX) || USE(SKIA_ON_MAC_CHROMIUM)
+#if USE(CG) || USE(CAIRO)
float syntheticBoldOffset() const { return m_syntheticBoldOffset; }
#endif
Glyph spaceGlyph() const { return m_spaceGlyph; }
void setSpaceGlyph(Glyph spaceGlyph) { m_spaceGlyph = spaceGlyph; }
+ Glyph zeroWidthSpaceGlyph() const { return m_zeroWidthSpaceGlyph; }
void setZeroWidthSpaceGlyph(Glyph spaceGlyph) { m_zeroWidthSpaceGlyph = spaceGlyph; }
bool isZeroWidthSpaceGlyph(Glyph glyph) const { return glyph == m_zeroWidthSpaceGlyph && glyph; }
+ Glyph zeroGlyph() const { return m_zeroGlyph; }
+ void setZeroGlyph(Glyph zeroGlyph) { m_zeroGlyph = zeroGlyph; }
virtual const SimpleFontData* fontDataForCharacter(UChar32) const;
virtual bool containsCharacters(const UChar*, int length) const;
@@ -182,19 +184,16 @@ public:
virtual String description() const;
#endif
-#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))
+#if PLATFORM(MAC)
const SimpleFontData* getCompositeFontReferenceFontData(NSFont *key) const;
NSFont* getNSFont() const { return m_platformData.font(); }
-#elif (PLATFORM(WX) && OS(DARWIN))
- const SimpleFontData* getCompositeFontReferenceFontData(NSFont *key) const;
- NSFont* getNSFont() const { return m_platformData.nsFont(); }
#endif
-#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN)) || (PLATFORM(WX) && OS(DARWIN))
+#if PLATFORM(MAC)
CFDictionaryRef getCFStringAttributes(TypesettingFeatures, FontOrientation) const;
#endif
-#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN)) || (PLATFORM(WX) && OS(DARWIN)) || USE(HARFBUZZ_NG)
+#if PLATFORM(MAC) || USE(HARFBUZZ)
bool canRenderCombiningCharacterSequence(const UChar*, size_t) const;
#endif
@@ -213,7 +212,6 @@ public:
UNUSED_PARAM(advances);
UNUSED_PARAM(glyphCount);
UNUSED_PARAM(typesettingFeatures);
- ASSERT_NOT_REACHED();
return false;
#endif
}
@@ -222,7 +220,7 @@ public:
QRawFont getQtRawFont() const { return m_platformData.rawFont(); }
#endif
-#if PLATFORM(WIN) || (OS(WINDOWS) && PLATFORM(WX))
+#if PLATFORM(WIN)
bool isSystemFont() const { return m_isSystemFont; }
#if !OS(WINCE) // disable unused members to save space
SCRIPT_FONTPROPERTIES* scriptFontProperties() const;
@@ -233,10 +231,6 @@ public:
static float ascentConsideringMacAscentHack(const WCHAR*, float ascent, float descent);
#endif
-#if PLATFORM(WX)
- wxFont* getWxFont() const { return m_platformData.font(); }
-#endif
-
private:
SimpleFontData(const FontPlatformData&, bool isCustomFont = false, bool isLoading = false, bool isTextOrientationFallback = false);
@@ -249,12 +243,10 @@ private:
void initCharWidths();
- void commonInit();
-
PassRefPtr<SimpleFontData> createScaledFontData(const FontDescription&, float scaleFactor) const;
+ PassRefPtr<SimpleFontData> platformCreateScaledFontData(const FontDescription&, float scaleFactor) const;
-#if (PLATFORM(WIN) && !OS(WINCE)) \
- || (OS(WINDOWS) && PLATFORM(WX))
+#if (PLATFORM(WIN) && !OS(WINCE))
void initGDIFont();
void platformCommonDestroy();
FloatRect boundsForGDIGlyph(Glyph glyph) const;
@@ -284,6 +276,7 @@ private:
Glyph m_spaceGlyph;
float m_spaceWidth;
+ Glyph m_zeroGlyph;
float m_adjustedSpaceWidth;
Glyph m_zeroWidthSpaceGlyph;
@@ -300,7 +293,8 @@ private:
RefPtr<SimpleFontData> brokenIdeograph;
RefPtr<SimpleFontData> verticalRightOrientation;
RefPtr<SimpleFontData> uprightOrientation;
-#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))
+ RefPtr<SimpleFontData> nonSyntheticItalic;
+#if PLATFORM(MAC)
mutable RetainPtr<CFMutableDictionaryRef> compositeFontReferences;
#endif
@@ -313,19 +307,19 @@ private:
mutable OwnPtr<DerivedFontData> m_derivedFontData;
-#if USE(CG) || USE(CAIRO) || PLATFORM(WX) || USE(SKIA_ON_MAC_CHROMIUM)
+#if USE(CG) || USE(CAIRO)
float m_syntheticBoldOffset;
#endif
-#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN)) || (PLATFORM(WX) && OS(DARWIN))
+#if PLATFORM(MAC)
mutable HashMap<unsigned, RetainPtr<CFDictionaryRef> > m_CFStringAttributes;
#endif
-#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN)) || (PLATFORM(WX) && OS(DARWIN)) || USE(HARFBUZZ_NG)
+#if PLATFORM(MAC) || USE(HARFBUZZ)
mutable OwnPtr<HashMap<String, bool> > m_combiningCharacterSequenceSupport;
#endif
-#if PLATFORM(WIN) || (OS(WINDOWS) && PLATFORM(WX))
+#if PLATFORM(WIN)
bool m_isSystemFont;
#if !OS(WINCE) // disable unused members to save space
mutable SCRIPT_CACHE m_scriptCache;
@@ -366,7 +360,7 @@ ALWAYS_INLINE float SimpleFontData::widthForGlyph(Glyph glyph) const
width = m_fontData->widthForSVGGlyph(glyph, m_platformData.size());
#if ENABLE(OPENTYPE_VERTICAL)
else if (m_verticalData)
-#if USE(CG) || USE(CAIRO) || PLATFORM(WX) || USE(SKIA_ON_MAC_CHROMIUM)
+#if USE(CG) || USE(CAIRO)
width = m_verticalData->advanceHeight(this, glyph) + m_syntheticBoldOffset;
#else
width = m_verticalData->advanceHeight(this, glyph);
diff --git a/Source/WebCore/platform/graphics/blackberry/skia/PlatformSupport.h b/Source/WebCore/platform/graphics/SourceBufferPrivate.h
index d0c043bdc..009badf77 100644
--- a/Source/WebCore/platform/graphics/blackberry/skia/PlatformSupport.h
+++ b/Source/WebCore/platform/graphics/SourceBufferPrivate.h
@@ -1,6 +1,5 @@
/*
- * Copyright (c) 2010, Google Inc. All rights reserved.
- * Copyright (c) 2011, Research In Motion. All rights reserved.
+ * Copyright (C) 2013 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -28,22 +27,28 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef SourceBufferPrivate_h
+#define SourceBufferPrivate_h
-#ifndef PlatformSupport_h
-#define PlatformSupport_h
+#if ENABLE(MEDIA_SOURCE)
-#include <wtf/text/WTFString.h>
+#include "TimeRanges.h"
namespace WebCore {
-struct FontRenderStyle;
-
-// This is a minimal version of the Chromium PlatformSupport/WebFontInfo classes used for font support.
-class PlatformSupport {
+class SourceBufferPrivate {
public:
- static void getRenderStyleForStrike(const char* family, int sizeAndStyle, FontRenderStyle* result);
+ SourceBufferPrivate() { }
+ virtual ~SourceBufferPrivate() { }
+
+ virtual PassRefPtr<TimeRanges> buffered() = 0;
+ virtual void append(const unsigned char* data, unsigned length) = 0;
+ virtual void abort() = 0;
+ virtual bool setTimestampOffset(double) = 0;
+ virtual void removedFromMediaSource() = 0;
};
-} // namespace WebCore
+}
#endif
+#endif
diff --git a/Source/WebCore/platform/graphics/SurrogatePairAwareTextIterator.cpp b/Source/WebCore/platform/graphics/SurrogatePairAwareTextIterator.cpp
index 11da4b901..e7eb43b56 100644
--- a/Source/WebCore/platform/graphics/SurrogatePairAwareTextIterator.cpp
+++ b/Source/WebCore/platform/graphics/SurrogatePairAwareTextIterator.cpp
@@ -90,11 +90,6 @@ UChar32 SurrogatePairAwareTextIterator::normalizeVoicingMarks()
int32_t resultLength = unorm_normalize(m_characters, 2, UNORM_NFC, UNORM_UNICODE_3_2, &normalizedCharacters[0], 2, &uStatus);
if (resultLength == 1 && !uStatus)
return normalizedCharacters[0];
-#elif USE(QT4_UNICODE)
- QString tmp(reinterpret_cast<const QChar*>(m_characters), 2);
- QString res = tmp.normalized(QString::NormalizationForm_C, QChar::Unicode_3_2);
- if (res.length() == 1)
- return res.at(0).unicode();
#endif
}
diff --git a/Source/WebCore/platform/graphics/TextRun.h b/Source/WebCore/platform/graphics/TextRun.h
index c64f098fe..895a1e95d 100644
--- a/Source/WebCore/platform/graphics/TextRun.h
+++ b/Source/WebCore/platform/graphics/TextRun.h
@@ -155,9 +155,9 @@ public:
return result;
}
- UChar operator[](unsigned i) const { ASSERT(i < m_len); return is8Bit() ? m_data.characters8[i] :m_data.characters16[i]; }
- const LChar* data8(unsigned i) const { ASSERT(i < m_len); ASSERT(is8Bit()); return &m_data.characters8[i]; }
- const UChar* data16(unsigned i) const { ASSERT(i < m_len); ASSERT(!is8Bit()); return &m_data.characters16[i]; }
+ UChar operator[](unsigned i) const { ASSERT_WITH_SECURITY_IMPLICATION(i < m_len); return is8Bit() ? m_data.characters8[i] :m_data.characters16[i]; }
+ const LChar* data8(unsigned i) const { ASSERT_WITH_SECURITY_IMPLICATION(i < m_len); ASSERT(is8Bit()); return &m_data.characters8[i]; }
+ const UChar* data16(unsigned i) const { ASSERT_WITH_SECURITY_IMPLICATION(i < m_len); ASSERT(!is8Bit()); return &m_data.characters16[i]; }
const LChar* characters8() const { ASSERT(is8Bit()); return m_data.characters8; }
const UChar* characters16() const { ASSERT(!is8Bit()); return m_data.characters16; }
diff --git a/Source/WebCore/platform/graphics/TextTrackRepresentation.cpp b/Source/WebCore/platform/graphics/TextTrackRepresentation.cpp
new file mode 100644
index 000000000..68e4c2d4a
--- /dev/null
+++ b/Source/WebCore/platform/graphics/TextTrackRepresentation.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(VIDEO_TRACK)
+
+#include "TextTrackRepresentation.h"
+
+namespace WebCore {
+
+class NullTextTrackRepresentation : public TextTrackRepresentation {
+public:
+ virtual ~NullTextTrackRepresentation() { }
+ virtual void update() { }
+#if USE(ACCELERATED_COMPOSITING)
+ virtual PlatformLayer* platformLayer() { return 0; }
+#endif
+ virtual void setContentScale(float) { }
+ virtual IntRect bounds() const { return IntRect(); }
+};
+
+PassOwnPtr<TextTrackRepresentation> TextTrackRepresentation::create(TextTrackRepresentationClient*)
+{
+ return WTF::adoptPtr(new NullTextTrackRepresentation());
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/platform/graphics/TextTrackRepresentation.h b/Source/WebCore/platform/graphics/TextTrackRepresentation.h
new file mode 100644
index 000000000..5f844483d
--- /dev/null
+++ b/Source/WebCore/platform/graphics/TextTrackRepresentation.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef TextTrackRepresentation_h
+#define TextTrackRepresentation_h
+
+#if ENABLE(VIDEO_TRACK)
+
+#include "IntRect.h"
+#include "PlatformLayer.h"
+#include <wtf/PassOwnPtr.h>
+
+namespace WebCore {
+
+class GraphicsContext;
+class Image;
+class IntRect;
+
+class TextTrackRepresentationClient {
+public:
+ virtual ~TextTrackRepresentationClient() { }
+
+ virtual PassRefPtr<Image> createTextTrackRepresentationImage() = 0;
+ virtual void textTrackRepresentationBoundsChanged(const IntRect&) = 0;
+};
+
+class TextTrackRepresentation {
+public:
+ static PassOwnPtr<TextTrackRepresentation> create(TextTrackRepresentationClient*);
+
+ virtual ~TextTrackRepresentation() { }
+
+ virtual void update() = 0;
+#if USE(ACCELERATED_COMPOSITING)
+ virtual PlatformLayer* platformLayer() = 0;
+#endif
+ virtual void setContentScale(float) = 0;
+ virtual IntRect bounds() const = 0;
+};
+
+}
+
+#endif
+
+#endif // TextTrackRepresentation_h
diff --git a/Source/WebCore/platform/graphics/TiledBacking.h b/Source/WebCore/platform/graphics/TiledBacking.h
index 8c213feb2..2e66f6086 100644
--- a/Source/WebCore/platform/graphics/TiledBacking.h
+++ b/Source/WebCore/platform/graphics/TiledBacking.h
@@ -26,16 +26,33 @@
#ifndef TiledBacking_h
#define TiledBacking_h
+#if PLATFORM(MAC)
+OBJC_CLASS CALayer;
+#endif
+
namespace WebCore {
class IntRect;
+enum ScrollingModeIndication {
+ MainThreadScrollingBecauseOfStyleIndication,
+ MainThreadScrollingBecauseOfEventHandlersIndication,
+ ThreadedScrollingIndication
+};
+
class TiledBacking {
public:
virtual ~TiledBacking() { }
- virtual void setVisibleRect(const IntRect&) = 0;
- virtual IntRect visibleRect() const = 0;
+ virtual void setVisibleRect(const FloatRect&) = 0;
+ virtual FloatRect visibleRect() const = 0;
+ virtual bool tilesWouldChangeForVisibleRect(const FloatRect&) const = 0;
+
+ virtual void setExposedRect(const FloatRect&) = 0;
+ virtual void setClipsToExposedRect(bool) = 0;
+ virtual bool clipsToExposedRect() = 0;
+
+ virtual void prepopulateRect(const FloatRect&) = 0;
virtual void setIsInWindow(bool) = 0;
@@ -58,9 +75,22 @@ public:
virtual void setScrollingPerformanceLoggingEnabled(bool) = 0;
virtual bool scrollingPerformanceLoggingEnabled() const = 0;
+ virtual void setAggressivelyRetainsTiles(bool) = 0;
+ virtual bool aggressivelyRetainsTiles() const = 0;
+
+ virtual void setUnparentsOffscreenTiles(bool) = 0;
+ virtual bool unparentsOffscreenTiles() const = 0;
+
+ virtual double retainedTileBackingStoreMemory() const = 0;
+
// Exposed for testing
virtual IntRect tileCoverageRect() const = 0;
virtual IntRect tileGridExtent() const = 0;
+ virtual void setScrollingModeIndication(ScrollingModeIndication) = 0;
+
+#if PLATFORM(MAC)
+ virtual CALayer *tiledScrollingIndicatorLayer() = 0;
+#endif
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/TiledBackingStore.cpp b/Source/WebCore/platform/graphics/TiledBackingStore.cpp
index 418fb5dc2..ec00dd61d 100644
--- a/Source/WebCore/platform/graphics/TiledBackingStore.cpp
+++ b/Source/WebCore/platform/graphics/TiledBackingStore.cpp
@@ -41,12 +41,13 @@ TiledBackingStore::TiledBackingStore(TiledBackingStoreClient* client, PassOwnPtr
, m_tileBufferUpdateTimer(this, &TiledBackingStore::tileBufferUpdateTimerFired)
, m_backingStoreUpdateTimer(this, &TiledBackingStore::backingStoreUpdateTimerFired)
, m_tileSize(defaultTileDimension, defaultTileDimension)
- , m_tileCreationDelay(0.01)
, m_coverAreaMultiplier(2.0f)
, m_contentsScale(1.f)
, m_pendingScale(0)
+ , m_commitTileUpdatesOnIdleEventLoop(false)
, m_contentsFrozen(false)
, m_supportsAlpha(false)
+ , m_pendingTileCreation(false)
{
}
@@ -61,26 +62,20 @@ void TiledBackingStore::setTileSize(const IntSize& size)
startBackingStoreUpdateTimer();
}
-void TiledBackingStore::setTileCreationDelay(double delay)
+void TiledBackingStore::setTrajectoryVector(const FloatPoint& trajectoryVector)
{
- m_tileCreationDelay = delay;
+ m_pendingTrajectoryVector = trajectoryVector;
+ m_pendingTrajectoryVector.normalize();
}
-void TiledBackingStore::coverWithTilesIfNeeded(const FloatPoint& trajectoryVector)
+void TiledBackingStore::coverWithTilesIfNeeded()
{
IntRect visibleRect = this->visibleRect();
IntRect rect = mapFromContents(m_client->tiledBackingStoreContentsRect());
- FloatPoint normalizedVector = trajectoryVector;
- normalizedVector.normalize();
-
- if (m_trajectoryVector == normalizedVector && m_visibleRect == visibleRect && m_rect == rect)
- return;
-
- m_trajectoryVector = normalizedVector;
- m_visibleRect = visibleRect;
-
- createTiles();
+ bool didChange = m_trajectoryVector != m_pendingTrajectoryVector || m_visibleRect != visibleRect || m_rect != rect;
+ if (didChange || m_pendingTileCreation)
+ createTiles();
}
void TiledBackingStore::invalidate(const IntRect& contentsDirtyRect)
@@ -110,7 +105,7 @@ void TiledBackingStore::invalidate(const IntRect& contentsDirtyRect)
void TiledBackingStore::updateTileBuffers()
{
- if (!m_client->tiledBackingStoreUpdatesAllowed() || m_contentsFrozen)
+ if (m_contentsFrozen)
return;
m_client->tiledBackingStorePaintBegin();
@@ -135,7 +130,7 @@ void TiledBackingStore::updateTileBuffers()
unsigned size = dirtyTiles.size();
for (unsigned n = 0; n < size; ++n) {
Vector<IntRect> paintedRects = dirtyTiles[n]->updateBackBuffer();
- paintedArea.append(paintedRects);
+ paintedArea.appendVector(paintedRects);
dirtyTiles[n]->swapBackBufferToFront();
}
@@ -247,6 +242,8 @@ void TiledBackingStore::createTiles()
// Update our backing store geometry.
const IntRect previousRect = m_rect;
m_rect = mapFromContents(m_client->tiledBackingStoreContentsRect());
+ m_trajectoryVector = m_pendingTrajectoryVector;
+ m_visibleRect = visibleRect();
if (m_rect.isEmpty()) {
setCoverRect(IntRect());
@@ -275,12 +272,9 @@ void TiledBackingStore::createTiles()
* We must create or keep the tiles in the HERE region.
*/
- const IntRect visibleRect = this->visibleRect();
- m_visibleRect = visibleRect;
-
IntRect coverRect;
IntRect keepRect;
- computeCoverAndKeepRect(visibleRect, coverRect, keepRect);
+ computeCoverAndKeepRect(m_visibleRect, coverRect, keepRect);
setCoverRect(coverRect);
setKeepRect(keepRect);
@@ -311,7 +305,7 @@ void TiledBackingStore::createTiles()
if (tileAt(currentCoordinate))
continue;
++requiredTileCount;
- double distance = tileDistance(visibleRect, currentCoordinate);
+ double distance = tileDistance(m_visibleRect, currentCoordinate);
if (distance > shortestDistance)
continue;
if (distance < shortestDistance) {
@@ -335,8 +329,16 @@ void TiledBackingStore::createTiles()
updateTileBuffers();
// Re-call createTiles on a timer to cover the visible area with the newest shortest distance.
- if (requiredTileCount)
- m_backingStoreUpdateTimer.startOneShot(m_tileCreationDelay);
+ m_pendingTileCreation = requiredTileCount;
+ if (m_pendingTileCreation) {
+ if (!m_commitTileUpdatesOnIdleEventLoop) {
+ m_client->tiledBackingStoreHasPendingTileCreation();
+ return;
+ }
+
+ static const double tileCreationDelay = 0.01;
+ startBackingStoreUpdateTimer(tileCreationDelay);
+ }
}
void TiledBackingStore::adjustForContentsRect(IntRect& rect) const
@@ -344,31 +346,36 @@ void TiledBackingStore::adjustForContentsRect(IntRect& rect) const
IntRect bounds = m_rect;
IntSize candidateSize = rect.size();
- // If candidateSize is bigger than bounds (i.e. TBS is used as a backing store of GraphicsLayer), we skip the below adjusting logic which expects bounds to cover the given rect.
- if (candidateSize.width() > bounds.width() && candidateSize.height() > bounds.height()) {
- rect.intersect(bounds);
- return;
- }
-
- // We will try to keep the cover and keep rect the same size at all time, which
- // might not be the case when at the content edges.
-
- // We start by moving when at the edges.
- rect.move(std::max(0, bounds.x() - rect.x()), std::max(0, bounds.y() - rect.y()));
- rect.move(std::min(0, bounds.maxX() - rect.maxX()), std::min(0, bounds.maxY() - rect.maxY()));
-
rect.intersect(bounds);
if (rect.size() == candidateSize)
return;
- // Even now we might cover more than the content area so let's inflate in the
- // opposite directions.
+ /*
+ * In the following case, there is no intersection of the contents rect and the cover rect.
+ * Thus the latter should not be inflated.
+ *
+ * +---------------+
+ * | m_rect |
+ * +---------------+
+ *
+ * +-------------------------------+
+ * | cover rect |
+ * | +---------+ |
+ * | | visible | |
+ * | | rect | |
+ * | +---------+ |
+ * +-------------------------------+
+ */
+ if (rect.isEmpty())
+ return;
+
+ // Try to create a cover rect of the same size as the candidate, but within content bounds.
int pixelsCovered = candidateSize.width() * candidateSize.height();
- if (rect.width() != candidateSize.width())
+ if (rect.width() < candidateSize.width())
rect.inflateY(((pixelsCovered / rect.width()) - rect.height()) / 2);
- if (rect.height() != candidateSize.height())
+ if (rect.height() < candidateSize.height())
rect.inflateX(((pixelsCovered / rect.height()) - rect.width()) / 2);
rect.intersect(bounds);
@@ -406,16 +413,18 @@ void TiledBackingStore::computeCoverAndKeepRect(const IntRect& visibleRect, IntR
coverRect.unite(visibleRect);
}
+ ASSERT(keepRect.contains(coverRect));
}
- ASSERT(keepRect.contains(coverRect));
+ adjustForContentsRect(coverRect);
// The keep rect is an inflated version of the cover rect, inflated in tile dimensions.
+ keepRect.unite(coverRect);
keepRect.inflateX(m_tileSize.width() / 2);
keepRect.inflateY(m_tileSize.height() / 2);
+ keepRect.intersect(m_rect);
- adjustForContentsRect(coverRect);
- adjustForContentsRect(keepRect);
+ ASSERT(coverRect.isEmpty() || keepRect.contains(coverRect));
}
bool TiledBackingStore::isBackingStoreUpdatesSuspended() const
@@ -425,7 +434,7 @@ bool TiledBackingStore::isBackingStoreUpdatesSuspended() const
bool TiledBackingStore::isTileBufferUpdatesSuspended() const
{
- return m_contentsFrozen || !m_client->tiledBackingStoreUpdatesAllowed();
+ return m_contentsFrozen;
}
bool TiledBackingStore::resizeEdgeTiles()
@@ -528,6 +537,9 @@ Tile::Coordinate TiledBackingStore::tileCoordinateForPoint(const IntPoint& point
void TiledBackingStore::startTileBufferUpdateTimer()
{
+ if (!m_commitTileUpdatesOnIdleEventLoop)
+ return;
+
if (m_tileBufferUpdateTimer.isActive() || isTileBufferUpdatesSuspended())
return;
m_tileBufferUpdateTimer.startOneShot(0);
@@ -535,18 +547,23 @@ void TiledBackingStore::startTileBufferUpdateTimer()
void TiledBackingStore::tileBufferUpdateTimerFired(Timer<TiledBackingStore>*)
{
+ ASSERT(m_commitTileUpdatesOnIdleEventLoop);
updateTileBuffers();
}
-void TiledBackingStore::startBackingStoreUpdateTimer()
+void TiledBackingStore::startBackingStoreUpdateTimer(double interval)
{
+ if (!m_commitTileUpdatesOnIdleEventLoop)
+ return;
+
if (m_backingStoreUpdateTimer.isActive() || isBackingStoreUpdatesSuspended())
return;
- m_backingStoreUpdateTimer.startOneShot(0);
+ m_backingStoreUpdateTimer.startOneShot(interval);
}
void TiledBackingStore::backingStoreUpdateTimerFired(Timer<TiledBackingStore>*)
{
+ ASSERT(m_commitTileUpdatesOnIdleEventLoop);
createTiles();
}
@@ -572,7 +589,7 @@ void TiledBackingStore::setContentsFrozen(bool freeze)
void TiledBackingStore::setSupportsAlpha(bool a)
{
- if (a == supportsAlpha())
+ if (a == m_supportsAlpha)
return;
m_supportsAlpha = a;
invalidate(m_rect);
diff --git a/Source/WebCore/platform/graphics/TiledBackingStore.h b/Source/WebCore/platform/graphics/TiledBackingStore.h
index 082be70c8..6ac8da751 100644
--- a/Source/WebCore/platform/graphics/TiledBackingStore.h
+++ b/Source/WebCore/platform/graphics/TiledBackingStore.h
@@ -46,7 +46,12 @@ public:
TiledBackingStoreClient* client() { return m_client; }
- void coverWithTilesIfNeeded(const FloatPoint& panningTrajectoryVector = FloatPoint());
+ // Used when class methods cannot be called asynchronously by client.
+ // Updates of tiles are committed as soon as all the events in event queue have been processed.
+ void setCommitTileUpdatesOnIdleEventLoop(bool enable) { m_commitTileUpdatesOnIdleEventLoop = enable; }
+
+ void setTrajectoryVector(const FloatPoint&);
+ void coverWithTilesIfNeeded();
float contentsScale() { return m_contentsScale; }
void setContentsScale(float);
@@ -62,9 +67,6 @@ public:
IntSize tileSize() { return m_tileSize; }
void setTileSize(const IntSize&);
- double tileCreationDelay() const { return m_tileCreationDelay; }
- void setTileCreationDelay(double delay);
-
IntRect mapToContents(const IntRect&) const;
IntRect mapFromContents(const IntRect&) const;
@@ -77,11 +79,10 @@ public:
void removeAllNonVisibleTiles();
void setSupportsAlpha(bool);
- bool supportsAlpha() const { return m_supportsAlpha; }
private:
void startTileBufferUpdateTimer();
- void startBackingStoreUpdateTimer();
+ void startBackingStoreUpdateTimer(double = 0);
void tileBufferUpdateTimerFired(Timer<TiledBackingStore>*);
void backingStoreUpdateTimerFired(Timer<TiledBackingStore>*);
@@ -120,10 +121,10 @@ private:
Timer<TiledBackingStore> m_backingStoreUpdateTimer;
IntSize m_tileSize;
- double m_tileCreationDelay;
float m_coverAreaMultiplier;
FloatPoint m_trajectoryVector;
+ FloatPoint m_pendingTrajectoryVector;
IntRect m_visibleRect;
IntRect m_coverRect;
@@ -133,8 +134,10 @@ private:
float m_contentsScale;
float m_pendingScale;
+ bool m_commitTileUpdatesOnIdleEventLoop;
bool m_contentsFrozen;
bool m_supportsAlpha;
+ bool m_pendingTileCreation;
friend class Tile;
};
diff --git a/Source/WebCore/platform/graphics/TiledBackingStoreClient.h b/Source/WebCore/platform/graphics/TiledBackingStoreClient.h
index 0e0214777..eb9a7d932 100644
--- a/Source/WebCore/platform/graphics/TiledBackingStoreClient.h
+++ b/Source/WebCore/platform/graphics/TiledBackingStoreClient.h
@@ -33,7 +33,7 @@ public:
virtual void tiledBackingStorePaintBegin() = 0;
virtual void tiledBackingStorePaint(GraphicsContext*, const IntRect&) = 0;
virtual void tiledBackingStorePaintEnd(const Vector<IntRect>& paintedArea) = 0;
- virtual bool tiledBackingStoreUpdatesAllowed() const { return true; }
+ virtual void tiledBackingStoreHasPendingTileCreation() { }
virtual IntRect tiledBackingStoreContentsRect() = 0;
virtual IntRect tiledBackingStoreVisibleRect() = 0;
virtual Color tiledBackingStoreBackgroundColor() const = 0;
diff --git a/Source/WebCore/platform/graphics/VideoTrackPrivate.h b/Source/WebCore/platform/graphics/VideoTrackPrivate.h
new file mode 100644
index 000000000..b15168438
--- /dev/null
+++ b/Source/WebCore/platform/graphics/VideoTrackPrivate.h
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef VideoTrackPrivate_h
+#define VideoTrackPrivate_h
+
+#include <wtf/Forward.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/RefCounted.h>
+#include <wtf/text/AtomicString.h>
+
+#if ENABLE(VIDEO_TRACK)
+
+namespace WebCore {
+
+class VideoTrackPrivate;
+
+class VideoTrackPrivateClient {
+public:
+ virtual ~VideoTrackPrivateClient() { }
+ virtual void willRemoveVideoTrackPrivate(VideoTrackPrivate*) = 0;
+};
+
+class VideoTrackPrivate : public RefCounted<VideoTrackPrivate> {
+ WTF_MAKE_NONCOPYABLE(VideoTrackPrivate); WTF_MAKE_FAST_ALLOCATED;
+public:
+ static PassRefPtr<VideoTrackPrivate> create()
+ {
+ return adoptRef(new VideoTrackPrivate());
+ }
+ virtual ~VideoTrackPrivate() { }
+
+ void setClient(VideoTrackPrivateClient* client) { m_client = client; }
+ VideoTrackPrivateClient* client() { return m_client; }
+
+ virtual void setSelected(bool selected) { m_selected = selected; };
+ virtual bool selected() const { return m_selected; }
+
+ enum Kind { Alternative, Captions, Main, Sign, Subtitles, Commentary, None };
+ virtual Kind kind() const { return None; }
+
+ virtual AtomicString id() const { return emptyAtom; }
+ virtual AtomicString label() const { return emptyAtom; }
+ virtual AtomicString language() const { return emptyAtom; }
+
+ virtual int videoTrackIndex() const { return 0; }
+
+ void willBeRemoved()
+ {
+ if (m_client)
+ m_client->willRemoveVideoTrackPrivate(this);
+ }
+
+protected:
+ VideoTrackPrivate()
+ : m_selected(false)
+ {
+ }
+
+private:
+ VideoTrackPrivateClient* m_client;
+ bool m_selected;
+};
+
+} // namespace WebCore
+
+#endif
+#endif
diff --git a/Source/WebCore/platform/graphics/WidthCache.h b/Source/WebCore/platform/graphics/WidthCache.h
index 2be546d0c..1f7464ad2 100644
--- a/Source/WebCore/platform/graphics/WidthCache.h
+++ b/Source/WebCore/platform/graphics/WidthCache.h
@@ -58,6 +58,7 @@ private:
: m_length(length)
{
ASSERT(length <= s_capacity);
+
StringHasher hasher;
bool remainder = length & 1;
@@ -67,7 +68,7 @@ private:
while (length--) {
m_characters[i] = characters[i];
m_characters[i + 1] = characters[i + 1];
- hasher.addCharacters(characters[i], characters[i + 1]);
+ hasher.addCharactersAssumingAligned(characters[i], characters[i + 1]);
i += 2;
}
@@ -143,20 +144,38 @@ public:
return addSlowCase(run, entry);
}
- float* addSlowCase(const TextRun& run, float entry)
+ void clear()
{
- SmallStringKey smallStringKey;
- if (run.is8Bit())
- smallStringKey = SmallStringKey(run.characters8(), run.length());
- else
- smallStringKey = SmallStringKey(run.characters16(), run.length());
+ m_singleCharMap.clear();
+ m_map.clear();
+ }
- Map::AddResult addResult = m_map.add(smallStringKey, entry);
+private:
+ float* addSlowCase(const TextRun& run, float entry)
+ {
+ int length = run.length();
+ bool isNewEntry;
+ float *value;
+ if (length == 1) {
+ SingleCharMap::AddResult addResult = m_singleCharMap.add(run[0], entry);
+ isNewEntry = addResult.isNewEntry;
+ value = &addResult.iterator->value;
+ } else {
+ SmallStringKey smallStringKey;
+ if (run.is8Bit())
+ smallStringKey = SmallStringKey(run.characters8(), length);
+ else
+ smallStringKey = SmallStringKey(run.characters16(), length);
+
+ Map::AddResult addResult = m_map.add(smallStringKey, entry);
+ isNewEntry = addResult.isNewEntry;
+ value = &addResult.iterator->value;
+ }
// Cache hit: ramp up by sampling the next few words.
- if (!addResult.isNewEntry) {
+ if (!isNewEntry) {
m_interval = s_minInterval;
- return &addResult.iterator->value;
+ return value;
}
// Cache miss: ramp down by increasing our sampling interval.
@@ -164,23 +183,24 @@ public:
++m_interval;
m_countdown = m_interval;
- if (m_map.size() < s_maxSize)
- return &addResult.iterator->value;
+ if ((m_singleCharMap.size() + m_map.size()) < s_maxSize)
+ return value;
- m_map.clear(); // No need to be fancy: we're just trying to avoid pathological growth.
+ // No need to be fancy: we're just trying to avoid pathological growth.
+ m_singleCharMap.clear();
+ m_map.clear();
return 0;
}
- void clear() { m_map.clear(); }
-
-private:
typedef HashMap<SmallStringKey, float, SmallStringKeyHash, SmallStringKeyHashTraits> Map;
+ typedef HashMap<uint32_t, float, DefaultHash<uint32_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint32_t> > SingleCharMap;
static const int s_minInterval = -3; // A cache hit pays for about 3 cache misses.
static const int s_maxInterval = 20; // Sampling at this interval has almost no overhead.
static const int s_maxSize = 500000; // Just enough to guard against pathological growth.
int m_interval;
int m_countdown;
+ SingleCharMap m_singleCharMap;
Map m_map;
};
diff --git a/Source/WebCore/platform/graphics/WidthIterator.cpp b/Source/WebCore/platform/graphics/WidthIterator.cpp
index 7a1698d19..5fcf94969 100644
--- a/Source/WebCore/platform/graphics/WidthIterator.cpp
+++ b/Source/WebCore/platform/graphics/WidthIterator.cpp
@@ -192,8 +192,10 @@ inline unsigned WidthIterator::advanceInternal(TextIterator& textIterator, Glyph
}
if (fontData != lastFontData && width) {
- if (shouldApplyFontTransforms())
+ if (shouldApplyFontTransforms()) {
m_runWidthSoFar += applyFontTransforms(glyphBuffer, m_run.ltr(), lastGlyphCount, lastFontData, m_typesettingFeatures, charactersTreatedAsSpace);
+ lastGlyphCount = glyphBuffer->size(); // applyFontTransforms doesn't update when there had been only one glyph.
+ }
lastFontData = fontData;
if (m_fallbackFonts && fontData != primaryFont) {
@@ -227,7 +229,10 @@ inline unsigned WidthIterator::advanceInternal(TextIterator& textIterator, Glyph
m_runWidthSoFar += expansionAtThisOpportunity;
if (glyphBuffer) {
if (glyphBuffer->isEmpty()) {
- glyphBuffer->add(fontData->spaceGlyph(), fontData, expansionAtThisOpportunity);
+ if (m_forTextEmphasis)
+ glyphBuffer->add(fontData->zeroWidthSpaceGlyph(), fontData, m_expansionPerOpportunity);
+ else
+ glyphBuffer->add(fontData->spaceGlyph(), fontData, expansionAtThisOpportunity);
m_characterIndexOfGlyph.append(currentCharacterIndex);
} else
glyphBuffer->expandLastAdvance(expansionAtThisOpportunity);
@@ -253,7 +258,7 @@ inline unsigned WidthIterator::advanceInternal(TextIterator& textIterator, Glyph
if (shouldApplyFontTransforms() && glyphBuffer && Font::treatAsSpace(character))
charactersTreatedAsSpace.append(make_pair(glyphBuffer->size(),
- OriginalAdvancesForCharacterTreatedAsSpace(character == ' ', glyphBuffer->size() ? glyphBuffer->advanceAt(glyphBuffer->size() - 1) : 0, width)));
+ OriginalAdvancesForCharacterTreatedAsSpace(character == ' ', glyphBuffer->size() ? glyphBuffer->advanceAt(glyphBuffer->size() - 1).width() : 0, width)));
if (m_accountForGlyphBounds) {
bounds = fontData->boundsForGlyph(glyph);
diff --git a/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp b/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp
new file mode 100644
index 000000000..0e932e474
--- /dev/null
+++ b/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp
@@ -0,0 +1,470 @@
+/*
+ * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(VIDEO) && (USE(AVFOUNDATION) || PLATFORM(IOS))
+
+#include "InbandTextTrackPrivateAVF.h"
+
+#include "InbandTextTrackPrivateClient.h"
+#include "Logging.h"
+#include "SoftLinking.h"
+#include <CoreMedia/CoreMedia.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/text/CString.h>
+#include <wtf/text/WTFString.h>
+#include <wtf/unicode/CharacterNames.h>
+
+#if !PLATFORM(WIN)
+#define SOFT_LINK_AVF_FRAMEWORK(Lib) SOFT_LINK_FRAMEWORK_OPTIONAL(Lib)
+#define SOFT_LINK_AVF_POINTER(Lib, Name, Type) SOFT_LINK_POINTER_OPTIONAL(Lib, Name, Type)
+#else
+#define SOFT_LINK_AVF_FRAMEWORK(Lib) SOFT_LINK_LIBRARY(Lib)
+#define SOFT_LINK_AVF_POINTER(Lib, Name, Type) SOFT_LINK_VARIABLE_DLL_IMPORT_OPTIONAL(Lib, Name, Type)
+#endif
+
+SOFT_LINK_AVF_FRAMEWORK(CoreMedia)
+
+SOFT_LINK_AVF_POINTER(CoreMedia, kCMTextMarkupAttribute_Alignment, CFStringRef)
+SOFT_LINK_AVF_POINTER(CoreMedia, kCMTextMarkupAlignmentType_Start, CFStringRef)
+SOFT_LINK_AVF_POINTER(CoreMedia, kCMTextMarkupAlignmentType_Middle, CFStringRef)
+SOFT_LINK_AVF_POINTER(CoreMedia, kCMTextMarkupAlignmentType_End, CFStringRef)
+SOFT_LINK_AVF_POINTER(CoreMedia, kCMTextMarkupAttribute_BoldStyle, CFStringRef)
+SOFT_LINK_AVF_POINTER(CoreMedia, kCMTextMarkupAttribute_ItalicStyle, CFStringRef)
+SOFT_LINK_AVF_POINTER(CoreMedia, kCMTextMarkupAttribute_UnderlineStyle, CFStringRef)
+SOFT_LINK_AVF_POINTER(CoreMedia, kCMTextMarkupAttribute_TextPositionPercentageRelativeToWritingDirection, CFStringRef)
+SOFT_LINK_AVF_POINTER(CoreMedia, kCMTextMarkupAttribute_WritingDirectionSizePercentage, CFStringRef)
+SOFT_LINK_AVF_POINTER(CoreMedia, kCMTextMarkupAttribute_OrthogonalLinePositionPercentageRelativeToWritingDirection, CFStringRef)
+SOFT_LINK_AVF_POINTER(CoreMedia, kCMTextMarkupAttribute_VerticalLayout, CFStringRef)
+SOFT_LINK_AVF_POINTER(CoreMedia, kCMTextVerticalLayout_LeftToRight, CFStringRef)
+SOFT_LINK_AVF_POINTER(CoreMedia, kCMTextVerticalLayout_RightToLeft, CFStringRef)
+SOFT_LINK_AVF_POINTER(CoreMedia, kCMTextMarkupAttribute_BaseFontSizePercentageRelativeToVideoHeight, CFStringRef)
+SOFT_LINK_AVF_POINTER(CoreMedia, kCMTextMarkupAttribute_RelativeFontSize, CFStringRef)
+SOFT_LINK_AVF_POINTER(CoreMedia, kCMTextMarkupAttribute_FontFamilyName, CFStringRef)
+SOFT_LINK_AVF_POINTER(CoreMedia, kCMTextMarkupAttribute_ForegroundColorARGB, CFStringRef)
+SOFT_LINK_AVF_POINTER(CoreMedia, kCMTextMarkupAttribute_BackgroundColorARGB, CFStringRef)
+SOFT_LINK_AVF_POINTER(CoreMedia, kCMTextMarkupAttribute_CharacterBackgroundColorARGB, CFStringRef)
+
+#define kCMTextMarkupAttribute_Alignment getkCMTextMarkupAttribute_Alignment()
+#define kCMTextMarkupAlignmentType_Start getkCMTextMarkupAlignmentType_Start()
+#define kCMTextMarkupAlignmentType_Middle getkCMTextMarkupAlignmentType_Middle()
+#define kCMTextMarkupAlignmentType_End getkCMTextMarkupAlignmentType_End()
+#define kCMTextMarkupAttribute_BoldStyle getkCMTextMarkupAttribute_BoldStyle()
+#define kCMTextMarkupAttribute_ItalicStyle getkCMTextMarkupAttribute_ItalicStyle()
+#define kCMTextMarkupAttribute_UnderlineStyle getkCMTextMarkupAttribute_UnderlineStyle()
+#define kCMTextMarkupAttribute_TextPositionPercentageRelativeToWritingDirection getkCMTextMarkupAttribute_TextPositionPercentageRelativeToWritingDirection()
+#define kCMTextMarkupAttribute_WritingDirectionSizePercentage getkCMTextMarkupAttribute_WritingDirectionSizePercentage()
+#define kCMTextMarkupAttribute_OrthogonalLinePositionPercentageRelativeToWritingDirection getkCMTextMarkupAttribute_OrthogonalLinePositionPercentageRelativeToWritingDirection()
+#define kCMTextMarkupAttribute_VerticalLayout getkCMTextMarkupAttribute_VerticalLayout()
+#define kCMTextVerticalLayout_LeftToRight getkCMTextVerticalLayout_LeftToRight()
+#define kCMTextVerticalLayout_RightToLeft getkCMTextVerticalLayout_RightToLeft()
+#define kCMTextMarkupAttribute_BaseFontSizePercentageRelativeToVideoHeight getkCMTextMarkupAttribute_BaseFontSizePercentageRelativeToVideoHeight()
+#define kCMTextMarkupAttribute_RelativeFontSize getkCMTextMarkupAttribute_RelativeFontSize()
+#define kCMTextMarkupAttribute_FontFamilyName getkCMTextMarkupAttribute_FontFamilyName()
+#define kCMTextMarkupAttribute_ForegroundColorARGB getkCMTextMarkupAttribute_ForegroundColorARGB()
+#define kCMTextMarkupAttribute_BackgroundColorARGB getkCMTextMarkupAttribute_BackgroundColorARGB()
+#define kCMTextMarkupAttribute_CharacterBackgroundColorARGB getkCMTextMarkupAttribute_CharacterBackgroundColorARGB()
+
+using namespace std;
+
+namespace WebCore {
+
+AVFInbandTrackParent::~AVFInbandTrackParent()
+{
+}
+
+InbandTextTrackPrivateAVF::InbandTextTrackPrivateAVF(AVFInbandTrackParent* owner)
+ : m_owner(owner)
+ , m_pendingCueStatus(None)
+ , m_index(0)
+ , m_hasBeenReported(false)
+ , m_seeking(false)
+{
+}
+
+InbandTextTrackPrivateAVF::~InbandTextTrackPrivateAVF()
+{
+ disconnect();
+}
+
+static bool makeRGBA32FromARGBCFArray(CFArrayRef colorArray, RGBA32& color)
+{
+ if (CFArrayGetCount(colorArray) < 4)
+ return false;
+
+ float componentArray[4];
+ for (int i = 0; i < 4; i++) {
+ CFNumberRef value = static_cast<CFNumberRef>(CFArrayGetValueAtIndex(colorArray, i));
+ if (CFGetTypeID(value) != CFNumberGetTypeID())
+ return false;
+
+ float component;
+ CFNumberGetValue(value, kCFNumberFloatType, &component);
+ componentArray[i] = component;
+ }
+
+ color = makeRGBA32FromFloats(componentArray[1] * 255, componentArray[2] * 255, componentArray[3] * 255, componentArray[0] * 255);
+ return true;
+}
+
+void InbandTextTrackPrivateAVF::processCueAttributes(CFAttributedStringRef attributedString, GenericCueData* cueData)
+{
+ // Some of the attributes we translate into per-cue WebVTT settings are are repeated on each part of an attributed string so only
+ // process the first instance of each.
+ enum AttributeFlags {
+ Line = 1 << 0,
+ Position = 1 << 1,
+ Size = 1 << 2,
+ Vertical = 1 << 3,
+ Align = 1 << 4,
+ FontName = 1 << 5
+ };
+ unsigned processed = 0;
+
+ StringBuilder content;
+ String attributedStringValue = CFAttributedStringGetString(attributedString);
+ CFIndex length = attributedStringValue.length();
+ if (!length)
+ return;
+
+ CFRange effectiveRange = CFRangeMake(0, 0);
+ while ((effectiveRange.location + effectiveRange.length) < length) {
+
+ CFDictionaryRef attributes = CFAttributedStringGetAttributes(attributedString, effectiveRange.location + effectiveRange.length, &effectiveRange);
+ if (!attributes)
+ continue;
+
+ StringBuilder tagStart;
+ CFStringRef valueString;
+ String tagEnd;
+ CFIndex attributeCount = CFDictionaryGetCount(attributes);
+ Vector<const void*> keys(attributeCount);
+ Vector<const void*> values(attributeCount);
+ CFDictionaryGetKeysAndValues(attributes, keys.data(), values.data());
+
+ for (CFIndex i = 0; i < attributeCount; ++i) {
+ CFStringRef key = static_cast<CFStringRef>(keys[i]);
+ CFTypeRef value = values[i];
+ if (CFGetTypeID(key) != CFStringGetTypeID() || !CFStringGetLength(key))
+ continue;
+
+ if (CFStringCompare(key, kCMTextMarkupAttribute_Alignment, 0) == kCFCompareEqualTo) {
+ valueString = static_cast<CFStringRef>(value);
+ if (CFGetTypeID(valueString) != CFStringGetTypeID() || !CFStringGetLength(valueString))
+ continue;
+ if (processed & Align)
+ continue;
+ processed |= Align;
+
+ if (CFStringCompare(valueString, kCMTextMarkupAlignmentType_Start, 0) == kCFCompareEqualTo)
+ cueData->setAlign(GenericCueData::Start);
+ else if (CFStringCompare(valueString, kCMTextMarkupAlignmentType_Middle, 0) == kCFCompareEqualTo)
+ cueData->setAlign(GenericCueData::Middle);
+ else if (CFStringCompare(valueString, kCMTextMarkupAlignmentType_End, 0) == kCFCompareEqualTo)
+ cueData->setAlign(GenericCueData::End);
+ else
+ ASSERT_NOT_REACHED();
+
+ continue;
+ }
+
+ if (CFStringCompare(key, kCMTextMarkupAttribute_BoldStyle, 0) == kCFCompareEqualTo) {
+ if (static_cast<CFBooleanRef>(value) != kCFBooleanTrue)
+ continue;
+
+ tagStart.append("<b>");
+ tagEnd.insert("</b>", 0);
+ continue;
+ }
+
+ if (CFStringCompare(key, kCMTextMarkupAttribute_ItalicStyle, 0) == kCFCompareEqualTo) {
+ if (static_cast<CFBooleanRef>(value) != kCFBooleanTrue)
+ continue;
+
+ tagStart.append("<i>");
+ tagEnd.insert("</i>", 0);
+ continue;
+ }
+
+ if (CFStringCompare(key, kCMTextMarkupAttribute_UnderlineStyle, 0) == kCFCompareEqualTo) {
+ if (static_cast<CFBooleanRef>(value) != kCFBooleanTrue)
+ continue;
+
+ tagStart.append("<u>");
+ tagEnd.insert("</u>", 0);
+ continue;
+ }
+
+ if (CFStringCompare(key, kCMTextMarkupAttribute_OrthogonalLinePositionPercentageRelativeToWritingDirection, 0) == kCFCompareEqualTo) {
+ if (CFGetTypeID(value) != CFNumberGetTypeID())
+ continue;
+ if (processed & Line)
+ continue;
+ processed |= Line;
+
+ CFNumberRef valueNumber = static_cast<CFNumberRef>(value);
+ double line;
+ CFNumberGetValue(valueNumber, kCFNumberFloat64Type, &line);
+ cueData->setLine(line);
+ continue;
+ }
+
+ if (CFStringCompare(key, kCMTextMarkupAttribute_TextPositionPercentageRelativeToWritingDirection, 0) == kCFCompareEqualTo) {
+ if (CFGetTypeID(value) != CFNumberGetTypeID())
+ continue;
+ if (processed & Position)
+ continue;
+ processed |= Position;
+
+ CFNumberRef valueNumber = static_cast<CFNumberRef>(value);
+ double position;
+ CFNumberGetValue(valueNumber, kCFNumberFloat64Type, &position);
+ cueData->setPosition(position);
+ continue;
+ }
+
+ if (CFStringCompare(key, kCMTextMarkupAttribute_WritingDirectionSizePercentage, 0) == kCFCompareEqualTo) {
+ if (CFGetTypeID(value) != CFNumberGetTypeID())
+ continue;
+ if (processed & Size)
+ continue;
+ processed |= Size;
+
+ CFNumberRef valueNumber = static_cast<CFNumberRef>(value);
+ double size;
+ CFNumberGetValue(valueNumber, kCFNumberFloat64Type, &size);
+ cueData->setSize(size);
+ continue;
+ }
+
+ if (CFStringCompare(key, kCMTextMarkupAttribute_VerticalLayout, 0) == kCFCompareEqualTo) {
+ valueString = static_cast<CFStringRef>(value);
+ if (CFGetTypeID(valueString) != CFStringGetTypeID() || !CFStringGetLength(valueString))
+ continue;
+
+ if (CFStringCompare(valueString, kCMTextVerticalLayout_LeftToRight, 0) == kCFCompareEqualTo)
+ tagStart.append(leftToRightMark);
+ else if (CFStringCompare(valueString, kCMTextVerticalLayout_RightToLeft, 0) == kCFCompareEqualTo)
+ tagStart.append(rightToLeftMark);
+ continue;
+ }
+
+ if (CFStringCompare(key, kCMTextMarkupAttribute_BaseFontSizePercentageRelativeToVideoHeight, 0) == kCFCompareEqualTo) {
+ if (CFGetTypeID(value) != CFNumberGetTypeID())
+ continue;
+
+ CFNumberRef valueNumber = static_cast<CFNumberRef>(value);
+ double baseFontSize;
+ CFNumberGetValue(valueNumber, kCFNumberFloat64Type, &baseFontSize);
+ cueData->setBaseFontSize(baseFontSize);
+ continue;
+ }
+
+ if (CFStringCompare(key, kCMTextMarkupAttribute_RelativeFontSize, 0) == kCFCompareEqualTo) {
+ if (CFGetTypeID(value) != CFNumberGetTypeID())
+ continue;
+
+ CFNumberRef valueNumber = static_cast<CFNumberRef>(value);
+ double relativeFontSize;
+ CFNumberGetValue(valueNumber, kCFNumberFloat64Type, &relativeFontSize);
+ cueData->setRelativeFontSize(relativeFontSize);
+ continue;
+ }
+
+ if (CFStringCompare(key, kCMTextMarkupAttribute_FontFamilyName, 0) == kCFCompareEqualTo) {
+ valueString = static_cast<CFStringRef>(value);
+ if (CFGetTypeID(valueString) != CFStringGetTypeID() || !CFStringGetLength(valueString))
+ continue;
+ if (processed & FontName)
+ continue;
+ processed |= FontName;
+
+ cueData->setFontName(valueString);
+ continue;
+ }
+
+ if (CFStringCompare(key, kCMTextMarkupAttribute_ForegroundColorARGB, 0) == kCFCompareEqualTo) {
+ CFArrayRef arrayValue = static_cast<CFArrayRef>(value);
+ if (CFGetTypeID(arrayValue) != CFArrayGetTypeID())
+ continue;
+
+ RGBA32 color;
+ if (!makeRGBA32FromARGBCFArray(arrayValue, color))
+ continue;
+ cueData->setForegroundColor(color);
+ }
+
+ if (CFStringCompare(key, kCMTextMarkupAttribute_BackgroundColorARGB, 0) == kCFCompareEqualTo) {
+ CFArrayRef arrayValue = static_cast<CFArrayRef>(value);
+ if (CFGetTypeID(arrayValue) != CFArrayGetTypeID())
+ continue;
+
+ RGBA32 color;
+ if (!makeRGBA32FromARGBCFArray(arrayValue, color))
+ continue;
+ cueData->setBackgroundColor(color);
+ }
+
+ if (CFStringCompare(key, kCMTextMarkupAttribute_CharacterBackgroundColorARGB, 0) == kCFCompareEqualTo) {
+ CFArrayRef arrayValue = static_cast<CFArrayRef>(value);
+ if (CFGetTypeID(arrayValue) != CFArrayGetTypeID())
+ continue;
+
+ RGBA32 color;
+ if (!makeRGBA32FromARGBCFArray(arrayValue, color))
+ continue;
+ cueData->setHighlightColor(color);
+ }
+ }
+
+ content.append(tagStart);
+ content.append(attributedStringValue.substring(effectiveRange.location, effectiveRange.length));
+ content.append(tagEnd);
+ }
+
+ if (content.length())
+ cueData->setContent(content.toString());
+}
+
+void InbandTextTrackPrivateAVF::processCue(CFArrayRef attributedStrings, double time)
+{
+ if (!client())
+ return;
+
+ LOG(Media, "InbandTextTrackPrivateAVF::processCue - %li cues at time %.2f\n", attributedStrings ? CFArrayGetCount(attributedStrings) : 0, time);
+
+ if (m_pendingCueStatus != None) {
+ // Cues do not have an explicit duration, they are displayed until the next "cue" (which might be empty) is emitted.
+ m_currentCueEndTime = time;
+
+ if (m_currentCueEndTime >= m_currentCueStartTime) {
+ for (size_t i = 0; i < m_cues.size(); i++) {
+ GenericCueData* cueData = m_cues[i].get();
+
+ if (m_pendingCueStatus == Valid) {
+ cueData->setEndTime(m_currentCueEndTime);
+ cueData->setStatus(GenericCueData::Complete);
+
+ LOG(Media, "InbandTextTrackPrivateAVF::processCue(%p) - updating cue: start=%.2f, end=%.2f, content=\"%s\"", this, cueData->startTime(), m_currentCueEndTime, cueData->content().utf8().data());
+ client()->updateGenericCue(this, cueData);
+ } else {
+ // We have to assume that the implicit duration is invalid for cues delivered during a seek because the AVF decode pipeline may not
+ // see every cue, so DO NOT update cue duration while seeking.
+ LOG(Media, "InbandTextTrackPrivateAVF::processCue(%p) - ignoring cue delivered during seek: start=%.2f, end=%.2f, content=\"%s\"", this, cueData->startTime(), m_currentCueEndTime, cueData->content().utf8().data());
+ }
+ }
+ } else
+ LOG(Media, "InbandTextTrackPrivateAVF::processCue negative length cue(s) ignored: start=%.2f, end=%.2f\n", m_currentCueStartTime, m_currentCueEndTime);
+
+ resetCueValues();
+ }
+
+ if (!attributedStrings)
+ return;
+
+ CFIndex count = CFArrayGetCount(attributedStrings);
+ if (!count)
+ return;
+
+ for (CFIndex i = 0; i < count; i++) {
+ CFAttributedStringRef attributedString = static_cast<CFAttributedStringRef>(CFArrayGetValueAtIndex(attributedStrings, i));
+
+ if (!attributedString || !CFAttributedStringGetLength(attributedString))
+ continue;
+
+ RefPtr<GenericCueData> cueData = GenericCueData::create();
+ processCueAttributes(attributedString, cueData.get());
+ if (!cueData->content().length())
+ continue;
+
+ m_cues.append(cueData);
+
+ m_currentCueStartTime = time;
+ cueData->setStartTime(m_currentCueStartTime);
+ cueData->setEndTime(numeric_limits<double>::infinity());
+
+ // AVFoundation cue "position" is to the center of the text so adjust relative to the edge because we will use it to
+ // set CSS "left".
+ if (cueData->position() >= 0 && cueData->size() > 0)
+ cueData->setPosition(cueData->position() - cueData->size() / 2);
+
+ LOG(Media, "InbandTextTrackPrivateAVF::processCue(%p) - adding cue for time = %.2f, position = %.2f, line = %.2f", this, cueData->startTime(), cueData->position(), cueData->line());
+
+ cueData->setStatus(GenericCueData::Partial);
+ client()->addGenericCue(this, cueData.release());
+
+ m_pendingCueStatus = seeking() ? DeliveredDuringSeek : Valid;
+ }
+}
+
+void InbandTextTrackPrivateAVF::beginSeeking()
+{
+ // Forget any partially accumulated cue data as the seek could be to a time outside of the cue's
+ // range, which will mean that the next cue delivered will result in the current cue getting the
+ // incorrect duration.
+ resetCueValues();
+ m_seeking = true;
+}
+
+void InbandTextTrackPrivateAVF::disconnect()
+{
+ m_owner = 0;
+ m_index = 0;
+}
+
+void InbandTextTrackPrivateAVF::resetCueValues()
+{
+ if (m_currentCueEndTime && m_cues.size())
+ LOG(Media, "InbandTextTrackPrivateAVF::resetCueValues flushing data for cues: start=%.2f\n", m_currentCueStartTime);
+
+ if (client()) {
+ for (size_t i = 0; i < m_cues.size(); i++)
+ client()->removeGenericCue(this, m_cues[i].get());
+ }
+
+ m_cues.resize(0);
+ m_pendingCueStatus = None;
+ m_currentCueStartTime = 0;
+ m_currentCueEndTime = 0;
+}
+
+void InbandTextTrackPrivateAVF::setMode(InbandTextTrackPrivate::Mode newMode)
+{
+ if (!m_owner)
+ return;
+
+ InbandTextTrackPrivate::Mode oldMode = mode();
+ InbandTextTrackPrivate::setMode(newMode);
+
+ if (oldMode == newMode)
+ return;
+
+ m_owner->trackModeChanged();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(VIDEO) && (USE(AVFOUNDATION) || PLATFORM(IOS))
diff --git a/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.h b/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.h
new file mode 100644
index 000000000..838bc26ea
--- /dev/null
+++ b/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.h
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef InbandTextTrackPrivateAVF_h
+#define InbandTextTrackPrivateAVF_h
+
+#if ENABLE(VIDEO) && (USE(AVFOUNDATION) || PLATFORM(IOS))
+
+#include "InbandTextTrackPrivate.h"
+#include "InbandTextTrackPrivateClient.h"
+#include <wtf/text/StringBuilder.h>
+
+namespace WebCore {
+
+class AVFInbandTrackParent {
+public:
+ virtual ~AVFInbandTrackParent();
+
+ virtual void trackModeChanged() = 0;
+};
+
+class InbandTextTrackPrivateAVF : public InbandTextTrackPrivate {
+public:
+
+ ~InbandTextTrackPrivateAVF();
+
+ virtual void setMode(InbandTextTrackPrivate::Mode) OVERRIDE;
+
+ virtual int textTrackIndex() const OVERRIDE { return m_index; }
+ void setTextTrackIndex(int index) { m_index = index; }
+
+ virtual void disconnect();
+
+ bool hasBeenReported() const { return m_hasBeenReported; }
+ void setHasBeenReported(bool reported) { m_hasBeenReported = reported; }
+
+ void processCue(CFArrayRef, double);
+ void resetCueValues();
+
+ void beginSeeking();
+ void endSeeking() { m_seeking = false; }
+ bool seeking() const { return m_seeking; }
+
+ virtual bool isLegacyClosedCaptionsTrack() const = 0;
+
+protected:
+ InbandTextTrackPrivateAVF(AVFInbandTrackParent*);
+
+ void processCueAttributes(CFAttributedStringRef, GenericCueData*);
+
+ double m_currentCueStartTime;
+ double m_currentCueEndTime;
+
+ Vector<RefPtr<GenericCueData> > m_cues;
+ AVFInbandTrackParent* m_owner;
+
+ enum PendingCueStatus {
+ None,
+ DeliveredDuringSeek,
+ Valid
+ };
+ PendingCueStatus m_pendingCueStatus;
+
+ int m_index;
+ bool m_hasBeenReported;
+ bool m_seeking;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(VIDEO) && (USE(AVFOUNDATION) || PLATFORM(IOS))
+
+#endif // InbandTextTrackPrivateAVF_h
diff --git a/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp b/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp
index 8ee5baf59..f0248ac0f 100644
--- a/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp
+++ b/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -33,6 +33,8 @@
#include "Frame.h"
#include "FrameView.h"
#include "GraphicsContext.h"
+#include "InbandTextTrackPrivateAVF.h"
+#include "InbandTextTrackPrivateClient.h"
#include "KURL.h"
#include "Logging.h"
#include "PlatformLayer.h"
@@ -40,7 +42,6 @@
#include "TimeRanges.h"
#include <CoreMedia/CoreMedia.h>
#include <wtf/MainThread.h>
-#include <wtf/UnusedParam.h>
using namespace std;
@@ -55,6 +56,7 @@ MediaPlayerPrivateAVFoundation::MediaPlayerPrivateAVFoundation(MediaPlayer* play
, m_preload(MediaPlayer::Auto)
, m_cachedMaxTimeLoaded(0)
, m_cachedMaxTimeSeekable(0)
+ , m_cachedMinTimeSeekable(0)
, m_cachedDuration(MediaPlayer::invalidTime())
, m_reportedDuration(MediaPlayer::invalidTime())
, m_maxTimeLoadedAtLastDidLoadingProgress(MediaPlayer::invalidTime())
@@ -72,6 +74,8 @@ MediaPlayerPrivateAVFoundation::MediaPlayerPrivateAVFoundation(MediaPlayer* play
, m_ignoreLoadStateChanges(false)
, m_haveReportedFirstVideoFrame(false)
, m_playWhenFramesAvailable(false)
+ , m_inbandTrackConfigurationPending(false)
+ , m_seekCount(0)
{
LOG(Media, "MediaPlayerPrivateAVFoundation::MediaPlayerPrivateAVFoundation(%p)", this);
}
@@ -261,9 +265,13 @@ void MediaPlayerPrivateAVFoundation::seek(float time)
if (currentTime() == time)
return;
+ if (currentTrack())
+ currentTrack()->beginSeeking();
+
LOG(Media, "MediaPlayerPrivateAVFoundation::seek(%p) - seeking to %f", this, time);
m_seekTo = time;
+ ++m_seekCount;
seekToTime(time);
}
@@ -348,7 +356,7 @@ PassRefPtr<TimeRanges> MediaPlayerPrivateAVFoundation::buffered() const
return m_cachedLoadedTimeRanges->copy();
}
-float MediaPlayerPrivateAVFoundation::maxTimeSeekable() const
+double MediaPlayerPrivateAVFoundation::maxTimeSeekableDouble() const
{
if (!metaDataAvailable())
return 0;
@@ -360,6 +368,18 @@ float MediaPlayerPrivateAVFoundation::maxTimeSeekable() const
return m_cachedMaxTimeSeekable;
}
+double MediaPlayerPrivateAVFoundation::minTimeSeekable() const
+{
+ if (!metaDataAvailable())
+ return 0;
+
+ if (!m_cachedMinTimeSeekable)
+ m_cachedMinTimeSeekable = platformMinTimeSeekable();
+
+ LOG(Media, "MediaPlayerPrivateAVFoundation::minTimeSeekable(%p) - returning %f", this, m_cachedMinTimeSeekable);
+ return m_cachedMinTimeSeekable;
+}
+
float MediaPlayerPrivateAVFoundation::maxTimeLoaded() const
{
if (!metaDataAvailable())
@@ -378,7 +398,7 @@ bool MediaPlayerPrivateAVFoundation::didLoadingProgress() const
float currentMaxTimeLoaded = maxTimeLoaded();
bool didLoadingProgress = currentMaxTimeLoaded != m_maxTimeLoadedAtLastDidLoadingProgress;
m_maxTimeLoadedAtLastDidLoadingProgress = currentMaxTimeLoaded;
- LOG(Media, "MediaPlayerPrivateAVFoundation::didLoadingProgress(%p) - returning %d", this, didLoadingProgress);
+
return didLoadingProgress;
}
@@ -420,9 +440,6 @@ void MediaPlayerPrivateAVFoundation::updateStates()
MediaPlayer::NetworkState oldNetworkState = m_networkState;
MediaPlayer::ReadyState oldReadyState = m_readyState;
- LOG(Media, "MediaPlayerPrivateAVFoundation::updateStates(%p) - entering with networkState = %i, readyState = %i",
- this, static_cast<int>(m_networkState), static_cast<int>(m_readyState));
-
if (m_loadingMetadata)
m_networkState = MediaPlayer::Loading;
else {
@@ -509,8 +526,12 @@ void MediaPlayerPrivateAVFoundation::updateStates()
platformPlay();
}
- LOG(Media, "MediaPlayerPrivateAVFoundation::updateStates(%p) - exiting with networkState = %i, readyState = %i",
- this, static_cast<int>(m_networkState), static_cast<int>(m_readyState));
+#if !LOG_DISABLED
+ if (m_networkState != oldNetworkState || oldReadyState != m_readyState) {
+ LOG(Media, "MediaPlayerPrivateAVFoundation::updateStates(%p) - entered with networkState = %i, readyState = %i, exiting with networkState = %i, readyState = %i",
+ this, static_cast<int>(oldNetworkState), static_cast<int>(oldReadyState), static_cast<int>(m_networkState), static_cast<int>(m_readyState));
+ }
+#endif
}
void MediaPlayerPrivateAVFoundation::setSize(const IntSize&)
@@ -556,6 +577,7 @@ void MediaPlayerPrivateAVFoundation::loadedTimeRangesChanged()
void MediaPlayerPrivateAVFoundation::seekableTimeRangesChanged()
{
m_cachedMaxTimeSeekable = 0;
+ m_cachedMinTimeSeekable = 0;
}
void MediaPlayerPrivateAVFoundation::timeChanged(double time)
@@ -568,7 +590,14 @@ void MediaPlayerPrivateAVFoundation::seekCompleted(bool finished)
{
LOG(Media, "MediaPlayerPrivateAVFoundation::seekCompleted(%p) - finished = %d", this, finished);
UNUSED_PARAM(finished);
-
+
+ ASSERT(m_seekCount);
+ if (--m_seekCount)
+ return;
+
+ if (currentTrack())
+ currentTrack()->endSeeking();
+
m_seekTo = MediaPlayer::invalidTime();
updateStates();
m_player->timeChanged();
@@ -677,9 +706,22 @@ void MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification(Notification
scheduleMainThreadNotification(Notification(type, finished));
}
+#if !LOG_DISABLED
+static const char* notificationName(MediaPlayerPrivateAVFoundation::Notification& notification)
+{
+#define DEFINE_TYPE_STRING_CASE(type) case MediaPlayerPrivateAVFoundation::Notification::type: return #type;
+ switch (notification.type()) {
+ FOR_EACH_MEDIAPLAYERPRIVATEAVFOUNDATION_NOTIFICATION_TYPE(DEFINE_TYPE_STRING_CASE)
+ default: return "";
+ }
+#undef DEFINE_TYPE_STRING_CASE
+}
+#endif // !LOG_DISABLED
+
+
void MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification(Notification notification)
{
- LOG(Media, "MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification(%p) - notification %d", this, static_cast<int>(notification.type()));
+ LOG(Media, "MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification(%p) - notification %s", this, notificationName(notification));
m_queueMutex.lock();
// It is important to always process the properties in the order that we are notified,
@@ -726,7 +768,7 @@ void MediaPlayerPrivateAVFoundation::dispatchNotification()
return;
}
- LOG(Media, "MediaPlayerPrivateAVFoundation::dispatchNotification(%p) - dispatching %d", this, static_cast<int>(notification.type()));
+ LOG(Media, "MediaPlayerPrivateAVFoundation::dispatchNotification(%p) - dispatching %s", this, notificationName(notification));
switch (notification.type()) {
case Notification::ItemDidPlayToEndTime:
@@ -784,6 +826,10 @@ void MediaPlayerPrivateAVFoundation::dispatchNotification()
case Notification::ContentsNeedsDisplay:
contentsNeedsDisplay();
break;
+ case Notification::InbandTracksNeedConfiguration:
+ m_inbandTrackConfigurationPending = false;
+ configureInbandTracks();
+ break;
case Notification::None:
ASSERT_NOT_REACHED();
@@ -791,6 +837,77 @@ void MediaPlayerPrivateAVFoundation::dispatchNotification()
}
}
+void MediaPlayerPrivateAVFoundation::configureInbandTracks()
+{
+ RefPtr<InbandTextTrackPrivateAVF> trackToEnable;
+
+ // AVFoundation can only emit cues for one track at a time, so enable the first track that is showing, or the first that
+ // is hidden if none are showing. Otherwise disable all tracks.
+ for (unsigned i = 0; i < m_textTracks.size(); ++i) {
+ RefPtr<InbandTextTrackPrivateAVF> track = m_textTracks[i];
+ if (track->mode() == InbandTextTrackPrivate::Showing) {
+ trackToEnable = track;
+ break;
+ }
+ if (track->mode() == InbandTextTrackPrivate::Hidden)
+ trackToEnable = track;
+ }
+
+ setCurrentTrack(trackToEnable.get());
+}
+
+void MediaPlayerPrivateAVFoundation::trackModeChanged()
+{
+ if (m_inbandTrackConfigurationPending)
+ return;
+ m_inbandTrackConfigurationPending = true;
+ scheduleMainThreadNotification(Notification::InbandTracksNeedConfiguration);
+}
+
+size_t MediaPlayerPrivateAVFoundation::extraMemoryCost() const
+{
+ double duration = this->duration();
+ if (!duration)
+ return 0;
+
+ return totalBytes() * buffered()->totalDuration() / duration;
+}
+
+void MediaPlayerPrivateAVFoundation::clearTextTracks()
+{
+ for (unsigned i = 0; i < m_textTracks.size(); ++i) {
+ RefPtr<InbandTextTrackPrivateAVF> track = m_textTracks[i];
+ player()->removeTextTrack(track);
+ track->disconnect();
+ }
+ m_textTracks.clear();
+}
+
+void MediaPlayerPrivateAVFoundation::processNewAndRemovedTextTracks(const Vector<RefPtr<InbandTextTrackPrivateAVF> >& removedTextTracks)
+{
+ if (removedTextTracks.size()) {
+ for (unsigned i = 0; i < m_textTracks.size(); ++i) {
+ if (!removedTextTracks.contains(m_textTracks[i]))
+ continue;
+
+ player()->removeTextTrack(removedTextTracks[i].get());
+ m_textTracks.remove(i);
+ }
+ }
+
+ for (unsigned i = 0; i < m_textTracks.size(); ++i) {
+ RefPtr<InbandTextTrackPrivateAVF> track = m_textTracks[i];
+
+ track->setTextTrackIndex(i);
+ if (track->hasBeenReported())
+ continue;
+
+ track->setHasBeenReported(true);
+ player()->addTextTrack(track.get());
+ }
+ LOG(Media, "MediaPlayerPrivateAVFoundation::processNewAndRemovedTextTracks(%p) - found %lu text tracks", this, m_textTracks.size());
+}
+
} // namespace WebCore
#endif
diff --git a/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h b/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h
index b7c3b39af..d9d717807 100644
--- a/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h
+++ b/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2012, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -29,13 +29,18 @@
#if ENABLE(VIDEO) && USE(AVFOUNDATION)
#include "FloatSize.h"
+#include "InbandTextTrackPrivateAVF.h"
#include "MediaPlayerPrivate.h"
#include "Timer.h"
#include <wtf/RetainPtr.h>
namespace WebCore {
-class MediaPlayerPrivateAVFoundation : public MediaPlayerPrivateInterface {
+class InbandTextTrackPrivateAVF;
+class GenericCueData;
+
+class MediaPlayerPrivateAVFoundation : public MediaPlayerPrivateInterface, public AVFInbandTrackParent
+{
public:
virtual void repaint();
@@ -48,27 +53,36 @@ public:
virtual void seekCompleted(bool);
virtual void didEnd();
virtual void contentsNeedsDisplay() { }
+ virtual void configureInbandTracks();
+ virtual void setCurrentTrack(InbandTextTrackPrivateAVF*) { }
+ virtual InbandTextTrackPrivateAVF* currentTrack() const = 0;
class Notification {
public:
+#define FOR_EACH_MEDIAPLAYERPRIVATEAVFOUNDATION_NOTIFICATION_TYPE(macro) \
+ macro(None) \
+ macro(ItemDidPlayToEndTime) \
+ macro(ItemTracksChanged) \
+ macro(ItemStatusChanged) \
+ macro(ItemSeekableTimeRangesChanged) \
+ macro(ItemLoadedTimeRangesChanged) \
+ macro(ItemPresentationSizeChanged) \
+ macro(ItemIsPlaybackLikelyToKeepUpChanged) \
+ macro(ItemIsPlaybackBufferEmptyChanged) \
+ macro(ItemIsPlaybackBufferFullChanged) \
+ macro(AssetMetadataLoaded) \
+ macro(AssetPlayabilityKnown) \
+ macro(PlayerRateChanged) \
+ macro(PlayerTimeChanged) \
+ macro(SeekCompleted) \
+ macro(DurationChanged) \
+ macro(ContentsNeedsDisplay) \
+ macro(InbandTracksNeedConfiguration) \
+
enum Type {
- None,
- ItemDidPlayToEndTime,
- ItemTracksChanged,
- ItemStatusChanged,
- ItemSeekableTimeRangesChanged,
- ItemLoadedTimeRangesChanged,
- ItemPresentationSizeChanged,
- ItemIsPlaybackLikelyToKeepUpChanged,
- ItemIsPlaybackBufferEmptyChanged,
- ItemIsPlaybackBufferFullChanged,
- AssetMetadataLoaded,
- AssetPlayabilityKnown,
- PlayerRateChanged,
- PlayerTimeChanged,
- SeekCompleted,
- DurationChanged,
- ContentsNeedsDisplay,
+#define DEFINE_TYPE_ENUM(type) type,
+ FOR_EACH_MEDIAPLAYERPRIVATEAVFOUNDATION_NOTIFICATION_TYPE(DEFINE_TYPE_ENUM)
+#undef DEFINE_TYPE_ENUM
};
Notification()
@@ -86,9 +100,9 @@ public:
}
Notification(Type type, bool finished)
- : m_type(type)
- , m_time(0)
- , m_finished(finished)
+ : m_type(type)
+ , m_time(0)
+ , m_finished(finished)
{
}
@@ -138,7 +152,8 @@ protected:
virtual void setClosedCaptionsVisible(bool) = 0;
virtual MediaPlayer::NetworkState networkState() const { return m_networkState; }
virtual MediaPlayer::ReadyState readyState() const { return m_readyState; }
- virtual float maxTimeSeekable() const;
+ virtual double maxTimeSeekableDouble() const;
+ virtual double minTimeSeekable() const;
virtual PassRefPtr<TimeRanges> buffered() const;
virtual bool didLoadingProgress() const;
virtual void setSize(const IntSize&);
@@ -190,10 +205,11 @@ protected:
virtual void checkPlayability() = 0;
virtual void updateRate() = 0;
virtual float rate() const = 0;
- virtual void seekToTime(float time) = 0;
+ virtual void seekToTime(double time) = 0;
virtual unsigned totalBytes() const = 0;
virtual PassRefPtr<TimeRanges> platformBufferedTimeRanges() const = 0;
- virtual float platformMaxTimeSeekable() const = 0;
+ virtual double platformMaxTimeSeekable() const = 0;
+ virtual double platformMinTimeSeekable() const = 0;
virtual float platformMaxTimeLoaded() const = 0;
virtual float platformDuration() const = 0;
@@ -221,7 +237,7 @@ protected:
void setDelayCallbacks(bool) const;
void setIgnoreLoadStateChanges(bool delay) { m_ignoreLoadStateChanges = delay; }
void setNaturalSize(IntSize);
- bool isLiveStream() const { return isinf(duration()); }
+ bool isLiveStream() const { return std::isinf(duration()); }
enum MediaRenderingMode { MediaRenderingNone, MediaRenderingToContext, MediaRenderingToLayer };
MediaRenderingMode currentRenderingMode() const;
@@ -245,6 +261,13 @@ protected:
virtual String engineDescription() const { return "AVFoundation"; }
+ virtual size_t extraMemoryCost() const OVERRIDE;
+
+ virtual void trackModeChanged() OVERRIDE;
+ void processNewAndRemovedTextTracks(const Vector<RefPtr<InbandTextTrackPrivateAVF> >&);
+ void clearTextTracks();
+ Vector<RefPtr<InbandTextTrackPrivateAVF> > m_textTracks;
+
private:
MediaPlayer* m_player;
@@ -261,11 +284,12 @@ private:
IntSize m_cachedNaturalSize;
mutable float m_cachedMaxTimeLoaded;
- mutable float m_cachedMaxTimeSeekable;
+ mutable double m_cachedMaxTimeSeekable;
+ mutable double m_cachedMinTimeSeekable;
mutable float m_cachedDuration;
float m_reportedDuration;
mutable float m_maxTimeLoadedAtLastDidLoadingProgress;
- float m_seekTo;
+ double m_seekTo;
float m_requestedRate;
mutable int m_delayCallbacks;
bool m_mainThreadCallPending;
@@ -279,6 +303,8 @@ private:
bool m_ignoreLoadStateChanges;
bool m_haveReportedFirstVideoFrame;
bool m_playWhenFramesAvailable;
+ bool m_inbandTrackConfigurationPending;
+ size_t m_seekCount;
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/avfoundation/cf/AVFoundationCFSoftLinking.h b/Source/WebCore/platform/graphics/avfoundation/cf/AVFoundationCFSoftLinking.h
index 95b9403bf..a3becdc72 100644
--- a/Source/WebCore/platform/graphics/avfoundation/cf/AVFoundationCFSoftLinking.h
+++ b/Source/WebCore/platform/graphics/avfoundation/cf/AVFoundationCFSoftLinking.h
@@ -42,6 +42,9 @@ SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFAssetCancelLoading, void, __cdecl, (AVC
SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFAssetCopyAssetTracks, CFArrayRef, __cdecl, (AVCFAssetRef asset), (asset))
#define AVCFAssetCopyAssetTracks softLink_AVCFAssetCopyAssetTracks
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFAssetCopyAvailableMediaCharacteristicsWithMediaSelectionOptions, CFArrayRef, __cdecl, (AVCFAssetRef asset), (asset))
+#define AVCFAssetCopyAvailableMediaCharacteristicsWithMediaSelectionOptions softLink_AVCFAssetCopyAvailableMediaCharacteristicsWithMediaSelectionOptions
+
SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFAssetCopyTracksWithMediaCharacteristic, CFArrayRef, __cdecl, (AVCFAssetRef asset, CFStringRef mediaCharacteristic), (asset, mediaCharacteristic))
#define AVCFAssetCopyTracksWithMediaCharacteristic softLink_AVCFAssetCopyTracksWithMediaCharacteristic
@@ -87,6 +90,15 @@ SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFAssetIsPlayable, Boolean, __cdecl, (AVC
SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFAssetLoadValuesAsynchronouslyForProperties, void, __cdecl, (AVCFAssetRef asset, CFArrayRef properties, AVCFAssetLoadValuesCompletionCallback callback, void *clientContext), (asset, properties, callback, clientContext))
#define AVCFAssetLoadValuesAsynchronouslyForProperties softLink_AVCFAssetLoadValuesAsynchronouslyForProperties
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFAssetTrackCopyCommonMetadata, CFArrayRef, __cdecl, (AVCFAssetTrackRef assetTrack), (assetTrack))
+#define AVCFAssetTrackCopyCommonMetadata softLink_AVCFAssetTrackCopyCommonMetadata
+
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFAssetTrackCopyExtendedLanguageTag, CFStringRef, __cdecl, (AVCFAssetTrackRef assetTrack), (assetTrack))
+#define AVCFAssetTrackCopyExtendedLanguageTag softLink_AVCFAssetTrackCopyExtendedLanguageTag
+
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFAssetTrackCopyLanguageCode, CFStringRef, __cdecl, (AVCFAssetTrackRef assetTrack), (assetTrack))
+#define AVCFAssetTrackCopyLanguageCode softLink_AVCFAssetTrackCopyLanguageCode
+
SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFAssetTrackGetMediaType, CFStringRef, __cdecl, (AVCFAssetTrackRef assetTrack), (assetTrack))
#define AVCFAssetTrackGetMediaType softLink_AVCFAssetTrackGetMediaType
@@ -99,6 +111,18 @@ SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFAssetTrackGetPreferredTransform, CGAffi
SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFAssetTrackGetTotalSampleDataLength, int64_t, __cdecl, (AVCFAssetTrackRef assetTrack), (assetTrack))
#define AVCFAssetTrackGetTotalSampleDataLength softLink_AVCFAssetTrackGetTotalSampleDataLength
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFMediaSelectionCopyOptionsFromArrayFilteredAndSortedAccordingToPreferredLanguages, CFArrayRef, __cdecl, (CFArrayRef selectionOptions, CFArrayRef preferredLanguages), (selectionOptions, preferredLanguages))
+#define AVCFMediaSelectionCopyOptionsFromArrayFilteredAndSortedAccordingToPreferredLanguages softLink_AVCFMediaSelectionCopyOptionsFromArrayFilteredAndSortedAccordingToPreferredLanguages
+
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFMetadataItemCopyStringValue, CFStringRef, __cdecl, (AVCFMetadataItemRef metadataItem), (metadataItem))
+#define AVCFMetadataItemCopyStringValue softLink_AVCFMetadataItemCopyStringValue
+
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFMetadataItemCopyItemsWithKeyAndKeySpace, CFArrayRef, __cdecl, (CFArrayRef array, CFTypeRef key, CFStringRef keySpace), (array, key, keySpace))
+#define AVCFMetadataItemCopyItemsWithKeyAndKeySpace softLink_AVCFMetadataItemCopyItemsWithKeyAndKeySpace
+
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFMetadataItemCopyItemsWithLocale, CFArrayRef, __cdecl, (CFArrayRef items, CFLocaleRef locale), (items, locale))
+#define AVCFMetadataItemCopyItemsWithLocale softLink_AVCFMetadataItemCopyItemsWithLocale
+
SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFPlayerCreatePeriodicTimeObserverForInterval, AVCFPlayerObserverRef, __cdecl, (AVCFPlayerRef player, CMTime interval, dispatch_queue_t queue, AVCFPlayerPeriodicTimeObserverCallback callback, void *clientContext), (player, interval, queue, callback, clientContext))
#define AVCFPlayerCreatePeriodicTimeObserverForInterval softLink_AVCFPlayerCreatePeriodicTimeObserverForInterval
@@ -123,6 +147,9 @@ SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemGetAsset, AVCFAssetRef, __cde
SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemGetCurrentTime, CMTime, __cdecl, (AVCFPlayerItemRef playerItem), (playerItem))
#define AVCFPlayerItemGetCurrentTime softLink_AVCFPlayerItemGetCurrentTime
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemGetDuration, CMTime, __cdecl, (AVCFPlayerItemRef playerItem), (playerItem))
+#define AVCFPlayerItemGetDuration softLink_AVCFPlayerItemGetDuration
+
SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemGetStatus, AVCFPlayerItemStatus, __cdecl, (AVCFPlayerItemRef playerItem, CFErrorRef *errorOut), (playerItem, errorOut))
#define AVCFPlayerItemGetStatus softLink_AVCFPlayerItemGetStatus
@@ -135,6 +162,12 @@ SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemIsPlaybackBufferFull, Boolean
SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemIsPlaybackLikelyToKeepUp, Boolean, __cdecl, (AVCFPlayerItemRef playerItem), (playerItem))
#define AVCFPlayerItemIsPlaybackLikelyToKeepUp softLink_AVCFPlayerItemIsPlaybackLikelyToKeepUp
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemLegibleOutputGetTypeID, CFTypeID, __cdecl, (), ())
+#define AVCFPlayerItemLegibleOutputGetTypeID softLink_AVCFPlayerItemLegibleOutputGetTypeID
+
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemRemoveOutput, void, __cdecl, (AVCFPlayerItemRef playerItem, AVCFPlayerItemOutputRef output), (playerItem, output))
+#define AVCFPlayerItemRemoveOutput softLink_AVCFPlayerItemRemoveOutput
+
SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemSeekToTimeWithToleranceAndCompletionCallback, AVCFAssetRef, __cdecl, (AVCFPlayerItemRef playerItem, CMTime time, CMTime toleranceBefore, CMTime toleranceAfter, AVCFPlayerItemSeekCompletionCallback completionCallback, void *context), (playerItem, time, toleranceBefore, toleranceAfter, completionCallback, context))
#define AVCFPlayerItemSeekToTimeWithToleranceAndCompletionCallback softLink_AVCFPlayerItemSeekToTimeWithToleranceAndCompletionCallback
@@ -159,6 +192,9 @@ SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFPlayerLayerIsReadyForDisplay, Boolean,
SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFPlayerLayerSetPlayer, void, __cdecl, (AVCFPlayerLayerRef playerLayer, AVCFPlayerRef player), (playerLayer, player))
#define AVCFPlayerLayerSetPlayer softLink_AVCFPlayerLayerSetPlayer
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFPlayerPlay, void, __cdecl, (AVCFPlayerRef player), (player))
+#define AVCFPlayerPlay softLink_AVCFPlayerPlay
+
SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFPlayerRemoveObserver, OSStatus, __cdecl, (AVCFPlayerRef player, AVCFPlayerObserverRef observer), (player, observer))
#define AVCFPlayerRemoveObserver softLink_AVCFPlayerRemoveObserver
@@ -179,73 +215,168 @@ SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFURLAssetCreateWithURLAndOptions, AVCFUR
SOFT_LINK_DLL_IMPORT_OPTIONAL(AVFoundationCF, AVCFPlayerSetDirect3DDevice, void, __cdecl, (AVCFPlayerRef player, IDirect3DDevice9* d3dDevice))
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP) && HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
+
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFAssetGetSelectionGroupForMediaCharacteristic , AVCFMediaSelectionGroupRef, __cdecl, (AVCFAssetRef asset, CFStringRef mediaCharacteristic), (asset, mediaCharacteristic))
+#define AVCFAssetGetSelectionGroupForMediaCharacteristic softLink_AVCFAssetGetSelectionGroupForMediaCharacteristic
+
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFMediaSelectionCopyPlayableOptionsFromArray, CFArrayRef, __cdecl, (CFArrayRef selectionOptions), (selectionOptions))
+#define AVCFMediaSelectionCopyPlayableOptionsFromArray softLink_AVCFMediaSelectionCopyPlayableOptionsFromArray
+
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFMediaSelectionOptionCopyCommonMetadata, CFArrayRef, __cdecl, (AVCFMediaSelectionOptionRef selectionOption), (selectionOption))
+#define AVCFMediaSelectionOptionCopyCommonMetadata softLink_AVCFMediaSelectionOptionCopyCommonMetadata
+
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFMediaSelectionOptionCopyLocale, CFLocaleRef, __cdecl, (AVCFMediaSelectionOptionRef selectionOption), (selectionOption))
+#define AVCFMediaSelectionOptionCopyLocale softLink_AVCFMediaSelectionOptionCopyLocale
+
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFMediaSelectionOptionGetMediaType, CFStringRef, __cdecl, (AVCFMediaSelectionOptionRef selectionOption), (selectionOption))
+#define AVCFMediaSelectionOptionGetMediaType softLink_AVCFMediaSelectionOptionGetMediaType
+
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFMediaSelectionOptionHasMediaCharacteristic, Boolean, __cdecl, (AVCFMediaSelectionOptionRef selectionOption, CFStringRef mediaCharacteristic), (selectionOption, mediaCharacteristic))
+#define AVCFMediaSelectionOptionHasMediaCharacteristic softLink_AVCFMediaSelectionOptionHasMediaCharacteristic
+
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFMediaSelectionGroupAllowsEmptySelection, Boolean, __cdecl, (AVCFMediaSelectionGroupRef selectionGroup), (selectionGroup))
+#define AVCFMediaSelectionGroupAllowsEmptySelection softLink_AVCFMediaSelectionGroupAllowsEmptySelection
+
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFMediaSelectionGroupGetOptions, CFArrayRef, __cdecl, (AVCFMediaSelectionGroupRef selectionGroup), (selectionGroup))
+#define AVCFMediaSelectionGroupGetOptions softLink_AVCFMediaSelectionGroupGetOptions
+
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemAddOutput, void, __cdecl, (AVCFPlayerItemRef playerItem, AVCFPlayerItemOutputRef output), (playerItem, output))
+#define AVCFPlayerItemAddOutput softLink_AVCFPlayerItemAddOutput
+
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemLegibleOutputCreateWithMediaSubtypesForNativeRepresentation, AVCFPlayerItemLegibleOutputRef, __cdecl, (CFAllocatorRef allocator, CFArrayRef subtypes), (allocator, subtypes))
+#define AVCFPlayerItemLegibleOutputCreateWithMediaSubtypesForNativeRepresentation softLink_AVCFPlayerItemLegibleOutputCreateWithMediaSubtypesForNativeRepresentation
+
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemGetSelectedMediaOptionInMediaSelectionGroup, AVCFMediaSelectionOptionRef, __cdecl, (AVCFPlayerItemRef playerItem, AVCFMediaSelectionGroupRef selectionGroup), (playerItem, selectionGroup))
+#define AVCFPlayerItemGetSelectedMediaOptionInMediaSelectionGroup softLink_AVCFPlayerItemGetSelectedMediaOptionInMediaSelectionGroup
+
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemLegibleOutputSetAdvanceIntervalForCallbackInvocation, void, __cdecl, (AVCFPlayerItemLegibleOutputRef legibleOutput, CFTimeInterval timeInterval), (legibleOutput, timeInterval))
+#define AVCFPlayerItemLegibleOutputSetAdvanceIntervalForCallbackInvocation softLink_AVCFPlayerItemLegibleOutputSetAdvanceIntervalForCallbackInvocation
+
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemLegibleOutputSetCallbacks, void, __cdecl, (AVCFPlayerItemLegibleOutputRef output, const AVCFPlayerItemLegibleOutputCallbacks* callbacks, dispatch_queue_t callbackQueue), (output, callbacks, callbackQueue))
+#define AVCFPlayerItemLegibleOutputSetCallbacks softLink_AVCFPlayerItemLegibleOutputSetCallbacks
+
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemLegibleOutputSetTextStylingResolution, void, __cdecl, (AVCFPlayerItemLegibleOutputRef output, CFStringRef textStylingResolution), (output, textStylingResolution))
+#define AVCFPlayerItemLegibleOutputSetTextStylingResolution softLink_AVCFPlayerItemLegibleOutputSetTextStylingResolution
+
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemOutputSetSuppressPlayerRendering, void, __cdecl, (AVCFPlayerItemOutputRef output, Boolean suppressed), (output, suppressed))
+#define AVCFPlayerItemOutputSetSuppressPlayerRendering softLink_AVCFPlayerItemOutputSetSuppressPlayerRendering
+
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemSelectMediaOptionInMediaSelectionGroup, void, __cdecl, (AVCFPlayerItemRef playerItem, AVCFMediaSelectionOptionRef selectionOption, AVCFMediaSelectionGroupRef selectionGroup), (playerItem, selectionOption, selectionGroup))
+#define AVCFPlayerItemSelectMediaOptionInMediaSelectionGroup softLink_AVCFPlayerItemSelectMediaOptionInMediaSelectionGroup
+
+#endif
+
// Variables
SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFAssetImageGeneratorApertureModeCleanAperture, const CFStringRef);
-#define AVCFAssetImageGeneratorApertureModeCleanAperture get_AVCFAssetImageGeneratorApertureModeCleanAperture()
+#define AVCFAssetImageGeneratorApertureModeCleanAperture getAVCFAssetImageGeneratorApertureModeCleanAperture()
SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFAssetPropertyDuration, const CFStringRef);
-#define AVCFAssetPropertyDuration get_AVCFAssetPropertyDuration()
+#define AVCFAssetPropertyDuration getAVCFAssetPropertyDuration()
SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFAssetPropertyNaturalSize, const CFStringRef);
-#define AVCFAssetPropertyNaturalSize get_AVCFAssetPropertyNaturalSize()
+#define AVCFAssetPropertyNaturalSize getAVCFAssetPropertyNaturalSize()
SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFAssetPropertyPlayable, const CFStringRef);
-#define AVCFAssetPropertyPlayable get_AVCFAssetPropertyPlayable()
+#define AVCFAssetPropertyPlayable getAVCFAssetPropertyPlayable()
SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFAssetPropertyPreferredRate, const CFStringRef);
-#define AVCFAssetPropertyPreferredRate get_AVCFAssetPropertyPreferredRate()
+#define AVCFAssetPropertyPreferredRate getAVCFAssetPropertyPreferredRate()
SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFAssetPropertyPreferredTransform, const CFStringRef);
-#define AVCFAssetPropertyPreferredTransform get_AVCFAssetPropertyPreferredTransform()
+#define AVCFAssetPropertyPreferredTransform getAVCFAssetPropertyPreferredTransform()
SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFAssetPropertyTracks, const CFStringRef);
-#define AVCFAssetPropertyTracks get_AVCFAssetPropertyTracks()
+#define AVCFAssetPropertyTracks getAVCFAssetPropertyTracks()
SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFMediaCharacteristicAudible, const CFStringRef);
-#define AVCFMediaCharacteristicAudible get_AVCFMediaCharacteristicAudible()
+#define AVCFMediaCharacteristicAudible getAVCFMediaCharacteristicAudible()
SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFMediaCharacteristicVisual, const CFStringRef);
-#define AVCFMediaCharacteristicVisual get_AVCFMediaCharacteristicVisual()
+#define AVCFMediaCharacteristicVisual getAVCFMediaCharacteristicVisual()
SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFMediaTypeAudio, const CFStringRef);
-#define AVCFMediaTypeAudio get_AVCFMediaTypeAudio()
+#define AVCFMediaTypeAudio getAVCFMediaTypeAudio()
SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFMediaTypeClosedCaption, const CFStringRef);
-#define AVCFMediaTypeClosedCaption get_AVCFMediaTypeClosedCaption()
+#define AVCFMediaTypeClosedCaption getAVCFMediaTypeClosedCaption()
SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFMediaTypeVideo, const CFStringRef);
-#define AVCFMediaTypeVideo get_AVCFMediaTypeVideo()
+#define AVCFMediaTypeVideo getAVCFMediaTypeVideo()
+
+SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFMetadataCommonKeyTitle, const CFStringRef);
+#define AVCFMetadataCommonKeyTitle getAVCFMetadataCommonKeyTitle()
+
+SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFMetadataKeySpaceCommon, const CFStringRef);
+#define AVCFMetadataKeySpaceCommon getAVCFMetadataKeySpaceCommon()
SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemDidPlayToEndTimeNotification, const CFStringRef);
-#define AVCFPlayerItemDidPlayToEndTimeNotification get_AVCFPlayerItemDidPlayToEndTimeNotification()
+#define AVCFPlayerItemDidPlayToEndTimeNotification getAVCFPlayerItemDidPlayToEndTimeNotification()
+
+SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemDurationChangedNotification, const CFStringRef);
+#define AVCFPlayerItemDurationChangedNotification getAVCFPlayerItemDurationChangedNotification()
SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemIsPlaybackBufferEmptyChangedNotification, const CFStringRef);
-#define AVCFPlayerItemIsPlaybackBufferEmptyChangedNotification get_AVCFPlayerItemIsPlaybackBufferEmptyChangedNotification()
+#define AVCFPlayerItemIsPlaybackBufferEmptyChangedNotification getAVCFPlayerItemIsPlaybackBufferEmptyChangedNotification()
SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemIsPlaybackBufferFullChangedNotification, const CFStringRef);
-#define AVCFPlayerItemIsPlaybackBufferFullChangedNotification get_AVCFPlayerItemIsPlaybackBufferFullChangedNotification()
+#define AVCFPlayerItemIsPlaybackBufferFullChangedNotification getAVCFPlayerItemIsPlaybackBufferFullChangedNotification()
SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemIsPlaybackLikelyToKeepUpChangedNotification, const CFStringRef);
-#define AVCFPlayerItemIsPlaybackLikelyToKeepUpChangedNotification get_AVCFPlayerItemIsPlaybackLikelyToKeepUpChangedNotification()
+#define AVCFPlayerItemIsPlaybackLikelyToKeepUpChangedNotification getAVCFPlayerItemIsPlaybackLikelyToKeepUpChangedNotification()
SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemLoadedTimeRangesChangedNotification, const CFStringRef);
-#define AVCFPlayerItemLoadedTimeRangesChangedNotification get_AVCFPlayerItemLoadedTimeRangesChangedNotification()
+#define AVCFPlayerItemLoadedTimeRangesChangedNotification getAVCFPlayerItemLoadedTimeRangesChangedNotification()
SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemPresentationSizeChangedNotification, const CFStringRef);
-#define AVCFPlayerItemPresentationSizeChangedNotification get_AVCFPlayerItemPresentationSizeChangedNotification()
+#define AVCFPlayerItemPresentationSizeChangedNotification getAVCFPlayerItemPresentationSizeChangedNotification()
SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemSeekableTimeRangesChangedNotification, const CFStringRef);
-#define AVCFPlayerItemSeekableTimeRangesChangedNotification get_AVCFPlayerItemSeekableTimeRangesChangedNotification()
+#define AVCFPlayerItemSeekableTimeRangesChangedNotification getAVCFPlayerItemSeekableTimeRangesChangedNotification()
SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemStatusChangedNotification, const CFStringRef);
-#define AVCFPlayerItemStatusChangedNotification get_AVCFPlayerItemStatusChangedNotification()
+#define AVCFPlayerItemStatusChangedNotification getAVCFPlayerItemStatusChangedNotification()
SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemTracksChangedNotification, const CFStringRef);
-#define AVCFPlayerItemTracksChangedNotification get_AVCFPlayerItemTracksChangedNotification()
+#define AVCFPlayerItemTracksChangedNotification getAVCFPlayerItemTracksChangedNotification()
SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFPlayerRateChangedNotification, const CFStringRef);
-#define AVCFPlayerRateChangedNotification get_AVCFPlayerRateChangedNotification()
+#define AVCFPlayerRateChangedNotification getAVCFPlayerRateChangedNotification()
SOFT_LINK_VARIABLE_DLL_IMPORT_OPTIONAL(AVFoundationCF, AVCFPlayerEnableHardwareAcceleratedVideoDecoderKey, const CFStringRef);
-#define AVCFPlayerEnableHardwareAcceleratedVideoDecoderKey get_AVCFPlayerEnableHardwareAcceleratedVideoDecoderKey()
+#define AVCFPlayerEnableHardwareAcceleratedVideoDecoderKey getAVCFPlayerEnableHardwareAcceleratedVideoDecoderKey()
+
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP) && HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
+
+SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFAssetPropertyAvailableMediaCharacteristicsWithMediaSelectionOptions, const CFStringRef);
+#define AVCFAssetPropertyAvailableMediaCharacteristicsWithMediaSelectionOptions getAVCFAssetPropertyAvailableMediaCharacteristicsWithMediaSelectionOptions()
+
+SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFMediaCharacteristicEasyToRead, const CFStringRef);
+#define AVCFMediaCharacteristicEasyToRead getAVCFMediaCharacteristicEasyToRead()
+
+SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFMediaCharacteristicContainsOnlyForcedSubtitles, const CFStringRef);
+#define AVCFMediaCharacteristicContainsOnlyForcedSubtitles getAVCFMediaCharacteristicContainsOnlyForcedSubtitles()
+
+SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFMediaCharacteristicDescribesMusicAndSoundForAccessibility, const CFStringRef);
+#define AVCFMediaCharacteristicDescribesMusicAndSoundForAccessibility getAVCFMediaCharacteristicDescribesMusicAndSoundForAccessibility()
+
+SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFMediaCharacteristicIsMainProgramContent, const CFStringRef);
+#define AVCFMediaCharacteristicIsMainProgramContent getAVCFMediaCharacteristicIsMainProgramContent()
+
+SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFMediaCharacteristicLegible, const CFStringRef);
+#define AVCFMediaCharacteristicLegible getAVCFMediaCharacteristicLegible()
+
+SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFMediaCharacteristicTranscribesSpokenDialogForAccessibility, const CFStringRef);
+#define AVCFMediaCharacteristicTranscribesSpokenDialogForAccessibility getAVCFMediaCharacteristicTranscribesSpokenDialogForAccessibility()
+
+SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFMediaTypeSubtitle, const CFStringRef);
+#define AVCFMediaTypeSubtitle getAVCFMediaTypeSubtitle()
+
+SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFPlayerAppliesMediaSelectionCriteriaAutomaticallyKey, const CFStringRef);
+#define AVCFPlayerAppliesMediaSelectionCriteriaAutomaticallyKey getAVCFPlayerAppliesMediaSelectionCriteriaAutomaticallyKey()
+
+SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFPlayerItemLegibleOutputTextStylingResolutionSourceAndRulesOnly, const CFStringRef);
+#define AVCFPlayerItemLegibleOutputTextStylingResolutionSourceAndRulesOnly getAVCFPlayerItemLegibleOutputTextStylingResolutionSourceAndRulesOnly()
+
+#endif
diff --git a/Source/WebCore/platform/graphics/avfoundation/cf/CoreMediaSoftLinking.h b/Source/WebCore/platform/graphics/avfoundation/cf/CoreMediaSoftLinking.h
index 0020f4b9f..8714ecfa2 100644
--- a/Source/WebCore/platform/graphics/avfoundation/cf/CoreMediaSoftLinking.h
+++ b/Source/WebCore/platform/graphics/avfoundation/cf/CoreMediaSoftLinking.h
@@ -53,7 +53,10 @@ SOFT_LINK_DLL_IMPORT(CoreMedia, CMTimeMakeFromDictionary, CMTime, __cdecl, (CFDi
SOFT_LINK_DLL_IMPORT(CoreMedia, CMTimeMakeWithSeconds, CMTime, __cdecl, (Float64 seconds, int32_t preferredTimeScale), (seconds, preferredTimeScale))
#define CMTimeMakeWithSeconds softLink_CMTimeMakeWithSeconds
+SOFT_LINK_DLL_IMPORT(CoreMedia, CMTimeRangeGetEnd, CMTime, __cdecl, (CMTimeRange range), (range))
+#define CMTimeRangeGetEnd softLink_CMTimeRangeGetEnd
+
// Variables
SOFT_LINK_VARIABLE_DLL_IMPORT(CoreMedia, kCMTimeZero, const CMTime);
-#define kCMTimeZero get_kCMTimeZero()
+#define kCMTimeZero getkCMTimeZero()
diff --git a/Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.cpp b/Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.cpp
new file mode 100644
index 000000000..849e11845
--- /dev/null
+++ b/Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.cpp
@@ -0,0 +1,183 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if PLATFORM(WIN) && ENABLE(VIDEO) && HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
+
+#include "InbandTextTrackPrivateAVCF.h"
+
+#include "FloatConversion.h"
+#include "InbandTextTrackPrivate.h"
+#include "InbandTextTrackPrivateAVF.h"
+#include "Logging.h"
+#include "SoftLinking.h"
+
+#include <AVFoundationCF/AVCFPlayerItemLegibleOutput.h>
+#include <AVFoundationCF/AVFoundationCF.h>
+
+#include <d3d9.h>
+
+// The softlink header files must be included after the AVCF and CoreMedia header files.
+#include "AVFoundationCFSoftLinking.h"
+
+namespace WebCore {
+
+InbandTextTrackPrivateAVCF::InbandTextTrackPrivateAVCF(AVFInbandTrackParent* player, AVCFMediaSelectionOptionRef selection)
+ : InbandTextTrackPrivateAVF(player)
+ , m_mediaSelectionOption(selection)
+{
+}
+
+void InbandTextTrackPrivateAVCF::disconnect()
+{
+ m_mediaSelectionOption = 0;
+ InbandTextTrackPrivateAVF::disconnect();
+}
+
+InbandTextTrackPrivate::Kind InbandTextTrackPrivateAVCF::kind() const
+{
+ if (!m_mediaSelectionOption)
+ return InbandTextTrackPrivate::None;
+
+ CFStringRef mediaType = AVCFMediaSelectionOptionGetMediaType(mediaSelectionOption());
+
+ if (CFStringCompare(mediaType, AVCFMediaTypeClosedCaption, kCFCompareCaseInsensitive) == kCFCompareEqualTo)
+ return InbandTextTrackPrivate::Captions;
+ if (CFStringCompare(mediaType, AVCFMediaTypeSubtitle, kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
+ if (AVCFMediaSelectionOptionHasMediaCharacteristic(mediaSelectionOption(), AVCFMediaCharacteristicContainsOnlyForcedSubtitles))
+ return InbandTextTrackPrivate::Forced;
+
+ // An "SDH" track is a subtitle track created for the deaf or hard-of-hearing. "captions" in WebVTT are
+ // "labeled as appropriate for the hard-of-hearing", so tag SDH sutitles as "captions".
+ if (AVCFMediaSelectionOptionHasMediaCharacteristic(mediaSelectionOption(), AVCFMediaCharacteristicTranscribesSpokenDialogForAccessibility))
+ return InbandTextTrackPrivate::Captions;
+ if (AVCFMediaSelectionOptionHasMediaCharacteristic(mediaSelectionOption(), AVCFMediaCharacteristicDescribesMusicAndSoundForAccessibility))
+ return InbandTextTrackPrivate::Captions;
+
+ return InbandTextTrackPrivate::Subtitles;
+ }
+
+ return InbandTextTrackPrivate::Captions;
+}
+
+bool InbandTextTrackPrivateAVCF::isClosedCaptions() const
+{
+ if (!m_mediaSelectionOption)
+ return false;
+
+ CFStringRef mediaType = AVCFMediaSelectionOptionGetMediaType(mediaSelectionOption());
+
+ return (CFStringCompare(mediaType, AVCFMediaTypeClosedCaption, kCFCompareCaseInsensitive) == kCFCompareEqualTo);
+}
+
+bool InbandTextTrackPrivateAVCF::isSDH() const
+{
+ if (!m_mediaSelectionOption)
+ return false;
+
+ CFStringRef mediaType = AVCFMediaSelectionOptionGetMediaType(mediaSelectionOption());
+
+ if (CFStringCompare(mediaType, AVCFMediaTypeSubtitle, kCFCompareCaseInsensitive) != kCFCompareEqualTo)
+ return false;
+
+ if (AVCFMediaSelectionOptionHasMediaCharacteristic(mediaSelectionOption(), AVCFMediaCharacteristicTranscribesSpokenDialogForAccessibility)
+ && AVCFMediaSelectionOptionHasMediaCharacteristic(mediaSelectionOption(), AVCFMediaCharacteristicDescribesMusicAndSoundForAccessibility))
+ return true;
+
+ return false;
+}
+
+bool InbandTextTrackPrivateAVCF::containsOnlyForcedSubtitles() const
+{
+ if (!m_mediaSelectionOption)
+ return false;
+
+ return AVCFMediaSelectionOptionHasMediaCharacteristic(mediaSelectionOption(), AVCFMediaCharacteristicContainsOnlyForcedSubtitles);
+}
+
+bool InbandTextTrackPrivateAVCF::isMainProgramContent() const
+{
+ if (!m_mediaSelectionOption)
+ return false;
+
+ return AVCFMediaSelectionOptionHasMediaCharacteristic(mediaSelectionOption(), AVCFMediaCharacteristicIsMainProgramContent);
+}
+
+bool InbandTextTrackPrivateAVCF::isEasyToRead() const
+{
+ if (!m_mediaSelectionOption)
+ return false;
+
+ return AVCFMediaSelectionOptionHasMediaCharacteristic(mediaSelectionOption(), AVCFMediaCharacteristicEasyToRead);
+}
+
+AtomicString InbandTextTrackPrivateAVCF::label() const
+{
+ if (!m_mediaSelectionOption)
+ return emptyAtom;
+
+ RetainPtr<CFStringRef> title;
+
+ RetainPtr<CFArrayRef> commonMetaData = adoptCF(AVCFMediaSelectionOptionCopyCommonMetadata(mediaSelectionOption()));
+ RetainPtr<CFArrayRef> titles = adoptCF(AVCFMetadataItemCopyItemsWithKeyAndKeySpace(commonMetaData.get(), AVCFMetadataCommonKeyTitle, AVCFMetadataKeySpaceCommon));
+ CFIndex titlesCount = CFArrayGetCount(titles.get());
+ if (!titlesCount)
+ return emptyAtom;
+
+ // If possible, return a title in one of the user's preferred languages.
+ RetainPtr<CFArrayRef> preferredLanguages = CFLocaleCopyPreferredLanguages();
+ RetainPtr<CFArrayRef> titlesForPreferredLanguages = AVCFMediaSelectionCopyOptionsFromArrayFilteredAndSortedAccordingToPreferredLanguages(titles.get(), preferredLanguages.get());
+ CFIndex preferredTitlesCount = CFArrayGetCount(titlesForPreferredLanguages.get());
+ if (preferredTitlesCount) {
+ AVCFMetadataItemRef titleMetadata = static_cast<AVCFMetadataItemRef>(CFArrayGetValueAtIndex(titlesForPreferredLanguages.get(), 0));
+ title = adoptCF(AVCFMetadataItemCopyStringValue(titleMetadata));
+ }
+
+ if (!title) {
+ AVCFMetadataItemRef titleMetadata = static_cast<AVCFMetadataItemRef>(CFArrayGetValueAtIndex(titles.get(), 0));
+ title = adoptCF(AVCFMetadataItemCopyStringValue(titleMetadata));
+ }
+
+ return title ? AtomicString(title.get()) : emptyAtom;
+}
+
+AtomicString InbandTextTrackPrivateAVCF::language() const
+{
+ if (!m_mediaSelectionOption)
+ return emptyAtom;
+
+ RetainPtr<CFLocaleRef> locale = adoptCF(AVCFMediaSelectionOptionCopyLocale(mediaSelectionOption()));
+ return CFLocaleGetIdentifier(locale.get());
+}
+
+bool InbandTextTrackPrivateAVCF::isDefault() const
+{
+ return false;
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.h b/Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.h
new file mode 100644
index 000000000..d9d70b344
--- /dev/null
+++ b/Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef InbandTextTrackPrivateAVCF_h
+#define InbandTextTrackPrivateAVCF_h
+
+#if PLATFORM(WIN) && ENABLE(VIDEO) && HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
+
+#include "InbandTextTrackPrivateAVF.h"
+#include <AVFoundationCF/AVCFPlayerItem.h>
+#include <wtf/RetainPtr.h>
+
+namespace WebCore {
+
+class InbandTextTrackPrivateAVCF : public InbandTextTrackPrivateAVF {
+public:
+ static PassRefPtr<InbandTextTrackPrivateAVCF> create(AVFInbandTrackParent* player, AVCFMediaSelectionOptionRef selection)
+ {
+ return adoptRef(new InbandTextTrackPrivateAVCF(player, selection));
+ }
+
+ ~InbandTextTrackPrivateAVCF() { }
+
+ virtual InbandTextTrackPrivate::Kind kind() const OVERRIDE;
+ virtual bool isClosedCaptions() const OVERRIDE;
+ virtual bool isSDH() const OVERRIDE;
+ virtual bool containsOnlyForcedSubtitles() const OVERRIDE;
+ virtual bool isMainProgramContent() const OVERRIDE;
+ virtual bool isEasyToRead() const OVERRIDE;
+ virtual AtomicString label() const OVERRIDE;
+ virtual AtomicString language() const OVERRIDE;
+ virtual bool isDefault() const OVERRIDE;
+
+ virtual void disconnect() OVERRIDE;
+
+ virtual bool isLegacyClosedCaptionsTrack() const OVERRIDE { return false; }
+
+ AVCFMediaSelectionOptionRef mediaSelectionOption() const { return m_mediaSelectionOption.get(); }
+
+protected:
+ InbandTextTrackPrivateAVCF(AVFInbandTrackParent*, AVCFMediaSelectionOptionRef);
+
+ RetainPtr<AVCFMediaSelectionOptionRef> m_mediaSelectionOption;
+};
+
+}
+
+#endif
+#endif
diff --git a/Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateLegacyAVCF.cpp b/Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateLegacyAVCF.cpp
new file mode 100644
index 000000000..b526b9896
--- /dev/null
+++ b/Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateLegacyAVCF.cpp
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(VIDEO) && USE(AVFOUNDATION) && !HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT) && !PLATFORM(IOS)
+
+#include "InbandTextTrackPrivateLegacyAVCF.h"
+
+#include "InbandTextTrackPrivateAVF.h"
+#include "Logging.h"
+#include "MediaPlayerPrivateAVFoundationCF.h"
+#include "SoftLinking.h"
+
+#include <AVFoundationCF/AVFoundationCF.h>
+
+#include <d3d9.h>
+
+// The softlink header files must be included after the AVCF and CoreMedia header files.
+#include "AVFoundationCFSoftLinking.h"
+
+namespace WebCore {
+
+InbandTextTrackPrivateLegacyAVCF::InbandTextTrackPrivateLegacyAVCF(MediaPlayerPrivateAVFoundationCF* player, AVCFPlayerItemTrackRef track)
+ : InbandTextTrackPrivateAVF(player)
+ , m_playerItemTrack(track)
+{
+}
+
+void InbandTextTrackPrivateLegacyAVCF::disconnect()
+{
+ m_playerItemTrack = 0;
+ InbandTextTrackPrivateAVF::disconnect();
+}
+
+InbandTextTrackPrivate::Kind InbandTextTrackPrivateLegacyAVCF::kind() const
+{
+ if (!m_playerItemTrack)
+ return InbandTextTrackPrivate::None;
+
+ return InbandTextTrackPrivate::Captions;
+}
+
+bool InbandTextTrackPrivateLegacyAVCF::isClosedCaptions() const
+{
+ return m_playerItemTrack;
+}
+
+bool InbandTextTrackPrivateLegacyAVCF::containsOnlyForcedSubtitles() const
+{
+ return false;
+}
+
+bool InbandTextTrackPrivateLegacyAVCF::isMainProgramContent() const
+{
+ return m_playerItemTrack;
+}
+
+bool InbandTextTrackPrivateLegacyAVCF::isEasyToRead() const
+{
+ return false;
+}
+
+AtomicString InbandTextTrackPrivateLegacyAVCF::label() const
+{
+ if (!m_playerItemTrack)
+ return emptyAtom;
+
+ RetainPtr<CFStringRef> title;
+
+ RetainPtr<AVCFAssetTrackRef> assetTrack = adoptCF(AVCFPlayerItemTrackCopyAssetTrack(m_playerItemTrack.get()));
+ RetainPtr<CFArrayRef> commonMetaData = adoptCF(AVCFAssetTrackCopyCommonMetadata(assetTrack.get()));
+ RetainPtr<CFArrayRef> titles = adoptCF(AVCFMetadataItemCopyItemsWithKeyAndKeySpace(commonMetaData.get(), AVCFMetadataCommonKeyTitle, AVCFMetadataKeySpaceCommon));
+ CFIndex titlesCount = CFArrayGetCount(titles.get());
+ if (titlesCount) {
+ RetainPtr<CFLocaleRef> currentLocale = adoptCF(CFLocaleCopyCurrent());
+ RetainPtr<CFArrayRef> titlesForPreferredLanguages = adoptCF(AVCFMetadataItemCopyItemsWithLocale(titles.get(), currentLocale.get()));
+ CFIndex preferredTitlesCount = CFArrayGetCount(titlesForPreferredLanguages.get());
+ if (preferredTitlesCount) {
+ AVCFMetadataItemRef titleMetadata = static_cast<AVCFMetadataItemRef>(CFArrayGetValueAtIndex(titlesForPreferredLanguages.get(), 0));
+ title = adoptCF(AVCFMetadataItemCopyStringValue(titleMetadata));
+ }
+
+ if (!title) {
+ AVCFMetadataItemRef titleMetadata = static_cast<AVCFMetadataItemRef>(CFArrayGetValueAtIndex(titles.get(), 0));
+ title = adoptCF(AVCFMetadataItemCopyStringValue(titleMetadata));
+ }
+ }
+
+ return title ? AtomicString(title.get()) : emptyAtom;
+}
+
+AtomicString InbandTextTrackPrivateLegacyAVCF::language() const
+{
+ if (!m_playerItemTrack)
+ return emptyAtom;
+
+ RetainPtr<AVCFAssetTrackRef> assetTrack = adoptCF(AVCFPlayerItemTrackCopyAssetTrack(m_playerItemTrack.get()));
+ RetainPtr<CFStringRef> languageCode = adoptCF(AVCFAssetTrackCopyLanguageCode(assetTrack.get()));
+ RetainPtr<CFLocaleRef> locale = adoptCF(CFLocaleCreate(kCFAllocatorDefault, languageCode.get()));
+ return CFLocaleGetIdentifier(locale.get());
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateLegacyAVCF.h b/Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateLegacyAVCF.h
new file mode 100644
index 000000000..29cfc6141
--- /dev/null
+++ b/Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateLegacyAVCF.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef InbandTextTrackPrivateLegacyAVCF_h
+#define InbandTextTrackPrivateLegacyAVCF_h
+
+#if ENABLE(VIDEO) && USE(AVFOUNDATION) && !HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT) && !PLATFORM(IOS)
+
+#include "InbandTextTrackPrivateAVF.h"
+#include <AVFoundationCF/AVCFPlayerItemTrack.h>
+#include <wtf/RetainPtr.h>
+
+namespace WebCore {
+
+class MediaPlayerPrivateAVFoundationCF;
+
+class InbandTextTrackPrivateLegacyAVCF : public InbandTextTrackPrivateAVF {
+public:
+ static PassRefPtr<InbandTextTrackPrivateLegacyAVCF> create(MediaPlayerPrivateAVFoundationCF* player, AVCFPlayerItemTrackRef track)
+ {
+ return adoptRef(new InbandTextTrackPrivateLegacyAVCF(player, track));
+ }
+
+ ~InbandTextTrackPrivateLegacyAVCF() { }
+
+ virtual InbandTextTrackPrivate::Kind kind() const OVERRIDE;
+ virtual bool isClosedCaptions() const OVERRIDE;
+ virtual bool containsOnlyForcedSubtitles() const OVERRIDE;
+ virtual bool isMainProgramContent() const OVERRIDE;
+ virtual bool isEasyToRead() const OVERRIDE;
+ virtual AtomicString label() const OVERRIDE;
+ virtual AtomicString language() const OVERRIDE;
+
+ virtual void disconnect() OVERRIDE;
+
+ virtual bool isLegacyClosedCaptionsTrack() const OVERRIDE { return true; }
+
+ AVCFPlayerItemTrackRef avPlayerItemTrack() const { return m_playerItemTrack.get(); }
+
+protected:
+ InbandTextTrackPrivateLegacyAVCF(MediaPlayerPrivateAVFoundationCF*, AVCFPlayerItemTrackRef);
+
+ RetainPtr<AVCFPlayerItemTrackRef> m_playerItemTrack;
+};
+
+}
+
+#endif // ENABLE(VIDEO) && USE(AVFOUNDATION) && !HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT) && !PLATFORM(IOS)
+
+#endif
diff --git a/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp b/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp
index 75faa0caa..a47892952 100644
--- a/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp
+++ b/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2012, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -25,7 +25,7 @@
#include "config.h"
-#if PLATFORM(WIN)&& ENABLE(VIDEO)
+#if PLATFORM(WIN) && ENABLE(VIDEO)
#if USE(AVFOUNDATION)
@@ -36,21 +36,24 @@
#include "FloatConversion.h"
#include "FrameView.h"
#include "GraphicsContext.h"
+#include "InbandTextTrackPrivateAVCF.h"
#include "KURL.h"
#include "Logging.h"
#include "PlatformCALayer.h"
#include "SoftLinking.h"
#include "TimeRanges.h"
+#include <AVFoundationCF/AVCFPlayerItem.h>
+#include <AVFoundationCF/AVCFPlayerItemLegibleOutput.h>
#include <AVFoundationCF/AVCFPlayerLayer.h>
#include <AVFoundationCF/AVFoundationCF.h>
#include <CoreMedia/CoreMedia.h>
+#include <d3d9.h>
#include <delayimp.h>
#include <dispatch/dispatch.h>
-#include <WebKitQuartzCoreAdditions/WKCACFTypes.h>
#include <wtf/HashMap.h>
#include <wtf/Threading.h>
-#include <wtf/UnusedParam.h>
+#include <wtf/text/CString.h>
// The softlink header files must be included after the AVCF and CoreMedia header files.
#include "AVFoundationCFSoftLinking.h"
@@ -96,6 +99,13 @@ public:
void seekToTime(float);
+ void setCurrentTrack(InbandTextTrackPrivateAVF*);
+ InbandTextTrackPrivateAVF* currentTrack() const { return m_currentTrack; }
+
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP) && HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
+ static void legibleOutputCallback(void* context, AVCFPlayerItemLegibleOutputRef, CFArrayRef attributedString, CFArrayRef nativeSampleBuffers, CMTime itemTime);
+ static void processCue(void* context);
+#endif
static void loadMetadataCompletionCallback(AVCFAssetRef, void*);
static void loadPlayableCompletionCallback(AVCFAssetRef, void*);
static void periodicTimeObserverCallback(AVCFPlayerRef, CMTime, void*);
@@ -108,6 +118,10 @@ public:
inline AVCFPlayerItemRef avPlayerItem() const { return (AVCFPlayerItemRef)m_avPlayerItem.get(); }
inline AVCFPlayerObserverRef timeObserver() const { return (AVCFPlayerObserverRef)m_timeObserver.get(); }
inline AVCFAssetImageGeneratorRef imageGenerator() const { return m_imageGenerator.get(); }
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP) && HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
+ inline AVCFPlayerItemLegibleOutputRef legibleOutput() const { return m_legibleOutput.get(); }
+ AVCFMediaSelectionGroupRef safeMediaSelectionGroupForLegibleMedia() const;
+#endif
inline dispatch_queue_t dispatchQueue() const { return m_notificationQueue; }
private:
@@ -132,6 +146,10 @@ private:
RetainPtr<AVCFPlayerLayerRef> m_avCFVideoLayer;
RetainPtr<AVCFPlayerObserverRef> m_timeObserver;
RetainPtr<AVCFAssetImageGeneratorRef> m_imageGenerator;
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP) && HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
+ RetainPtr<AVCFPlayerItemLegibleOutputRef> m_legibleOutput;
+ RetainPtr<AVCFMediaSelectionGroupRef> m_selectionGroup;
+#endif
dispatch_queue_t m_notificationQueue;
mutable RetainPtr<CACFLayerRef> m_caVideoLayer;
@@ -139,6 +157,8 @@ private:
OwnPtr<LayerClient> m_layerClient;
COMPtr<IDirect3DDevice9Ex> m_d3dDevice;
+
+ InbandTextTrackPrivateAVF* m_currentTrack;
};
uintptr_t AVFWrapper::s_nextAVFWrapperObjectID;
@@ -183,7 +203,8 @@ static CFArrayRef createMetadataKeyNames()
AVCFAssetPropertyPreferredTransform,
AVCFAssetPropertyPreferredRate,
AVCFAssetPropertyPlayable,
- AVCFAssetPropertyTracks
+ AVCFAssetPropertyTracks,
+ AVCFAssetPropertyAvailableMediaCharacteristicsWithMediaSelectionOptions
};
return CFArrayCreate(0, (const void**)keyNames, sizeof(keyNames) / sizeof(keyNames[0]), &kCFTypeArrayCallBacks);
@@ -243,6 +264,18 @@ inline AVCFAssetImageGeneratorRef imageGenerator(AVFWrapper* wrapper)
return wrapper ? wrapper->imageGenerator() : 0;
}
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP) && HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
+inline AVCFPlayerItemLegibleOutputRef avLegibleOutput(AVFWrapper* wrapper)
+{
+ return wrapper ? wrapper->legibleOutput() : 0;
+}
+
+inline AVCFMediaSelectionGroupRef safeMediaSelectionGroupForLegibleMedia(AVFWrapper* wrapper)
+{
+ return wrapper ? wrapper->safeMediaSelectionGroupForLegibleMedia() : 0;
+}
+#endif
+
PassOwnPtr<MediaPlayerPrivateInterface> MediaPlayerPrivateAVFoundationCF::create(MediaPlayer* player)
{
return adoptPtr(new MediaPlayerPrivateAVFoundationCF(player));
@@ -278,6 +311,8 @@ void MediaPlayerPrivateAVFoundationCF::cancelLoad()
tearDownVideoRendering();
+ clearTextTracks();
+
if (m_avfWrapper) {
// The AVCF objects have to be destroyed on the same dispatch queue used for notifications, so schedule a call to
// disconnectAndDeleteAVFWrapper on that queue.
@@ -336,6 +371,31 @@ bool MediaPlayerPrivateAVFoundationCF::hasAvailableVideoFrame() const
return (m_videoFrameHasDrawn || (videoLayer(m_avfWrapper) && AVCFPlayerLayerIsReadyForDisplay(videoLayer(m_avfWrapper))));
}
+void MediaPlayerPrivateAVFoundationCF::setCurrentTrack(InbandTextTrackPrivateAVF* track)
+{
+ if (m_avfWrapper)
+ m_avfWrapper->setCurrentTrack(track);
+}
+
+InbandTextTrackPrivateAVF* MediaPlayerPrivateAVFoundationCF::currentTrack() const
+{
+ if (m_avfWrapper)
+ return m_avfWrapper->currentTrack();
+
+ return 0;
+}
+
+void MediaPlayerPrivateAVFoundationCF::createAVAssetForURL(const String& url)
+{
+ ASSERT(!m_avfWrapper);
+
+ setDelayCallbacks(true);
+
+ m_avfWrapper = new AVFWrapper(this);
+ m_avfWrapper->createAssetForURL(url);
+ setDelayCallbacks(false);
+}
+
void MediaPlayerPrivateAVFoundationCF::createAVPlayer()
{
ASSERT(m_avfWrapper);
@@ -351,17 +411,7 @@ void MediaPlayerPrivateAVFoundationCF::createAVPlayerItem()
setDelayCallbacks(true);
m_avfWrapper->createPlayerItem();
- setDelayCallbacks(false);
-}
-
-void MediaPlayerPrivateAVFoundationCF::createAVAssetForURL(const String& url)
-{
- ASSERT(!m_avfWrapper);
- setDelayCallbacks(true);
-
- m_avfWrapper = new AVFWrapper(this);
- m_avfWrapper->createAssetForURL(url);
setDelayCallbacks(false);
}
@@ -447,34 +497,27 @@ void MediaPlayerPrivateAVFoundationCF::platformPause()
setDelayCallbacks(false);
}
-void MediaPlayerPrivateAVFoundationCF::updateRate()
-{
- LOG(Media, "MediaPlayerPrivateAVFoundationCF::updateRate(%p)", this);
- if (!metaDataAvailable() || !avPlayer(m_avfWrapper))
- return;
-
- setDelayCallbacks(true);
- AVCFPlayerSetRate(avPlayer(m_avfWrapper), requestedRate());
- setDelayCallbacks(false);
-}
-
float MediaPlayerPrivateAVFoundationCF::platformDuration() const
{
if (!metaDataAvailable() || !avAsset(m_avfWrapper))
return 0;
- float duration;
- CMTime cmDuration = AVCFAssetGetDuration(avAsset(m_avfWrapper));
+ CMTime cmDuration;
+
+ // Check the AVItem if we have one and it has loaded duration, some assets never report duration.
+ if (avPlayerItem(m_avfWrapper) && playerItemStatus() >= MediaPlayerAVPlayerItemStatusReadyToPlay)
+ cmDuration = AVCFPlayerItemGetDuration(avPlayerItem(m_avfWrapper));
+ else
+ cmDuration = AVCFAssetGetDuration(avAsset(m_avfWrapper));
+
if (CMTIME_IS_NUMERIC(cmDuration))
- duration = narrowPrecisionToFloat(CMTimeGetSeconds(cmDuration));
- else if (CMTIME_IS_INDEFINITE(cmDuration))
- duration = numeric_limits<float>::infinity();
- else {
- LOG(Media, "MediaPlayerPrivateAVFMac::duration(%p) - invalid duration, returning 0", this);
- return 0;
- }
+ return narrowPrecisionToFloat(CMTimeGetSeconds(cmDuration));
- return duration;
+ if (CMTIME_IS_INDEFINITE(cmDuration))
+ return numeric_limits<float>::infinity();
+
+ LOG(Media, "MediaPlayerPrivateAVFoundationCF::platformDuration(%p) - invalid duration, returning %.0f", this, static_cast<float>(MediaPlayer::invalidTime()));
+ return static_cast<float>(MediaPlayer::invalidTime());
}
float MediaPlayerPrivateAVFoundationCF::currentTime() const
@@ -484,12 +527,12 @@ float MediaPlayerPrivateAVFoundationCF::currentTime() const
CMTime itemTime = AVCFPlayerItemGetCurrentTime(avPlayerItem(m_avfWrapper));
if (CMTIME_IS_NUMERIC(itemTime))
- return narrowPrecisionToFloat(CMTimeGetSeconds(itemTime));
+ return max(narrowPrecisionToFloat(CMTimeGetSeconds(itemTime)), 0.0f);
return 0;
}
-void MediaPlayerPrivateAVFoundationCF::seekToTime(float time)
+void MediaPlayerPrivateAVFoundationCF::seekToTime(double time)
{
if (!m_avfWrapper)
return;
@@ -517,6 +560,17 @@ void MediaPlayerPrivateAVFoundationCF::setClosedCaptionsVisible(bool closedCapti
AVCFPlayerSetClosedCaptionDisplayEnabled(avPlayer(m_avfWrapper), closedCaptionsVisible);
}
+void MediaPlayerPrivateAVFoundationCF::updateRate()
+{
+ LOG(Media, "MediaPlayerPrivateAVFoundationCF::updateRate(%p)", this);
+ if (!metaDataAvailable() || !avPlayer(m_avfWrapper))
+ return;
+
+ setDelayCallbacks(true);
+ AVCFPlayerSetRate(avPlayer(m_avfWrapper), requestedRate());
+ setDelayCallbacks(false);
+}
+
float MediaPlayerPrivateAVFoundationCF::rate() const
{
if (!metaDataAvailable() || !avPlayer(m_avfWrapper))
@@ -548,7 +602,7 @@ PassRefPtr<TimeRanges> MediaPlayerPrivateAVFoundationCF::platformBufferedTimeRan
if (!avPlayerItem(m_avfWrapper))
return timeRanges.release();
- RetainPtr<CFArrayRef> loadedRanges(AdoptCF, AVCFPlayerItemCopyLoadedTimeRanges(avPlayerItem(m_avfWrapper)));
+ RetainPtr<CFArrayRef> loadedRanges = adoptCF(AVCFPlayerItemCopyLoadedTimeRanges(avPlayerItem(m_avfWrapper)));
if (!loadedRanges)
return timeRanges.release();
@@ -568,16 +622,40 @@ PassRefPtr<TimeRanges> MediaPlayerPrivateAVFoundationCF::platformBufferedTimeRan
return timeRanges.release();
}
-float MediaPlayerPrivateAVFoundationCF::platformMaxTimeSeekable() const
+double MediaPlayerPrivateAVFoundationCF::platformMinTimeSeekable() const
+{
+ RetainPtr<CFArrayRef> seekableRanges = adoptCF(AVCFPlayerItemCopySeekableTimeRanges(avPlayerItem(m_avfWrapper)));
+ if (!seekableRanges)
+ return 0;
+
+ double minTimeSeekable = std::numeric_limits<double>::infinity();
+ bool hasValidRange = false;
+ CFIndex rangeCount = CFArrayGetCount(seekableRanges.get());
+ for (CFIndex i = 0; i < rangeCount; i++) {
+ CFDictionaryRef range = static_cast<CFDictionaryRef>(CFArrayGetValueAtIndex(seekableRanges.get(), i));
+ CMTime start = CMTimeMakeFromDictionary(static_cast<CFDictionaryRef>(CFDictionaryGetValue(range, CMTimeRangeStartKey())));
+ CMTime duration = CMTimeMakeFromDictionary(static_cast<CFDictionaryRef>(CFDictionaryGetValue(range, CMTimeRangeDurationKey())));
+ if (!timeRangeIsValidAndNotEmpty(start, duration))
+ continue;
+
+ hasValidRange = true;
+ double startOfRange = CMTimeGetSeconds(start);
+ if (minTimeSeekable > startOfRange)
+ minTimeSeekable = startOfRange;
+ }
+ return hasValidRange ? minTimeSeekable : 0;
+}
+
+double MediaPlayerPrivateAVFoundationCF::platformMaxTimeSeekable() const
{
if (!avPlayerItem(m_avfWrapper))
return 0;
- RetainPtr<CFArrayRef> seekableRanges(AdoptCF, AVCFPlayerItemCopySeekableTimeRanges(avPlayerItem(m_avfWrapper)));
+ RetainPtr<CFArrayRef> seekableRanges = adoptCF(AVCFPlayerItemCopySeekableTimeRanges(avPlayerItem(m_avfWrapper)));
if (!seekableRanges)
return 0;
- float maxTimeSeekable = 0;
+ double maxTimeSeekable = 0;
CFIndex rangeCount = CFArrayGetCount(seekableRanges.get());
for (CFIndex i = 0; i < rangeCount; i++) {
CFDictionaryRef range = static_cast<CFDictionaryRef>(CFArrayGetValueAtIndex(seekableRanges.get(), i));
@@ -586,7 +664,7 @@ float MediaPlayerPrivateAVFoundationCF::platformMaxTimeSeekable() const
if (!timeRangeIsValidAndNotEmpty(start, duration))
continue;
- float endOfRange = narrowPrecisionToFloat(CMTimeGetSeconds(CMTimeAdd(start, duration)));
+ double endOfRange = CMTimeGetSeconds(CMTimeAdd(start, duration));
if (maxTimeSeekable < endOfRange)
maxTimeSeekable = endOfRange;
}
@@ -599,7 +677,7 @@ float MediaPlayerPrivateAVFoundationCF::platformMaxTimeLoaded() const
if (!avPlayerItem(m_avfWrapper))
return 0;
- RetainPtr<CFArrayRef> loadedRanges(AdoptCF, AVCFPlayerItemCopyLoadedTimeRanges(avPlayerItem(m_avfWrapper)));
+ RetainPtr<CFArrayRef> loadedRanges = adoptCF(AVCFPlayerItemCopyLoadedTimeRanges(avPlayerItem(m_avfWrapper)));
if (!loadedRanges)
return 0;
@@ -626,7 +704,7 @@ unsigned MediaPlayerPrivateAVFoundationCF::totalBytes() const
return 0;
int64_t totalMediaSize = 0;
- RetainPtr<CFArrayRef> tracks(AdoptCF, AVCFAssetCopyAssetTracks(avAsset(m_avfWrapper)));
+ RetainPtr<CFArrayRef> tracks = adoptCF(AVCFAssetCopyAssetTracks(avAsset(m_avfWrapper)));
CFIndex trackCount = CFArrayGetCount(tracks.get());
for (CFIndex i = 0; i < trackCount; i++) {
AVCFAssetTrackRef assetTrack = (AVCFAssetTrackRef)CFArrayGetValueAtIndex(tracks.get(), i);
@@ -648,7 +726,7 @@ MediaPlayerPrivateAVFoundation::AssetStatus MediaPlayerPrivateAVFoundationCF::as
for (CFIndex i = 0; i < keyCount; i++) {
CFStringRef keyName = static_cast<CFStringRef>(CFArrayGetValueAtIndex(keys, i));
AVCFPropertyValueStatus keyStatus = AVCFAssetGetStatusOfValueForProperty(avAsset(m_avfWrapper), keyName, 0);
-
+
if (keyStatus < AVCFPropertyValueStatusLoaded)
return MediaPlayerAVAssetStatusLoading;
if (keyStatus == AVCFPropertyValueStatusFailed)
@@ -665,7 +743,7 @@ MediaPlayerPrivateAVFoundation::AssetStatus MediaPlayerPrivateAVFoundationCF::as
void MediaPlayerPrivateAVFoundationCF::paintCurrentFrameInContext(GraphicsContext* context, const IntRect& rect)
{
- if (context->paintingDisabled())
+ if (!metaDataAvailable() || context->paintingDisabled())
return;
if (currentRenderingMode() == MediaRenderingToLayer && !imageGenerator(m_avfWrapper)) {
@@ -679,7 +757,7 @@ void MediaPlayerPrivateAVFoundationCF::paintCurrentFrameInContext(GraphicsContex
void MediaPlayerPrivateAVFoundationCF::paint(GraphicsContext* context, const IntRect& rect)
{
- if (context->paintingDisabled() || !imageGenerator(m_avfWrapper))
+ if (!metaDataAvailable() || context->paintingDisabled() || !imageGenerator(m_avfWrapper))
return;
LOG(Media, "MediaPlayerPrivateAVFoundationCF::paint(%p)", this);
@@ -709,8 +787,8 @@ static HashSet<String> mimeTypeCache()
if (typeListInitialized)
return cache;
typeListInitialized = true;
-
- RetainPtr<CFArrayRef> supportedTypes(AdoptCF, AVCFURLAssetCopyAudiovisualMIMETypes());
+
+ RetainPtr<CFArrayRef> supportedTypes = adoptCF(AVCFURLAssetCopyAudiovisualMIMETypes());
ASSERT(supportedTypes);
if (!supportedTypes)
@@ -755,35 +833,42 @@ float MediaPlayerPrivateAVFoundationCF::mediaTimeForTimeValue(float timeValue) c
void MediaPlayerPrivateAVFoundationCF::tracksChanged()
{
+ String primaryAudioTrackLanguage = m_languageOfPrimaryAudioTrack;
+ m_languageOfPrimaryAudioTrack = String();
+
if (!avAsset(m_avfWrapper))
return;
-
+
+ bool haveCCTrack = false;
+ bool hasCaptions = false;
+
// This is called whenever the tracks collection changes so cache hasVideo and hasAudio since we are
// asked about those fairly frequently.
if (!avPlayerItem(m_avfWrapper)) {
// We don't have a player item yet, so check with the asset because some assets support inspection
// prior to becoming ready to play.
- RetainPtr<CFArrayRef> visualTracks(AdoptCF, AVCFAssetCopyTracksWithMediaCharacteristic(avAsset(m_avfWrapper), AVCFMediaCharacteristicVisual));
+ RetainPtr<CFArrayRef> visualTracks = adoptCF(AVCFAssetCopyTracksWithMediaCharacteristic(avAsset(m_avfWrapper), AVCFMediaCharacteristicVisual));
setHasVideo(CFArrayGetCount(visualTracks.get()));
- RetainPtr<CFArrayRef> audioTracks(AdoptCF, AVCFAssetCopyTracksWithMediaCharacteristic(avAsset(m_avfWrapper), AVCFMediaCharacteristicAudible));
+ RetainPtr<CFArrayRef> audioTracks = adoptCF(AVCFAssetCopyTracksWithMediaCharacteristic(avAsset(m_avfWrapper), AVCFMediaCharacteristicAudible));
setHasAudio(CFArrayGetCount(audioTracks.get()));
- RetainPtr<CFArrayRef> captionTracks(AdoptCF, AVCFAssetCopyTracksWithMediaType(avAsset(m_avfWrapper), AVCFMediaTypeClosedCaption));
- setHasAudio(CFArrayGetCount(captionTracks.get()));
+#if !HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
+ RetainPtr<CFArrayRef> captionTracks = adoptCF(AVCFAssetCopyTracksWithMediaType(avAsset(m_avfWrapper), AVCFMediaTypeClosedCaption));
+ hasCaptions = CFArrayGetCount(captionTracks.get());
+#endif
} else {
bool hasVideo = false;
bool hasAudio = false;
- bool hasCaptions = false;
- RetainPtr<CFArrayRef> tracks(AdoptCF, AVCFPlayerItemCopyTracks(avPlayerItem(m_avfWrapper)));
+ RetainPtr<CFArrayRef> tracks = adoptCF(AVCFPlayerItemCopyTracks(avPlayerItem(m_avfWrapper)));
CFIndex trackCount = CFArrayGetCount(tracks.get());
for (CFIndex i = 0; i < trackCount; i++) {
AVCFPlayerItemTrackRef track = (AVCFPlayerItemTrackRef)(CFArrayGetValueAtIndex(tracks.get(), i));
if (AVCFPlayerItemTrackIsEnabled(track)) {
- RetainPtr<AVCFAssetTrackRef> assetTrack(AdoptCF, AVCFPlayerItemTrackCopyAssetTrack(track));
+ RetainPtr<AVCFAssetTrackRef> assetTrack = adoptCF(AVCFPlayerItemTrackCopyAssetTrack(track));
CFStringRef mediaType = AVCFAssetTrackGetMediaType(assetTrack.get());
if (!mediaType)
continue;
@@ -792,20 +877,43 @@ void MediaPlayerPrivateAVFoundationCF::tracksChanged()
hasVideo = true;
else if (CFStringCompare(mediaType, AVCFMediaTypeAudio, kCFCompareCaseInsensitive) == kCFCompareEqualTo)
hasAudio = true;
- else if (CFStringCompare(mediaType, AVCFMediaTypeClosedCaption, kCFCompareCaseInsensitive) == kCFCompareEqualTo)
+ else if (CFStringCompare(mediaType, AVCFMediaTypeClosedCaption, kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
+#if !HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
hasCaptions = true;
+#endif
+ haveCCTrack = true;
+ }
}
}
setHasVideo(hasVideo);
setHasAudio(hasAudio);
- setHasClosedCaptions(hasCaptions);
}
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
+ AVCFMediaSelectionGroupRef legibleGroup = safeMediaSelectionGroupForLegibleMedia(m_avfWrapper);
+ if (legibleGroup) {
+ RetainPtr<CFArrayRef> playableOptions = adoptCF(AVCFMediaSelectionCopyPlayableOptionsFromArray(AVCFMediaSelectionGroupGetOptions(legibleGroup)));
+ hasCaptions = CFArrayGetCount(playableOptions.get());
+ if (hasCaptions)
+ processMediaSelectionOptions();
+ }
+#endif
+
+#if !HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
+ if (haveCCTrack)
+ processLegacyClosedCaptionsTracks();
+#endif
+
+ setHasClosedCaptions(hasCaptions);
+
LOG(Media, "MediaPlayerPrivateAVFoundationCF:tracksChanged(%p) - hasVideo = %s, hasAudio = %s, hasCaptions = %s",
this, boolString(hasVideo()), boolString(hasAudio()), boolString(hasClosedCaptions()));
sizeChanged();
+
+ if (!primaryAudioTrackLanguage.isNull() && primaryAudioTrackLanguage != languageOfPrimaryAudioTrack())
+ player()->characteristicChanged();
}
void MediaPlayerPrivateAVFoundationCF::sizeChanged()
@@ -816,7 +924,7 @@ void MediaPlayerPrivateAVFoundationCF::sizeChanged()
// AVAsset's 'naturalSize' property only considers the movie's first video track, so we need to compute
// the union of all visual track rects.
CGRect trackRectUnion = CGRectZero;
- RetainPtr<CFArrayRef> tracks(AdoptCF, AVCFAssetCopyTracksWithMediaType(avAsset(m_avfWrapper), AVCFMediaCharacteristicVisual));
+ RetainPtr<CFArrayRef> tracks = adoptCF(AVCFAssetCopyTracksWithMediaType(avAsset(m_avfWrapper), AVCFMediaCharacteristicVisual));
CFIndex trackCount = CFArrayGetCount(tracks.get());
for (CFIndex i = 0; i < trackCount; i++) {
AVCFAssetTrackRef assetTrack = (AVCFAssetTrackRef)(CFArrayGetValueAtIndex(tracks.get(), i));
@@ -838,6 +946,165 @@ void MediaPlayerPrivateAVFoundationCF::sizeChanged()
setNaturalSize(IntSize(naturalSize));
}
+#if !HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
+void MediaPlayerPrivateAVFoundationCF::processLegacyClosedCaptionsTracks()
+{
+ AVCFPlayerItemSelectMediaOptionInMediaSelectionGroup(avPlayerItem(m_avfWrapper), 0, safeMediaSelectionGroupForLegibleMedia(m_avfWrapper));
+
+ Vector<RefPtr<InbandTextTrackPrivateAVF> > removedTextTracks = m_textTracks;
+ RetainPtr<CFArrayRef> tracks = adoptCF(AVCFPlayerItemCopyTracks(avPlayerItem(m_avfWrapper)));
+ CFIndex trackCount = CFArrayGetCount(tracks.get());
+ for (CFIndex i = 0; i < trackCount; ++i) {
+ AVCFPlayerItemTrackRef playerItemTrack = (AVCFPlayerItemTrackRef)(CFArrayGetValueAtIndex(tracks.get(), i));
+
+ RetainPtr<AVCFAssetTrackRef> assetTrack = adoptCF(AVCFPlayerItemTrackCopyAssetTrack(playerItemTrack));
+ CFStringRef mediaType = AVCFAssetTrackGetMediaType(assetTrack.get());
+ if (!mediaType)
+ continue;
+
+ if (CFStringCompare(mediaType, AVCFMediaTypeClosedCaption, kCFCompareCaseInsensitive) != kCFCompareEqualTo)
+ continue;
+
+ bool newCCTrack = true;
+ for (unsigned i = removedTextTracks.size(); i > 0; --i) {
+ if (!removedTextTracks[i - 1]->isLegacyClosedCaptionsTrack())
+ continue;
+
+ RefPtr<InbandTextTrackPrivateLegacyAVCF> track = static_cast<InbandTextTrackPrivateLegacyAVCF*>(m_textTracks[i - 1].get());
+ if (track->avPlayerItemTrack() == playerItemTrack) {
+ removedTextTracks.remove(i - 1);
+ newCCTrack = false;
+ break;
+ }
+ }
+
+ if (!newCCTrack)
+ continue;
+
+ m_textTracks.append(InbandTextTrackPrivateLegacyAVCF::create(this, playerItemTrack));
+ }
+
+ processNewAndRemovedTextTracks(removedTextTracks);
+}
+#endif
+
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
+void MediaPlayerPrivateAVFoundationCF::processMediaSelectionOptions()
+{
+ AVCFMediaSelectionGroupRef legibleGroup = safeMediaSelectionGroupForLegibleMedia(m_avfWrapper);
+ if (!legibleGroup) {
+ LOG(Media, "MediaPlayerPrivateAVFoundationCF::processMediaSelectionOptions(%p) - nil mediaSelectionGroup", this);
+ return;
+ }
+
+ // We enabled automatic media selection because we want alternate audio tracks to be enabled/disabled automatically,
+ // but set the selected legible track to nil so text tracks will not be automatically configured.
+ if (!m_textTracks.size()) {
+ ASSERT(AVCFMediaSelectionGroupAllowsEmptySelection(legibleGroup));
+ AVCFPlayerItemRef playerItem = avPlayerItem(m_avfWrapper);
+
+ if (playerItem)
+ AVCFPlayerItemSelectMediaOptionInMediaSelectionGroup(playerItem, 0, legibleGroup);
+ }
+
+ Vector<RefPtr<InbandTextTrackPrivateAVF> > removedTextTracks = m_textTracks;
+ RetainPtr<CFArrayRef> legibleOptions = adoptCF(AVCFMediaSelectionCopyPlayableOptionsFromArray(AVCFMediaSelectionGroupGetOptions(legibleGroup)));
+ CFIndex legibleOptionsCount = CFArrayGetCount(legibleOptions.get());
+ for (CFIndex i = 0; i < legibleOptionsCount; ++i) {
+ AVCFMediaSelectionOptionRef option = static_cast<AVCFMediaSelectionOptionRef>(CFArrayGetValueAtIndex(legibleOptions.get(), i));
+ bool newTrack = true;
+ for (unsigned i = removedTextTracks.size(); i > 0; --i) {
+ if (removedTextTracks[i - 1]->isLegacyClosedCaptionsTrack())
+ continue;
+
+ RefPtr<InbandTextTrackPrivateAVCF> track = static_cast<InbandTextTrackPrivateAVCF*>(removedTextTracks[i - 1].get());
+ if (CFEqual(track->mediaSelectionOption(), option)) {
+ removedTextTracks.remove(i - 1);
+ newTrack = false;
+ break;
+ }
+ }
+ if (!newTrack)
+ continue;
+
+ m_textTracks.append(InbandTextTrackPrivateAVCF::create(this, option));
+ }
+
+ processNewAndRemovedTextTracks(removedTextTracks);
+}
+
+#endif // HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
+
+void AVFWrapper::setCurrentTrack(InbandTextTrackPrivateAVF* track)
+{
+ if (m_currentTrack == track)
+ return;
+
+ LOG(Media, "MediaPlayerPrivateAVFoundationCF::setCurrentTrack(%p) - selecting track %p, language = %s", this, track, track ? track->language().string().utf8().data() : "");
+
+ m_currentTrack = track;
+
+ if (track) {
+ if (track->isLegacyClosedCaptionsTrack())
+ AVCFPlayerSetClosedCaptionDisplayEnabled(avPlayer(), TRUE);
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
+ else
+ AVCFPlayerItemSelectMediaOptionInMediaSelectionGroup(avPlayerItem(), static_cast<InbandTextTrackPrivateAVCF*>(track)->mediaSelectionOption(), safeMediaSelectionGroupForLegibleMedia());
+#endif
+ } else {
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
+ AVCFPlayerItemSelectMediaOptionInMediaSelectionGroup(avPlayerItem(), 0, safeMediaSelectionGroupForLegibleMedia());
+#endif
+ AVCFPlayerSetClosedCaptionDisplayEnabled(avPlayer(), FALSE);
+ }
+}
+
+String MediaPlayerPrivateAVFoundationCF::languageOfPrimaryAudioTrack() const
+{
+ if (!m_languageOfPrimaryAudioTrack.isNull())
+ return m_languageOfPrimaryAudioTrack;
+
+ if (!avPlayerItem(m_avfWrapper))
+ return emptyString();
+
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
+ // If AVFoundation has an audible group, return the language of the currently selected audible option.
+ AVCFMediaSelectionGroupRef audibleGroup = AVCFAssetGetSelectionGroupForMediaCharacteristic(avAsset(m_avfWrapper), AVCFMediaCharacteristicAudible);
+ AVCFMediaSelectionOptionRef currentlySelectedAudibleOption = AVCFPlayerItemGetSelectedMediaOptionInMediaSelectionGroup(avPlayerItem(m_avfWrapper), audibleGroup);
+ if (currentlySelectedAudibleOption) {
+ RetainPtr<CFLocaleRef> audibleOptionLocale = adoptCF(AVCFMediaSelectionOptionCopyLocale(currentlySelectedAudibleOption));
+ m_languageOfPrimaryAudioTrack = CFLocaleGetIdentifier(audibleOptionLocale.get());
+ LOG(Media, "MediaPlayerPrivateAVFoundationCF::languageOfPrimaryAudioTrack(%p) - returning language of selected audible option: %s", this, m_languageOfPrimaryAudioTrack.utf8().data());
+
+ return m_languageOfPrimaryAudioTrack;
+ }
+#endif // HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
+
+ // AVFoundation synthesizes an audible group when there is only one ungrouped audio track if there is also a legible group (one or
+ // more in-band text tracks). It doesn't know about out-of-band tracks, so if there is a single audio track return its language.
+ RetainPtr<CFArrayRef> tracks = adoptCF(AVCFAssetCopyTracksWithMediaType(avAsset(m_avfWrapper), AVCFMediaTypeAudio));
+ CFIndex trackCount = CFArrayGetCount(tracks.get());
+ if (!tracks || trackCount != 1) {
+ m_languageOfPrimaryAudioTrack = emptyString();
+ LOG(Media, "MediaPlayerPrivateAVFoundationCF::languageOfPrimaryAudioTrack(%p) - %i audio tracks, returning emptyString()", this, (tracks ? trackCount : 0));
+ return m_languageOfPrimaryAudioTrack;
+ }
+
+ AVCFAssetTrackRef track = (AVCFAssetTrackRef)CFArrayGetValueAtIndex(tracks.get(), 0);
+ RetainPtr<CFStringRef> language = adoptCF(AVCFAssetTrackCopyExtendedLanguageTag(track));
+
+ // Some legacy tracks have "und" as a language, treat that the same as no language at all.
+ if (language && CFStringCompare(language.get(), CFSTR("und"), kCFCompareCaseInsensitive) != kCFCompareEqualTo) {
+ m_languageOfPrimaryAudioTrack = language.get();
+ LOG(Media, "MediaPlayerPrivateAVFoundationCF::languageOfPrimaryAudioTrack(%p) - returning language of single audio track: %s", this, m_languageOfPrimaryAudioTrack.utf8().data());
+ return m_languageOfPrimaryAudioTrack;
+ }
+
+ LOG(Media, "MediaPlayerPrivateAVFoundationCF::languageOfPrimaryAudioTrack(%p) - single audio track has no language, returning emptyString()", this);
+ m_languageOfPrimaryAudioTrack = emptyString();
+ return m_languageOfPrimaryAudioTrack;
+}
+
void MediaPlayerPrivateAVFoundationCF::contentsNeedsDisplay()
{
if (m_avfWrapper)
@@ -847,6 +1114,7 @@ void MediaPlayerPrivateAVFoundationCF::contentsNeedsDisplay()
AVFWrapper::AVFWrapper(MediaPlayerPrivateAVFoundationCF* owner)
: m_owner(owner)
, m_objectID(s_nextAVFWrapperObjectID++)
+ , m_currentTrack(0)
{
LOG(Media, "AVFWrapper::AVFWrapper(%p)", this);
@@ -869,6 +1137,14 @@ AVFWrapper::~AVFWrapper()
m_avAsset = 0;
}
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP) && HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
+ if (legibleOutput()) {
+ if (avPlayerItem())
+ AVCFPlayerItemRemoveOutput(avPlayerItem(), legibleOutput());
+ m_legibleOutput = 0;
+ }
+#endif
+
m_avPlayerItem = 0;
m_timeObserver = 0;
m_avPlayer = 0;
@@ -959,17 +1235,17 @@ void AVFWrapper::createAssetForURL(const String& url)
{
ASSERT(!avAsset());
- RetainPtr<CFURLRef> urlRef(AdoptCF, KURL(ParsedURLString, url).createCFURL());
+ RetainPtr<CFURLRef> urlRef = KURL(ParsedURLString, url).createCFURL();
AVCFURLAssetRef assetRef = AVCFURLAssetCreateWithURLAndOptions(kCFAllocatorDefault, urlRef.get(), 0, m_notificationQueue);
- m_avAsset.adoptCF(assetRef);
+ m_avAsset = adoptCF(assetRef);
}
void AVFWrapper::createPlayer(IDirect3DDevice9* d3dDevice)
{
ASSERT(!avPlayer() && avPlayerItem());
- RetainPtr<CFMutableDictionaryRef> optionsRef(AdoptCF, CFDictionaryCreateMutable(kCFAllocatorDefault, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+ RetainPtr<CFMutableDictionaryRef> optionsRef = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
if (d3dDevice) {
// QI for an IDirect3DDevice9Ex interface, it is required to do HW video decoding.
@@ -981,13 +1257,27 @@ void AVFWrapper::createPlayer(IDirect3DDevice9* d3dDevice)
if (m_d3dDevice && AVCFPlayerEnableHardwareAcceleratedVideoDecoderKey)
CFDictionarySetValue(optionsRef.get(), AVCFPlayerEnableHardwareAcceleratedVideoDecoderKey, kCFBooleanTrue);
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP) && HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
+ CFDictionarySetValue(optionsRef.get(), AVCFPlayerAppliesMediaSelectionCriteriaAutomaticallyKey, kCFBooleanTrue);
+#endif
+
// FIXME: We need a way to create a AVPlayer without an AVPlayerItem, see <rdar://problem/9877730>.
AVCFPlayerRef playerRef = AVCFPlayerCreateWithPlayerItemAndOptions(kCFAllocatorDefault, avPlayerItem(), optionsRef.get(), m_notificationQueue);
- m_avPlayer.adoptCF(playerRef);
+ m_avPlayer = adoptCF(playerRef);
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP) && HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
+ AVCFPlayerSetClosedCaptionDisplayEnabled(playerRef, FALSE);
+#endif
if (m_d3dDevice && AVCFPlayerSetDirect3DDevicePtr())
AVCFPlayerSetDirect3DDevicePtr()(playerRef, m_d3dDevice.get());
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP) && HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
+ // Because of a bug in AVFoundationCF, we have to wait until the player is created before we can add the legible output:
+ // Once <rdar://problem/14390466> this is fixed, we can remove the following two lines.
+ ::Sleep(1000); // FIXME: This is being fixed as part of <rdar://problem/14390466>
+ AVCFPlayerItemAddOutput(avPlayerItem(), legibleOutput());
+#endif
+
CFNotificationCenterRef center = CFNotificationCenterGetLocalCenter();
ASSERT(center);
@@ -996,7 +1286,7 @@ void AVFWrapper::createPlayer(IDirect3DDevice9* d3dDevice)
// Add a time observer, ask to be called infrequently because we don't really want periodic callbacks but
// our observer will also be called whenever a seek happens.
const double veryLongInterval = 60*60*60*24*30;
- m_timeObserver.adoptCF(AVCFPlayerCreatePeriodicTimeObserverForInterval(playerRef, CMTimeMake(veryLongInterval, 10), m_notificationQueue, &periodicTimeObserverCallback, callbackContext()));
+ m_timeObserver = adoptCF(AVCFPlayerCreatePeriodicTimeObserverForInterval(playerRef, CMTimeMake(veryLongInterval, 10), m_notificationQueue, &periodicTimeObserverCallback, callbackContext()));
}
void AVFWrapper::createPlayerItem()
@@ -1005,7 +1295,7 @@ void AVFWrapper::createPlayerItem()
// Create the player item so we begin loading media data.
AVCFPlayerItemRef itemRef = AVCFPlayerItemCreateWithAsset(kCFAllocatorDefault, avAsset(), m_notificationQueue);
- m_avPlayerItem.adoptCF(itemRef);
+ m_avPlayerItem = adoptCF(itemRef);
CFNotificationCenterRef center = CFNotificationCenterGetLocalCenter();
ASSERT(center);
@@ -1018,8 +1308,30 @@ void AVFWrapper::createPlayerItem()
CFNotificationCenterAddObserver(center, callbackContext(), notificationCallback, AVCFPlayerItemIsPlaybackLikelyToKeepUpChangedNotification, itemRef, CFNotificationSuspensionBehaviorDeliverImmediately);
CFNotificationCenterAddObserver(center, callbackContext(), notificationCallback, AVCFPlayerItemIsPlaybackBufferEmptyChangedNotification, itemRef, CFNotificationSuspensionBehaviorDeliverImmediately);
CFNotificationCenterAddObserver(center, callbackContext(), notificationCallback, AVCFPlayerItemIsPlaybackBufferFullChangedNotification, itemRef, CFNotificationSuspensionBehaviorDeliverImmediately);
+ CFNotificationCenterAddObserver(center, callbackContext(), notificationCallback, AVCFPlayerItemDurationChangedNotification, itemRef, CFNotificationSuspensionBehaviorDeliverImmediately);
+ // FIXME: Are there other legible output things we need to register for? asset, hasEnabledAudio?
CFNotificationCenterAddObserver(center, callbackContext(), notificationCallback, CACFContextNeedsFlushNotification(), 0, CFNotificationSuspensionBehaviorDeliverImmediately);
+
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP) && HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
+ const CFTimeInterval legibleOutputAdvanceInterval = 2;
+
+ m_legibleOutput = adoptCF(AVCFPlayerItemLegibleOutputCreateWithMediaSubtypesForNativeRepresentation(kCFAllocatorDefault, 0));
+ AVCFPlayerItemOutputSetSuppressPlayerRendering(m_legibleOutput.get(), TRUE);
+
+ AVCFPlayerItemLegibleOutputCallbacks callbackInfo;
+ callbackInfo.version = kAVCFPlayerItemLegibleOutput_CallbacksVersion_1;
+ ASSERT(callbackContext());
+ callbackInfo.context = callbackContext();
+ callbackInfo.legibleOutputCallback = AVFWrapper::legibleOutputCallback;
+
+ AVCFPlayerItemLegibleOutputSetCallbacks(m_legibleOutput.get(), &callbackInfo, dispatch_get_main_queue());
+ AVCFPlayerItemLegibleOutputSetAdvanceIntervalForCallbackInvocation(m_legibleOutput.get(), legibleOutputAdvanceInterval);
+ AVCFPlayerItemLegibleOutputSetTextStylingResolution(m_legibleOutput.get(), AVCFPlayerItemLegibleOutputTextStylingResolutionSourceAndRulesOnly);
+ // We cannot add the Legible Output to the player item until the player is constructed. <rdar://problem/14390466>
+ // Once this is fixed, we can uncomment the following line.
+ // AVCFPlayerItemAddOutput(m_avPlayerItem.get(), m_legibleOutput.get());
+#endif
}
void AVFWrapper::periodicTimeObserverCallback(AVCFPlayerRef, CMTime cmTime, void* context)
@@ -1148,13 +1460,66 @@ void AVFWrapper::seekToTime(float time)
kCMTimeZero, kCMTimeZero, &seekCompletedCallback, callbackContext());
}
+struct LegibleOutputData {
+ RetainPtr<CFArrayRef> m_attributedStrings;
+ double m_time;
+ void* m_context;
+
+ LegibleOutputData(CFArrayRef strings, double time, void* context)
+ : m_attributedStrings(strings), m_time(time), m_context(context)
+ {
+ }
+};
+
+void AVFWrapper::processCue(void* context)
+{
+ ASSERT(dispatch_get_main_queue() == dispatch_get_current_queue());
+ ASSERT(context);
+
+ if (!context)
+ return;
+
+ OwnPtr<LegibleOutputData> legibleOutputData = adoptPtr(reinterpret_cast<LegibleOutputData*>(context));
+
+ MutexLocker locker(mapLock());
+ AVFWrapper* self = avfWrapperForCallbackContext(legibleOutputData->m_context);
+ if (!self) {
+ LOG(Media, "AVFWrapper::processCue invoked for deleted AVFWrapper %d", reinterpret_cast<uintptr_t>(context));
+ return;
+ }
+
+ if (!self->m_currentTrack)
+ return;
+
+ self->m_currentTrack->processCue(legibleOutputData->m_attributedStrings.get(), legibleOutputData->m_time);
+}
+
+void AVFWrapper::legibleOutputCallback(void* context, AVCFPlayerItemLegibleOutputRef legibleOutput, CFArrayRef attributedStrings, CFArrayRef /*nativeSampleBuffers*/, CMTime itemTime)
+{
+ ASSERT(dispatch_get_main_queue() == dispatch_get_current_queue());
+ MutexLocker locker(mapLock());
+ AVFWrapper* self = avfWrapperForCallbackContext(context);
+ if (!self) {
+ LOG(Media, "AVFWrapper::legibleOutputCallback invoked for deleted AVFWrapper %d", reinterpret_cast<uintptr_t>(context));
+ return;
+ }
+
+ LOG(Media, "AVFWrapper::legibleOutputCallback(%p)", self);
+
+ ASSERT(legibleOutput == self->m_legibleOutput);
+
+ OwnPtr<LegibleOutputData> legibleOutputData = adoptPtr(new LegibleOutputData(attributedStrings, CMTimeGetSeconds(itemTime), context));
+
+ dispatch_async_f(dispatch_get_main_queue(), legibleOutputData.leakPtr(), processCue);
+}
+
void AVFWrapper::setAsset(AVCFURLAssetRef asset)
{
if (asset == avAsset())
return;
AVCFAssetCancelLoading(avAsset());
- m_avAsset.adoptCF(asset);
+ m_avAsset = adoptCF(asset);
}
PlatformLayer* AVFWrapper::platformLayer()
@@ -1175,7 +1540,7 @@ PlatformLayer* AVFWrapper::platformLayer()
return 0;
CACFLayerRef layerRef = AVCFPlayerLayerCopyCACFLayer(m_avCFVideoLayer.get());
- m_caVideoLayer.adoptCF(layerRef);
+ m_caVideoLayer = adoptCF(layerRef);
CACFLayerInsertSublayer(m_videoLayerWrapper->platformLayer(), m_caVideoLayer.get(), 0);
m_videoLayerWrapper->setAnchorPoint(FloatPoint3D());
@@ -1190,7 +1555,7 @@ void AVFWrapper::createAVCFVideoLayer()
return;
// The layer will get hooked up via RenderLayerBacking::updateGraphicsLayerConfiguration().
- m_avCFVideoLayer.adoptCF(AVCFPlayerLayerCreateWithAVCFPlayer(kCFAllocatorDefault, avPlayer(), m_notificationQueue));
+ m_avCFVideoLayer = adoptCF(AVCFPlayerLayerCreateWithAVCFPlayer(kCFAllocatorDefault, avPlayer(), m_notificationQueue));
LOG(Media, "AVFWrapper::createAVCFVideoLayer(%p) - returning %p", this, videoLayer());
}
@@ -1224,7 +1589,7 @@ void AVFWrapper::createImageGenerator()
if (!avAsset() || m_imageGenerator)
return;
- m_imageGenerator.adoptCF(AVCFAssetImageGeneratorCreateWithAsset(kCFAllocatorDefault, avAsset()));
+ m_imageGenerator = adoptCF(AVCFAssetImageGeneratorCreateWithAsset(kCFAllocatorDefault, avAsset()));
AVCFAssetImageGeneratorSetApertureMode(m_imageGenerator.get(), AVCFAssetImageGeneratorApertureModeCleanAperture);
AVCFAssetImageGeneratorSetRequestedTimeToleranceBefore(m_imageGenerator.get(), kCMTimeZero);
@@ -1260,6 +1625,19 @@ RetainPtr<CGImageRef> AVFWrapper::createImageForTimeInRect(float time, const Int
return image;
}
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP) && HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
+AVCFMediaSelectionGroupRef AVFWrapper::safeMediaSelectionGroupForLegibleMedia() const
+{
+ if (!avAsset())
+ return 0;
+
+ if (AVCFAssetGetStatusOfValueForProperty(avAsset(), AVCFAssetPropertyAvailableMediaCharacteristicsWithMediaSelectionOptions, 0) != AVCFPropertyValueStatusLoaded)
+ return 0;
+
+ return AVCFAssetGetSelectionGroupForMediaCharacteristic(avAsset(), AVCFMediaCharacteristicLegible);
+}
+#endif
+
void LayerClient::platformCALayerLayoutSublayersOfLayer(PlatformCALayer* wrapperLayer)
{
ASSERT(m_parent);
diff --git a/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h b/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h
index 81a9bc6e4..3b1451037 100644
--- a/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h
+++ b/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -38,6 +38,8 @@ class MediaPlayerPrivateAVFoundationCF : public MediaPlayerPrivateAVFoundation {
public:
virtual ~MediaPlayerPrivateAVFoundationCF();
+ virtual void tracksChanged() OVERRIDE;
+
static void registerMediaEngine(MediaEngineRegistrar);
private:
@@ -74,14 +76,14 @@ private:
virtual void checkPlayability();
virtual void updateRate();
virtual float rate() const;
- virtual void seekToTime(float time);
+ virtual void seekToTime(double time);
virtual unsigned totalBytes() const;
virtual PassRefPtr<TimeRanges> platformBufferedTimeRanges() const;
- virtual float platformMaxTimeSeekable() const;
+ virtual double platformMinTimeSeekable() const;
+ virtual double platformMaxTimeSeekable() const;
virtual float platformDuration() const;
virtual float platformMaxTimeLoaded() const;
virtual void beginLoadingMetadata();
- virtual void tracksChanged();
virtual void sizeChanged();
virtual bool hasAvailableVideoFrame() const;
@@ -97,9 +99,23 @@ private:
virtual void contentsNeedsDisplay();
+ virtual String languageOfPrimaryAudioTrack() const OVERRIDE;
+
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
+ void processMediaSelectionOptions();
+#endif
+
+ virtual void setCurrentTrack(InbandTextTrackPrivateAVF*) OVERRIDE;
+ virtual InbandTextTrackPrivateAVF* currentTrack() const OVERRIDE;
+
+#if !HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
+ void processLegacyClosedCaptionsTracks();
+#endif
+
friend class AVFWrapper;
AVFWrapper* m_avfWrapper;
+ mutable String m_languageOfPrimaryAudioTrack;
bool m_videoFrameHasDrawn;
};
diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.h b/Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.h
new file mode 100644
index 000000000..0e5e6caf0
--- /dev/null
+++ b/Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef InbandTextTrackPrivateAVFObjC_h
+#define InbandTextTrackPrivateAVFObjC_h
+
+#if ENABLE(VIDEO) && USE(AVFOUNDATION) && HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
+
+#include "InbandTextTrackPrivateAVF.h"
+#include <wtf/RetainPtr.h>
+
+OBJC_CLASS AVMediaSelectionOption;
+
+namespace WebCore {
+
+class InbandTextTrackPrivateAVFObjC : public InbandTextTrackPrivateAVF {
+public:
+ static PassRefPtr<InbandTextTrackPrivateAVFObjC> create(AVFInbandTrackParent* player, AVMediaSelectionOption *selection)
+ {
+ return adoptRef(new InbandTextTrackPrivateAVFObjC(player, selection));
+ }
+
+ ~InbandTextTrackPrivateAVFObjC() { }
+
+ virtual InbandTextTrackPrivate::Kind kind() const OVERRIDE;
+ virtual bool isClosedCaptions() const OVERRIDE;
+ virtual bool isSDH() const OVERRIDE;
+ virtual bool containsOnlyForcedSubtitles() const OVERRIDE;
+ virtual bool isMainProgramContent() const OVERRIDE;
+ virtual bool isEasyToRead() const OVERRIDE;
+ virtual AtomicString label() const OVERRIDE;
+ virtual AtomicString language() const OVERRIDE;
+ virtual bool isDefault() const OVERRIDE;
+
+ virtual void disconnect() OVERRIDE;
+
+ virtual bool isLegacyClosedCaptionsTrack() const OVERRIDE { return false; }
+
+ AVMediaSelectionOption *mediaSelectionOption() const { return m_mediaSelectionOption.get(); }
+
+protected:
+ InbandTextTrackPrivateAVFObjC(AVFInbandTrackParent*, AVMediaSelectionOption *);
+
+ RetainPtr<AVMediaSelectionOption> m_mediaSelectionOption;
+};
+
+}
+
+#endif
+#endif
diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.mm b/Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.mm
new file mode 100644
index 000000000..a6b373b34
--- /dev/null
+++ b/Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.mm
@@ -0,0 +1,203 @@
+/*
+ * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#if ENABLE(VIDEO) && USE(AVFOUNDATION) && HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
+
+#import "InbandTextTrackPrivateAVFObjC.h"
+
+#import "BlockExceptions.h"
+#import "FloatConversion.h"
+#import "InbandTextTrackPrivate.h"
+#import "InbandTextTrackPrivateAVF.h"
+#import "Logging.h"
+#import "SoftLinking.h"
+#import <AVFoundation/AVFoundation.h>
+#import <objc/runtime.h>
+
+SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)
+
+#define AVPlayer getAVPlayerClass()
+#define AVPlayerItem getAVPlayerItemClass()
+
+SOFT_LINK_CLASS(AVFoundation, AVPlayer)
+SOFT_LINK_CLASS(AVFoundation, AVPlayerItem)
+SOFT_LINK_CLASS(AVFoundation, AVMetadataItem)
+SOFT_LINK_CLASS(AVFoundation, AVPlayerItemLegibleOutput)
+#define AVMediaCharacteristicVisual getAVMediaCharacteristicVisual()
+#define AVMediaCharacteristicAudible getAVMediaCharacteristicAudible()
+#define AVMediaTypeClosedCaption getAVMediaTypeClosedCaption()
+#define AVMediaCharacteristicContainsOnlyForcedSubtitles getAVMediaCharacteristicContainsOnlyForcedSubtitles()
+#define AVMediaCharacteristicIsMainProgramContent getAVMediaCharacteristicIsMainProgramContent()
+#define AVMediaCharacteristicEasyToRead getAVMediaCharacteristicEasyToRead()
+
+SOFT_LINK_POINTER(AVFoundation, AVMediaTypeClosedCaption, NSString *)
+SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicLegible, NSString *)
+SOFT_LINK_POINTER(AVFoundation, AVMetadataCommonKeyTitle, NSString *)
+SOFT_LINK_POINTER(AVFoundation, AVMetadataKeySpaceCommon, NSString *)
+SOFT_LINK_POINTER(AVFoundation, AVMediaTypeSubtitle, NSString *)
+SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicTranscribesSpokenDialogForAccessibility, NSString *)
+SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicDescribesMusicAndSoundForAccessibility, NSString *)
+SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicContainsOnlyForcedSubtitles, NSString *)
+SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicIsMainProgramContent, NSString *)
+SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicEasyToRead, NSString *)
+
+#define AVMetadataItem getAVMetadataItemClass()
+#define AVPlayerItemLegibleOutput getAVPlayerItemLegibleOutputClass()
+#define AVMediaCharacteristicLegible getAVMediaCharacteristicLegible()
+#define AVMetadataCommonKeyTitle getAVMetadataCommonKeyTitle()
+#define AVMetadataKeySpaceCommon getAVMetadataKeySpaceCommon()
+#define AVMediaTypeSubtitle getAVMediaTypeSubtitle()
+#define AVMediaCharacteristicTranscribesSpokenDialogForAccessibility getAVMediaCharacteristicTranscribesSpokenDialogForAccessibility()
+#define AVMediaCharacteristicDescribesMusicAndSoundForAccessibility getAVMediaCharacteristicDescribesMusicAndSoundForAccessibility()
+
+using namespace WebCore;
+using namespace std;
+
+namespace WebCore {
+
+InbandTextTrackPrivateAVFObjC::InbandTextTrackPrivateAVFObjC(AVFInbandTrackParent* player, AVMediaSelectionOption *selection)
+ : InbandTextTrackPrivateAVF(player)
+ , m_mediaSelectionOption(selection)
+{
+}
+
+void InbandTextTrackPrivateAVFObjC::disconnect()
+{
+ m_mediaSelectionOption = 0;
+ InbandTextTrackPrivateAVF::disconnect();
+}
+
+InbandTextTrackPrivate::Kind InbandTextTrackPrivateAVFObjC::kind() const
+{
+ if (!m_mediaSelectionOption)
+ return InbandTextTrackPrivate::None;
+
+ NSString *mediaType = [m_mediaSelectionOption mediaType];
+
+ if ([mediaType isEqualToString:AVMediaTypeClosedCaption])
+ return InbandTextTrackPrivate::Captions;
+ if ([mediaType isEqualToString:AVMediaTypeSubtitle]) {
+
+ if ([m_mediaSelectionOption hasMediaCharacteristic:AVMediaCharacteristicContainsOnlyForcedSubtitles])
+ return InbandTextTrackPrivate::Forced;
+
+ // An "SDH" track is a subtitle track created for the deaf or hard-of-hearing. "captions" in WebVTT are
+ // "labeled as appropriate for the hard-of-hearing", so tag SDH sutitles as "captions".
+ if ([m_mediaSelectionOption hasMediaCharacteristic:AVMediaCharacteristicTranscribesSpokenDialogForAccessibility])
+ return InbandTextTrackPrivate::Captions;
+ if ([m_mediaSelectionOption hasMediaCharacteristic:AVMediaCharacteristicDescribesMusicAndSoundForAccessibility])
+ return InbandTextTrackPrivate::Captions;
+
+ return InbandTextTrackPrivate::Subtitles;
+ }
+
+ return InbandTextTrackPrivate::Captions;
+}
+
+bool InbandTextTrackPrivateAVFObjC::isClosedCaptions() const
+{
+ if (!m_mediaSelectionOption)
+ return false;
+
+ return [[m_mediaSelectionOption mediaType] isEqualToString:AVMediaTypeClosedCaption];
+}
+
+bool InbandTextTrackPrivateAVFObjC::isSDH() const
+{
+ if (!m_mediaSelectionOption)
+ return false;
+
+ if (![[m_mediaSelectionOption mediaType] isEqualToString:AVMediaTypeSubtitle])
+ return false;
+
+ if ([m_mediaSelectionOption hasMediaCharacteristic:AVMediaCharacteristicTranscribesSpokenDialogForAccessibility] && [m_mediaSelectionOption hasMediaCharacteristic:AVMediaCharacteristicDescribesMusicAndSoundForAccessibility])
+ return true;
+
+ return false;
+}
+
+bool InbandTextTrackPrivateAVFObjC::containsOnlyForcedSubtitles() const
+{
+ if (!m_mediaSelectionOption)
+ return false;
+
+ return [m_mediaSelectionOption hasMediaCharacteristic:AVMediaCharacteristicContainsOnlyForcedSubtitles];
+}
+
+bool InbandTextTrackPrivateAVFObjC::isMainProgramContent() const
+{
+ if (!m_mediaSelectionOption)
+ return false;
+
+ return [m_mediaSelectionOption hasMediaCharacteristic:AVMediaCharacteristicIsMainProgramContent];
+}
+
+bool InbandTextTrackPrivateAVFObjC::isEasyToRead() const
+{
+ if (!m_mediaSelectionOption)
+ return false;
+
+ return [m_mediaSelectionOption hasMediaCharacteristic:AVMediaCharacteristicEasyToRead];
+}
+
+AtomicString InbandTextTrackPrivateAVFObjC::label() const
+{
+ if (!m_mediaSelectionOption)
+ return emptyAtom;
+
+ NSString *title = 0;
+
+ NSArray *titles = [AVMetadataItem metadataItemsFromArray:[m_mediaSelectionOption.get() commonMetadata] withKey:AVMetadataCommonKeyTitle keySpace:AVMetadataKeySpaceCommon];
+ if ([titles count]) {
+ // If possible, return a title in one of the user's preferred languages.
+ NSArray *titlesForPreferredLanguages = [AVMetadataItem metadataItemsFromArray:titles filteredAndSortedAccordingToPreferredLanguages:[NSLocale preferredLanguages]];
+ if ([titlesForPreferredLanguages count])
+ title = [[titlesForPreferredLanguages objectAtIndex:0] stringValue];
+
+ if (!title)
+ title = [[titles objectAtIndex:0] stringValue];
+ }
+
+ return title ? AtomicString(title) : emptyAtom;
+}
+
+AtomicString InbandTextTrackPrivateAVFObjC::language() const
+{
+ if (!m_mediaSelectionOption)
+ return emptyAtom;
+
+ return [[m_mediaSelectionOption.get() locale] localeIdentifier];
+}
+
+bool InbandTextTrackPrivateAVFObjC::isDefault() const
+{
+ return false;
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateLegacyAVFObjC.h b/Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateLegacyAVFObjC.h
new file mode 100644
index 000000000..32e019c75
--- /dev/null
+++ b/Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateLegacyAVFObjC.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef InbandTextTrackPrivateLegacyAVFObjC_h
+#define InbandTextTrackPrivateLegacyAVFObjC_h
+
+#if ENABLE(VIDEO) && USE(AVFOUNDATION) && !HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT) && !PLATFORM(IOS)
+
+#include "InbandTextTrackPrivateAVF.h"
+#include <wtf/RetainPtr.h>
+
+OBJC_CLASS AVPlayerItemTrack;
+
+namespace WebCore {
+
+class MediaPlayerPrivateAVFoundationObjC;
+
+class InbandTextTrackPrivateLegacyAVFObjC : public InbandTextTrackPrivateAVF {
+public:
+ static PassRefPtr<InbandTextTrackPrivateLegacyAVFObjC> create(MediaPlayerPrivateAVFoundationObjC* player, AVPlayerItemTrack *track)
+ {
+ return adoptRef(new InbandTextTrackPrivateLegacyAVFObjC(player, track));
+ }
+
+ ~InbandTextTrackPrivateLegacyAVFObjC() { }
+
+ virtual InbandTextTrackPrivate::Kind kind() const OVERRIDE;
+ virtual bool isClosedCaptions() const OVERRIDE;
+ virtual bool containsOnlyForcedSubtitles() const OVERRIDE;
+ virtual bool isMainProgramContent() const OVERRIDE;
+ virtual bool isEasyToRead() const OVERRIDE;
+ virtual AtomicString label() const OVERRIDE;
+ virtual AtomicString language() const OVERRIDE;
+
+ virtual void disconnect() OVERRIDE;
+
+ virtual bool isLegacyClosedCaptionsTrack() const OVERRIDE { return true; }
+
+ AVPlayerItemTrack *avPlayerItemTrack() const { return m_playerItemTrack.get(); }
+
+protected:
+ InbandTextTrackPrivateLegacyAVFObjC(MediaPlayerPrivateAVFoundationObjC*, AVPlayerItemTrack *);
+
+ RetainPtr<AVPlayerItemTrack> m_playerItemTrack;
+};
+
+}
+
+#endif // ENABLE(VIDEO) && USE(AVFOUNDATION) && !HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT) && !PLATFORM(IOS)
+
+#endif
diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateLegacyAVFObjC.mm b/Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateLegacyAVFObjC.mm
new file mode 100644
index 000000000..bd5c5e163
--- /dev/null
+++ b/Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateLegacyAVFObjC.mm
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#if ENABLE(VIDEO) && USE(AVFOUNDATION) && !HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT) && !PLATFORM(IOS)
+
+#import "InbandTextTrackPrivateLegacyAVFObjC.h"
+
+#import "InbandTextTrackPrivateAVF.h"
+#import "Logging.h"
+#import "MediaPlayerPrivateAVFoundationObjC.h"
+#import "SoftLinking.h"
+#import <AVFoundation/AVFoundation.h>
+#import <objc/runtime.h>
+
+SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)
+#define AVPlayerItem getAVPlayerItemClass()
+
+SOFT_LINK_CLASS(AVFoundation, AVPlayerItem)
+SOFT_LINK_CLASS(AVFoundation, AVMetadataItem)
+#define AVMediaTypeClosedCaption getAVMediaTypeClosedCaption()
+
+SOFT_LINK_POINTER(AVFoundation, AVMediaTypeClosedCaption, NSString *)
+SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicLegible, NSString *)
+SOFT_LINK_POINTER(AVFoundation, AVMetadataCommonKeyTitle, NSString *)
+SOFT_LINK_POINTER(AVFoundation, AVMetadataKeySpaceCommon, NSString *)
+
+#define AVMetadataItem getAVMetadataItemClass()
+#define AVMediaCharacteristicLegible getAVMediaCharacteristicLegible()
+#define AVMetadataCommonKeyTitle getAVMetadataCommonKeyTitle()
+#define AVMetadataKeySpaceCommon getAVMetadataKeySpaceCommon()
+
+using namespace WebCore;
+using namespace std;
+
+namespace WebCore {
+
+InbandTextTrackPrivateLegacyAVFObjC::InbandTextTrackPrivateLegacyAVFObjC(MediaPlayerPrivateAVFoundationObjC* player, AVPlayerItemTrack* track)
+ : InbandTextTrackPrivateAVF(player)
+ , m_playerItemTrack(track)
+{
+}
+
+void InbandTextTrackPrivateLegacyAVFObjC::disconnect()
+{
+ m_playerItemTrack = 0;
+ InbandTextTrackPrivateAVF::disconnect();
+}
+
+InbandTextTrackPrivate::Kind InbandTextTrackPrivateLegacyAVFObjC::kind() const
+{
+ if (!m_playerItemTrack)
+ return InbandTextTrackPrivate::None;
+
+ return InbandTextTrackPrivate::Captions;
+}
+
+bool InbandTextTrackPrivateLegacyAVFObjC::isClosedCaptions() const
+{
+ return m_playerItemTrack;
+}
+
+bool InbandTextTrackPrivateLegacyAVFObjC::containsOnlyForcedSubtitles() const
+{
+ return false;
+}
+
+bool InbandTextTrackPrivateLegacyAVFObjC::isMainProgramContent() const
+{
+ return m_playerItemTrack;
+}
+
+bool InbandTextTrackPrivateLegacyAVFObjC::isEasyToRead() const
+{
+ return false;
+}
+
+AtomicString InbandTextTrackPrivateLegacyAVFObjC::label() const
+{
+ if (!m_playerItemTrack)
+ return emptyAtom;
+
+ NSString *title = 0;
+
+ NSArray *titles = [AVMetadataItem metadataItemsFromArray:[[m_playerItemTrack assetTrack] commonMetadata] withKey:AVMetadataCommonKeyTitle keySpace:AVMetadataKeySpaceCommon];
+ if ([titles count]) {
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
+ // If possible, return a title in one of the user's preferred languages.
+ NSArray *titlesForPreferredLanguages = [AVMetadataItem metadataItemsFromArray:titles filteredAndSortedAccordingToPreferredLanguages:[NSLocale preferredLanguages]];
+#else
+ NSArray *titlesForPreferredLanguages = [AVMetadataItem metadataItemsFromArray:titles withLocale:[NSLocale currentLocale]];
+#endif
+ if ([titlesForPreferredLanguages count])
+ title = [[titlesForPreferredLanguages objectAtIndex:0] stringValue];
+
+ if (!title)
+ title = [[titles objectAtIndex:0] stringValue];
+ }
+
+ return title ? AtomicString(title) : emptyAtom;
+}
+
+AtomicString InbandTextTrackPrivateLegacyAVFObjC::language() const
+{
+ if (!m_playerItemTrack)
+ return emptyAtom;
+
+ NSString *languageCode = [[m_playerItemTrack assetTrack] languageCode];
+ RetainPtr<NSLocale> locale = adoptNS([[NSLocale alloc] initWithLocaleIdentifier:languageCode]);
+ return [locale localeIdentifier];
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h
index 9cc4b58e0..cba096af4 100644
--- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h
+++ b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2012, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -28,33 +28,36 @@
#if ENABLE(VIDEO) && USE(AVFOUNDATION)
-#include "CachedResourceClient.h"
#include "MediaPlayerPrivateAVFoundation.h"
#include <wtf/HashMap.h>
-OBJC_CLASS AVURLAsset;
+OBJC_CLASS AVAssetImageGenerator;
+OBJC_CLASS AVMediaSelectionGroup;
OBJC_CLASS AVPlayer;
OBJC_CLASS AVPlayerItem;
+OBJC_CLASS AVPlayerItemLegibleOutput;
+OBJC_CLASS AVPlayerItemTrack;
OBJC_CLASS AVPlayerItemVideoOutput;
OBJC_CLASS AVPlayerLayer;
-OBJC_CLASS AVAssetImageGenerator;
+OBJC_CLASS AVURLAsset;
+OBJC_CLASS NSArray;
OBJC_CLASS WebCoreAVFMovieObserver;
+typedef struct objc_object* id;
+
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
OBJC_CLASS WebCoreAVFLoaderDelegate;
OBJC_CLASS AVAssetResourceLoadingRequest;
#endif
-#ifndef __OBJC__
-typedef struct objc_object *id;
-#endif
-
typedef struct CGImage *CGImageRef;
typedef struct __CVBuffer *CVPixelBufferRef;
+typedef struct OpaqueVTPixelTransferSession* VTPixelTransferSessionRef;
namespace WebCore {
class WebCoreAVFResourceLoader;
+class InbandTextTrackPrivateAVFObjC;
class MediaPlayerPrivateAVFoundationObjC : public MediaPlayerPrivateAVFoundation {
public:
@@ -65,11 +68,25 @@ public:
void setAsset(id);
virtual void tracksChanged();
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
+ RetainPtr<AVPlayerItem> playerItem() const { return m_avPlayerItem; }
+ void processCue(NSArray *, double);
+ void flushCues();
+#endif
+
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
bool shouldWaitForLoadingOfResource(AVAssetResourceLoadingRequest*);
void didCancelLoadingRequest(AVAssetResourceLoadingRequest*);
#endif
+#if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2)
+ static bool extractKeyURIKeyIDAndCertificateFromInitData(Uint8Array* initData, String& keyURI, String& keyID, RefPtr<Uint8Array>& certificate);
+#endif
+
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+ static RetainPtr<AVAssetResourceLoadingRequest> takeRequestForPlayerAndKeyURI(MediaPlayer*, const String&);
+#endif
+
private:
MediaPlayerPrivateAVFoundationObjC(MediaPlayer*);
@@ -77,7 +94,7 @@ private:
static PassOwnPtr<MediaPlayerPrivateInterface> create(MediaPlayer*);
static void getSupportedTypes(HashSet<String>& types);
static MediaPlayer::SupportsType supportsType(const String& type, const String& codecs, const KURL&);
-#if ENABLE(ENCRYPTED_MEDIA)
+#if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2)
static MediaPlayer::SupportsType extendedSupportsType(const String& type, const String& codecs, const String& keySystem, const KURL&);
#endif
@@ -108,10 +125,11 @@ private:
virtual void checkPlayability();
virtual void updateRate();
virtual float rate() const;
- virtual void seekToTime(float time);
+ virtual void seekToTime(double time);
virtual unsigned totalBytes() const;
virtual PassRefPtr<TimeRanges> platformBufferedTimeRanges() const;
- virtual float platformMaxTimeSeekable() const;
+ virtual double platformMinTimeSeekable() const;
+ virtual double platformMaxTimeSeekable() const;
virtual float platformDuration() const;
virtual float platformMaxTimeLoaded() const;
virtual void beginLoadingMetadata();
@@ -129,7 +147,7 @@ private:
virtual bool hasLayerRenderer() const;
virtual bool hasSingleSecurityOrigin() const;
-
+
#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1080
void createImageGenerator();
void destroyImageGenerator();
@@ -148,12 +166,27 @@ private:
virtual MediaPlayer::MediaKeyException cancelKeyRequest(const String&, const String&);
#endif
+ virtual String languageOfPrimaryAudioTrack() const OVERRIDE;
+
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
+ void processMediaSelectionOptions();
+ AVMediaSelectionGroup* safeMediaSelectionGroupForLegibleMedia();
+#endif
+
+ virtual void setCurrentTrack(InbandTextTrackPrivateAVF*) OVERRIDE;
+ virtual InbandTextTrackPrivateAVF* currentTrack() const OVERRIDE { return m_currentTrack; }
+
+#if !HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
+ void processLegacyClosedCaptionsTracks();
+#endif
+
RetainPtr<AVURLAsset> m_avAsset;
RetainPtr<AVPlayer> m_avPlayer;
RetainPtr<AVPlayerItem> m_avPlayerItem;
RetainPtr<AVPlayerLayer> m_videoLayer;
RetainPtr<WebCoreAVFMovieObserver> m_objcObserver;
RetainPtr<id> m_timeObserver;
+ mutable String m_languageOfPrimaryAudioTrack;
bool m_videoFrameHasDrawn;
bool m_haveCheckedPlayability;
@@ -164,16 +197,21 @@ private:
RetainPtr<CVPixelBufferRef> m_lastImage;
#endif
-#if ENABLE(ENCRYPTED_MEDIA) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+ RetainPtr<VTPixelTransferSessionRef> m_pixelTransferSession;
+
+ friend class WebCoreAVFResourceLoader;
+ OwnPtr<WebCoreAVFResourceLoader> m_resourceLoader;
RetainPtr<WebCoreAVFLoaderDelegate> m_loaderDelegate;
HashMap<String, RetainPtr<AVAssetResourceLoadingRequest> > m_keyURIToRequestMap;
HashMap<String, RetainPtr<AVAssetResourceLoadingRequest> > m_sessionIDToRequestMap;
#endif
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
- friend class WebCoreAVFResourceLoader;
- OwnPtr<WebCoreAVFResourceLoader> m_resourceLoader;
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP) && HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
+ RetainPtr<AVPlayerItemLegibleOutput> m_legibleOutput;
#endif
+
+ InbandTextTrackPrivateAVF* m_currentTrack;
};
}
diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
index 80a3c6959..53d12ac39 100644
--- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
+++ b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2012, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -31,10 +31,13 @@
#import "BlockExceptions.h"
#import "DataView.h"
+#import "ExceptionCodePlaceholder.h"
#import "FloatConversion.h"
-#import "FrameView.h"
#import "FloatConversion.h"
+#import "FrameView.h"
#import "GraphicsContext.h"
+#import "InbandTextTrackPrivateAVFObjC.h"
+#import "InbandTextTrackPrivateLegacyAVFObjC.h"
#import "KURL.h"
#import "Logging.h"
#import "SecurityOrigin.h"
@@ -44,22 +47,40 @@
#import "WebCoreAVFResourceLoader.h"
#import "WebCoreSystemInterface.h"
#import <objc/runtime.h>
-#import <wtf/UnusedParam.h>
-#import <wtf/Uint8Array.h>
+#import <wtf/CurrentTime.h>
#import <wtf/Uint16Array.h>
#import <wtf/Uint32Array.h>
+#import <wtf/Uint8Array.h>
+#import <wtf/text/CString.h>
-#import <CoreMedia/CoreMedia.h>
#import <AVFoundation/AVFoundation.h>
+#import <CoreMedia/CoreMedia.h>
+
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+#import <CoreVideo/CoreVideo.h>
+#import <VideoToolbox/VideoToolbox.h>
+#endif
SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)
SOFT_LINK_FRAMEWORK_OPTIONAL(CoreMedia)
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+SOFT_LINK_FRAMEWORK_OPTIONAL(CoreVideo)
+SOFT_LINK_FRAMEWORK_OPTIONAL(VideoToolbox)
+#endif
+
SOFT_LINK(CoreMedia, CMTimeCompare, int32_t, (CMTime time1, CMTime time2), (time1, time2))
SOFT_LINK(CoreMedia, CMTimeMakeWithSeconds, CMTime, (Float64 seconds, int32_t preferredTimeScale), (seconds, preferredTimeScale))
SOFT_LINK(CoreMedia, CMTimeGetSeconds, Float64, (CMTime time), (time))
SOFT_LINK(CoreMedia, CMTimeRangeGetEnd, CMTime, (CMTimeRange range), (range))
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+SOFT_LINK(CoreVideo, CVPixelBufferGetWidth, size_t, (CVPixelBufferRef pixelBuffer), (pixelBuffer))
+SOFT_LINK(CoreVideo, CVPixelBufferGetHeight, size_t, (CVPixelBufferRef pixelBuffer), (pixelBuffer))
+SOFT_LINK(VideoToolbox, VTPixelTransferSessionCreate, OSStatus, (CFAllocatorRef allocator, VTPixelTransferSessionRef *pixelTransferSessionOut), (allocator, pixelTransferSessionOut))
+SOFT_LINK(VideoToolbox, VTPixelTransferSessionTransferImage, OSStatus, (VTPixelTransferSessionRef session, CVPixelBufferRef sourceBuffer, CVPixelBufferRef destinationBuffer), (session, sourceBuffer, destinationBuffer))
+#endif
+
SOFT_LINK_CLASS(AVFoundation, AVPlayer)
SOFT_LINK_CLASS(AVFoundation, AVPlayerItem)
SOFT_LINK_CLASS(AVFoundation, AVPlayerItemVideoOutput)
@@ -94,6 +115,28 @@ SOFT_LINK_CONSTANT(CoreMedia, kCMTimeZero, CMTime)
#define AVAssetImageGeneratorApertureModeCleanAperture getAVAssetImageGeneratorApertureModeCleanAperture()
#define AVURLAssetReferenceRestrictionsKey getAVURLAssetReferenceRestrictionsKey()
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
+typedef AVMediaSelectionGroup AVMediaSelectionGroupType;
+typedef AVMediaSelectionOption AVMediaSelectionOptionType;
+
+SOFT_LINK_CLASS(AVFoundation, AVPlayerItemLegibleOutput)
+SOFT_LINK_CLASS(AVFoundation, AVMediaSelectionGroup)
+SOFT_LINK_CLASS(AVFoundation, AVMediaSelectionOption)
+
+SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicLegible, NSString *)
+SOFT_LINK_POINTER(AVFoundation, AVMediaTypeSubtitle, NSString *)
+SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicContainsOnlyForcedSubtitles, NSString *)
+SOFT_LINK_POINTER(AVFoundation, AVPlayerItemLegibleOutputTextStylingResolutionSourceAndRulesOnly, NSString *)
+
+#define AVPlayerItemLegibleOutput getAVPlayerItemLegibleOutputClass()
+#define AVMediaSelectionGroup getAVMediaSelectionGroupClass()
+#define AVMediaSelectionOption getAVMediaSelectionOptionClass()
+#define AVMediaCharacteristicLegible getAVMediaCharacteristicLegible()
+#define AVMediaTypeSubtitle getAVMediaTypeSubtitle()
+#define AVMediaCharacteristicContainsOnlyForcedSubtitles getAVMediaCharacteristicContainsOnlyForcedSubtitles()
+#define AVPlayerItemLegibleOutputTextStylingResolutionSourceAndRulesOnly getAVPlayerItemLegibleOutputTextStylingResolutionSourceAndRulesOnly()
+#endif
+
#define kCMTimeZero getkCMTimeZero()
using namespace WebCore;
@@ -104,7 +147,11 @@ enum MediaPlayerAVFoundationObservationContext {
MediaPlayerAVFoundationObservationContextPlayer
};
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP) && HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
+@interface WebCoreAVFMovieObserver : NSObject <AVPlayerItemLegibleOutputPushDelegate>
+#else
@interface WebCoreAVFMovieObserver : NSObject
+#endif
{
MediaPlayerPrivateAVFoundationObjC* m_callback;
int m_delayCallbacks;
@@ -116,6 +163,10 @@ enum MediaPlayerAVFoundationObservationContext {
-(void)seekCompleted:(BOOL)finished;
-(void)didEnd:(NSNotification *)notification;
-(void)observeValueForKeyPath:keyPath ofObject:(id)object change:(NSDictionary *)change context:(MediaPlayerAVFoundationObservationContext)context;
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
+- (void)legibleOutput:(id)output didOutputAttributedStrings:(NSArray *)strings nativeSampleBuffers:(NSArray *)nativeSamples forItemTime:(CMTime)itemTime;
+- (void)outputSequenceWasFlushed:(id)output;
+#endif
@end
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
@@ -124,6 +175,7 @@ enum MediaPlayerAVFoundationObservationContext {
}
- (id)initWithCallback:(MediaPlayerPrivateAVFoundationObjC*)callback;
- (BOOL)resourceLoader:(AVAssetResourceLoader *)resourceLoader shouldWaitForLoadingOfRequestedResource:(AVAssetResourceLoadingRequest *)loadingRequest;
+- (void)setCallback:(MediaPlayerPrivateAVFoundationObjC*)callback;
@end
#endif
@@ -139,6 +191,27 @@ static const char *boolString(bool val)
}
#endif
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+typedef HashMap<MediaPlayer*, MediaPlayerPrivateAVFoundationObjC*> PlayerToPrivateMapType;
+static PlayerToPrivateMapType& playerToPrivateMap()
+{
+ DEFINE_STATIC_LOCAL(PlayerToPrivateMapType, map, ());
+ return map;
+};
+#endif
+
+#if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2)
+static dispatch_queue_t globalLoaderDelegateQueue()
+{
+ static dispatch_queue_t globalQueue;
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ globalQueue = dispatch_queue_create("WebCoreAVFLoaderDelegate queue", DISPATCH_QUEUE_SERIAL);
+ });
+ return globalQueue;
+}
+#endif
+
PassOwnPtr<MediaPlayerPrivateInterface> MediaPlayerPrivateAVFoundationObjC::create(MediaPlayer* player)
{
return adoptPtr(new MediaPlayerPrivateAVFoundationObjC(player));
@@ -147,7 +220,7 @@ PassOwnPtr<MediaPlayerPrivateInterface> MediaPlayerPrivateAVFoundationObjC::crea
void MediaPlayerPrivateAVFoundationObjC::registerMediaEngine(MediaEngineRegistrar registrar)
{
if (isAvailable())
-#if ENABLE(ENCRYPTED_MEDIA)
+#if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2)
registrar(create, getSupportedTypes, extendedSupportsType, 0, 0, 0);
#else
registrar(create, getSupportedTypes, supportsType, 0, 0, 0);
@@ -156,19 +229,29 @@ void MediaPlayerPrivateAVFoundationObjC::registerMediaEngine(MediaEngineRegistra
MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC(MediaPlayer* player)
: MediaPlayerPrivateAVFoundation(player)
- , m_objcObserver(AdoptNS, [[WebCoreAVFMovieObserver alloc] initWithCallback:this])
+ , m_objcObserver(adoptNS([[WebCoreAVFMovieObserver alloc] initWithCallback:this]))
, m_videoFrameHasDrawn(false)
, m_haveCheckedPlayability(false)
-#if ENABLE(ENCRYPTED_MEDIA)
- , m_loaderDelegate(AdoptNS, [[WebCoreAVFLoaderDelegate alloc] initWithCallback:this])
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+ , m_loaderDelegate(adoptNS([[WebCoreAVFLoaderDelegate alloc] initWithCallback:this]))
#endif
+ , m_currentTrack(0)
{
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+ playerToPrivateMap().set(player, this);
+#endif
}
MediaPlayerPrivateAVFoundationObjC::~MediaPlayerPrivateAVFoundationObjC()
{
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+ playerToPrivateMap().remove(player());
+#endif
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+ [m_loaderDelegate.get() setCallback:0];
+ [[m_avAsset.get() resourceLoader] setDelegate:nil queue:0];
+#endif
cancelLoad();
- [m_objcObserver.get() disconnect];
}
void MediaPlayerPrivateAVFoundationObjC::cancelLoad()
@@ -177,6 +260,7 @@ void MediaPlayerPrivateAVFoundationObjC::cancelLoad()
tearDownVideoRendering();
[[NSNotificationCenter defaultCenter] removeObserver:m_objcObserver.get()];
+ [m_objcObserver.get() disconnect];
// Tell our observer to do nothing when our cancellation of pending loading calls its completion handler.
setIgnoreLoadStateChanges(true);
@@ -184,6 +268,17 @@ void MediaPlayerPrivateAVFoundationObjC::cancelLoad()
[m_avAsset.get() cancelLoading];
m_avAsset = nil;
}
+
+ clearTextTracks();
+
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP) && HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
+ if (m_legibleOutput) {
+ if (m_avPlayerItem)
+ [m_avPlayerItem.get() removeOutput:m_legibleOutput.get()];
+ m_legibleOutput = nil;
+ }
+#endif
+
if (m_avPlayerItem) {
for (NSString *keyName in itemKVOProperties())
[m_avPlayerItem.get() removeObserver:m_objcObserver.get() forKeyPath:keyName];
@@ -269,8 +364,9 @@ void MediaPlayerPrivateAVFoundationObjC::createVideoLayer()
return;
if (!m_videoLayer) {
- m_videoLayer.adoptNS([[AVPlayerLayer alloc] init]);
+ m_videoLayer = adoptNS([[AVPlayerLayer alloc] init]);
[m_videoLayer.get() setPlayer:m_avPlayer.get()];
+ [m_videoLayer.get() setBackgroundColor:CGColorGetConstantColor(kCGColorBlack)];
#ifndef NDEBUG
[m_videoLayer.get() setName:@"Video layer"];
#endif
@@ -304,12 +400,12 @@ void MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL(const String& url)
setDelayCallbacks(true);
- RetainPtr<NSMutableDictionary> options(AdoptNS, [[NSMutableDictionary alloc] init]);
+ RetainPtr<NSMutableDictionary> options = adoptNS([[NSMutableDictionary alloc] init]);
[options.get() setObject:[NSNumber numberWithInt:AVAssetReferenceRestrictionForbidRemoteReferenceToLocal | AVAssetReferenceRestrictionForbidLocalReferenceToRemote] forKey:AVURLAssetReferenceRestrictionsKey];
#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
- RetainPtr<NSMutableDictionary> headerFields(AdoptNS, [[NSMutableDictionary alloc] init]);
+ RetainPtr<NSMutableDictionary> headerFields = adoptNS([[NSMutableDictionary alloc] init]);
String referrer = player()->referrer();
if (!referrer.isEmpty())
@@ -324,10 +420,10 @@ void MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL(const String& url)
#endif
NSURL *cocoaURL = KURL(ParsedURLString, url);
- m_avAsset.adoptNS([[AVURLAsset alloc] initWithURL:cocoaURL options:options.get()]);
+ m_avAsset = adoptNS([[AVURLAsset alloc] initWithURL:cocoaURL options:options.get()]);
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
- [[m_avAsset.get() resourceLoader] setDelegate:m_loaderDelegate.get() queue:dispatch_get_main_queue()];
+ [[m_avAsset.get() resourceLoader] setDelegate:m_loaderDelegate.get() queue:globalLoaderDelegateQueue()];
#endif
m_haveCheckedPlayability = false;
@@ -344,9 +440,13 @@ void MediaPlayerPrivateAVFoundationObjC::createAVPlayer()
setDelayCallbacks(true);
- m_avPlayer.adoptNS([[AVPlayer alloc] init]);
+ m_avPlayer = adoptNS([[AVPlayer alloc] init]);
[m_avPlayer.get() addObserver:m_objcObserver.get() forKeyPath:@"rate" options:nil context:(void *)MediaPlayerAVFoundationObservationContextPlayer];
-
+
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP) && HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
+ [m_avPlayer.get() setAppliesMediaSelectionCriteriaAutomatically:YES];
+#endif
+
if (m_avPlayerItem)
[m_avPlayer.get() replaceCurrentItemWithPlayerItem:m_avPlayerItem.get()];
@@ -363,8 +463,8 @@ void MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem()
setDelayCallbacks(true);
// Create the player item so we can load media data.
- m_avPlayerItem.adoptNS([[AVPlayerItem alloc] initWithAsset:m_avAsset.get()]);
-
+ m_avPlayerItem = adoptNS([[AVPlayerItem alloc] initWithAsset:m_avAsset.get()]);
+
[[NSNotificationCenter defaultCenter] addObserver:m_objcObserver.get() selector:@selector(didEnd:) name:AVPlayerItemDidPlayToEndTimeNotification object:m_avPlayerItem.get()];
for (NSString *keyName in itemKVOProperties())
@@ -373,6 +473,18 @@ void MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem()
if (m_avPlayer)
[m_avPlayer.get() replaceCurrentItemWithPlayerItem:m_avPlayerItem.get()];
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP) && HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
+ const NSTimeInterval legibleOutputAdvanceInterval = 2;
+
+ m_legibleOutput = adoptNS([[AVPlayerItemLegibleOutput alloc] initWithMediaSubtypesForNativeRepresentation:[NSArray array]]);
+ [m_legibleOutput.get() setSuppressesPlayerRendering:YES];
+
+ [m_legibleOutput.get() setDelegate:m_objcObserver.get() queue:dispatch_get_main_queue()];
+ [m_legibleOutput.get() setAdvanceIntervalForDelegateInvocation:legibleOutputAdvanceInterval];
+ [m_legibleOutput.get() setTextStylingResolution:AVPlayerItemLegibleOutputTextStylingResolutionSourceAndRulesOnly];
+ [m_avPlayerItem.get() addOutput:m_legibleOutput.get()];
+#endif
+
setDelayCallbacks(false);
}
@@ -428,7 +540,6 @@ PlatformMedia MediaPlayerPrivateAVFoundationObjC::platformMedia() const
PlatformLayer* MediaPlayerPrivateAVFoundationObjC::platformLayer() const
{
- LOG(Media, "MediaPlayerPrivateAVFoundationObjC::platformLayer(%p)", this);
return m_videoLayer.get();
}
@@ -482,10 +593,7 @@ float MediaPlayerPrivateAVFoundationObjC::platformDuration() const
return narrowPrecisionToFloat(CMTimeGetSeconds(cmDuration));
if (CMTIME_IS_INDEFINITE(cmDuration)) {
- if (![[m_avAsset.get() tracks] count])
- return 0;
- else
- return numeric_limits<float>::infinity();
+ return numeric_limits<float>::infinity();
}
LOG(Media, "MediaPlayerPrivateAVFoundationObjC::platformDuration(%p) - invalid duration, returning %.0f", this, MediaPlayer::invalidTime());
@@ -505,7 +613,7 @@ float MediaPlayerPrivateAVFoundationObjC::currentTime() const
return 0;
}
-void MediaPlayerPrivateAVFoundationObjC::seekToTime(float time)
+void MediaPlayerPrivateAVFoundationObjC::seekToTime(double time)
{
// setCurrentTime generates several event callbacks, update afterwards.
setDelayCallbacks(true);
@@ -528,11 +636,12 @@ void MediaPlayerPrivateAVFoundationObjC::setVolume(float volume)
void MediaPlayerPrivateAVFoundationObjC::setClosedCaptionsVisible(bool closedCaptionsVisible)
{
+ UNUSED_PARAM(closedCaptionsVisible);
+
if (!metaDataAvailable())
return;
- LOG(Media, "MediaPlayerPrivateAVFoundationObjC::setClosedCaptionsVisible(%p) - setting to %s", this, boolString(closedCaptionsVisible));
- [m_avPlayer.get() setClosedCaptionDisplayEnabled:closedCaptionsVisible];
+ LOG(Media, "MediaPlayerPrivateAVFoundationObjC::setClosedCaptionsVisible(%p) - set to %s", this, boolString(closedCaptionsVisible));
}
void MediaPlayerPrivateAVFoundationObjC::updateRate()
@@ -569,23 +678,44 @@ PassRefPtr<TimeRanges> MediaPlayerPrivateAVFoundationObjC::platformBufferedTimeR
return timeRanges.release();
}
-float MediaPlayerPrivateAVFoundationObjC::platformMaxTimeSeekable() const
+double MediaPlayerPrivateAVFoundationObjC::platformMinTimeSeekable() const
+{
+ NSArray *seekableRanges = [m_avPlayerItem.get() seekableTimeRanges];
+ if (!seekableRanges || ![seekableRanges count])
+ return 0;
+
+ double minTimeSeekable = std::numeric_limits<double>::infinity();
+ bool hasValidRange = false;
+ for (NSValue *thisRangeValue in seekableRanges) {
+ CMTimeRange timeRange = [thisRangeValue CMTimeRangeValue];
+ if (!CMTIMERANGE_IS_VALID(timeRange) || CMTIMERANGE_IS_EMPTY(timeRange))
+ continue;
+
+ hasValidRange = true;
+ double startOfRange = CMTimeGetSeconds(timeRange.start);
+ if (minTimeSeekable > startOfRange)
+ minTimeSeekable = startOfRange;
+ }
+ return hasValidRange ? minTimeSeekable : 0;
+}
+
+double MediaPlayerPrivateAVFoundationObjC::platformMaxTimeSeekable() const
{
NSArray *seekableRanges = [m_avPlayerItem.get() seekableTimeRanges];
if (!seekableRanges)
return 0;
- float maxTimeSeekable = 0;
+ double maxTimeSeekable = 0;
for (NSValue *thisRangeValue in seekableRanges) {
CMTimeRange timeRange = [thisRangeValue CMTimeRangeValue];
if (!CMTIMERANGE_IS_VALID(timeRange) || CMTIMERANGE_IS_EMPTY(timeRange))
continue;
- float endOfRange = narrowPrecisionToFloat(CMTimeGetSeconds(CMTimeRangeGetEnd(timeRange)));
+ double endOfRange = CMTimeGetSeconds(CMTimeRangeGetEnd(timeRange));
if (maxTimeSeekable < endOfRange)
maxTimeSeekable = endOfRange;
}
- return maxTimeSeekable;
+ return maxTimeSeekable;
}
float MediaPlayerPrivateAVFoundationObjC::platformMaxTimeLoaded() const
@@ -633,6 +763,7 @@ MediaPlayerPrivateAVFoundation::AssetStatus MediaPlayerPrivateAVFoundationObjC::
for (NSString *keyName in assetMetadataKeyNames()) {
AVKeyValueStatus keyStatus = [m_avAsset.get() statusOfValueForKey:keyName error:nil];
+
if (keyStatus < AVKeyValueStatusLoaded)
return MediaPlayerAVAssetStatusLoading;// At least one key is not loaded yet.
@@ -751,7 +882,7 @@ MediaPlayer::SupportsType MediaPlayerPrivateAVFoundationObjC::supportsType(const
return [AVURLAsset isPlayableExtendedMIMEType:typeString] ? MediaPlayer::IsSupported : MediaPlayer::MayBeSupported;;
}
-#if ENABLE(ENCRYPTED_MEDIA)
+#if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2)
static bool keySystemIsSupported(const String& keySystem)
{
if (equalIgnoringCase(keySystem, "com.apple.lskd") || equalIgnoringCase(keySystem, "com.apple.lskd.1_0"))
@@ -786,20 +917,24 @@ bool MediaPlayerPrivateAVFoundationObjC::shouldWaitForLoadingOfResource(AVAssetR
String scheme = [[[avRequest request] URL] scheme];
String keyURI = [[[avRequest request] URL] absoluteString];
-#if ENABLE(ENCRYPTED_MEDIA)
+#if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2)
if (scheme == "skd") {
// Create an initData with the following layout:
// [4 bytes: keyURI size], [keyURI size bytes: keyURI]
unsigned keyURISize = keyURI.length() * sizeof(UChar);
RefPtr<ArrayBuffer> initDataBuffer = ArrayBuffer::create(4 + keyURISize, 1);
RefPtr<DataView> initDataView = DataView::create(initDataBuffer, 0, initDataBuffer->byteLength());
- ExceptionCode ec = 0;
- initDataView->setUint32(0, keyURISize, true, ec);
+ initDataView->setUint32(0, keyURISize, true, IGNORE_EXCEPTION);
RefPtr<Uint16Array> keyURIArray = Uint16Array::create(initDataBuffer, 4, keyURI.length());
keyURIArray->setRange(keyURI.characters(), keyURI.length() / sizeof(unsigned char), 0);
+#if ENABLE(ENCRYPTED_MEDIA)
if (!player()->keyNeeded("com.apple.lskd", emptyString(), static_cast<const unsigned char*>(initDataBuffer->data()), initDataBuffer->byteLength()))
+#elif ENABLE(ENCRYPTED_MEDIA_V2)
+ RefPtr<Uint8Array> initData = Uint8Array::create(initDataBuffer, 0, initDataBuffer->byteLength());
+ if (!player()->keyNeeded(initData.get()))
+#endif
return false;
m_keyURIToRequestMap.set(keyURI, avRequest);
@@ -837,9 +972,15 @@ float MediaPlayerPrivateAVFoundationObjC::mediaTimeForTimeValue(float timeValue)
void MediaPlayerPrivateAVFoundationObjC::tracksChanged()
{
+ String primaryAudioTrackLanguage = m_languageOfPrimaryAudioTrack;
+ m_languageOfPrimaryAudioTrack = String();
+
if (!m_avAsset)
return;
+ bool haveCCTrack = false;
+ bool hasCaptions = false;
+
// This is called whenever the tracks collection changes so cache hasVideo and hasAudio since we are
// asked about those fairly fequently.
if (!m_avPlayerItem) {
@@ -847,11 +988,12 @@ void MediaPlayerPrivateAVFoundationObjC::tracksChanged()
// prior to becoming ready to play.
setHasVideo([[m_avAsset.get() tracksWithMediaCharacteristic:AVMediaCharacteristicVisual] count]);
setHasAudio([[m_avAsset.get() tracksWithMediaCharacteristic:AVMediaCharacteristicAudible] count]);
- setHasClosedCaptions([[m_avAsset.get() tracksWithMediaType:AVMediaTypeClosedCaption] count]);
+#if !HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
+ hasCaptions = [[m_avAsset.get() tracksWithMediaType:AVMediaTypeClosedCaption] count];
+#endif
} else {
bool hasVideo = false;
bool hasAudio = false;
- bool hasCaptions = false;
NSArray *tracks = [m_avPlayerItem.get() tracks];
for (AVPlayerItemTrack *track in tracks) {
if ([track isEnabled]) {
@@ -860,19 +1002,43 @@ void MediaPlayerPrivateAVFoundationObjC::tracksChanged()
hasVideo = true;
else if ([[assetTrack mediaType] isEqualToString:AVMediaTypeAudio])
hasAudio = true;
- else if ([[assetTrack mediaType] isEqualToString:AVMediaTypeClosedCaption])
+ else if ([[assetTrack mediaType] isEqualToString:AVMediaTypeClosedCaption]) {
+#if !HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
hasCaptions = true;
+#endif
+ haveCCTrack = true;
+ }
}
}
setHasVideo(hasVideo);
setHasAudio(hasAudio);
- setHasClosedCaptions(hasCaptions);
}
- LOG(Media, "WebCoreAVFMovieObserver:tracksChanged(%p) - hasVideo = %s, hasAudio = %s, hasCaptions = %s",
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
+ if (AVMediaSelectionGroupType *legibleGroup = safeMediaSelectionGroupForLegibleMedia()) {
+ hasCaptions = [[AVMediaSelectionGroup playableMediaSelectionOptionsFromArray:[legibleGroup options]] count];
+ if (hasCaptions)
+ processMediaSelectionOptions();
+ }
+#endif
+
+#if !HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT) && HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
+ if (!hasCaptions && haveCCTrack)
+ processLegacyClosedCaptionsTracks();
+#elif !HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
+ if (haveCCTrack)
+ processLegacyClosedCaptionsTracks();
+#endif
+
+ setHasClosedCaptions(hasCaptions);
+
+ LOG(Media, "WebCoreAVFMovieObserver:tracksChanged(%p) - hasVideo = %s, hasAudio = %s, hasCaptions = %s",
this, boolString(hasVideo()), boolString(hasAudio()), boolString(hasClosedCaptions()));
sizeChanged();
+
+ if (!primaryAudioTrackLanguage.isNull() && primaryAudioTrackLanguage != languageOfPrimaryAudioTrack())
+ player()->characteristicChanged();
}
void MediaPlayerPrivateAVFoundationObjC::sizeChanged()
@@ -926,9 +1092,13 @@ void MediaPlayerPrivateAVFoundationObjC::createVideoOutput()
if (!m_avPlayerItem || m_videoOutput)
return;
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+ NSDictionary* attributes = @{ (NSString*)kCVPixelBufferPixelFormatTypeKey: @(kCVPixelFormatType_422YpCbCr8) };
+#else
NSDictionary* attributes = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInt:k32BGRAPixelFormat], kCVPixelBufferPixelFormatTypeKey,
nil];
- m_videoOutput.adoptNS([[AVPlayerItemVideoOutput alloc] initWithPixelBufferAttributes:attributes]);
+#endif
+ m_videoOutput = adoptNS([[AVPlayerItemVideoOutput alloc] initWithPixelBufferAttributes:attributes]);
ASSERT(m_videoOutput);
[m_avPlayerItem.get() addOutput:m_videoOutput.get()];
@@ -958,7 +1128,28 @@ RetainPtr<CVPixelBufferRef> MediaPlayerPrivateAVFoundationObjC::createPixelBuffe
double start = WTF::currentTime();
#endif
- RetainPtr<CVPixelBufferRef> buffer = adoptCF([m_videoOutput.get() copyPixelBufferForItemTime:[m_avPlayerItem.get() currentTime] itemTimeForDisplay:nil]);
+ CMTime currentTime = [m_avPlayerItem.get() currentTime];
+
+ if (![m_videoOutput.get() hasNewPixelBufferForItemTime:currentTime])
+ return 0;
+
+ RetainPtr<CVPixelBufferRef> buffer = adoptCF([m_videoOutput.get() copyPixelBufferForItemTime:currentTime itemTimeForDisplay:nil]);
+ if (!buffer)
+ return 0;
+
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+ // Create a VTPixelTransferSession, if necessary, as we cannot guarantee timely delivery of ARGB pixels.
+ if (!m_pixelTransferSession) {
+ VTPixelTransferSessionRef session = 0;
+ VTPixelTransferSessionCreate(kCFAllocatorDefault, &session);
+ m_pixelTransferSession = adoptCF(session);
+ }
+
+ CVPixelBufferRef outputBuffer;
+ CVPixelBufferCreate(kCFAllocatorDefault, CVPixelBufferGetWidth(buffer.get()), CVPixelBufferGetHeight(buffer.get()), k32BGRAPixelFormat, 0, &outputBuffer);
+ VTPixelTransferSessionTransferImage(m_pixelTransferSession.get(), buffer.get(), outputBuffer);
+ buffer = adoptCF(outputBuffer);
+#endif
#if !LOG_DISABLED
double duration = WTF::currentTime() - start;
@@ -982,20 +1173,20 @@ void MediaPlayerPrivateAVFoundationObjC::paintWithVideoOutput(GraphicsContext* c
GraphicsContextStateSaver stateSaver(*context);
context->translate(rect.x(), rect.y() + rect.height());
context->scale(FloatSize(1.0f, -1.0f));
- RetainPtr<CIImage> image(AdoptNS, [[CIImage alloc] initWithCVImageBuffer:m_lastImage.get()]);
+ RetainPtr<CIImage> image = adoptNS([[CIImage alloc] initWithCVImageBuffer:m_lastImage.get()]);
// ciContext does not use a RetainPtr for results of contextWithCGContext:, as the returned value
// is autoreleased, and there is no non-autoreleased version of that function.
CIContext* ciContext = [CIContext contextWithCGContext:context->platformContext() options:nil];
- [ciContext drawImage:image.get() inRect:rect fromRect:rect];
+ CGRect outputRect = { CGPointZero, rect.size() };
+ CGRect imageRect = CGRectMake(0, 0, CVPixelBufferGetWidth(m_lastImage.get()), CVPixelBufferGetHeight(m_lastImage.get()));
+ [ciContext drawImage:image.get() inRect:outputRect fromRect:imageRect];
}
}
-
#endif
-#if ENABLE(ENCRYPTED_MEDIA)
-
-static bool extractKeyURIKeyIDAndCertificateFromInitData(Uint8Array* initData, String& keyURI, String& keyID, RefPtr<Uint8Array>& certificate)
+#if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2)
+bool MediaPlayerPrivateAVFoundationObjC::extractKeyURIKeyIDAndCertificateFromInitData(Uint8Array* initData, String& keyURI, String& keyID, RefPtr<Uint8Array>& certificate)
{
// initData should have the following layout:
// [4 bytes: keyURI length][N bytes: keyURI][4 bytes: contentID length], [N bytes: contentID], [4 bytes: certificate length][N bytes: certificate]
@@ -1044,7 +1235,9 @@ static bool extractKeyURIKeyIDAndCertificateFromInitData(Uint8Array* initData, S
return true;
}
+#endif
+#if ENABLE(ENCRYPTED_MEDIA)
MediaPlayer::MediaKeyException MediaPlayerPrivateAVFoundationObjC::generateKeyRequest(const String& keySystem, const unsigned char* initDataPtr, unsigned initDataLength)
{
if (!keySystemIsSupported(keySystem))
@@ -1078,7 +1271,7 @@ MediaPlayer::MediaKeyException MediaPlayerPrivateAVFoundationObjC::generateKeyRe
RefPtr<ArrayBuffer> keyRequestBuffer = ArrayBuffer::create([keyRequest.get() bytes], [keyRequest.get() length]);
RefPtr<Uint8Array> keyRequestArray = Uint8Array::create(keyRequestBuffer, 0, keyRequestBuffer->byteLength());
- player()->keyMessage(keySystem, sessionID, keyRequestArray->data(), keyRequestArray->byteLength());
+ player()->keyMessage(keySystem, sessionID, keyRequestArray->data(), keyRequestArray->byteLength(), KURL());
// Move ownership of the AVAssetResourceLoadingRequestfrom the keyIDToRequestMap to the sessionIDToRequestMap:
m_sessionIDToRequestMap.set(sessionID, avRequest);
@@ -1121,6 +1314,193 @@ MediaPlayer::MediaKeyException MediaPlayerPrivateAVFoundationObjC::cancelKeyRequ
}
#endif
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+RetainPtr<AVAssetResourceLoadingRequest> MediaPlayerPrivateAVFoundationObjC::takeRequestForPlayerAndKeyURI(MediaPlayer* player, const String& keyURI)
+{
+ MediaPlayerPrivateAVFoundationObjC* _this = playerToPrivateMap().get(player);
+ if (!_this)
+ return nullptr;
+
+ return _this->m_keyURIToRequestMap.take(keyURI);
+
+}
+#endif
+
+#if !HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
+void MediaPlayerPrivateAVFoundationObjC::processLegacyClosedCaptionsTracks()
+{
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
+ [m_avPlayerItem.get() selectMediaOption:nil inMediaSelectionGroup:safeMediaSelectionGroupForLegibleMedia()];
+#endif
+
+ Vector<RefPtr<InbandTextTrackPrivateAVF> > removedTextTracks = m_textTracks;
+ NSArray *tracks = [m_avPlayerItem.get() tracks];
+ for (AVPlayerItemTrack *playerItemTrack in tracks) {
+
+ AVAssetTrack *assetTrack = [playerItemTrack assetTrack];
+ if (![[assetTrack mediaType] isEqualToString:AVMediaTypeClosedCaption])
+ continue;
+
+ bool newCCTrack = true;
+ for (unsigned i = removedTextTracks.size(); i > 0; --i) {
+ if (!removedTextTracks[i - 1]->isLegacyClosedCaptionsTrack())
+ continue;
+
+ RefPtr<InbandTextTrackPrivateLegacyAVFObjC> track = static_cast<InbandTextTrackPrivateLegacyAVFObjC*>(m_textTracks[i - 1].get());
+ if (track->avPlayerItemTrack() == playerItemTrack) {
+ removedTextTracks.remove(i - 1);
+ newCCTrack = false;
+ break;
+ }
+ }
+
+ if (!newCCTrack)
+ continue;
+
+ m_textTracks.append(InbandTextTrackPrivateLegacyAVFObjC::create(this, playerItemTrack));
+ }
+
+ processNewAndRemovedTextTracks(removedTextTracks);
+}
+#endif
+
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
+AVMediaSelectionGroupType* MediaPlayerPrivateAVFoundationObjC::safeMediaSelectionGroupForLegibleMedia()
+{
+ if (!m_avAsset)
+ return nil;
+
+ if ([m_avAsset.get() statusOfValueForKey:@"availableMediaCharacteristicsWithMediaSelectionOptions" error:NULL] != AVKeyValueStatusLoaded)
+ return nil;
+
+ return [m_avAsset.get() mediaSelectionGroupForMediaCharacteristic:AVMediaCharacteristicLegible];
+}
+
+void MediaPlayerPrivateAVFoundationObjC::processMediaSelectionOptions()
+{
+ AVMediaSelectionGroupType *legibleGroup = safeMediaSelectionGroupForLegibleMedia();
+ if (!legibleGroup) {
+ LOG(Media, "MediaPlayerPrivateAVFoundationObjC::processMediaSelectionOptions(%p) - nil mediaSelectionGroup", this);
+ return;
+ }
+
+ // We enabled automatic media selection because we want alternate audio tracks to be enabled/disabled automatically,
+ // but set the selected legible track to nil so text tracks will not be automatically configured.
+ if (!m_textTracks.size())
+ [m_avPlayerItem.get() selectMediaOption:nil inMediaSelectionGroup:safeMediaSelectionGroupForLegibleMedia()];
+
+ Vector<RefPtr<InbandTextTrackPrivateAVF> > removedTextTracks = m_textTracks;
+ NSArray *legibleOptions = [AVMediaSelectionGroup playableMediaSelectionOptionsFromArray:[legibleGroup options]];
+ for (AVMediaSelectionOptionType *option in legibleOptions) {
+ bool newTrack = true;
+ for (unsigned i = removedTextTracks.size(); i > 0; --i) {
+ if (removedTextTracks[i - 1]->isLegacyClosedCaptionsTrack())
+ continue;
+
+ RefPtr<InbandTextTrackPrivateAVFObjC> track = static_cast<InbandTextTrackPrivateAVFObjC*>(removedTextTracks[i - 1].get());
+ if ([track->mediaSelectionOption() isEqual:option]) {
+ removedTextTracks.remove(i - 1);
+ newTrack = false;
+ break;
+ }
+ }
+ if (!newTrack)
+ continue;
+
+ m_textTracks.append(InbandTextTrackPrivateAVFObjC::create(this, option));
+ }
+
+ processNewAndRemovedTextTracks(removedTextTracks);
+}
+
+void MediaPlayerPrivateAVFoundationObjC::processCue(NSArray *attributedStrings, double time)
+{
+ if (!m_currentTrack)
+ return;
+
+ m_currentTrack->processCue(reinterpret_cast<CFArrayRef>(attributedStrings), time);
+}
+
+void MediaPlayerPrivateAVFoundationObjC::flushCues()
+{
+ LOG(Media, "MediaPlayerPrivateAVFoundationObjC::flushCues(%p)", this);
+
+ if (!m_currentTrack)
+ return;
+
+ m_currentTrack->resetCueValues();
+}
+#endif // HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
+
+void MediaPlayerPrivateAVFoundationObjC::setCurrentTrack(InbandTextTrackPrivateAVF *track)
+{
+ if (m_currentTrack == track)
+ return;
+
+ LOG(Media, "MediaPlayerPrivateAVFoundationObjC::setCurrentTrack(%p) - selecting track %p, language = %s", this, track, track ? track->language().string().utf8().data() : "");
+
+ m_currentTrack = track;
+
+ if (track) {
+ if (track->isLegacyClosedCaptionsTrack())
+ [m_avPlayer.get() setClosedCaptionDisplayEnabled:YES];
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
+ else
+ [m_avPlayerItem.get() selectMediaOption:static_cast<InbandTextTrackPrivateAVFObjC*>(track)->mediaSelectionOption() inMediaSelectionGroup:safeMediaSelectionGroupForLegibleMedia()];
+#endif
+ } else {
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
+ [m_avPlayerItem.get() selectMediaOption:0 inMediaSelectionGroup:safeMediaSelectionGroupForLegibleMedia()];
+#endif
+ [m_avPlayer.get() setClosedCaptionDisplayEnabled:NO];
+ }
+
+}
+
+String MediaPlayerPrivateAVFoundationObjC::languageOfPrimaryAudioTrack() const
+{
+ if (!m_languageOfPrimaryAudioTrack.isNull())
+ return m_languageOfPrimaryAudioTrack;
+
+ if (!m_avPlayerItem.get())
+ return emptyString();
+
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
+ // If AVFoundation has an audible group, return the language of the currently selected audible option.
+ AVMediaSelectionGroupType *audibleGroup = [m_avAsset.get() mediaSelectionGroupForMediaCharacteristic:AVMediaCharacteristicAudible];
+ AVMediaSelectionOptionType *currentlySelectedAudibleOption = [m_avPlayerItem.get() selectedMediaOptionInMediaSelectionGroup:audibleGroup];
+ if (currentlySelectedAudibleOption) {
+ m_languageOfPrimaryAudioTrack = [[currentlySelectedAudibleOption locale] localeIdentifier];
+ LOG(Media, "MediaPlayerPrivateAVFoundationObjC::languageOfPrimaryAudioTrack(%p) - returning language of selected audible option: %s", this, m_languageOfPrimaryAudioTrack.utf8().data());
+
+ return m_languageOfPrimaryAudioTrack;
+ }
+#endif // HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
+
+ // AVFoundation synthesizes an audible group when there is only one ungrouped audio track if there is also a legible group (one or
+ // more in-band text tracks). It doesn't know about out-of-band tracks, so if there is a single audio track return its language.
+ NSArray *tracks = [m_avAsset.get() tracksWithMediaType:AVMediaTypeAudio];
+ if (!tracks || [tracks count] != 1) {
+ m_languageOfPrimaryAudioTrack = emptyString();
+ LOG(Media, "MediaPlayerPrivateAVFoundationObjC::languageOfPrimaryAudioTrack(%p) - %i audio tracks, returning emptyString()", this, (tracks ? [tracks count] : 0));
+ return m_languageOfPrimaryAudioTrack;
+ }
+
+ AVAssetTrack *track = [tracks objectAtIndex:0];
+ NSString *language = [track extendedLanguageTag];
+
+ // Some legacy tracks have "und" as a language, treat that the same as no language at all.
+ if (language && ![language isEqualToString:@"und"]) {
+ m_languageOfPrimaryAudioTrack = language;
+ LOG(Media, "MediaPlayerPrivateAVFoundationObjC::languageOfPrimaryAudioTrack(%p) - returning language of single audio track: %s", this, m_languageOfPrimaryAudioTrack.utf8().data());
+ return m_languageOfPrimaryAudioTrack;
+ }
+
+ LOG(Media, "MediaPlayerPrivateAVFoundationObjC::languageOfPrimaryAudioTrack(%p) - single audio track has no language, returning emptyString()", this);
+ m_languageOfPrimaryAudioTrack = emptyString();
+ return m_languageOfPrimaryAudioTrack;
+}
+
NSArray* assetMetadataKeyNames()
{
static NSArray* keys;
@@ -1132,6 +1512,7 @@ NSArray* assetMetadataKeyNames()
@"preferredRate",
@"playable",
@"tracks",
+ @"availableMediaCharacteristicsWithMediaSelectionOptions",
nil];
}
return keys;
@@ -1151,6 +1532,7 @@ NSArray* itemKVOProperties()
@"playbackBufferFull",
@"playbackBufferEmpty",
@"duration",
+ @"hasEnabledAudio",
nil];
}
return keys;
@@ -1231,6 +1613,8 @@ NSArray* itemKVOProperties()
m_callback->scheduleMainThreadNotification(MediaPlayerPrivateAVFoundation::Notification::ItemSeekableTimeRangesChanged);
else if ([keyPath isEqualToString:@"tracks"])
m_callback->scheduleMainThreadNotification(MediaPlayerPrivateAVFoundation::Notification::ItemTracksChanged);
+ else if ([keyPath isEqualToString:@"hasEnabledAudio"])
+ m_callback->scheduleMainThreadNotification(MediaPlayerPrivateAVFoundation::Notification::ItemTracksChanged);
else if ([keyPath isEqualToString:@"presentationSize"])
m_callback->scheduleMainThreadNotification(MediaPlayerPrivateAVFoundation::Notification::ItemPresentationSizeChanged);
else if ([keyPath isEqualToString:@"duration"])
@@ -1246,6 +1630,37 @@ NSArray* itemKVOProperties()
}
}
+#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
+- (void)legibleOutput:(id)output didOutputAttributedStrings:(NSArray *)strings nativeSampleBuffers:(NSArray *)nativeSamples forItemTime:(CMTime)itemTime
+{
+ UNUSED_PARAM(output);
+ UNUSED_PARAM(nativeSamples);
+
+ if (!m_callback)
+ return;
+
+ dispatch_async(dispatch_get_main_queue(), ^{
+ if (!m_callback)
+ return;
+ m_callback->processCue(strings, CMTimeGetSeconds(itemTime));
+ });
+}
+
+- (void)outputSequenceWasFlushed:(id)output
+{
+ UNUSED_PARAM(output);
+
+ if (!m_callback)
+ return;
+
+ dispatch_async(dispatch_get_main_queue(), ^{
+ if (!m_callback)
+ return;
+ m_callback->flushCues();
+ });
+}
+#endif
+
@end
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
@@ -1260,13 +1675,37 @@ NSArray* itemKVOProperties()
- (BOOL)resourceLoader:(AVAssetResourceLoader *)resourceLoader shouldWaitForLoadingOfRequestedResource:(AVAssetResourceLoadingRequest *)loadingRequest
{
UNUSED_PARAM(resourceLoader);
- return m_callback->shouldWaitForLoadingOfResource(loadingRequest);
+ if (!m_callback)
+ return NO;
+
+ dispatch_async(dispatch_get_main_queue(), ^{
+ if (!m_callback) {
+ [loadingRequest finishLoadingWithError:nil];
+ return;
+ }
+
+ if (!m_callback->shouldWaitForLoadingOfResource(loadingRequest))
+ [loadingRequest finishLoadingWithError:nil];
+ });
+
+ return YES;
}
- (void)resourceLoader:(AVAssetResourceLoader *)resourceLoader didCancelLoadingRequest:(AVAssetResourceLoadingRequest *)loadingRequest
{
UNUSED_PARAM(resourceLoader);
- return m_callback->didCancelLoadingRequest(loadingRequest);
+ if (!m_callback)
+ return;
+
+ dispatch_async(dispatch_get_main_queue(), ^{
+ if (m_callback)
+ m_callback->didCancelLoadingRequest(loadingRequest);
+ });
+}
+
+- (void)setCallback:(MediaPlayerPrivateAVFoundationObjC*)callback
+{
+ m_callback = callback;
}
@end
#endif
diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.h b/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.h
index 39ea6bdbc..8ce898080 100644
--- a/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.h
+++ b/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.h
@@ -28,8 +28,9 @@
#if ENABLE(VIDEO) && USE(AVFOUNDATION) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
-#include "CachedRawResource.h"
+#include "CachedRawResourceClient.h"
#include "CachedResourceHandle.h"
+#include <wtf/Noncopyable.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/RetainPtr.h>
@@ -37,6 +38,7 @@ OBJC_CLASS AVAssetResourceLoadingRequest;
namespace WebCore {
+class CachedRawResource;
class CachedResourceLoader;
class MediaPlayerPrivateAVFoundationObjC;
diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm b/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm
index 5b9b883c2..85606855d 100644
--- a/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm
+++ b/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm
@@ -68,7 +68,7 @@ void WebCoreAVFResourceLoader::startLoading()
KURL requestURL = [[m_avRequest.get() request] URL];
- CachedResourceRequest request(ResourceRequest(requestURL), ResourceLoaderOptions(SendCallbacks, DoNotSniffContent, BufferData, DoNotAllowStoredCredentials, DoNotAskClientForCrossOriginCredentials, DoSecurityCheck));
+ CachedResourceRequest request(ResourceRequest(requestURL), ResourceLoaderOptions(SendCallbacks, DoNotSniffContent, BufferData, DoNotAllowStoredCredentials, DoNotAskClientForCrossOriginCredentials, DoSecurityCheck, UseDefaultOriginRestrictionsForType));
request.mutableResourceRequest().setPriority(ResourceLoadPriorityLow);
CachedResourceLoader* loader = m_parent->player()->cachedResourceLoader();
@@ -122,8 +122,17 @@ void WebCoreAVFResourceLoader::dataReceived(CachedResource* resource, const char
void WebCoreAVFResourceLoader::notifyFinished(CachedResource* resource)
{
- fulfillRequestWithResource(resource);
- [m_avRequest.get() finishLoading];
+ if (resource->loadFailedOrCanceled()) {
+ // <rdar://problem/13987417> Set the contentType of the contentInformationRequest to an empty
+ // string to trigger AVAsset's playable value to complete loading.
+ if ([m_avRequest.get() contentInformationRequest] && ![[m_avRequest.get() contentInformationRequest] contentType])
+ [[m_avRequest.get() contentInformationRequest] setContentType:@""];
+
+ [m_avRequest.get() finishLoadingWithError:0];
+ } else {
+ fulfillRequestWithResource(resource);
+ [m_avRequest.get() finishLoading];
+ }
stopLoading();
}
@@ -134,7 +143,9 @@ void WebCoreAVFResourceLoader::fulfillRequestWithResource(CachedResource* resour
if (!dataRequest)
return;
- SharedBuffer* data = resource->resourceBuffer()->sharedBuffer();
+ SharedBuffer* data = resource->resourceBuffer() ? resource->resourceBuffer()->sharedBuffer() : 0;
+ if (!data)
+ return;
// Check for possible unsigned overflow.
ASSERT([dataRequest currentOffset] >= [dataRequest requestedOffset]);
diff --git a/Source/WebCore/platform/graphics/blackberry/CanvasLayerWebKitThread.cpp b/Source/WebCore/platform/graphics/blackberry/CanvasLayerWebKitThread.cpp
index dfcf9b998..c8a9f8ccd 100644
--- a/Source/WebCore/platform/graphics/blackberry/CanvasLayerWebKitThread.cpp
+++ b/Source/WebCore/platform/graphics/blackberry/CanvasLayerWebKitThread.cpp
@@ -19,55 +19,94 @@
#include "config.h"
#include "CanvasLayerWebKitThread.h"
+#include "LayerCompositingThread.h"
+
#if USE(ACCELERATED_COMPOSITING) && ENABLE(ACCELERATED_2D_CANVAS)
-#include "SharedGraphicsContext3D.h"
-#include <GLES2/gl2.h>
-#include <SkGpuDevice.h>
+#include <BlackBerryPlatformGLES2Program.h>
+
+using BlackBerry::Platform::Graphics::GLES2Program;
namespace WebCore {
-CanvasLayerWebKitThread::CanvasLayerWebKitThread(SkGpuDevice* device)
- : EGLImageLayerWebKitThread(CanvasLayer)
+void CanvasLayerWebKitThread::deleteTextures()
{
- setDevice(device);
}
-CanvasLayerWebKitThread::~CanvasLayerWebKitThread()
+class CanvasLayerCompositingThreadClient : public LayerCompositingThreadClient {
+public:
+ CanvasLayerCompositingThreadClient(BlackBerry::Platform::Graphics::Buffer*, const IntSize&);
+
+ void layerCompositingThreadDestroyed(LayerCompositingThread*) { }
+ void layerVisibilityChanged(LayerCompositingThread*, bool) { }
+ void uploadTexturesIfNeeded(LayerCompositingThread*) { }
+
+ void drawTextures(LayerCompositingThread*, const GLES2Program&, double scale, const FloatRect& clipRect);
+ void deleteTextures(LayerCompositingThread*);
+
+ void commitPendingTextureUploads(LayerCompositingThread*);
+
+ void clearBuffer() { m_buffer = 0; }
+
+private:
+ BlackBerry::Platform::Graphics::Buffer* m_buffer;
+ IntSize m_size;
+};
+
+CanvasLayerCompositingThreadClient::CanvasLayerCompositingThreadClient(BlackBerry::Platform::Graphics::Buffer* buffer, const IntSize& size)
+ : m_buffer(buffer)
+ , m_size(size)
+{
+}
+
+void CanvasLayerCompositingThreadClient::drawTextures(LayerCompositingThread* layer, const GLES2Program&, double, const FloatRect& /*clipRect*/)
{
- if (SharedGraphicsContext3D::get()->makeContextCurrent())
- deleteFrontBuffer();
+ if (!m_buffer)
+ return;
+
+ TransformationMatrix dt = layer->drawTransform();
+ dt.translate(-layer->bounds().width() / 2.0, -layer->bounds().height() / 2.0);
+ dt.scaleNonUniform(static_cast<double>(layer->bounds().width()) / m_size.width(), static_cast<double>(layer->bounds().height()) / m_size.height());
+ blitToBuffer(0, m_buffer, reinterpret_cast<BlackBerry::Platform::TransformationMatrix&>(dt),
+ BlackBerry::Platform::Graphics::SourceOver, static_cast<unsigned char>(layer->drawOpacity() * 255));
}
-void CanvasLayerWebKitThread::setDevice(SkGpuDevice* device)
+void CanvasLayerCompositingThreadClient::deleteTextures(LayerCompositingThread*)
{
- m_device = device;
- setNeedsDisplay();
+ // Nothing to do here, the buffer is not owned by us.
}
-void CanvasLayerWebKitThread::updateTextureContentsIfNeeded()
+void CanvasLayerCompositingThreadClient::commitPendingTextureUploads(LayerCompositingThread*)
{
- if (!m_device)
+ if (!m_buffer)
return;
- if (!SharedGraphicsContext3D::get()->makeContextCurrent())
- return;
+ // This method is called during a synchronization point between WebKit and compositing thread.
+ // This is our only chance to transfer the back display list to the front display list without
+ // race conditions.
+ // 1. Flush back display list to front
+ BlackBerry::Platform::Graphics::releaseBufferDrawable(m_buffer);
+ // 2. Draw front display list to FBO
+ BlackBerry::Platform::Graphics::updateBufferBackingSurface(m_buffer);
+}
- GrRenderTarget* renderTarget = reinterpret_cast<GrRenderTarget*>(m_device->accessRenderTarget());
- if (!renderTarget)
- return;
- GrTexture* texture = renderTarget->asTexture();
- if (!texture)
- return;
+CanvasLayerWebKitThread::CanvasLayerWebKitThread(BlackBerry::Platform::Graphics::Buffer* buffer, const IntSize& size)
+ : LayerWebKitThread(CanvasLayer, 0)
+{
+ m_compositingThreadClient = new CanvasLayerCompositingThreadClient(buffer, size);
+ layerCompositingThread()->setClient(m_compositingThreadClient);
+}
- updateFrontBuffer(IntSize(m_device->width(), m_device->height()), texture->getTextureHandle());
+CanvasLayerWebKitThread::~CanvasLayerWebKitThread()
+{
+ layerCompositingThread()->setClient(0);
+ delete m_compositingThreadClient;
}
-void CanvasLayerWebKitThread::deleteTextures()
+void CanvasLayerWebKitThread::clearBuffer(CanvasLayerWebKitThread* layer)
{
- if (SharedGraphicsContext3D::get()->makeContextCurrent())
- deleteFrontBuffer();
+ layer->m_compositingThreadClient->clearBuffer();
}
}
diff --git a/Source/WebCore/platform/graphics/blackberry/CanvasLayerWebKitThread.h b/Source/WebCore/platform/graphics/blackberry/CanvasLayerWebKitThread.h
index 62e62b2e3..a0ff192b6 100644
--- a/Source/WebCore/platform/graphics/blackberry/CanvasLayerWebKitThread.h
+++ b/Source/WebCore/platform/graphics/blackberry/CanvasLayerWebKitThread.h
@@ -23,31 +23,27 @@
#include "EGLImageLayerWebKitThread.h"
-class SkGpuDevice;
-
namespace WebCore {
-class HTMLCanvasElement;
+class CanvasLayerCompositingThreadClient;
-class CanvasLayerWebKitThread : public EGLImageLayerWebKitThread {
+class CanvasLayerWebKitThread : public LayerWebKitThread {
public:
- static PassRefPtr<CanvasLayerWebKitThread> create(SkGpuDevice* device)
+ static PassRefPtr<CanvasLayerWebKitThread> create(BlackBerry::Platform::Graphics::Buffer* buffer, const IntSize& size)
{
- return adoptRef(new CanvasLayerWebKitThread(device));
+ return adoptRef(new CanvasLayerWebKitThread(buffer, size));
}
virtual ~CanvasLayerWebKitThread();
- void setDevice(SkGpuDevice*);
+ static void clearBuffer(CanvasLayerWebKitThread*);
protected:
- virtual void updateTextureContentsIfNeeded();
virtual void deleteTextures();
private:
- CanvasLayerWebKitThread(SkGpuDevice*);
-
- SkGpuDevice* m_device;
+ CanvasLayerWebKitThread(BlackBerry::Platform::Graphics::Buffer*, const IntSize&);
+ CanvasLayerCompositingThreadClient* m_compositingThreadClient;
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/blackberry/DrawingBufferBlackBerry.cpp b/Source/WebCore/platform/graphics/blackberry/DrawingBufferBlackBerry.cpp
index 8dfd6f3f7..c53108c00 100644
--- a/Source/WebCore/platform/graphics/blackberry/DrawingBufferBlackBerry.cpp
+++ b/Source/WebCore/platform/graphics/blackberry/DrawingBufferBlackBerry.cpp
@@ -67,8 +67,6 @@ DrawingBuffer::DrawingBuffer(GraphicsContext3D* context, const IntSize& size)
: m_context(context)
, m_size(size)
, m_fbo(context->createFramebuffer())
- , m_frontColorBuffer(0)
- , m_separateFrontTexture(false)
{
m_internal = adoptPtr(new DrawingBufferInternal);
@@ -87,6 +85,25 @@ DrawingBuffer::~DrawingBuffer()
clear();
}
+#if USE(ACCELERATED_COMPOSITING)
+void DrawingBuffer::publishToPlatformLayer()
+{
+ if (!m_context)
+ return;
+
+ if (m_callback)
+ m_callback->willPublish();
+
+ // FIXME: We do the copy in the canvas' (child) context so that it executes in the correct order relative to
+ // other commands in the child context. This ensures that the parent texture always contains a complete
+ // frame and not some intermediate result. However, there is no synchronization to ensure that this copy
+ // happens before the compositor draws. This means we might draw stale frames sometimes. Ideally this
+ // would insert a fence into the child command stream that the compositor could wait for.
+ m_context->makeContextCurrent();
+ m_context->flush();
+}
+#endif
+
bool DrawingBuffer::reset(const IntSize& newSize)
{
if (!m_context)
@@ -108,20 +125,6 @@ PlatformLayer* DrawingBuffer::platformLayer()
{
return m_internal->platformLayer.get();
}
-
-void DrawingBuffer::prepareBackBuffer()
-{
-}
-
-bool DrawingBuffer::requiresCopyFromBackToFrontBuffer() const
-{
- return false;
-}
-
-unsigned DrawingBuffer::frontColorBuffer() const
-{
- return colorBuffer();
-}
#endif
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/blackberry/EGLImageLayerCompositingThreadClient.cpp b/Source/WebCore/platform/graphics/blackberry/EGLImageLayerCompositingThreadClient.cpp
index e54aeada3..fbeef3c05 100644
--- a/Source/WebCore/platform/graphics/blackberry/EGLImageLayerCompositingThreadClient.cpp
+++ b/Source/WebCore/platform/graphics/blackberry/EGLImageLayerCompositingThreadClient.cpp
@@ -22,6 +22,8 @@
#if USE(ACCELERATED_COMPOSITING)
#include "LayerCompositingThread.h"
+#include <BlackBerryPlatformGLES2Program.h>
+#include <BlackBerryPlatformGLES2SharedTexture.h>
#include <BlackBerryPlatformGraphics.h>
#include <BlackBerryPlatformLog.h>
#include <EGL/egl.h>
@@ -29,96 +31,54 @@
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
-namespace WebCore {
+using namespace BlackBerry::Platform::Graphics;
-static PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES = 0;
-static PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR = 0;
+namespace WebCore {
EGLImageLayerCompositingThreadClient::~EGLImageLayerCompositingThreadClient()
{
// Someone should have called deleteTextures() by now
- ASSERT(!m_texture && !m_image);
+ ASSERT(!m_textureAccessor);
}
void EGLImageLayerCompositingThreadClient::uploadTexturesIfNeeded(LayerCompositingThread*)
{
- if (!m_imageChanged)
- return;
-
- if (!glEGLImageTargetTexture2DOES) {
- glEGLImageTargetTexture2DOES = reinterpret_cast<PFNGLEGLIMAGETARGETTEXTURE2DOESPROC>(eglGetProcAddress("glEGLImageTargetTexture2DOES"));
- ASSERT(glEGLImageTargetTexture2DOES);
- if (!glEGLImageTargetTexture2DOES) {
- using namespace BlackBerry::Platform;
- logAlways(LogLevelWarn, "eglGetProcAddress for glEGLImageTargetTexture2DOES FAILED");
- m_imageChanged = false;
- return;
- }
- }
-
- if (m_image) {
- if (!m_texture) {
- m_texture = Texture::create();
- m_texture->protect();
- }
-
- // Connect to the new image
- glBindTexture(GL_TEXTURE_2D, m_texture->textureId());
- glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, m_image);
- } else if (m_texture) {
- m_texture->unprotect();
- m_texture.clear();
- }
-
- m_imageChanged = false;
}
-void EGLImageLayerCompositingThreadClient::drawTextures(LayerCompositingThread* layer, double /*scale*/, int positionLocation, int texCoordLocation)
+void EGLImageLayerCompositingThreadClient::drawTextures(LayerCompositingThread* layer, const GLES2Program& program, double /*scale*/, const FloatRect& /*clipRect*/)
{
- static float upsideDown[4 * 2] = { 0, 1, 0, 0, 1, 0, 1, 1 };
-
- if (!m_texture)
+ if (!m_textureAccessor || !m_textureAccessor->textureID())
return;
- glVertexAttribPointer(positionLocation, 2, GL_FLOAT, GL_FALSE, 0, &layer->getTransformedBounds());
- glVertexAttribPointer(texCoordLocation, 2, GL_FLOAT, GL_FALSE, 0, upsideDown);
- glBindTexture(GL_TEXTURE_2D, m_texture->textureId());
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ glUseProgram(program.m_program);
+ glUniform1f(program.opacityLocation(), layer->drawOpacity());
+ glVertexAttribPointer(program.positionLocation(), 2, GL_FLOAT, GL_FALSE, 0, layer->transformedBounds().data());
+ glVertexAttribPointer(program.texCoordLocation(), 2, GL_FLOAT, GL_FALSE, 0, layer->textureCoordinates(LayerCompositingThread::UpsideDown).data());
+ glBindTexture(GL_TEXTURE_2D, m_textureAccessor->textureID());
+ glDrawArrays(GL_TRIANGLE_FAN, 0, layer->transformedBounds().size());
}
void EGLImageLayerCompositingThreadClient::deleteTextures(LayerCompositingThread*)
{
- if (m_texture) {
- m_texture->unprotect();
- m_texture.clear();
- }
-
- if (!m_image)
- return;
-
- // If the image is still with us, it was never destroyed by the EGLImageLayerWebKitThread.
- if (!eglDestroyImageKHR)
- eglDestroyImageKHR = reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(eglGetProcAddress("eglDestroyImageKHR"));
-
- ASSERT(eglDestroyImageKHR);
- if (eglDestroyImageKHR)
- eglDestroyImageKHR(BlackBerry::Platform::Graphics::eglDisplay(), m_image);
-
- m_image = 0;
+ delete m_textureAccessor;
+ m_textureAccessor = 0;
}
void EGLImageLayerCompositingThreadClient::bindContentsTexture(LayerCompositingThread*)
{
- glBindTexture(GL_TEXTURE_2D, m_texture->textureId());
+ if (m_textureAccessor)
+ glBindTexture(GL_TEXTURE_2D, m_textureAccessor->textureID());
}
-void EGLImageLayerCompositingThreadClient::setImage(void* image)
+void EGLImageLayerCompositingThreadClient::setTextureAccessor(GLES2SharedTextureAccessor* textureAccessor)
{
- if (m_image == image)
+ if (m_textureAccessor == textureAccessor)
return;
- m_image = image;
- m_imageChanged = true;
+ delete m_textureAccessor;
+ m_textureAccessor = textureAccessor;
}
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/blackberry/EGLImageLayerCompositingThreadClient.h b/Source/WebCore/platform/graphics/blackberry/EGLImageLayerCompositingThreadClient.h
index 967c130a6..03c98a46a 100644
--- a/Source/WebCore/platform/graphics/blackberry/EGLImageLayerCompositingThreadClient.h
+++ b/Source/WebCore/platform/graphics/blackberry/EGLImageLayerCompositingThreadClient.h
@@ -22,11 +22,18 @@
#if USE(ACCELERATED_COMPOSITING)
#include "LayerCompositingThreadClient.h"
-#include "Texture.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefPtr.h>
#include <wtf/ThreadSafeRefCounted.h>
+namespace BlackBerry {
+namespace Platform {
+namespace Graphics {
+class GLES2SharedTextureAccessor;
+}
+}
+}
+
namespace WebCore {
class LayerCompositingThread;
@@ -48,25 +55,21 @@ public:
virtual void layerVisibilityChanged(LayerCompositingThread*, bool visible) { }
virtual void uploadTexturesIfNeeded(LayerCompositingThread*);
- virtual void drawTextures(LayerCompositingThread*, double scale, int positionLocation, int texCoordLocation);
+ virtual void drawTextures(LayerCompositingThread*, const BlackBerry::Platform::Graphics::GLES2Program&, double scale, const FloatRect& clipRect);
virtual void deleteTextures(LayerCompositingThread*);
virtual void bindContentsTexture(LayerCompositingThread*);
- // The image must not be deleted while in our custody, however after changing image you are free to delete the old one.
- void setImage(void*);
+ void setTextureAccessor(BlackBerry::Platform::Graphics::GLES2SharedTextureAccessor*);
private:
EGLImageLayerCompositingThreadClient()
- : m_image(0)
- , m_imageChanged(false)
+ : m_textureAccessor(0)
{
ref(); // Matched by deref() in layerCompositingThreadDestroyed()
}
- void* m_image;
- bool m_imageChanged;
- RefPtr<Texture> m_texture;
+ BlackBerry::Platform::Graphics::GLES2SharedTextureAccessor* m_textureAccessor;
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/blackberry/EGLImageLayerWebKitThread.cpp b/Source/WebCore/platform/graphics/blackberry/EGLImageLayerWebKitThread.cpp
index 8920e987a..b28d5d585 100644
--- a/Source/WebCore/platform/graphics/blackberry/EGLImageLayerWebKitThread.cpp
+++ b/Source/WebCore/platform/graphics/blackberry/EGLImageLayerWebKitThread.cpp
@@ -25,41 +25,36 @@
#include "LayerRenderer.h"
#include "SharedGraphicsContext3D.h"
#include <BlackBerryPlatformGLES2ContextState.h>
+#include <BlackBerryPlatformGLES2SharedTexture.h>
#include <BlackBerryPlatformGraphics.h>
#include <BlackBerryPlatformLog.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <GLES2/gl2.h>
-using BlackBerry::Platform::Graphics::GLES2Program;
-using BlackBerry::Platform::Graphics::GLES2ContextState;
+using namespace BlackBerry::Platform::Graphics;
namespace WebCore {
-static PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR = 0;
-static PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR = 0;
-
EGLImageLayerWebKitThread::EGLImageLayerWebKitThread(LayerType type)
: LayerWebKitThread(type, 0)
, m_client(EGLImageLayerCompositingThreadClient::create())
, m_needsDisplay(false)
- , m_frontBufferTexture(0)
- , m_fbo(0)
, m_program(0)
- , m_image(0)
+ , m_texture(0)
+ , m_textureAccessor(0)
{
layerCompositingThread()->setClient(m_client.get());
- setLayerProgramShader(LayerProgramShaderRGBA);
+ setLayerProgram(LayerProgramRGBA);
}
EGLImageLayerWebKitThread::~EGLImageLayerWebKitThread()
{
// The subclass is responsible for calling deleteFrontBuffer()
// before we get this far.
- ASSERT(!m_frontBufferTexture);
- ASSERT(!m_fbo);
ASSERT(!m_program);
- ASSERT(!m_image);
+ ASSERT(!m_texture);
+ ASSERT(!m_textureAccessor);
}
void EGLImageLayerWebKitThread::setNeedsDisplay()
@@ -76,9 +71,6 @@ void EGLImageLayerWebKitThread::updateFrontBuffer(const IntSize& size, unsigned
if (size.isEmpty()) {
if (size != m_size) {
deleteFrontBuffer();
- if (m_image)
- m_garbage.append(m_image);
- m_image = 0;
m_size = size;
}
@@ -86,19 +78,6 @@ void EGLImageLayerWebKitThread::updateFrontBuffer(const IntSize& size, unsigned
return;
}
- if (!eglCreateImageKHR) {
- eglCreateImageKHR = reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>(eglGetProcAddress("eglCreateImageKHR"));
- eglDestroyImageKHR = reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(eglGetProcAddress("eglDestroyImageKHR"));
- }
-
- ASSERT(eglCreateImageKHR && eglDestroyImageKHR);
- if (!eglCreateImageKHR || !eglDestroyImageKHR) {
- using namespace BlackBerry::Platform;
- logAlways(LogLevelWarn, "eglGetProcAddress for eglCreate/DestroyImageKHR FAILED");
- m_needsDisplay = false;
- return;
- }
-
GLenum currentActiveTexture = 0;
glGetIntegerv(GL_ACTIVE_TEXTURE, reinterpret_cast<GLint*>(&currentActiveTexture));
glActiveTexture(GL_TEXTURE0);
@@ -106,7 +85,7 @@ void EGLImageLayerWebKitThread::updateFrontBuffer(const IntSize& size, unsigned
{
GLES2ContextState::TextureAndFBOStateSaver textureAndFBOStateSaver;
- if (!createImageIfNeeded(size))
+ if (!createTextureIfNeeded(size))
return;
m_needsDisplay = false;
@@ -119,16 +98,14 @@ void EGLImageLayerWebKitThread::updateFrontBuffer(const IntSize& size, unsigned
void EGLImageLayerWebKitThread::deleteFrontBuffer()
{
- glDeleteTextures(1, &m_frontBufferTexture);
- m_frontBufferTexture = 0;
- glDeleteFramebuffers(1, &m_fbo);
- m_fbo = 0;
+ delete m_texture;
+ m_texture = 0;
glDeleteProgram(m_program);
m_program = 0;
- // The image is in our EGLImageLayerCompositingThreadClient's custody
+ // The texture accessor is in our EGLImageLayerCompositingThreadClient's custody
// at this point, and that object is responsible for deleting it.
- m_image = 0;
+ m_textureAccessor = 0;
// If anyone tries to render us after this, we're certainly going to need display.
m_needsDisplay = true;
@@ -139,55 +116,21 @@ void EGLImageLayerWebKitThread::commitPendingTextureUploads()
// This call is serialized with the compositing thread, so it's safe to update the
// image and destroy any old images.
- m_client->setImage(m_image);
-
- // Destroy the garbage images in a thread-safe way
- for (size_t i = 0; i < m_garbage.size(); ++i)
- eglDestroyImageKHR(BlackBerry::Platform::Graphics::eglDisplay(), m_garbage[i]);
+ m_client->setTextureAccessor(m_textureAccessor);
}
-bool EGLImageLayerWebKitThread::createImageIfNeeded(const IntSize& size)
+bool EGLImageLayerWebKitThread::createTextureIfNeeded(const IntSize& size)
{
- // We use a texture rather than a renderbuffer as the basis of the FBO and EGLImage,
- // since the EGLImage will be used as a texture on the compositing thread in the end.
-
- if (!m_frontBufferTexture) {
- glGenTextures(1, &m_frontBufferTexture);
- glBindTexture(GL_TEXTURE_2D, m_frontBufferTexture);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- }
-
- if (!m_fbo)
- glGenFramebuffers(1, &m_fbo);
-
- if (!m_image || size != m_size) {
- IntSize fboSize = size;
-
- // Imagination-specific fix
- static bool isImaginationHardware = std::strstr(reinterpret_cast<const char*>(glGetString(GL_RENDERER)), "PowerVR SGX");
- if (isImaginationHardware)
- fboSize = fboSize.expandedTo(IntSize(16, 16));
-
- glBindTexture(GL_TEXTURE_2D, m_frontBufferTexture);
- glBindFramebuffer(GL_FRAMEBUFFER, m_fbo);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, fboSize.width(), fboSize.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_frontBufferTexture, 0);
-
- if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
- return false;
- if (glGetError() != GL_NO_ERROR)
+ if (!m_texture || size != m_size) {
+ delete m_texture;
+ m_texture = new GLES2SharedTexture(size);
+ if (!m_texture->isValid()) {
+ delete m_texture;
+ m_texture = 0;
return false;
+ }
- // The sibling is orphaned after glTexImage2D, recreate the image.
- if (m_image)
- m_garbage.append(m_image);
- m_image = eglCreateImageKHR(BlackBerry::Platform::Graphics::eglDisplay(), eglGetCurrentContext(),
- EGL_GL_TEXTURE_2D_KHR, (EGLClientBuffer)m_frontBufferTexture, 0);
- if (!m_image)
- return false;
+ m_textureAccessor = m_texture->createTextureAccessor();
m_size = size;
}
@@ -234,17 +177,12 @@ void EGLImageLayerWebKitThread::blitToFrontBuffer(unsigned backBufferTexture)
if (!backBufferTexture)
return;
- GLuint currentProgram = 0;
- glGetIntegerv(GL_CURRENT_PROGRAM, reinterpret_cast<GLint*>(&currentProgram));
+ GLES2ContextState::ProgramStateSaver programStateSaver;
createShaderIfNeeded();
- GLuint currentArrayBufferBinding = 0, currentElementArrayBufferBinding = 0;
- GLint currentViewport[4] = { 0, 0, 0, 0 };
- glGetIntegerv(GL_ARRAY_BUFFER_BINDING, reinterpret_cast<GLint*>(&currentArrayBufferBinding));
- glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, reinterpret_cast<GLint*>(&currentElementArrayBufferBinding));
- glGetIntegerv(GL_VIEWPORT, &currentViewport[0]);
-
+ GLES2ContextState::BufferBindingSaver bufferBindingSaver;
+ GLES2ContextState::ViewportSaver viewportSaver;
GLES2ContextState::GlobalFlagStateSaver flagStateSaver(GLES2ContextState::GlobalFlagState::DontRestoreBlendFunc);
glDisable(GL_DEPTH_TEST);
@@ -254,13 +192,14 @@ void EGLImageLayerWebKitThread::blitToFrontBuffer(unsigned backBufferTexture)
glDisable(GL_BLEND);
glViewport(0, 0, m_size.width(), m_size.height());
- glBindFramebuffer(GL_FRAMEBUFFER, m_fbo);
+ makeBufferCurrent(m_texture->buffer(), GLES2);
glUseProgram(m_program);
glBindTexture(GL_TEXTURE_2D, backBufferTexture);
glColorMask(true, true, true, true);
{
GLES2ContextState::VertexAttributeStateSaver vertexAttribStateSaver;
+ GLES2ContextState::VertexArrayOESStateSaver vertexArrayOESStateSaver;
static float texcoords[4 * 2] = { 0, 0, 0, 1, 1, 1, 1, 0 };
static float vertices[] = { -1, -1, -1, 1, 1, 1, 1, -1 };
@@ -277,18 +216,7 @@ void EGLImageLayerWebKitThread::blitToFrontBuffer(unsigned backBufferTexture)
glDisableVertexAttribArray(GLES2Program::PositionAttributeIndex);
glDisableVertexAttribArray(GLES2Program::TexCoordAttributeIndex);
-
- glBindBuffer(GL_ARRAY_BUFFER, currentArrayBufferBinding);
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, currentElementArrayBufferBinding);
}
-
- // The previous program might have been deleted by refcount destruction
- // with another one now in use. Don't try to restore it later.
- if (currentProgram && !glIsProgram(currentProgram))
- currentProgram = 0;
-
- glUseProgram(currentProgram);
- glViewport(currentViewport[0], currentViewport[1], currentViewport[2], currentViewport[3]);
}
}
diff --git a/Source/WebCore/platform/graphics/blackberry/EGLImageLayerWebKitThread.h b/Source/WebCore/platform/graphics/blackberry/EGLImageLayerWebKitThread.h
index 7f842e960..27e9878fa 100644
--- a/Source/WebCore/platform/graphics/blackberry/EGLImageLayerWebKitThread.h
+++ b/Source/WebCore/platform/graphics/blackberry/EGLImageLayerWebKitThread.h
@@ -24,6 +24,15 @@
#include "EGLImageLayerCompositingThreadClient.h"
#include "LayerWebKitThread.h"
+namespace BlackBerry {
+namespace Platform {
+namespace Graphics {
+class GLES2SharedTexture;
+class GLES2SharedTextureAccessor;
+}
+}
+}
+
namespace WebCore {
// Base class for EGLImage based layers
@@ -48,17 +57,15 @@ protected:
void deleteFrontBuffer();
private:
- bool createImageIfNeeded(const IntSize&);
+ bool createTextureIfNeeded(const IntSize&);
void createShaderIfNeeded();
void blitToFrontBuffer(unsigned backBufferTexture);
RefPtr<EGLImageLayerCompositingThreadClient> m_client;
bool m_needsDisplay;
- unsigned m_frontBufferTexture;
- unsigned m_fbo;
unsigned m_program;
- void* m_image;
- Vector<void*> m_garbage;
+ BlackBerry::Platform::Graphics::GLES2SharedTexture* m_texture;
+ BlackBerry::Platform::Graphics::GLES2SharedTextureAccessor* m_textureAccessor;
IntSize m_size;
};
diff --git a/Source/WebCore/platform/graphics/blackberry/FloatRectBlackBerry.cpp b/Source/WebCore/platform/graphics/blackberry/FloatRectBlackBerry.cpp
index d41139720..e7d3c32e7 100644
--- a/Source/WebCore/platform/graphics/blackberry/FloatRectBlackBerry.cpp
+++ b/Source/WebCore/platform/graphics/blackberry/FloatRectBlackBerry.cpp
@@ -34,4 +34,19 @@ FloatRect::operator BlackBerry::Platform::FloatRect() const
return BlackBerry::Platform::FloatRect(x(), y(), width(), height());
}
+FloatRect FloatRect::normalized() const
+{
+ FloatRect normalizedRect = *this;
+
+ if (width() < 0) {
+ normalizedRect.setX(x() + width());
+ normalizedRect.setWidth(-width());
+ }
+ if (height() < 0) {
+ normalizedRect.setY(y() + height());
+ normalizedRect.setHeight(-height());
+ }
+ return normalizedRect;
+}
+
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/blackberry/FontBlackBerry.cpp b/Source/WebCore/platform/graphics/blackberry/FontBlackBerry.cpp
new file mode 100644
index 000000000..e94c787c6
--- /dev/null
+++ b/Source/WebCore/platform/graphics/blackberry/FontBlackBerry.cpp
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 2012, 2013 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include "config.h"
+#include "Font.h"
+
+#include "AffineTransform.h"
+#include "FloatPoint.h"
+#include "FloatRect.h"
+#include "FontCache.h"
+#include "GlyphBuffer.h"
+#include "GraphicsContext.h"
+#include "HarfBuzzShaper.h"
+#include "ShadowBlur.h"
+#include "TextRun.h"
+
+#include <BlackBerryPlatformGraphicsContext.h>
+
+#include <fs_api.h>
+#include <wtf/MathExtras.h>
+
+static inline float FSFixedToFloat(FS_FIXED n) { return n / 65536.0; }
+static inline FS_FIXED FloatToFSFixed(float n) { return static_cast<FS_FIXED>(n * 65536); }
+
+namespace WebCore {
+
+void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
+{
+ if (!run.length())
+ return;
+
+ GlyphBuffer glyphBuffer;
+ HarfBuzzShaper shaper(this, run);
+ shaper.setDrawRange(from, to);
+ if (!shaper.shape(&glyphBuffer))
+ return;
+ FloatPoint adjustedPoint = shaper.adjustStartPoint(point);
+
+ drawGlyphBuffer(context, run, glyphBuffer, adjustedPoint);
+}
+
+float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>* /* fallbackFonts */, GlyphOverflow* /* glyphOverflow */) const
+{
+ HarfBuzzShaper shaper(this, run);
+ if (!shaper.shape())
+ return 0;
+ return shaper.totalWidth();
+}
+
+// Return the code point index for the given |x| offset into the text run.
+int Font::offsetForPositionForComplexText(const TextRun& run, float position, bool) const
+{
+ // FIXME: This truncation is not a problem for HTML, but only affects SVG, which passes floating-point numbers
+ // to Font::offsetForPosition(). Bug http://webkit.org/b/40673 tracks fixing this problem.
+ int targetX = static_cast<int>(position);
+
+ HarfBuzzShaper shaper(this, run);
+ if (!shaper.shape())
+ return 0;
+ return shaper.offsetForPosition(targetX);
+}
+
+FloatRect Font::selectionRectForComplexText(const TextRun& run, const FloatPoint& point, int height, int from, int to) const
+{
+ HarfBuzzShaper shaper(this, run);
+ if (!shaper.shape())
+ return FloatRect();
+ return shaper.selectionRect(point, height, from, to);
+}
+
+void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point) const
+{
+ FS_STATE* iType = font->platformData().scaledFont(context->getCTM().yScale());
+ if (!iType)
+ return;
+
+ FloatPoint adjustedPoint = point;
+
+ if (font->platformData().orientation() == Vertical)
+ adjustedPoint.move(-(font->fontMetrics().floatAscent(IdeographicBaseline) - font->fontMetrics().floatAscent()), 0);
+
+ bool softwareBlurRequired = context->state().shadowBlur / font->fontMetrics().xHeight() > 0.5;
+
+ FloatSize currentShadowOffset;
+ float currentShadowBlur;
+ Color currentShadowColor;
+ ColorSpace currentColorSpace;
+
+ // If we have a shadow blur, and it is too big to apply at text-render time, we must render it now.
+ if (context->hasShadow() && softwareBlurRequired) {
+ context->getShadow(currentShadowOffset, currentShadowBlur, currentShadowColor, currentColorSpace);
+
+ const GraphicsContextState state = context->state();
+ FloatSize offset = state.shadowOffset;
+ if (state.shadowsIgnoreTransforms)
+ offset.setHeight(-offset.height());
+ ShadowBlur shadow(FloatSize(state.shadowBlur, state.shadowBlur), offset, state.shadowColor, state.shadowColorSpace);
+ FloatPoint minPoint(adjustedPoint.x(), adjustedPoint.y() - fontMetrics().ascent());
+ FloatPoint maxPoint(adjustedPoint.x(), adjustedPoint.y() + fontMetrics().descent());
+ FloatPoint currentPoint = adjustedPoint;
+ for (int i = 0; i < numGlyphs; ++i) {
+ currentPoint += *glyphBuffer.advances(from + i);
+ minPoint.setX(std::min(minPoint.x(), currentPoint.x()));
+ minPoint.setY(std::min(minPoint.y(), currentPoint.y()));
+ maxPoint = maxPoint.expandedTo(currentPoint);
+ }
+ const FloatRect boundingRect(minPoint.x(), minPoint.y(), maxPoint.x() - minPoint.x(), maxPoint.y() - minPoint.y());
+ GraphicsContext* shadowContext = shadow.beginShadowLayer(context, boundingRect);
+ if (shadowContext) {
+ iType = font->platformData().scaledFont(shadowContext->getCTM().yScale());
+ shadowContext->platformContext()->addGlyphs(glyphBuffer.glyphs(from),
+ reinterpret_cast<const BlackBerry::Platform::FloatSize*>(glyphBuffer.advances(from)),
+ numGlyphs, adjustedPoint, iType, 0, 0);
+ iType = font->platformData().scaledFont(context->getCTM().yScale());
+ shadow.endShadowLayer(context);
+ }
+ context->platformContext()->clearShadow();
+ }
+
+ context->platformContext()->addGlyphs(glyphBuffer.glyphs(from),
+ reinterpret_cast<const BlackBerry::Platform::FloatSize*>(glyphBuffer.advances(from)),
+ numGlyphs, adjustedPoint, iType,
+ context->fillGradient() ? context->fillGradient()->platformGradient() : (context->fillPattern() ? context->fillPattern()->platformPattern(AffineTransform()) : static_cast<BlackBerry::Platform::Graphics::Paint*>(0)),
+ context->strokeGradient() ? context->strokeGradient()->platformGradient() : (context->strokePattern() ? context->strokePattern()->platformPattern(AffineTransform()) : static_cast<BlackBerry::Platform::Graphics::Paint*>(0)));
+
+ if (softwareBlurRequired)
+ context->platformContext()->setShadow(currentShadowOffset, currentShadowBlur, currentShadowColor.isValid() ? currentShadowColor.rgb() : makeRGBA(0, 0, 0, 0xFF / 3), context->state().shadowsIgnoreTransforms);
+}
+
+bool Font::canReturnFallbackFontsForComplexText()
+{
+ return false;
+}
+
+void Font::drawEmphasisMarksForComplexText(GraphicsContext* /* context */, const TextRun& /* run */, const AtomicString& /* mark */, const FloatPoint& /* point */, int /* from */, int /* to */) const
+{
+ // notImplemented();
+}
+
+bool Font::canExpandAroundIdeographsInComplexText()
+{
+ return false;
+}
+
+}
diff --git a/Source/WebCore/platform/graphics/blackberry/FontCacheBlackBerry.cpp b/Source/WebCore/platform/graphics/blackberry/FontCacheBlackBerry.cpp
new file mode 100644
index 000000000..8a0741f2f
--- /dev/null
+++ b/Source/WebCore/platform/graphics/blackberry/FontCacheBlackBerry.cpp
@@ -0,0 +1,339 @@
+/*
+ * Copyright (C) 2008 Alp Toker <alp@atoker.com>
+ * Copyright (C) 2009-2010, Google Inc. All rights reserved.
+ * Copyright (C) 2010 Igalia S.L.
+ * Copyright (C) 2012, 2013 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include "config.h"
+#include "FontCache.h"
+
+#include "Font.h"
+#include "FontDescription.h"
+#include "FontPlatformData.h"
+#include "ITypeUtils.h"
+#include "Logging.h"
+#include "NotImplemented.h"
+#include "SimpleFontData.h"
+
+#include <BlackBerryPlatformGraphicsContext.h>
+#include <fontconfig/fontconfig.h>
+#include <fs_api.h>
+#include <unicode/locid.h>
+#include <unistd.h>
+#include <wtf/Assertions.h>
+#include <wtf/text/AtomicString.h>
+#include <wtf/text/CString.h>
+
+namespace WebCore {
+
+void FontCache::platformInit()
+{
+ // It's fine to call FcInit multiple times per the documentation.
+ if (!FcInit())
+ CRASH();
+}
+
+void FontCache::getFontFamilyForCharacters(const UChar* characters, size_t numCharacters, const char*, const FontDescription& description, SimpleFontFamily* family)
+{
+ FcCharSet* cset = FcCharSetCreate();
+ for (size_t i = 0; i < numCharacters; ++i) {
+ if (U16_IS_SURROGATE(characters[i])
+ && U16_IS_SURROGATE_LEAD(characters[i])
+ && i != numCharacters - 1
+ && U16_IS_TRAIL(characters[i + 1])) {
+ FcCharSetAddChar(cset, U16_GET_SUPPLEMENTARY(characters[i], characters[i+1]));
+ i++;
+ } else
+ FcCharSetAddChar(cset, characters[i]);
+ }
+ FcPattern* pattern = FcPatternCreate();
+
+ FcValue fcvalue;
+ fcvalue.type = FcTypeCharSet;
+ fcvalue.u.c = cset;
+ FcPatternAdd(pattern, FC_CHARSET, fcvalue, FcFalse);
+
+ fcvalue.type = FcTypeBool;
+ fcvalue.u.b = FcTrue;
+ FcPatternAdd(pattern, FC_SCALABLE, fcvalue, FcFalse);
+
+ fcvalue.type = FcTypeInteger;
+ fcvalue.u.i = (description.weight() >= FontWeightBold) ? FC_WEIGHT_BOLD : FC_WEIGHT_NORMAL;
+ FcPatternAdd(pattern, FC_WEIGHT, fcvalue, FcFalse);
+
+ fcvalue.type = FcTypeInteger;
+ fcvalue.u.i = (description.italic() == FontItalicOn) ? FC_SLANT_ITALIC : FC_SLANT_ROMAN;
+ FcPatternAdd(pattern, FC_SLANT, fcvalue, FcFalse);
+
+ FcConfigSubstitute(0, pattern, FcMatchPattern);
+ FcDefaultSubstitute(pattern);
+
+ FcResult result;
+ FcFontSet* fontSet = FcFontSort(0, pattern, 0, 0, &result);
+ FcPatternDestroy(pattern);
+ FcCharSetDestroy(cset);
+
+ if (!fontSet) {
+ family->name = String();
+ family->isBold = false;
+ family->isItalic = false;
+ return;
+ }
+
+ // Older versions of fontconfig have a bug where they cannot select
+ // only scalable fonts so we have to manually filter the results.
+ for (int i = 0; i < fontSet->nfont; ++i) {
+ FcPattern* current = fontSet->fonts[i];
+ FcBool isScalable;
+
+ if (FcPatternGetBool(current, FC_SCALABLE, 0, &isScalable) != FcResultMatch
+ || !isScalable)
+ continue;
+
+ // fontconfig can also return fonts which are unreadable
+ FcChar8* cFilename;
+ if (FcPatternGetString(current, FC_FILE, 0, &cFilename) != FcResultMatch)
+ continue;
+
+ if (access(reinterpret_cast<char*>(cFilename), R_OK))
+ continue;
+
+ FcChar8* familyName;
+ if (FcPatternGetString(current, FC_FAMILY, 0, &familyName) == FcResultMatch) {
+ const char* charFamily = reinterpret_cast<char*>(familyName);
+ family->name = String::fromUTF8(charFamily, strlen(charFamily));
+ }
+
+ int weight;
+ if (FcPatternGetInteger(current, FC_WEIGHT, 0, &weight) == FcResultMatch)
+ family->isBold = weight >= FC_WEIGHT_BOLD;
+ else
+ family->isBold = false;
+
+ int slant;
+ if (FcPatternGetInteger(current, FC_SLANT, 0, &slant) == FcResultMatch)
+ family->isItalic = slant != FC_SLANT_ROMAN;
+ else
+ family->isItalic = false;
+
+ FcFontSetDestroy(fontSet);
+ return;
+ }
+
+ FcFontSetDestroy(fontSet);
+}
+
+PassRefPtr<SimpleFontData> FontCache::systemFallbackForCharacters(const FontDescription& fontDescription, const SimpleFontData*, bool, const UChar* characters, int length)
+{
+ icu::Locale locale = icu::Locale::getDefault();
+ FontCache::SimpleFontFamily family;
+ FontCache::getFontFamilyForCharacters(characters, length, locale.getLanguage(), fontDescription, &family);
+ if (family.name.isEmpty())
+ return 0;
+
+ AtomicString atomicFamily(family.name);
+ // Changes weight and/or italic of given FontDescription depends on
+ // the result of fontconfig so that keeping the correct font mapping
+ // of the given characters. See http://crbug.com/32109 for details.
+ bool shouldSetFakeBold = false;
+ bool shouldSetFakeItalic = false;
+ FontDescription description(fontDescription);
+ if (family.isBold && description.weight() < FontWeightBold)
+ description.setWeight(FontWeightBold);
+ if (!family.isBold && description.weight() >= FontWeightBold) {
+ shouldSetFakeBold = true;
+ description.setWeight(FontWeightNormal);
+ }
+ if (family.isItalic && description.italic() == FontItalicOff)
+ description.setItalic(FontItalicOn);
+ if (!family.isItalic && description.italic() == FontItalicOn) {
+ shouldSetFakeItalic = true;
+ description.setItalic(FontItalicOff);
+ }
+
+ FontPlatformData* substitutePlatformData = getCachedFontPlatformData(description, atomicFamily, DoNotRetain);
+ if (!substitutePlatformData)
+ return 0;
+ FontPlatformData platformData = FontPlatformData(*substitutePlatformData);
+ platformData.setFakeBold(shouldSetFakeBold);
+ platformData.setFakeItalic(shouldSetFakeItalic);
+ return getCachedFontData(&platformData, DoNotRetain);
+}
+
+PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& description, ShouldRetain)
+{
+ DEFINE_STATIC_LOCAL(const AtomicString, sansStr, ("Sans"));
+ DEFINE_STATIC_LOCAL(const AtomicString, serifStr, ("Serif"));
+ DEFINE_STATIC_LOCAL(const AtomicString, monospaceStr, ("Monospace"));
+
+ FontPlatformData* fontPlatformData = 0;
+ switch (description.genericFamily()) {
+ case FontDescription::SerifFamily:
+ fontPlatformData = getCachedFontPlatformData(description, serifStr);
+ break;
+ case FontDescription::MonospaceFamily:
+ fontPlatformData = getCachedFontPlatformData(description, monospaceStr);
+ break;
+ case FontDescription::SansSerifFamily:
+ default:
+ fontPlatformData = getCachedFontPlatformData(description, sansStr);
+ break;
+ }
+
+ if (!fontPlatformData) {
+ DEFINE_STATIC_LOCAL(const AtomicString, arialStr, ("Arial"));
+ fontPlatformData = getCachedFontPlatformData(description, arialStr);
+ }
+
+ ASSERT(fontPlatformData);
+ return getCachedFontData(fontPlatformData);
+}
+
+void FontCache::getTraitsInFamily(const AtomicString&, Vector<unsigned>&)
+{
+ notImplemented();
+}
+
+static String getFamilyNameStringFromFontDescriptionAndFamily(const FontDescription& fontDescription, const AtomicString& family)
+{
+ // If we're creating a fallback font (e.g. "-webkit-monospace"), convert the name into
+ // the fallback name (like "monospace") that fontconfig understands.
+ if (family.length() && !family.startsWith("-webkit-"))
+ return family.string();
+
+ switch (fontDescription.genericFamily()) {
+ case FontDescription::StandardFamily:
+ case FontDescription::SerifFamily:
+ return "serif";
+ case FontDescription::SansSerifFamily:
+ return "sans-serif";
+ case FontDescription::MonospaceFamily:
+ return "monospace";
+ case FontDescription::CursiveFamily:
+ return "cursive";
+ case FontDescription::FantasyFamily:
+ return "fantasy";
+ case FontDescription::NoFamily:
+ default:
+ return "";
+ }
+}
+
+int fontWeightToFontconfigWeight(FontWeight weight)
+{
+ switch (weight) {
+ case FontWeight100:
+ return FC_WEIGHT_THIN;
+ case FontWeight200:
+ return FC_WEIGHT_ULTRALIGHT;
+ case FontWeight300:
+ return FC_WEIGHT_LIGHT;
+ case FontWeight400:
+ return FC_WEIGHT_REGULAR;
+ case FontWeight500:
+ return FC_WEIGHT_MEDIUM;
+ case FontWeight600:
+ return FC_WEIGHT_SEMIBOLD;
+ case FontWeight700:
+ return FC_WEIGHT_BOLD;
+ case FontWeight800:
+ return FC_WEIGHT_EXTRABOLD;
+ case FontWeight900:
+ return FC_WEIGHT_ULTRABLACK;
+ default:
+ ASSERT_NOT_REACHED();
+ return FC_WEIGHT_REGULAR;
+ }
+}
+
+PassOwnPtr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
+{
+ // The CSS font matching algorithm (http://www.w3.org/TR/css3-fonts/#font-matching-algorithm)
+ // says that we must find an exact match for font family, slant (italic or oblique can be used)
+ // and font weight (we only match bold/non-bold here).
+ FcPattern* pattern = FcPatternCreate();
+ String familyNameString(getFamilyNameStringFromFontDescriptionAndFamily(fontDescription, family));
+ if (!FcPatternAddString(pattern, FC_FAMILY, reinterpret_cast<const FcChar8*>(familyNameString.utf8().data())))
+ return nullptr;
+
+ bool italic = fontDescription.italic();
+ if (!FcPatternAddInteger(pattern, FC_SLANT, italic ? FC_SLANT_ITALIC : FC_SLANT_ROMAN))
+ return nullptr;
+ if (!FcPatternAddInteger(pattern, FC_WEIGHT, fontWeightToFontconfigWeight(fontDescription.weight())))
+ return nullptr;
+ if (!FcPatternAddDouble(pattern, FC_PIXEL_SIZE, fontDescription.computedPixelSize()))
+ return nullptr;
+
+ // The strategy is originally from Skia (src/ports/SkFontHost_fontconfig.cpp):
+
+ // Allow Fontconfig to do pre-match substitution. Unless we are accessing a "fallback"
+ // family like "sans," this is the only time we allow Fontconfig to substitute one
+ // family name for another (i.e. if the fonts are aliased to each other).
+ FcConfigSubstitute(0, pattern, FcMatchPattern);
+ FcDefaultSubstitute(pattern);
+
+ FcChar8* fontConfigFamilyNameAfterConfiguration;
+ FcPatternGetString(pattern, FC_FAMILY, 0, &fontConfigFamilyNameAfterConfiguration);
+ String familyNameAfterConfiguration = String::fromUTF8(reinterpret_cast<char*>(fontConfigFamilyNameAfterConfiguration));
+
+ FcResult fontConfigResult;
+ FcPattern* resultPattern = FcFontMatch(0, pattern, &fontConfigResult);
+ FcPatternDestroy(pattern);
+ if (!resultPattern) // No match.
+ return nullptr;
+
+ FcChar8* fontConfigFamilyNameAfterMatching;
+ FcPatternGetString(resultPattern, FC_FAMILY, 0, &fontConfigFamilyNameAfterMatching);
+ String familyNameAfterMatching = String::fromUTF8(reinterpret_cast<char*>(fontConfigFamilyNameAfterMatching));
+
+ // If Fontconfig gave use a different font family than the one we requested, we should ignore it
+ // and allow WebCore to give us the next font on the CSS fallback list. The only exception is if
+ // this family name is a commonly used generic family.
+ if (!equalIgnoringCase(familyNameAfterConfiguration, familyNameAfterMatching)
+ && !(equalIgnoringCase(familyNameString, "sans") || equalIgnoringCase(familyNameString, "sans-serif")
+ || equalIgnoringCase(familyNameString, "serif") || equalIgnoringCase(familyNameString, "monospace")
+ || equalIgnoringCase(familyNameString, "fantasy") || equalIgnoringCase(familyNameString, "cursive")))
+ return nullptr;
+
+ int fontWeight;
+ FcPatternGetInteger(resultPattern, FC_WEIGHT, 0, &fontWeight);
+ bool shouldFakeBold = fontWeight < FC_WEIGHT_BOLD && fontDescription.weight() >= FontWeightBold;
+
+ int fontSlant;
+ FcPatternGetInteger(resultPattern, FC_SLANT, 0, &fontSlant);
+ bool shouldFakeItalic = fontSlant == FC_SLANT_ROMAN && fontDescription.italic() == FontItalicOn;
+
+ FcChar8* fontFileName;
+ FcPatternGetString(resultPattern, FC_FILE, 0, &fontFileName);
+ // fprintf(stderr, "Looking for %s found %s: i:%d b:%d\n", family.string().latin1().data(), fontFileName, shouldFakeItalic, shouldFakeBold);
+ FcPatternDestroy(resultPattern);
+
+ FILECHAR name[MAX_FONT_NAME_LEN+1];
+ memset(name, 0, MAX_FONT_NAME_LEN+1);
+ // fprintf(stderr, "FS_load_font %s: ", fontFileName);
+ if (FS_load_font(BlackBerry::Platform::Graphics::getIType(), reinterpret_cast<FILECHAR*>(fontFileName), 0, 0, MAX_FONT_NAME_LEN, name) != SUCCESS)
+ return nullptr;
+ // fprintf(stderr, " %s\n", name);
+
+ return adoptPtr(new FontPlatformData(name, fontDescription.computedSize(), shouldFakeBold, shouldFakeItalic, fontDescription.orientation()));
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/blackberry/FontCacheBlackberry.cpp b/Source/WebCore/platform/graphics/blackberry/FontCacheBlackberry.cpp
deleted file mode 100644
index 6f9896ad6..000000000
--- a/Source/WebCore/platform/graphics/blackberry/FontCacheBlackberry.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "FontCache.h"
-
-#include "FontRenderStyle.h"
-
-#include <fontconfig/fontconfig.h>
-#include <string.h>
-#include <unicode/utf16.h>
-#include <wtf/text/CString.h>
-
-namespace WebCore {
-
-void FontCache::getFontFamilyForCharacters(const UChar* characters, size_t numCharacters, const char*, FontCache::SimpleFontFamily* family)
-{
- FcCharSet* cset = FcCharSetCreate();
- for (size_t i = 0; i < numCharacters; ++i) {
- if (U16_IS_SURROGATE(characters[i])
- && U16_IS_SURROGATE_LEAD(characters[i])
- && i != numCharacters - 1
- && U16_IS_TRAIL(characters[i + 1])) {
- FcCharSetAddChar(cset, U16_GET_SUPPLEMENTARY(characters[i], characters[i+1]));
- i++;
- } else
- FcCharSetAddChar(cset, characters[i]);
- }
- FcPattern* pattern = FcPatternCreate();
-
- FcValue fcvalue;
- fcvalue.type = FcTypeCharSet;
- fcvalue.u.c = cset;
- FcPatternAdd(pattern, FC_CHARSET, fcvalue, FcFalse);
-
- fcvalue.type = FcTypeBool;
- fcvalue.u.b = FcTrue;
- FcPatternAdd(pattern, FC_SCALABLE, fcvalue, FcFalse);
-
- FcConfigSubstitute(0, pattern, FcMatchPattern);
- FcDefaultSubstitute(pattern);
-
- FcResult result;
- FcFontSet* fontSet = FcFontSort(0, pattern, 0, 0, &result);
- FcPatternDestroy(pattern);
- FcCharSetDestroy(cset);
-
- if (!fontSet) {
- family->name = String();
- family->isBold = false;
- family->isItalic = false;
- return;
- }
-
- // Older versions of fontconfig have a bug where they cannot select
- // only scalable fonts so we have to manually filter the results.
- for (int i = 0; i < fontSet->nfont; ++i) {
- FcPattern* current = fontSet->fonts[i];
- FcBool isScalable;
-
- if (FcPatternGetBool(current, FC_SCALABLE, 0, &isScalable) != FcResultMatch
- || !isScalable)
- continue;
-
- // fontconfig can also return fonts which are unreadable
- FcChar8* cFilename;
- if (FcPatternGetString(current, FC_FILE, 0, &cFilename) != FcResultMatch)
- continue;
-
- if (access(reinterpret_cast<char*>(cFilename), R_OK))
- continue;
-
- FcChar8* familyName;
- if (FcPatternGetString(current, FC_FAMILY, 0, &familyName) == FcResultMatch) {
- const char* charFamily = reinterpret_cast<char*>(familyName);
- family->name = String::fromUTF8(charFamily, strlen(charFamily));
- }
-
- int weight;
- if (FcPatternGetInteger(current, FC_WEIGHT, 0, &weight) == FcResultMatch)
- family->isBold = weight >= FC_WEIGHT_BOLD;
- else
- family->isBold = false;
-
- int slant;
- if (FcPatternGetInteger(current, FC_SLANT, 0, &slant) == FcResultMatch)
- family->isItalic = slant != FC_SLANT_ROMAN;
- else
- family->isItalic = false;
-
- FcFontSetDestroy(fontSet);
- return;
- }
-
- FcFontSetDestroy(fontSet);
-}
-
-}; // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/blackberry/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/blackberry/FontCustomPlatformData.h
new file mode 100644
index 000000000..1f5600ee8
--- /dev/null
+++ b/Source/WebCore/platform/graphics/blackberry/FontCustomPlatformData.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#ifndef FontCustomPlatformData_h
+#define FontCustomPlatformData_h
+
+#include "FontOrientation.h"
+#include "FontRenderingMode.h"
+#include "FontWidthVariant.h"
+#include <wtf/Noncopyable.h>
+#include <wtf/text/WTFString.h>
+
+typedef char FILECHAR;
+struct FS_STATE;
+
+namespace WebCore {
+
+class FontPlatformData;
+class MonotypeFont;
+class SharedBuffer;
+
+struct FontCustomPlatformData {
+ WTF_MAKE_NONCOPYABLE(FontCustomPlatformData);
+public:
+ FontCustomPlatformData(FILECHAR* fontName, PassRefPtr<SharedBuffer>);
+ ~FontCustomPlatformData();
+
+ FontPlatformData fontPlatformData(int size, bool syntheticBold, bool syntheticItalic, FontOrientation = Horizontal,
+ FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode);
+
+ static bool supportsFormat(const String&);
+
+ FILECHAR* m_fontName;
+ RefPtr<SharedBuffer> m_buffer;
+};
+
+FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer*);
+
+} // namespace WebCore
+
+#endif // FontCustomPlatformData_h
diff --git a/Source/WebCore/platform/graphics/blackberry/FontCustomPlatformDataBlackBerry.cpp b/Source/WebCore/platform/graphics/blackberry/FontCustomPlatformDataBlackBerry.cpp
new file mode 100644
index 000000000..d16784cf8
--- /dev/null
+++ b/Source/WebCore/platform/graphics/blackberry/FontCustomPlatformDataBlackBerry.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2012, 2013 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "FontCustomPlatformData.h"
+
+#include "FontPlatformData.h"
+#include "ITypeUtils.h"
+#include "OpenTypeSanitizer.h"
+#include "SharedBuffer.h"
+
+#include <BlackBerryPlatformGraphicsContext.h>
+#include <fs_api.h>
+
+namespace WebCore {
+
+FontCustomPlatformData::FontCustomPlatformData(FILECHAR* fontName, PassRefPtr<SharedBuffer> buffer)
+ : m_fontName(strdup(fontName))
+ , m_buffer(buffer)
+{
+}
+
+FontCustomPlatformData::~FontCustomPlatformData()
+{
+ FS_LONG ret = FS_delete_font(BlackBerry::Platform::Graphics::getIType(), const_cast<FILECHAR*>(m_fontName));
+ ASSERT_UNUSED(ret, ret == SUCCESS);
+ free(m_fontName);
+}
+
+FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool syntheticBold, bool syntheticItalic, FontOrientation orientation, FontWidthVariant widthVariant, FontRenderingMode)
+{
+ return FontPlatformData(m_fontName, size, syntheticBold, syntheticItalic, orientation, widthVariant);
+}
+
+bool FontCustomPlatformData::supportsFormat(const String& format)
+{
+ bool isSupported = equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "opentype");
+#if USE(OPENTYPE_SANITIZER)
+ isSupported = isSupported || equalIgnoringCase(format, "woff");
+#endif
+ return isSupported;
+}
+
+FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
+{
+ ASSERT_ARG(buffer, buffer);
+
+#if USE(OPENTYPE_SANITIZER)
+ OpenTypeSanitizer sanitizer(buffer);
+ RefPtr<SharedBuffer> transcodeBuffer = sanitizer.sanitize();
+ if (!transcodeBuffer)
+ return 0; // validation failed.
+ buffer = transcodeBuffer.get();
+#endif
+
+ FILECHAR name[MAX_FONT_NAME_LEN+1];
+ memset(name, 0, MAX_FONT_NAME_LEN+1);
+ if (FS_load_font(BlackBerry::Platform::Graphics::getIType(), 0, const_cast<FS_BYTE*>(reinterpret_cast<const FS_BYTE*>(buffer->data())), 0, MAX_FONT_NAME_LEN, name) != SUCCESS)
+ return 0;
+
+ return new FontCustomPlatformData(name, buffer);
+}
+
+}
diff --git a/Source/WebCore/platform/graphics/blackberry/FontPlatformDataBlackBerry.cpp b/Source/WebCore/platform/graphics/blackberry/FontPlatformDataBlackBerry.cpp
new file mode 100644
index 000000000..ff0467ac2
--- /dev/null
+++ b/Source/WebCore/platform/graphics/blackberry/FontPlatformDataBlackBerry.cpp
@@ -0,0 +1,229 @@
+/*
+ * Copyright (C) 2012, 2013 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "FontPlatformData.h"
+
+#include "HarfBuzzFace.h"
+#include "ITypeUtils.h"
+
+#include <BlackBerryPlatformGraphicsContext.h>
+#include <fs_api.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+FontPlatformData::FontPlatformData(FILECHAR* name, float size, bool syntheticBold, bool syntheticOblique, FontOrientation orientation, FontWidthVariant widthVariant)
+ : m_syntheticBold(syntheticBold)
+ , m_syntheticOblique(syntheticOblique)
+ , m_orientation(orientation)
+ , m_size(size)
+ , m_widthVariant(widthVariant)
+ , m_font(0)
+ , m_name(fastStrDup(name))
+ , m_scaledFont(0)
+ , m_harfBuzzFace()
+ , m_isColorBitmapFont(false)
+{
+ ASSERT(name);
+ m_font = FS_new_client(BlackBerry::Platform::Graphics::getIType(), 0);
+ ASSERT(m_font);
+ applyState(m_font);
+}
+
+FontPlatformData::~FontPlatformData()
+{
+ if (m_scaledFont) {
+ BlackBerry::Platform::Graphics::clearGlyphCacheForFont(m_scaledFont);
+ FS_end_client(m_scaledFont);
+ }
+ if (m_font && m_font != hashTableDeletedFontValue())
+ FS_end_client(m_font);
+ fastFree(m_name);
+}
+
+const char* FontPlatformData::name() const
+{
+ return m_name;
+}
+
+bool FontPlatformData::applyState(FS_STATE* font, float scale) const
+{
+ ASSERT(font);
+ ASSERT(m_name);
+ if (FS_set_font(font, m_name) != SUCCESS)
+ return false;
+
+ if (FS_set_cmap(font, 3, 10) != SUCCESS) // First try Windows Unicode with surrogates...
+ if (FS_set_cmap(font, 3, 1) != SUCCESS) // try normal Windows Unicode
+ if (FS_set_cmap(font, 1, 0) != SUCCESS)
+ return false;
+
+ if (m_syntheticBold) {
+ if (FS_set_bold_pct(font, ITYPEFAKEBOLDAMOUNT) != SUCCESS)
+ return false;
+ FS_set_flags(font, FLAGS_CHECK_CONTOUR_WINDING_ON); // we need correctly-wound contours to fake bold
+ } else {
+ if (FS_set_bold_pct(font, 0) != SUCCESS)
+ return false;
+ FS_set_flags(font, FLAGS_CHECK_CONTOUR_WINDING_OFF);
+ }
+
+ FS_FIXED skew = 0;
+ if (m_syntheticOblique)
+ skew = 13930; // 12 degrees
+
+ FS_FIXED fixedScale = std::min(FixMul(floatToITypeFixed(scale), floatToITypeFixed(m_size)), MAXITYPEFONTSCALE);
+ if (FS_set_scale(font, fixedScale, FixMul(fixedScale, skew), 0, fixedScale) != SUCCESS)
+ return false;
+
+ if (FS_set_flags(font, FLAGS_CMAP_OFF) != SUCCESS)
+ return false;
+
+ if (FS_set_flags(font, FLAGS_HINTS_OFF) != SUCCESS)
+ return false;
+
+ if (FS_set_flags(font, FLAGS_DEFAULT_CSM_OFF) != SUCCESS)
+ return false;
+
+ if (m_orientation == Vertical) {
+ if (FS_set_flags(font, FLAGS_VERTICAL_ON) != SUCCESS)
+ return false;
+ }
+ return true;
+}
+
+void FontPlatformData::platformDataInit(const FontPlatformData& source)
+{
+ m_harfBuzzFace = source.m_harfBuzzFace;
+ m_scaledFont = 0;
+ if (source.m_font && source.m_font != hashTableDeletedFontValue()) {
+ m_font = FS_new_client(source.m_font, 0);
+ m_name = fastStrDup(source.name());
+ bool ret = applyState(m_font);
+ ASSERT_UNUSED(ret, ret);
+ } else
+ m_font = source.m_font;
+}
+
+const FontPlatformData& FontPlatformData::platformDataAssign(const FontPlatformData& other)
+{
+ m_harfBuzzFace = other.m_harfBuzzFace;
+ m_scaledFont = 0;
+ if (other.m_font && other.m_font != hashTableDeletedFontValue()) {
+ m_font = FS_new_client(other.m_font, 0);
+ fastFree(m_name);
+ m_name = fastStrDup(other.name());
+ bool ret = applyState(m_font);
+ ASSERT_UNUSED(ret, ret);
+ } else
+ m_font = other.m_font;
+
+ return *this;
+}
+
+bool FontPlatformData::platformIsEqual(const FontPlatformData& other) const
+{
+ if (m_font == other.m_font)
+ return true;
+
+ if (!m_font || m_font == hashTableDeletedFontValue() || !other.m_font || other.m_font == hashTableDeletedFontValue())
+ return false;
+
+ return m_font->cur_sfnt == other.m_font->cur_sfnt;
+}
+
+#ifndef NDEBUG
+String FontPlatformData::description() const
+{
+ return "iType Font Data";
+}
+#endif
+
+HarfBuzzFace* FontPlatformData::harfBuzzFace()
+{
+ if (!m_harfBuzzFace) {
+ uint64_t uniqueID = reinterpret_cast<uintptr_t>(m_font);
+ m_harfBuzzFace = HarfBuzzFace::create(const_cast<FontPlatformData*>(this), uniqueID);
+ }
+
+ return m_harfBuzzFace.get();
+}
+
+FS_STATE* FontPlatformData::scaledFont(float scale) const
+{
+ ASSERT(scale > 0.0);
+ if (m_scale == scale && m_scaledFont)
+ return m_scaledFont;
+
+ // This must be an SVG Font. It seems like there is an upstream bug where web and SVG fonts
+ // are used in one TextRun. Other ports seem to be able to deal with having an SVG Font in
+ // this path so bail out instead of crash.
+ if (!m_font)
+ return 0;
+
+ if (m_scaledFont) {
+ BlackBerry::Platform::Graphics::clearGlyphCacheForFont(m_scaledFont);
+ if (FS_end_client(m_scaledFont) != SUCCESS)
+ CRASH();
+ }
+
+ m_scaledFont = FS_new_client(m_font, 0);
+ if (!applyState(m_scaledFont, scale)) {
+ if (FS_end_client(m_scaledFont) != SUCCESS)
+ CRASH();
+ m_scaledFont = 0;
+ return 0;
+ }
+
+ m_scale = scale;
+
+ return m_scaledFont;
+}
+
+void FontPlatformData::setFakeBold(bool fakeBold)
+{
+ m_syntheticBold = fakeBold;
+ applyState(m_font);
+}
+
+void FontPlatformData::setFakeItalic(bool fakeItalic)
+{
+ m_syntheticOblique = fakeItalic;
+ applyState(m_font);
+}
+
+const void* FontPlatformData::platformFontHandle() const
+{
+ ASSERT(m_font);
+ return m_font->cur_sfnt;
+}
+
+bool FontPlatformData::isFixedPitch() const
+{
+ FS_BYTE* postTable;
+ FS_ULONG length;
+ if (m_font && (postTable = FS_get_table(m_font, TAG_post, TBL_EXTRACT, &length))) {
+ bool fixed = reinterpret_cast<TTF_POST*>(postTable)->isFixedPitch;
+ FS_free_table(m_font, postTable);
+ return fixed;
+ }
+ return false;
+}
+
+}
diff --git a/Source/WebCore/platform/graphics/blackberry/GlyphPageTreeNodeBlackBerry.cpp b/Source/WebCore/platform/graphics/blackberry/GlyphPageTreeNodeBlackBerry.cpp
new file mode 100644
index 000000000..ce24c78d6
--- /dev/null
+++ b/Source/WebCore/platform/graphics/blackberry/GlyphPageTreeNodeBlackBerry.cpp
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "GlyphPageTreeNode.h"
+
+#include "SimpleFontData.h"
+#include <fs_api.h>
+
+namespace WebCore {
+
+template<typename T>
+class WorldTypeScopedPtr {
+public:
+ typedef void (*DestroyFunction)(T*);
+
+ WorldTypeScopedPtr(T* ptr, DestroyFunction destroy)
+ : m_ptr(ptr)
+ , m_destroy(destroy)
+ {
+ ASSERT(m_destroy);
+ }
+ ~WorldTypeScopedPtr()
+ {
+ if (m_ptr)
+ (*m_destroy)(m_ptr);
+ }
+
+ T* get() { return m_ptr; }
+private:
+ T* m_ptr;
+ DestroyFunction m_destroy;
+};
+
+bool GlyphPage::fill(unsigned offset, unsigned, UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData)
+{
+ bool haveGlyphs = false;
+ unsigned position = 0;
+ int i = 0;
+ while (position < bufferLength) {
+ UChar32 character;
+ unsigned nextPosition = position;
+ U16_NEXT(buffer, nextPosition, bufferLength, character);
+
+ FS_USHORT glyph = FS_map_char(fontData->platformData().font(), static_cast<FS_ULONG>(character));
+ if (!glyph)
+ setGlyphDataForIndex(offset + i, 0, 0);
+ else {
+ haveGlyphs = true;
+ setGlyphDataForIndex(offset + i, glyph, fontData);
+ }
+
+ i++;
+ position = nextPosition;
+ }
+
+ return haveGlyphs;
+}
+
+}
diff --git a/Source/WebCore/platform/graphics/blackberry/GradientBlackBerry.cpp b/Source/WebCore/platform/graphics/blackberry/GradientBlackBerry.cpp
new file mode 100644
index 000000000..6a4cd700e
--- /dev/null
+++ b/Source/WebCore/platform/graphics/blackberry/GradientBlackBerry.cpp
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include "config.h"
+#include "Gradient.h"
+
+#include "AffineTransform.h"
+#include "GraphicsContext.h"
+#include "GraphicsContext3D.h"
+#include "KURL.h"
+#include "NotImplemented.h"
+#include "TransformationMatrix.h"
+
+#include <BlackBerryPlatformGraphicsContext.h>
+#include <stdio.h>
+#include <wtf/Assertions.h>
+#include <wtf/MathExtras.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+// Determine the total number of stops needed, including pseudo-stops at the
+// ends as necessary.
+static size_t totalStopsNeeded(const Gradient::ColorStop* stopData, size_t count)
+{
+ // N.B.: The tests in this function should kept in sync with the ones in
+ // fillStops(), or badness happens.
+ const Gradient::ColorStop* stop = stopData;
+ size_t countUsed = count;
+ if (count < 1 || stop->stop > 0.0)
+ countUsed++;
+ stop += count - 1;
+ if (count < 1 || stop->stop < 1.0)
+ countUsed++;
+ return countUsed;
+}
+
+// Collect sorted stop position and color information into the pos and colors
+// buffers, ensuring stops at both 0.0 and 1.0. The buffers must be large
+// enough to hold information for all stops, including the new endpoints if
+// stops at 0.0 and 1.0 aren't already included.
+static void fillStops(const Gradient::ColorStop* stopData, size_t count, float* pos, unsigned* colors)
+{
+ const Gradient::ColorStop* stop = stopData;
+ size_t start = 0;
+ if (count < 1) {
+ // A gradient with no stops must be transparent black.
+ pos[0] = 0.0;
+ colors[0] = 0;
+ start = 1;
+ } else if (stop->stop > 0.0) {
+ // Copy the first stop to 0.0. The first stop position may have a slight
+ // rounding error, but we don't care in this float comparison, since
+ // 0.0 comes through cleanly and people aren't likely to want a gradient
+ // with a stop at (0 + epsilon).
+ pos[0] = 0.0;
+ colors[0] = Color(stop->red, stop->green, stop->blue, stop->alpha).rgb();
+ start = 1;
+ }
+
+ for (size_t i = start; i < start + count; i++) {
+ pos[i] = stop->stop;
+ colors[i] = Color(stop->red, stop->green, stop->blue, stop->alpha).rgb();
+ ++stop;
+ }
+
+ // Copy the last stop to 1.0 if needed. See comment above about this float
+ // comparison.
+ if (count < 1 || (--stop)->stop < 1.0) {
+ pos[start + count] = 1.0;
+ colors[start + count] = colors[start + count - 1];
+ }
+}
+
+
+BlackBerry::Platform::Graphics::Gradient* Gradient::platformGradient()
+{
+ if (m_gradient)
+ return m_gradient;
+
+ if (m_radial)
+ m_gradient = BlackBerry::Platform::Graphics::Gradient::createRadialGradient(m_p0, m_p1, m_r0, m_r1, m_aspectRatio, (BlackBerry::Platform::Graphics::Gradient::SpreadMethod)m_spreadMethod);
+ else
+ m_gradient = BlackBerry::Platform::Graphics::Gradient::createLinearGradient(m_p0, m_p1, (BlackBerry::Platform::Graphics::Gradient::SpreadMethod)m_spreadMethod);
+
+ sortStopsIfNecessary();
+ ASSERT(m_stopsSorted);
+
+ size_t countUsed = totalStopsNeeded(m_stops.data(), m_stops.size());
+ ASSERT(countUsed >= 2);
+ ASSERT(countUsed >= m_stops.size());
+
+ Vector<float> pos(countUsed);
+ Vector<unsigned> colors(countUsed);
+ fillStops(m_stops.data(), m_stops.size(), pos.data(), colors.data());
+ m_gradient->setColorStops(pos.data(), colors.data(), countUsed);
+
+ if (!m_gradientSpaceTransformation.isIdentity())
+ m_gradient->setLocalMatrix(reinterpret_cast<const double*>(&m_gradientSpaceTransformation));
+
+ return m_gradient;
+}
+
+void Gradient::platformDestroy()
+{
+ delete m_gradient;
+ m_gradient = 0;
+}
+
+void Gradient::fill(GraphicsContext* context, const FloatRect& rect)
+{
+ platformGradient()->fill(context->platformContext(), rect);
+}
+
+void Gradient::setPlatformGradientSpaceTransform(const AffineTransform& gradientSpaceTransformation)
+{
+ platformGradient()->setLocalMatrix(reinterpret_cast<const double*>(&gradientSpaceTransformation));
+}
+
+}
diff --git a/Source/WebCore/platform/graphics/blackberry/GraphicsContext3DBlackBerry.cpp b/Source/WebCore/platform/graphics/blackberry/GraphicsContext3DBlackBerry.cpp
index 95e023d14..5a44aea18 100644
--- a/Source/WebCore/platform/graphics/blackberry/GraphicsContext3DBlackBerry.cpp
+++ b/Source/WebCore/platform/graphics/blackberry/GraphicsContext3DBlackBerry.cpp
@@ -30,14 +30,15 @@
#include "GraphicsContext3D.h"
-#include "BitmapImageSingleFrameSkia.h"
#include "Extensions3DOpenGLES.h"
#include "GraphicsContext.h"
#include "OpenGLESShims.h"
#include "WebGLLayerWebKitThread.h"
#include <BlackBerryPlatformGraphics.h>
+#include <BlackBerryPlatformGraphicsContext.h>
#include <BlackBerryPlatformLog.h>
+#include <TiledImage.h>
namespace WebCore {
@@ -55,16 +56,12 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi
, m_currentHeight(0)
, m_context(BlackBerry::Platform::Graphics::createWebGLContext())
, m_compiler(SH_ESSL_OUTPUT)
- , m_extensions(adoptPtr(new Extensions3DOpenGLES(this)))
, m_attrs(attrs)
, m_texture(0)
, m_fbo(0)
, m_depthStencilBuffer(0)
, m_layerComposited(false)
, m_internalColorFormat(GL_RGBA)
- , m_boundFBO(0)
- , m_activeTexture(GL_TEXTURE0)
- , m_boundTexture0(0)
, m_isImaginationHardware(0)
{
if (renderStyle != RenderDirectlyToHostWindow) {
@@ -87,7 +84,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi
::glBindFramebuffer(GL_FRAMEBUFFER, m_fbo);
if (m_attrs.stencil || m_attrs.depth)
::glGenRenderbuffers(1, &m_depthStencilBuffer);
- m_boundFBO = m_fbo;
+ m_state.boundFBO = m_fbo;
#if USE(ACCELERATED_COMPOSITING)
static_cast<WebGLLayerWebKitThread*>(m_compositingLayer.get())->setWebGLContext(this);
@@ -111,10 +108,10 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi
getIntegerv(GraphicsContext3D::MAX_TEXTURE_IMAGE_UNITS, &ANGLEResources.MaxTextureImageUnits);
getIntegerv(GraphicsContext3D::MAX_FRAGMENT_UNIFORM_VECTORS, &ANGLEResources.MaxFragmentUniformVectors);
- ANGLEResources.MaxDrawBuffers = 1; // Always set to 1 for OpenGL ES.
- ANGLEResources.OES_standard_derivatives = m_extensions->supports("GL_OES_standard_derivatives");
- ANGLEResources.OES_EGL_image_external = m_extensions->supports("GL_EGL_image_external");
- ANGLEResources.ARB_texture_rectangle = m_extensions->supports("GL_ARB_texture_rectangle");
+ GC3Dint range[2], precision;
+ getShaderPrecisionFormat(GraphicsContext3D::FRAGMENT_SHADER, GraphicsContext3D::HIGH_FLOAT, range, &precision);
+ ANGLEResources.FragmentPrecisionHigh = (range[0] || range[1] || precision);
+
m_compiler.setResources(ANGLEResources);
::glClearColor(0, 0, 0, 0);
@@ -130,7 +127,7 @@ GraphicsContext3D::~GraphicsContext3D()
::glDeleteFramebuffers(1, &m_fbo);
}
- m_compositingLayer = 0; // Must release compositing layer before destroying the context.
+ static_cast<WebGLLayerWebKitThread *>(m_compositingLayer.get())->webGLContextDestroyed(); // Must release compositing layer before destroying the context.
BlackBerry::Platform::Graphics::destroyWebGLContext(m_context);
}
@@ -188,7 +185,7 @@ bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
}
bool mustRestoreFBO = false;
- if (m_boundFBO != m_fbo) {
+ if (m_state.boundFBO != m_fbo) {
mustRestoreFBO = true;
::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_fbo);
}
@@ -282,9 +279,9 @@ void GraphicsContext3D::readPixelsIMG(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3
// If this ever changes, this code will need to be updated.
// Calculate the strides of our data and canvas
- unsigned int formatSize = 4; // RGBA UNSIGNED_BYTE
- unsigned int dataStride = width * formatSize;
- unsigned int canvasStride = m_currentWidth * formatSize;
+ unsigned formatSize = 4; // RGBA UNSIGNED_BYTE
+ unsigned dataStride = width * formatSize;
+ unsigned canvasStride = m_currentWidth * formatSize;
// If we are using a pack alignment of 8, then we need to align our strides to 8 byte boundaries
// See: http://en.wikipedia.org/wiki/Data_structure_alignment (computing padding)
@@ -314,10 +311,10 @@ void GraphicsContext3D::readPixelsIMG(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3
IntRect canvasRect(0, 0, m_currentWidth, m_currentHeight);
IntRect nonZeroDataRect = intersection(dataRect, canvasRect);
- unsigned int xDataOffset = x < 0 ? -x * formatSize : 0;
- unsigned int yDataOffset = y < 0 ? -y * dataStride : 0;
- unsigned int xCanvasOffset = nonZeroDataRect.x() * formatSize;
- unsigned int yCanvasOffset = nonZeroDataRect.y() * canvasStride;
+ unsigned xDataOffset = x < 0 ? -x * formatSize : 0;
+ unsigned yDataOffset = y < 0 ? -y * dataStride : 0;
+ unsigned xCanvasOffset = nonZeroDataRect.x() * formatSize;
+ unsigned yCanvasOffset = nonZeroDataRect.y() * canvasStride;
unsigned char* dst = static_cast<unsigned char*>(data) + xDataOffset + yDataOffset;
unsigned char* src = canvasData + xCanvasOffset + yCanvasOffset;
for (int row = 0; row < nonZeroDataRect.height(); row++) {
@@ -345,16 +342,6 @@ bool GraphicsContext3D::isGLES2Compliant() const
return true;
}
-bool GraphicsContext3D::isGLES2NPOTStrict() const
-{
- return true;
-}
-
-bool GraphicsContext3D::isErrorGeneratedOnOutOfBoundsAccesses() const
-{
- return false;
-}
-
Platform3DObject GraphicsContext3D::platformTexture() const
{
return m_texture;
@@ -373,32 +360,17 @@ PlatformLayer* GraphicsContext3D::platformLayer() const
#endif
void GraphicsContext3D::paintToCanvas(const unsigned char* imagePixels, int imageWidth, int imageHeight, int canvasWidth, int canvasHeight,
- GraphicsContext* context)
+ GraphicsContext* context)
{
- unsigned char* tempPixels = new unsigned char[imageWidth * imageHeight * 4];
-
- // 3D images have already been converted to BGRA. Don't do it twice!!
- for (int y = 0; y < imageHeight; y++) {
- const unsigned char *srcRow = imagePixels + (imageWidth * 4 * y);
- unsigned char *destRow = tempPixels + (imageWidth * 4 * (imageHeight - y - 1));
- for (int i = 0; i < imageWidth * 4; i += 4)
- memcpy(destRow + i, srcRow + i, 4);
- }
-
- SkBitmap canvasBitmap;
-
- canvasBitmap.setConfig(SkBitmap::kARGB_8888_Config, canvasWidth, canvasHeight);
- canvasBitmap.allocPixels(0, 0);
- canvasBitmap.lockPixels();
- memcpy(canvasBitmap.getPixels(), tempPixels, imageWidth * imageHeight * 4);
- canvasBitmap.unlockPixels();
- delete [] tempPixels;
-
FloatRect src(0, 0, canvasWidth, canvasHeight);
FloatRect dst(0, 0, imageWidth, imageHeight);
-
- RefPtr<BitmapImageSingleFrameSkia> bitmapImage = BitmapImageSingleFrameSkia::create(canvasBitmap, false);
- context->drawImage(bitmapImage.get(), ColorSpaceDeviceRGB, dst, src, CompositeCopy, RespectImageOrientation, false);
+ double oldTransform[6];
+ double flipYTransform[6] = { 1.0f, 0.0f, 0.0f, -1.0f, 0.0f, imageHeight };
+ context->platformContext()->getTransform(oldTransform);
+ context->platformContext()->setTransform(flipYTransform);
+ BlackBerry::Platform::Graphics::TiledImage image(IntSize(imageWidth, imageHeight), reinterpret_cast_ptr<const unsigned*>(imagePixels));
+ context->platformContext()->addImage(dst, src, &image);
+ context->platformContext()->setTransform(oldTransform);
}
void GraphicsContext3D::setContextLostCallback(PassOwnPtr<ContextLostCallback> callback)
@@ -410,6 +382,41 @@ void GraphicsContext3D::setErrorMessageCallback(PassOwnPtr<ErrorMessageCallback>
{
}
+GraphicsContext3D::ImageExtractor::~ImageExtractor()
+{
+}
+
+bool GraphicsContext3D::ImageExtractor::extractImage(bool premultiplyAlpha, bool)
+{
+ if (!m_image)
+ return false;
+
+ NativeImagePtr nativeImage = m_image->nativeImageForCurrentFrame();
+ if (!nativeImage)
+ return false;
+
+ m_imageWidth = nativeImage->width();
+ m_imageHeight = nativeImage->height();
+ if (!m_imageWidth || !m_imageHeight)
+ return false;
+
+ unsigned imageSize = m_imageWidth * m_imageHeight;
+ m_imageData.resize(imageSize);
+ if (!nativeImage->readPixels(m_imageData.data(), imageSize))
+ return false;
+
+ // Raw image data is premultiplied
+ m_alphaOp = AlphaDoNothing;
+ if (!premultiplyAlpha)
+ m_alphaOp = AlphaDoUnmultiply;
+
+ m_imagePixelData = m_imageData.data();
+ m_imageSourceFormat = DataFormatBGRA8;
+ m_imageSourceUnpackAlignment = 0;
+
+ return true;
+}
+
} // namespace WebCore
#endif // USE(3D_GRAPHICS)
diff --git a/Source/WebCore/platform/graphics/blackberry/GraphicsContextBlackBerry.cpp b/Source/WebCore/platform/graphics/blackberry/GraphicsContextBlackBerry.cpp
new file mode 100644
index 000000000..e2f1c4333
--- /dev/null
+++ b/Source/WebCore/platform/graphics/blackberry/GraphicsContextBlackBerry.cpp
@@ -0,0 +1,460 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include "config.h"
+#include "GraphicsContext.h"
+
+#include "AffineTransform.h"
+#include "Gradient.h"
+#include "GraphicsContext3D.h"
+#include "KURL.h"
+#include "NotImplemented.h"
+#include "RoundedRect.h"
+#include "TransformationMatrix.h"
+
+#include <BlackBerryPlatformGraphicsContext.h>
+#include <stdio.h>
+#include <wtf/Assertions.h>
+#include <wtf/MathExtras.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class GraphicsContextPlatformPrivate {
+public:
+ GraphicsContextPlatformPrivate(PlatformGraphicsContext* platformContext)
+ : m_platformContext(platformContext)
+ , m_isComposited(false)
+ {
+ }
+
+ PlatformGraphicsContext* m_platformContext;
+ bool m_isComposited;
+};
+
+void GraphicsContext::platformInit(PlatformGraphicsContext* platformContext)
+{
+ m_data = new GraphicsContextPlatformPrivate(platformContext);
+}
+
+void GraphicsContext::platformDestroy()
+{
+ delete m_data;
+}
+
+PlatformGraphicsContext* GraphicsContext::platformContext() const
+{
+ return m_data->m_platformContext;
+}
+
+void GraphicsContext::savePlatformState()
+{
+ if (paintingDisabled())
+ return;
+
+ platformContext()->save();
+}
+
+void GraphicsContext::restorePlatformState()
+{
+ if (paintingDisabled())
+ return;
+
+ platformContext()->restore();
+ platformContext()->setFillColor(m_state.fillColor.rgb());
+ if (hasShadow())
+ setPlatformShadow(m_state.shadowOffset, m_state.shadowBlur, m_state.shadowColor, m_state.shadowColorSpace);
+ else
+ clearPlatformShadow();
+ platformContext()->setStrokeColor(m_state.strokeColor.rgb());
+ platformContext()->setStrokeStyle(static_cast<BlackBerry::Platform::Graphics::StrokeStyle>(m_state.strokeStyle));
+ platformContext()->setStrokeThickness(m_state.strokeThickness);
+ platformContext()->setTextDrawingMode(m_state.textDrawingMode);
+}
+
+void GraphicsContext::setIsAcceleratedContext(bool accelerated)
+{
+ m_data->m_isComposited = accelerated;
+}
+
+bool GraphicsContext::isAcceleratedContext() const
+{
+ return m_data->m_isComposited;
+}
+
+AffineTransform GraphicsContext::getCTM(IncludeDeviceScale) const
+{
+ if (paintingDisabled())
+ return AffineTransform();
+
+ AffineTransform result;
+ platformContext()->getTransform((double*)&result);
+ return result;
+}
+
+void GraphicsContext::concatCTM(const AffineTransform& transformation)
+{
+ if (paintingDisabled())
+ return;
+
+ AffineTransform current;
+ platformContext()->getTransform((double*)&current);
+ current *= transformation;
+ platformContext()->setTransform((double*)&current);
+}
+
+void GraphicsContext::setCTM(const AffineTransform& transformation)
+{
+ if (paintingDisabled())
+ return;
+
+ platformContext()->setTransform((const double*)&transformation);
+}
+
+void GraphicsContext::scale(const FloatSize& scaleFactors)
+{
+ if (paintingDisabled())
+ return;
+
+ AffineTransform current;
+ platformContext()->getTransform((double*)&current);
+ current.scaleNonUniform(scaleFactors.width(), scaleFactors.height());
+ platformContext()->setTransform((double*)&current);
+}
+
+void GraphicsContext::rotate(float radians)
+{
+ if (paintingDisabled())
+ return;
+
+ AffineTransform current;
+ platformContext()->getTransform((double*)&current);
+ current.rotate(rad2deg(radians));
+ platformContext()->setTransform((double*)&current);
+}
+
+void GraphicsContext::translate(float dx, float dy)
+{
+ if (paintingDisabled())
+ return;
+
+ AffineTransform current;
+ platformContext()->getTransform((double*)&current);
+ current.translate(dx, dy);
+ platformContext()->setTransform((double*)&current);
+}
+
+void GraphicsContext::drawEllipse(const IntRect& rect)
+{
+ if (paintingDisabled())
+ return;
+
+ platformContext()->addEllipse(FloatRect(rect));
+}
+
+void GraphicsContext::drawConvexPolygon(size_t numPoints, const FloatPoint* points, bool)
+{
+ if (paintingDisabled())
+ return;
+
+ platformContext()->addConvexPolygon(numPoints, (const BlackBerry::Platform::FloatPoint*)points);
+}
+
+void GraphicsContext::drawRect(const IntRect& rect)
+{
+ if (paintingDisabled())
+ return;
+
+ platformContext()->addDrawRect(FloatRect(rect));
+}
+
+void GraphicsContext::fillRect(const FloatRect& rect)
+{
+ if (paintingDisabled())
+ return;
+
+ BlackBerry::Platform::Graphics::Gradient* platformGradient = fillGradient() ? fillGradient()->platformGradient() : 0;
+ BlackBerry::Platform::Graphics::Pattern* platformPattern = fillPattern() ? fillPattern()->platformPattern(AffineTransform()) : 0;
+ platformContext()->addFillRect(rect, platformGradient, platformPattern);
+}
+
+void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorSpace)
+{
+ if (paintingDisabled())
+ return;
+
+ platformContext()->setFillColor(color.rgb());
+ platformContext()->addFillRect(rect);
+ platformContext()->setFillColor(m_state.fillColor.rgb());
+}
+
+void GraphicsContext::clearRect(const FloatRect& rect)
+{
+ if (paintingDisabled())
+ return;
+
+ platformContext()->addClearRect(rect);
+}
+
+void GraphicsContext::strokeRect(const FloatRect& rect, float lineWidth)
+{
+ if (paintingDisabled())
+ return;
+
+ if (strokeGradient() || strokePattern()) {
+ Path path;
+ path.addRect(rect);
+ float oldLineWidth = m_state.strokeThickness;
+ setPlatformStrokeThickness(lineWidth);
+ strokePath(path);
+ setPlatformStrokeThickness(oldLineWidth);
+ } else
+ platformContext()->addStrokeRect(rect, lineWidth);
+}
+
+void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color, ColorSpace)
+{
+ if (paintingDisabled())
+ return;
+
+ BlackBerry::Platform::FloatRoundedRect r = BlackBerry::Platform::FloatRoundedRect(FloatRect(rect), FloatSize(topLeft), FloatSize(topRight), FloatSize(bottomLeft), FloatSize(bottomRight));
+ platformContext()->setFillColor(color.rgb());
+ platformContext()->addRoundedRect(r);
+ platformContext()->setFillColor(m_state.fillColor.rgb());
+}
+
+FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect, RoundingMode)
+{
+ return rect;
+}
+
+void GraphicsContext::setPlatformShadow(const FloatSize& offset, float blur, const Color& color, ColorSpace)
+{
+ if (paintingDisabled())
+ return;
+
+ FloatSize adjustedOffset = offset;
+
+ if (m_state.shadowsIgnoreTransforms) {
+ // Meaning that this graphics context is associated with a CanvasRenderingContext
+ // We flip the height since CG and HTML5 Canvas have opposite Y axis
+ adjustedOffset.setHeight(-offset.height());
+ }
+
+ // if there is an invalid shadow color, we're supposed to use Apple's CG default
+ platformContext()->setShadow(adjustedOffset, blur, color.isValid() ? color.rgb() : makeRGBA(0, 0, 0, 0xFF / 3), m_state.shadowsIgnoreTransforms);
+}
+
+void GraphicsContext::clearPlatformShadow()
+{
+ if (paintingDisabled())
+ return;
+
+ platformContext()->clearShadow();
+}
+
+void GraphicsContext::beginPlatformTransparencyLayer(float opacity)
+{
+ if (paintingDisabled())
+ return;
+
+ platformContext()->beginPlatformTransparencyLayer(opacity);
+}
+
+void GraphicsContext::endPlatformTransparencyLayer()
+{
+ if (paintingDisabled())
+ return;
+
+ platformContext()->endPlatformTransparencyLayer();
+}
+
+bool GraphicsContext::supportsTransparencyLayers()
+{
+ return true;
+}
+
+void GraphicsContext::setLineCap(LineCap lc)
+{
+ if (paintingDisabled())
+ return;
+
+ platformContext()->setLineCap((BlackBerry::Platform::Graphics::LineCap)lc);
+}
+
+void GraphicsContext::setLineDash(const DashArray& dashes, float dashOffset)
+{
+ if (paintingDisabled())
+ return;
+
+ platformContext()->setLineDash(dashes.data(), dashes.size(), dashOffset);
+}
+
+void GraphicsContext::setLineJoin(LineJoin lj)
+{
+ if (paintingDisabled())
+ return;
+
+ platformContext()->setLineJoin((BlackBerry::Platform::Graphics::LineJoin)lj); // naming coincides
+}
+
+void GraphicsContext::setMiterLimit(float limit)
+{
+ if (paintingDisabled())
+ return;
+
+ platformContext()->setMiterLimit(limit);
+}
+
+void GraphicsContext::setAlpha(float opacity)
+{
+ if (paintingDisabled())
+ return;
+
+ platformContext()->setAlpha(opacity);
+}
+
+
+void GraphicsContext::clip(const FloatRect& rect)
+{
+ if (paintingDisabled())
+ return;
+
+ platformContext()->clip(rect);
+}
+
+void GraphicsContext::clipOut(const IntRect& rect)
+{
+ if (paintingDisabled())
+ return;
+
+ platformContext()->clipOut(FloatRect(rect));
+}
+
+void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* points, bool)
+{
+ if (paintingDisabled())
+ return;
+
+ platformContext()->clipConvexPolygon(numPoints, (const BlackBerry::Platform::FloatPoint*)points);
+}
+
+void GraphicsContext::clipRoundedRect(const RoundedRect& rect)
+{
+ if (paintingDisabled())
+ return;
+
+ BlackBerry::Platform::FloatRoundedRect r = BlackBerry::Platform::FloatRoundedRect(
+ FloatRect(rect.rect()),
+ FloatSize(rect.radii().topLeft()),
+ FloatSize(rect.radii().topRight()),
+ FloatSize(rect.radii().bottomLeft()),
+ FloatSize(rect.radii().bottomRight()));
+ platformContext()->clipRoundedRect(r);
+}
+
+void GraphicsContext::clipOutRoundedRect(const RoundedRect& rect)
+{
+ if (paintingDisabled())
+ return;
+
+ BlackBerry::Platform::FloatRoundedRect r = BlackBerry::Platform::FloatRoundedRect(
+ FloatRect(rect.rect()),
+ FloatSize(rect.radii().topLeft()),
+ FloatSize(rect.radii().topRight()),
+ FloatSize(rect.radii().bottomLeft()),
+ FloatSize(rect.radii().bottomRight()));
+ platformContext()->clipOutRoundedRect(r);
+}
+
+IntRect GraphicsContext::clipBounds() const
+{
+ // FIXME: return the max IntRect for now
+ return IntRect(IntPoint(INT_MIN / 2, INT_MIN / 2), IntSize(INT_MAX, INT_MAX));
+}
+
+void GraphicsContext::setURLForRect(const KURL&, const IntRect&)
+{
+}
+
+void GraphicsContext::setPlatformTextDrawingMode(TextDrawingModeFlags mode)
+{
+ if (paintingDisabled())
+ return;
+
+ platformContext()->setTextDrawingMode(mode);
+}
+
+void GraphicsContext::setPlatformStrokeColor(const Color& color, ColorSpace)
+{
+ if (paintingDisabled())
+ return;
+
+ platformContext()->setStrokeColor(color.rgb());
+}
+
+void GraphicsContext::setPlatformStrokeStyle(StrokeStyle stroke)
+{
+ if (paintingDisabled())
+ return;
+
+ platformContext()->setStrokeStyle((BlackBerry::Platform::Graphics::StrokeStyle)stroke);
+}
+
+void GraphicsContext::setPlatformStrokeThickness(float thickness)
+{
+ if (paintingDisabled())
+ return;
+
+ platformContext()->setStrokeThickness(thickness);
+}
+
+void GraphicsContext::setPlatformFillColor(const Color& color, ColorSpace)
+{
+ if (paintingDisabled())
+ return;
+
+ platformContext()->setFillColor(color.rgb());
+}
+
+void GraphicsContext::setPlatformCompositeOperation(CompositeOperator op, BlendMode)
+{
+ if (paintingDisabled())
+ return;
+
+ platformContext()->setCompositeOperation(static_cast<BlackBerry::Platform::Graphics::CompositeOperator>(op), blendMode);
+}
+
+void GraphicsContext::setPlatformShouldAntialias(bool enable)
+{
+ if (paintingDisabled())
+ return;
+
+ platformContext()->setUseAntialiasing(enable);
+}
+
+void GraphicsContext::setImageInterpolationQuality(InterpolationQuality interpolationQuality)
+{
+ platformContext()->setHighQualityFilter(interpolationQuality != InterpolationNone);
+}
+
+InterpolationQuality GraphicsContext::imageInterpolationQuality() const
+{
+ return platformContext()->highQualityFilter() ? InterpolationDefault : InterpolationNone;
+}
+
+}
diff --git a/Source/WebCore/platform/graphics/blackberry/GraphicsLayerBlackBerry.cpp b/Source/WebCore/platform/graphics/blackberry/GraphicsLayerBlackBerry.cpp
index 12fc69df8..2c4994a34 100644
--- a/Source/WebCore/platform/graphics/blackberry/GraphicsLayerBlackBerry.cpp
+++ b/Source/WebCore/platform/graphics/blackberry/GraphicsLayerBlackBerry.cpp
@@ -97,7 +97,6 @@ GraphicsLayerBlackBerry::GraphicsLayerBlackBerry(GraphicsLayerClient* client)
: GraphicsLayer(client)
, m_suspendTime(0)
, m_contentsLayerPurpose(NoContentsLayer)
- , m_contentsLayerHasBackgroundColor(false)
{
m_layer = LayerWebKitThread::create(LayerData::Layer, this);
@@ -281,15 +280,6 @@ void GraphicsLayerBlackBerry::setReplicatedByLayer(GraphicsLayer* layer)
primaryLayer()->setReplicaLayer(replicaLayer);
}
-void GraphicsLayerBlackBerry::setFixedPosition(bool fixed)
-{
- if (fixed == m_fixedPosition)
- return;
-
- GraphicsLayer::setFixedPosition(fixed);
- updateFixedPosition();
-}
-
void GraphicsLayerBlackBerry::setHasFixedContainer(bool hasFixedContainer)
{
if (hasFixedContainer == m_hasFixedContainer)
@@ -330,24 +320,14 @@ bool GraphicsLayerBlackBerry::setFilters(const FilterOperations& filters)
void GraphicsLayerBlackBerry::setBackgroundColor(const Color& color)
{
- if (m_backgroundColorSet && m_backgroundColor == color)
+ if (color == m_backgroundColor)
return;
GraphicsLayer::setBackgroundColor(color);
- m_contentsLayerHasBackgroundColor = true;
updateLayerBackgroundColor();
}
-void GraphicsLayerBlackBerry::clearBackgroundColor()
-{
- if (!m_backgroundColorSet)
- return;
-
- GraphicsLayer::clearBackgroundColor();
- clearLayerBackgroundColor(*m_contentsLayer);
-}
-
void GraphicsLayerBlackBerry::setContentsOpaque(bool opaque)
{
if (m_contentsOpaque == opaque)
@@ -379,26 +359,20 @@ void GraphicsLayerBlackBerry::setOpacity(float opacity)
void GraphicsLayerBlackBerry::setContentsNeedsDisplay()
{
- if (m_contentsLayer) {
+ if (m_contentsLayer)
m_contentsLayer->setNeedsDisplay();
- addRepaintRect(contentsRect());
- }
}
void GraphicsLayerBlackBerry::setNeedsDisplay()
{
- if (drawsContent()) {
+ if (drawsContent())
m_layer->setNeedsDisplay();
- addRepaintRect(FloatRect(FloatPoint(), m_size));
- }
}
void GraphicsLayerBlackBerry::setNeedsDisplayInRect(const FloatRect& rect)
{
- if (drawsContent()) {
+ if (drawsContent())
m_layer->setNeedsDisplayInRect(rect);
- addRepaintRect(rect);
- }
}
void GraphicsLayerBlackBerry::setContentsRect(const IntRect& rect)
@@ -595,8 +569,11 @@ void GraphicsLayerBlackBerry::setContentsToMedia(PlatformLayer* layer)
m_contentsLayerPurpose = ContentsLayerForVideo;
childrenChanged = true;
}
- layer->setOwner(this);
- layer->setNeedsDisplay();
+
+ if (layer->owner() != this) {
+ layer->setOwner(this);
+ layer->setNeedsDisplay();
+ }
updateContentsRect();
} else {
if (m_contentsLayer) {
@@ -687,8 +664,9 @@ void GraphicsLayerBlackBerry::updateSublayerList()
void GraphicsLayerBlackBerry::updateLayerPosition()
{
// Position is offset on the layer by the layer anchor point.
- FloatPoint layerPosition(m_position.x() + m_anchorPoint.x() * m_size.width(),
- m_position.y() + m_anchorPoint.y() * m_size.height());
+ FloatPoint layerPosition(
+ m_position.x() + m_anchorPoint.x() * m_size.width(),
+ m_position.y() + m_anchorPoint.y() * m_size.height());
primaryLayer()->setPosition(layerPosition);
}
@@ -818,11 +796,6 @@ void GraphicsLayerBlackBerry::updateLayerIsDrawable()
updateDebugIndicators();
}
-void GraphicsLayerBlackBerry::updateFixedPosition()
-{
- m_layer->setFixedPosition(m_fixedPosition);
-}
-
void GraphicsLayerBlackBerry::updateHasFixedContainer()
{
m_layer->setHasFixedContainer(m_hasFixedContainer);
@@ -835,14 +808,10 @@ void GraphicsLayerBlackBerry::updateHasFixedAncestorInDOMTree()
void GraphicsLayerBlackBerry::updateLayerBackgroundColor()
{
- if (!m_contentsLayer)
- return;
-
- // We never create the contents layer just for background color yet.
- if (m_backgroundColorSet)
- setLayerBackgroundColor(*m_contentsLayer, m_backgroundColor);
+ if (m_backgroundColor.isValid())
+ setLayerBackgroundColor(*m_layer, m_backgroundColor);
else
- clearLayerBackgroundColor(*m_contentsLayer);
+ clearLayerBackgroundColor(*m_layer);
}
#if ENABLE(CSS_FILTERS)
@@ -888,8 +857,11 @@ void GraphicsLayerBlackBerry::updateContentsRect()
if (!m_contentsLayer)
return;
- m_contentsLayer->setPosition(m_contentsRect.location());
- m_contentsLayer->setBounds(m_contentsRect.size());
+ if (m_contentsLayer->position() != m_contentsRect.location())
+ m_contentsLayer->setPosition(m_contentsRect.location());
+
+ if (m_contentsLayer->bounds() != m_contentsRect.size())
+ m_contentsLayer->setBounds(m_contentsRect.size());
}
void GraphicsLayerBlackBerry::setupContentsLayer(LayerWebKitThread* contentsLayer)
@@ -917,7 +889,7 @@ void GraphicsLayerBlackBerry::setupContentsLayer(LayerWebKitThread* contentsLaye
updateContentsRect();
- if (showDebugBorders()) {
+ if (isShowingDebugBorder()) {
setLayerBorderColor(*m_contentsLayer, Color(0, 0, 128, 180));
m_contentsLayer->setBorderWidth(1);
}
@@ -931,14 +903,6 @@ void GraphicsLayerBlackBerry::updateOpacityOnLayer()
primaryLayer()->setOpacity(m_opacity);
}
-bool GraphicsLayerBlackBerry::contentsVisible(const IntRect& contentRect) const
-{
- if (!m_client)
- return false;
-
- return m_client->contentsVisible(this, contentRect);
-}
-
} // namespace WebCore
#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebCore/platform/graphics/blackberry/GraphicsLayerBlackBerry.h b/Source/WebCore/platform/graphics/blackberry/GraphicsLayerBlackBerry.h
index 5c861264e..76ebe83f1 100644
--- a/Source/WebCore/platform/graphics/blackberry/GraphicsLayerBlackBerry.h
+++ b/Source/WebCore/platform/graphics/blackberry/GraphicsLayerBlackBerry.h
@@ -29,8 +29,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "Platform.h"
-
#ifndef GraphicsLayerBlackBerry_h
#define GraphicsLayerBlackBerry_h
@@ -75,7 +73,6 @@ public:
virtual void setContentsVisible(bool);
virtual void setMaskLayer(GraphicsLayer*);
virtual void setReplicatedByLayer(GraphicsLayer*);
- virtual void setFixedPosition(bool);
virtual void setHasFixedContainer(bool);
virtual void setHasFixedAncestorInDOMTree(bool);
@@ -86,7 +83,6 @@ public:
#endif
virtual void setBackgroundColor(const Color&);
- virtual void clearBackgroundColor();
virtual void setContentsOpaque(bool);
virtual void setBackfaceVisibility(bool);
@@ -128,8 +124,6 @@ public:
m_client->notifyAnimationStarted(this, time);
}
- bool contentsVisible(const IntRect& contentRect) const;
-
private:
virtual void willBeDestroyed();
@@ -150,7 +144,6 @@ private:
void updateBackfaceVisibility();
void updateLayerPreserves3D();
void updateLayerIsDrawable();
- void updateFixedPosition();
void updateHasFixedContainer();
void updateHasFixedAncestorInDOMTree();
void updateLayerBackgroundColor();
@@ -186,7 +179,6 @@ private:
};
ContentsLayerPurpose m_contentsLayerPurpose;
- bool m_contentsLayerHasBackgroundColor : 1;
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/cairo/NativeImageCairo.h b/Source/WebCore/platform/graphics/blackberry/ITypeUtils.h
index 79dc1dbb2..430321823 100644
--- a/Source/WebCore/platform/graphics/cairo/NativeImageCairo.h
+++ b/Source/WebCore/platform/graphics/blackberry/ITypeUtils.h
@@ -1,6 +1,5 @@
/*
- * Copyright (c) 2008, Google Inc. All rights reserved.
- * Copyright (c) 2012, Igalia S.L.
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -12,7 +11,7 @@
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
- * * Neither the name of Google Inc. nor the names of its
+ * * Neither the name of Research In Motion Limited nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
@@ -29,24 +28,18 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef NativeImageCairo_h
-#define NativeImageCairo_h
+#ifndef ITypeUtils_h
+#define ITypeUtils_h
-#include "RefPtrCairo.h"
+#include <fs_api.h>
-namespace WebCore {
+static inline FS_FIXED floatToITypeFixed(float f) { return static_cast<FS_FIXED>(f * 65536.0); }
+static inline FS_FIXED intToITypeFixed(int i) { return static_cast<FS_FIXED>(i << 16); }
-class NativeImageCairo {
-public:
- NativeImageCairo();
- ~NativeImageCairo();
- explicit NativeImageCairo(cairo_surface_t*);
- cairo_surface_t* surface () { return m_surface.get(); }
+static inline float iTypeFixedToFloat(FS_FIXED n) { return n / 65536.0; }
-private:
- RefPtr<cairo_surface_t> m_surface;
-};
+static const FS_FIXED MAXITYPEFONTSCALE = intToITypeFixed(10000) - 1;
-}
-#endif // NativeImageCairo_h
+static const FS_FIXED ITYPEFAKEBOLDAMOUNT = floatToITypeFixed(0.06); // 6% pseudo bold
+#endif // ITypeUtils_h
diff --git a/Source/WebCore/platform/graphics/blackberry/ImageBlackBerry.cpp b/Source/WebCore/platform/graphics/blackberry/ImageBlackBerry.cpp
index 07da9915e..0f457866b 100644
--- a/Source/WebCore/platform/graphics/blackberry/ImageBlackBerry.cpp
+++ b/Source/WebCore/platform/graphics/blackberry/ImageBlackBerry.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010, 2011, 2012 Research In Motion Limited. All rights reserved.
+ * Copyright (C) 2010, 2011, 2012, 2013 Research In Motion Limited. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -19,11 +19,21 @@
#include "config.h"
#include "Image.h"
+#include "AffineTransform.h"
#include "BitmapImage.h"
+#include "FloatConversion.h"
+#include "FloatRect.h"
+#include "GraphicsContext.h"
#include "ImageBuffer.h"
+#include "ImageDecoder.h"
+#include "ImageObserver.h"
+#include "IntSize.h"
+#include "NotImplemented.h"
#include "SharedBuffer.h"
+#include <BlackBerryPlatformGraphicsContext.h>
#include <BlackBerryPlatformResourceStore.h>
+#include <wtf/MathExtras.h>
using BlackBerry::Platform::ResourceData;
using BlackBerry::Platform::ResourceStore;
@@ -32,7 +42,7 @@ namespace WebCore {
PassRefPtr<Image> Image::loadPlatformResource(const char *name)
{
- ResourceData data = ResourceStore::instance()->requestResource(BlackBerry::Platform::String(name));
+ ResourceData data = ResourceStore::instance()->requestResource(BlackBerry::Platform::String::fromUtf8(name));
if (!data.data())
return BitmapImage::nullImage();
@@ -45,4 +55,161 @@ PassRefPtr<Image> Image::loadPlatformResource(const char *name)
return img.release();
}
+PassNativeImagePtr ImageFrame::asNewNativeImage() const
+{
+ return new BlackBerry::Platform::Graphics::TiledImage(m_size, m_bytes);
+}
+
+bool FrameData::clear(bool clearMetadata)
+{
+ if (clearMetadata)
+ m_haveMetadata = false;
+
+ if (m_frame) {
+ delete m_frame;
+ m_frame = 0;
+ return true;
+ }
+ return false;
+}
+
+BitmapImage::BitmapImage(PassNativeImagePtr nativeImage, ImageObserver* observer)
+ : Image(observer)
+ , m_currentFrame(0)
+ , m_frames(0)
+ , m_frameTimer(0)
+ , m_repetitionCount(cAnimationNone)
+ , m_repetitionCountStatus(Unknown)
+ , m_repetitionsComplete(0)
+ , m_decodedSize(0)
+ , m_frameCount(1)
+ , m_isSolidColor(false)
+ , m_checkedForSolidColor(false)
+ , m_animationFinished(true)
+ , m_allDataReceived(true)
+ , m_haveSize(true)
+ , m_sizeAvailable(true)
+ , m_haveFrameCount(true)
+{
+ int width = nativeImage->size().width();
+ int height = nativeImage->size().height();
+ m_decodedSize = width * height * 4;
+ m_size = IntSize(width, height);
+
+ m_frames.grow(1);
+ m_frames[0].m_frame = nativeImage;
+ m_frames[0].m_hasAlpha = nativeImage->hasAlpha();
+ m_frames[0].m_haveMetadata = true;
+ checkForSolidColor();
+}
+
+void BitmapImage::checkForSolidColor()
+{
+ m_isSolidColor = size().width() == 1 && size().height() == 1 && frameCount() == 1;
+ m_checkedForSolidColor = true;
+ if (m_isSolidColor) {
+ unsigned buffer;
+ NativeImagePtr image = nativeImageForCurrentFrame();
+ image->readPixels(&buffer, 1);
+ m_solidColor = Color(buffer);
+ }
+}
+
+void BitmapImage::invalidatePlatformData()
+{
+}
+
+void BitmapImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator op, BlendMode blendMode)
+{
+ draw(context, dstRect, srcRect, styleColorSpace, op, blendMode, DoNotRespectImageOrientation);
+}
+
+void BitmapImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace, CompositeOperator op, BlendMode, RespectImageOrientationEnum shouldRespectImageOrientation)
+{
+ startAnimation();
+
+ NativeImagePtr image = nativeImageForCurrentFrame();
+ if (!image)
+ return;
+
+ FloatRect normDstRect = dstRect.normalized();
+ FloatRect normSrcRect = srcRect.normalized();
+
+ if (normSrcRect.isEmpty() || normDstRect.isEmpty())
+ return; // Nothing to draw.
+
+#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
+ normSrcRect = adjustSourceRectForDownSampling(normSrcRect, image->size());
+#endif
+
+ // use similar orientation code as ImageSkia
+ ImageOrientation orientation = DefaultImageOrientation;
+ if (shouldRespectImageOrientation == RespectImageOrientation)
+ orientation = frameOrientationAtIndex(m_currentFrame);
+
+ GraphicsContextStateSaver saveContext(*context, false);
+ if (orientation != DefaultImageOrientation) {
+ saveContext.save();
+
+ // ImageOrientation expects the origin to be at (0, 0)
+ context->translate(normDstRect.x(), normDstRect.y());
+ normDstRect.setLocation(FloatPoint());
+
+ context->concatCTM(orientation.transformFromDefault(normDstRect.size()));
+ if (orientation.usesWidthAsHeight()) {
+ // The destination rect will have its width and height already reversed for the orientation of
+ // the image, as it was needed for page layout, so we need to reverse it back here.
+ normDstRect = FloatRect(normDstRect.x(), normDstRect.y(), normDstRect.height(), normDstRect.width());
+ }
+ }
+
+ CompositeOperator oldOperator = context->compositeOperation();
+ context->setCompositeOperation(op);
+ context->platformContext()->addImage(normDstRect, normSrcRect, image);
+ context->setCompositeOperation(oldOperator);
+
+ if (ImageObserver* observer = imageObserver())
+ observer->didDraw(this);
+}
+
+void Image::drawPattern(GraphicsContext* context, const FloatRect& srcRect, const AffineTransform& patternTransformation, const FloatPoint& phase, ColorSpace, CompositeOperator op, const FloatRect& dstRect, BlendMode)
+{
+ NativeImagePtr image = nativeImageForCurrentFrame();
+ if (!image)
+ return;
+
+ // patternTransformation contains the tile scale factor relative to
+ // document coordinates. phase is given in document coordinates and
+ // corresponds to a texture drawn with src starting at (0, 0).
+ // Thus, dstRect starts at phase + patternTransformation.mapPoint(srcRect.location()).
+ AffineTransform srcTransform;
+ srcTransform.translate(phase.x(), phase.y());
+ srcTransform.multiply(patternTransformation);
+#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
+ FloatRect srcRectLocal(srcRect);
+ const IntSize unscaledSize = size();
+ const IntSize scaledSize = image->size();
+ if (unscaledSize != scaledSize) {
+ srcRectLocal = adjustSourceRectForDownSampling(srcRect, scaledSize);
+ // If the image has been down sampled, the transformation should take the scale into account.
+ float xscale = static_cast<float>(unscaledSize.width()) / scaledSize.width();
+ float yscale = static_cast<float>(unscaledSize.height()) / scaledSize.height();
+ srcTransform.scaleNonUniform(xscale, yscale);
+ }
+#else
+ FloatRect srcRectLocal(srcRect);
+#endif
+ srcTransform.translate(srcRectLocal.x(), srcRectLocal.y());
+ double srcTransformArray[6] = {
+ srcTransform.a(), srcTransform.b(),
+ srcTransform.c(), srcTransform.d(),
+ srcTransform.e(), srcTransform.f()
+ };
+
+ CompositeOperator oldOperator = context->compositeOperation();
+ context->setCompositeOperation(op);
+ context->platformContext()->addPattern(dstRect, srcRectLocal, srcTransformArray, image);
+ context->setCompositeOperation(oldOperator);
+}
+
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/blackberry/ImageBufferBlackBerry.cpp b/Source/WebCore/platform/graphics/blackberry/ImageBufferBlackBerry.cpp
new file mode 100644
index 000000000..a3b76eb1a
--- /dev/null
+++ b/Source/WebCore/platform/graphics/blackberry/ImageBufferBlackBerry.cpp
@@ -0,0 +1,316 @@
+/*
+ * Copyright (C) 2009, 2010, 2011, 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include "config.h"
+#include "ImageBuffer.h"
+
+#include "Base64.h"
+#include "BitmapImage.h"
+#include "HostWindow.h"
+#include "ImageData.h"
+#include "JPEGImageEncoder.h"
+#include "LayerMessage.h"
+#include "PNGImageEncoder.h"
+#include "TiledImage.h"
+
+#include <BlackBerryPlatformGLES2ContextState.h>
+#include <BlackBerryPlatformGraphics.h>
+#include <BlackBerryPlatformGraphicsContext.h>
+#include <BlackBerryPlatformSettings.h>
+#include <BlackBerryPlatformWindow.h>
+#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
+
+using namespace std;
+
+namespace WebCore {
+
+static bool makeBufferCurrent(HostWindow* window)
+{
+ ASSERT(isCompositingThread());
+
+ if (window && window->platformPageClient()) {
+ if (BlackBerry::Platform::Graphics::Window* platformWindow = window->platformPageClient()->platformWindow()) {
+ if (BlackBerry::Platform::Graphics::makeBufferCurrent(platformWindow->buffer(), BlackBerry::Platform::Graphics::GLES2))
+ return true;
+ }
+ }
+
+ // If we don't have a window but the application state saver is enabled,
+ // we're using a BlackBerry::WebKit::WebPageCompositor for rendering,
+ // that makes sure a context is always current on the compositing thread.
+ if (BlackBerry::Platform::Settings::isGLES2AppStateSaverEnabled())
+ return true;
+
+ // Otherwise, we'll have to try and fall back to our last hope.
+ return BlackBerry::Platform::Graphics::makeSharedResourceContextCurrent(BlackBerry::Platform::Graphics::GLES2);
+}
+
+static bool getImageDataInternal(GraphicsContext* context, const IntRect& rect, const IntRect& size, unsigned char* result, bool unmultiply, HostWindow* window)
+{
+ if (!makeBufferCurrent(window)) {
+ BlackBerry::Platform::logAlways(BlackBerry::Platform::LogLevelWarn,
+ "ImageBufferBlackBerry getImageDataInternal() error: cannot make buffer current, returning zeroed-out pixels.");
+ memset(result, 0, rect.width() * rect.height() * 4);
+ return false;
+ }
+
+ // readPixels can call updateBacking which draws the display list. This is out-of-band rendering and we need
+ // to protect the embedder from state mutations.
+ BlackBerry::Platform::Graphics::GLES2ContextState::AppStateSaver appStateSaver;
+
+ // Any pixels outside the canvas are returned as transparent black in the resulting ImageData object.
+ if (rect.x() < 0
+ || rect.y() < 0
+ || rect.maxX() > size.width()
+ || rect.maxY() > size.height())
+ memset(result, 0, rect.width() * rect.height() * 4);
+
+ IntRect subrect = rect;
+ subrect.intersect(size);
+ // nothing to do if rect is completely outside of the image area
+ if (subrect.isEmpty())
+ return true;
+ // adjust for negative x and y index
+ if (rect.x() < 0)
+ result += (-rect.x() * 4);
+ if (rect.y() < 0)
+ result += (-rect.y() * rect.width() * 4);
+
+ // FIXME: We need to implement a tiled buffer.
+ const int maxTileSize = BlackBerry::Platform::Graphics::TiledImage::defaultTileSize();
+ IntRect r = subrect;
+ IntRect tileRect(0, 0, maxTileSize, maxTileSize);
+ r.intersect(tileRect);
+ if (!r.isEmpty())
+ context->platformContext()->readPixels(r, result, unmultiply);
+ return true;
+}
+
+void ImageBufferData::getImageData(GraphicsContext* context, const IntRect& rect, const IntRect& size, unsigned char* result, bool unmultiply) const
+{
+ if (!isCompositingThread()) {
+ // Use createFunctionCallMessage instead of createMethodCallMessage to avoid deadlock
+ // with Guarded pointers.
+ dispatchSyncCompositingMessage(BlackBerry::Platform::createFunctionCallMessage(
+ &getImageDataInternal, context, rect, size, result, unmultiply, m_window));
+ return;
+ }
+
+ getImageDataInternal(context, rect, size, result, unmultiply, m_window);
+}
+
+static bool flushAndDraw(const ImageBufferData* object, GraphicsContext* context, ColorSpace, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator op, bool)
+{
+ if (!makeBufferCurrent(object->m_window)) {
+ BlackBerry::Platform::logAlways(BlackBerry::Platform::LogLevelWarn,
+ "ImageBufferBlackBerry flushAndDraw() error: cannot make buffer current, ignoring call.");
+ return false;
+ }
+
+ using namespace BlackBerry::Platform::Graphics;
+
+ // flushAndDrawBuffer calls updateBacking which draws the display list. This is out-of-band rendering and we need
+ // to protect the embedder from state mutations.
+ BlackBerry::Platform::Graphics::GLES2ContextState::AppStateSaver appStateSaver;
+
+ CompositeOperator oldOperator = context->compositeOperation();
+ context->setCompositeOperation(op);
+ context->platformContext()->flushAndDrawBuffer(object->m_buffer, destRect, srcRect);
+ context->setCompositeOperation(oldOperator);
+ return true;
+}
+
+void ImageBufferData::draw(GraphicsContext* thisContext, GraphicsContext* otherContext, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator op, bool useLowQualityScale) const
+{
+ const FloatRect normDestRect = destRect.normalized();
+ const FloatRect normSrcRect = srcRect.normalized();
+
+ if (normSrcRect.isEmpty() || normDestRect.isEmpty())
+ return; // Nothing to draw.
+
+ if (thisContext->platformContext()->isEmpty() && platformBufferHandle(m_buffer)) {
+ CompositeOperator oldOperator = otherContext->compositeOperation();
+ otherContext->setCompositeOperation(op);
+ otherContext->platformContext()->drawBuffer(m_buffer, normDestRect, normSrcRect);
+ otherContext->setCompositeOperation(oldOperator);
+ } else {
+ dispatchSyncCompositingMessage(BlackBerry::Platform::createFunctionCallMessage(
+ &flushAndDraw, this, otherContext, styleColorSpace, normDestRect, normSrcRect, op, useLowQualityScale));
+ }
+}
+
+ImageBuffer::ImageBuffer(const IntSize& size, float, ColorSpace, RenderingMode renderingMode, HostWindow* window, bool& success)
+ : m_size(size)
+ , m_logicalSize(size)
+ , m_resolutionScale(1)
+{
+ success = false;
+
+ // There is no explicitly defined default ctor for ImageBufferData::m_data,
+ // on purpose - precaution. Hence upon creation m_data will contain garbage
+ // leading to crash up dtor. To avoid the case, initilize it explicitly.
+ m_data.m_buffer = 0;
+ m_data.m_platformLayer = nullptr;
+ m_data.m_window = 0;
+
+ if (m_size.isEmpty())
+ return;
+
+ // anything bigger then defaultTileSize is just a problem for the HW.
+ const int maxTileSize = BlackBerry::Platform::Graphics::TiledImage::defaultTileSize();
+ if (maxTileSize <= size.width() || maxTileSize <= size.height()) {
+ BlackBerry::Platform::logAlways(BlackBerry::Platform::LogLevelWarn, "Requested ImageBuffer size [%d %d] is too big. HW allows up to [%d %d].",
+ size.width(), size.height(), maxTileSize, maxTileSize);
+ }
+
+ m_data.m_buffer = BlackBerry::Platform::Graphics::createBuffer(m_size, BlackBerry::Platform::Graphics::AlwaysBacked);
+ m_data.m_platformLayer = CanvasLayerWebKitThread::create(m_data.m_buffer, m_size);
+ m_data.m_window = window;
+ m_context = adoptPtr(new GraphicsContext(lockBufferDrawable(m_data.m_buffer)));
+ m_context->scale(FloatSize(m_resolutionScale, m_resolutionScale));
+ m_context->setIsAcceleratedContext(renderingMode == Accelerated);
+ success = true;
+}
+
+ImageBuffer::~ImageBuffer()
+{
+ m_context.clear();
+
+ // Ensure that we clear the buffer in the compositing thread before the buffer is destroyed.
+ if (m_data.m_platformLayer) {
+ dispatchSyncCompositingMessage(BlackBerry::Platform::createFunctionCallMessage(
+ &CanvasLayerWebKitThread::clearBuffer, m_data.m_platformLayer.get()));
+ }
+
+ BlackBerry::Platform::Graphics::destroyBuffer(m_data.m_buffer);
+ m_data.m_buffer = 0;
+}
+
+GraphicsContext* ImageBuffer::context() const
+{
+ return m_context.get();
+}
+
+PlatformLayer* ImageBuffer::platformLayer() const
+{
+ return m_data.m_platformLayer.get();
+}
+
+PassRefPtr<Image> ImageBuffer::copyImage(BackingStoreCopy, ScaleBehavior) const
+{
+ // FIXME respect copyBehaviour enum.
+ Vector<unsigned> pixels;
+ pixels.reserveCapacity(m_size.area());
+ m_data.getImageData(m_context.get(), IntRect(IntPoint(0, 0), m_size), IntRect(IntPoint(0, 0), m_size), reinterpret_cast<unsigned char*>(pixels.data()), false /* unmultiply */);
+ return BitmapImage::create(new BlackBerry::Platform::Graphics::TiledImage(m_size, pixels.data(), false /* dataIsBGRA */));
+}
+
+void ImageBuffer::clip(GraphicsContext* context, const FloatRect& rect) const
+{
+ WTF_ALIGNED(unsigned char*, imageData, 4) = new unsigned char[m_size.width() * m_size.height() * 4];
+ m_data.getImageData(m_context.get(), IntRect(IntPoint(0, 0), m_size), IntRect(IntPoint(0, 0), m_size), imageData, false /* unmultiply */);
+ BlackBerry::Platform::Graphics::TiledImage* nativeImage = new BlackBerry::Platform::Graphics::TiledImage(m_size, reinterpret_cast_ptr<unsigned*>(imageData), false /* dataIsBGRA */);
+ context->platformContext()->addMaskLayer(rect, nativeImage);
+}
+
+void ImageBuffer::draw(GraphicsContext* context, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator op, BlendMode, bool useLowQualityScale)
+{
+ m_data.draw(m_context.get(), context, styleColorSpace, destRect, srcRect, op, useLowQualityScale);
+}
+
+void ImageBuffer::drawPattern(GraphicsContext* context, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect)
+{
+ RefPtr<Image> image = copyImage(DontCopyBackingStore);
+ image->drawPattern(context, srcRect, patternTransform, phase, styleColorSpace, op, destRect);
+}
+
+void ImageBuffer::platformTransformColorSpace(const Vector<int>&)
+{
+}
+
+PassRefPtr<Uint8ClampedArray> ImageBuffer::getUnmultipliedImageData(const IntRect& rect, CoordinateSystem) const
+{
+ RefPtr<Uint8ClampedArray> result = Uint8ClampedArray::createUninitialized(rect.width() * rect.height() * 4);
+ m_data.getImageData(m_context.get(), rect, IntRect(IntPoint(0, 0), m_size), result->data(), true);
+ return result;
+}
+
+PassRefPtr<Uint8ClampedArray> ImageBuffer::getPremultipliedImageData(const IntRect& rect, CoordinateSystem) const
+{
+ RefPtr<Uint8ClampedArray> result = Uint8ClampedArray::createUninitialized(rect.width() * rect.height() * 4);
+ m_data.getImageData(m_context.get(), rect, IntRect(IntPoint(0, 0), m_size), result->data(), false);
+ return result;
+}
+
+void ImageBuffer::putByteArray(Multiply multiplied, Uint8ClampedArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, CoordinateSystem)
+{
+ BlackBerry::Platform::Graphics::TiledImage image(sourceSize, reinterpret_cast_ptr<unsigned*>(source->data()), false /* this data is RGBA, not BGRA */, multiplied == Premultiplied);
+ m_context->platformContext()->save();
+ const double matrix[] = { 1., 0., 0., 1., 0., 0. };
+ m_context->platformContext()->setTransform(matrix);
+ m_context->platformContext()->setAlpha(1.0);
+ m_context->platformContext()->resetClip();
+ m_context->platformContext()->setCompositeOperation(BlackBerry::Platform::Graphics::CompositeCopy);
+ m_context->platformContext()->addImage(FloatRect(destPoint + sourceRect.location(), sourceRect.size()), FloatRect(sourceRect), &image);
+ m_context->platformContext()->restore();
+}
+
+String ImageBuffer::toDataURL(const String& mimeType, const double* quality, CoordinateSystem) const
+{
+ if (m_size.isEmpty())
+ return "data:,";
+
+ enum {
+ EncodeJPEG,
+ EncodePNG,
+ } encodeType = mimeType.lower() == "image/png" ? EncodePNG : EncodeJPEG;
+
+ // According to http://www.w3.org/TR/html5/the-canvas-element.html,
+ // "For image types that do not support an alpha channel, the image must be"
+ // "composited onto a solid black background using the source-over operator,"
+ // "and the resulting image must be the one used to create the data: URL."
+ // JPEG doesn't have alpha channel, so we need premultiplied data.
+ RefPtr<Uint8ClampedArray> imageData = encodeType == EncodePNG
+ ? getUnmultipliedImageData(IntRect(IntPoint(0, 0), m_size))
+ : getPremultipliedImageData(IntRect(IntPoint(0, 0), m_size));
+
+ Vector<char> output;
+ const char* header;
+ if (encodeType == EncodePNG) {
+ if (!compressRGBABigEndianToPNG(imageData->data(), m_size, output))
+ return "data:,";
+ header = "data:image/png;base64,";
+ } else {
+ if (!compressRGBABigEndianToJPEG(imageData->data(), m_size, output, quality))
+ return "data:,";
+ header = "data:image/jpeg;base64,";
+ }
+
+ Vector<char> base64;
+ base64Encode(output, base64);
+
+ output.clear();
+
+ Vector<char> url;
+ url.append(header, strlen(header));
+ url.append(base64);
+
+ return String(url.data(), url.size());
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/blackberry/ImageBufferDataBlackBerry.h b/Source/WebCore/platform/graphics/blackberry/ImageBufferDataBlackBerry.h
new file mode 100644
index 000000000..8da330e93
--- /dev/null
+++ b/Source/WebCore/platform/graphics/blackberry/ImageBufferDataBlackBerry.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef ImageBufferDataBlackBerry_h
+#define ImageBufferDataBlackBerry_h
+
+#include "CanvasLayerWebKitThread.h"
+#include "GraphicsContext.h"
+
+#include <BlackBerryPlatformGraphics.h>
+#include <BlackBerryPlatformGuardedPointer.h>
+#include <wtf/Uint8ClampedArray.h>
+
+namespace WebCore {
+
+class GraphicsContext;
+class IntRect;
+class HostWindow;
+
+class ImageBufferData {
+public:
+ void getImageData(GraphicsContext*, const IntRect&, const IntRect&, unsigned char* result, bool unmultiply) const;
+ void draw(GraphicsContext* thisContext, GraphicsContext* otherContext, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator, bool useLowQualityScale) const;
+
+ BlackBerry::Platform::Graphics::Buffer* m_buffer;
+ RefPtr<CanvasLayerWebKitThread> m_platformLayer;
+ HostWindow* m_window;
+};
+
+} // namespace WebCore
+
+#endif // ImageBufferDataBlackBerry_h
diff --git a/Source/WebCore/platform/graphics/blackberry/InstrumentedPlatformCanvas.h b/Source/WebCore/platform/graphics/blackberry/InstrumentedPlatformCanvas.h
deleted file mode 100644
index 94a16cbc9..000000000
--- a/Source/WebCore/platform/graphics/blackberry/InstrumentedPlatformCanvas.h
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Copyright (C) 2011 Research In Motion Limited. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef InstrumentedPlatformCanvas_h
-#define InstrumentedPlatformCanvas_h
-
-#include <skia/ext/platform_canvas.h>
-
-#define DEBUG_SKIA_DRAWING 0
-#if DEBUG_SKIA_DRAWING
-#define WRAPCANVAS_LOG_ENTRY(...) do { \
- fprintf(stderr, "%s ", __FUNCTION__); \
- fprintf(stderr, __VA_ARGS__); \
- fprintf(stderr, "\n"); \
-} while (0)
-#else
-#define WRAPCANVAS_LOG_ENTRY(...) ((void)0)
-#endif
-
-namespace WebCore {
-
-class InstrumentedPlatformCanvas : public SkCanvas {
-public:
- InstrumentedPlatformCanvas(const SkBitmap& bitmap)
- : m_size(bitmap.width(), bitmap.height())
- , m_isSolidColor(true)
- , m_solidColor(0, 0, 0, 0)
- {
- setDevice(new SkDevice(bitmap))->unref();
- }
-
- virtual ~InstrumentedPlatformCanvas() { }
-
- bool isSolidColor() const { return m_isSolidColor; }
- Color solidColor() const { return m_solidColor; }
-
- // overrides from SkCanvas
- virtual int save(SaveFlags flags)
- {
- WRAPCANVAS_LOG_ENTRY("");
- return SkCanvas::save(flags);
- }
-
- virtual int saveLayer(const SkRect* bounds, const SkPaint* paint, SaveFlags flags)
- {
- WRAPCANVAS_LOG_ENTRY("");
- m_isSolidColor = false;
- return SkCanvas::saveLayer(bounds, paint, flags);
- }
-
- virtual void restore()
- {
- WRAPCANVAS_LOG_ENTRY("");
- SkCanvas::restore();
- }
-
- virtual bool translate(SkScalar dx, SkScalar dy)
- {
- WRAPCANVAS_LOG_ENTRY("");
- return SkCanvas::translate(dx, dy);
- }
-
- virtual bool scale(SkScalar sx, SkScalar sy)
- {
- WRAPCANVAS_LOG_ENTRY("");
- return SkCanvas::scale(sx, sy);
- }
-
- virtual bool rotate(SkScalar degrees)
- {
- WRAPCANVAS_LOG_ENTRY("");
- return SkCanvas::rotate(degrees);
- }
-
- virtual bool skew(SkScalar sx, SkScalar sy)
- {
- WRAPCANVAS_LOG_ENTRY("");
- return SkCanvas::skew(sx, sy);
- }
-
- virtual bool concat(const SkMatrix& matrix)
- {
- WRAPCANVAS_LOG_ENTRY("");
- return SkCanvas::concat(matrix);
- }
-
- virtual void setMatrix(const SkMatrix& matrix)
- {
- WRAPCANVAS_LOG_ENTRY("");
- SkCanvas::setMatrix(matrix);
- }
-
- virtual bool clipRect(const SkRect& rect, SkRegion::Op op)
- {
- WRAPCANVAS_LOG_ENTRY("");
- return SkCanvas::clipRect(rect, op);
- }
-
- virtual bool clipPath(const SkPath& path, SkRegion::Op op)
- {
- WRAPCANVAS_LOG_ENTRY("");
- m_isSolidColor = false;
- return SkCanvas::clipPath(path, op);
- }
-
- virtual bool clipRegion(const SkRegion& region, SkRegion::Op op)
- {
- WRAPCANVAS_LOG_ENTRY("");
- m_isSolidColor = false;
- return SkCanvas::clipRegion(region, op);
- }
-
- virtual void clear(SkColor color)
- {
- WRAPCANVAS_LOG_ENTRY("");
- m_isSolidColor = true;
- m_solidColor = Color(color);
- SkCanvas::clear(color);
- }
-
- virtual void drawPaint(const SkPaint& paint)
- {
- WRAPCANVAS_LOG_ENTRY("");
- m_isSolidColor = false;
- SkCanvas::drawPaint(paint);
- }
-
- virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[],
- const SkPaint& paint)
- {
- WRAPCANVAS_LOG_ENTRY("");
- m_isSolidColor = false;
- SkCanvas::drawPoints(mode, count, pts, paint);
- }
-
- virtual void drawRect(const SkRect& rect, const SkPaint& paint)
- {
- IntRect rectToDraw(rect);
- WRAPCANVAS_LOG_ENTRY("rect = (x=%d,y=%d,width=%d,height=%d)", rectToDraw.x(), rectToDraw.y(), rectToDraw.width(), rectToDraw.height());
- IntRect canvasRect(IntPoint(), m_size);
- if (m_isSolidColor && getTotalMatrix().rectStaysRect() && getTotalClip().contains(canvasRect)) {
- const SkMatrix& matrix = getTotalMatrix();
- SkRect mapped;
- matrix.mapRect(&mapped, rect);
- if (mapped.contains(canvasRect)) {
- Color color = solidColor(paint);
- m_isSolidColor = color.isValid();
- m_solidColor = color;
- } else
- m_isSolidColor = false;
- } else
- m_isSolidColor = false;
- SkCanvas::drawRect(rect, paint);
- }
-
- virtual void drawPath(const SkPath& path, const SkPaint& paint)
- {
- WRAPCANVAS_LOG_ENTRY("");
- m_isSolidColor = false;
- SkCanvas::drawPath(path, paint);
- }
-
- virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left,
- SkScalar top, const SkPaint* paint)
- {
- WRAPCANVAS_LOG_ENTRY("");
- m_isSolidColor = false;
- SkCanvas::drawBitmap(bitmap, left, top, paint);
- }
-
- virtual void drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
- const SkRect& dst, const SkPaint* paint)
- {
- WRAPCANVAS_LOG_ENTRY("");
- m_isSolidColor = false;
- SkCanvas::drawBitmapRect(bitmap, src, dst, paint);
- }
-
- virtual void drawBitmapMatrix(const SkBitmap& bitmap,
- const SkMatrix& matrix, const SkPaint* paint)
- {
- WRAPCANVAS_LOG_ENTRY("");
- m_isSolidColor = false;
- SkCanvas::drawBitmapMatrix(bitmap, matrix, paint);
- }
-
- virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
- const SkRect& dst, const SkPaint* paint = 0)
- {
- WRAPCANVAS_LOG_ENTRY("");
- m_isSolidColor = false;
- SkCanvas::drawBitmapNine(bitmap, center, dst, paint);
- }
-
- virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
- const SkPaint* paint)
- {
- WRAPCANVAS_LOG_ENTRY("");
- m_isSolidColor = false;
- SkCanvas::drawSprite(bitmap, left, top, paint);
- }
-
- virtual void drawText(const void* text, size_t byteLength, SkScalar x,
- SkScalar y, const SkPaint& paint)
- {
- WRAPCANVAS_LOG_ENTRY("");
- m_isSolidColor = false;
- SkCanvas::drawText(text, byteLength, x, y, paint);
- }
-
- virtual void drawPosText(const void* text, size_t byteLength,
- const SkPoint pos[], const SkPaint& paint)
- {
- WRAPCANVAS_LOG_ENTRY("");
- m_isSolidColor = false;
- SkCanvas::drawPosText(text, byteLength, pos, paint);
- }
-
- virtual void drawPosTextH(const void* text, size_t byteLength,
- const SkScalar xpos[], SkScalar constY, const SkPaint& paint)
- {
- WRAPCANVAS_LOG_ENTRY("");
- m_isSolidColor = false;
- SkCanvas::drawPosTextH(text, byteLength, xpos, constY, paint);
- }
-
- virtual void drawTextOnPath(const void* text, size_t byteLength,
- const SkPath& path, const SkMatrix* matrix, const SkPaint& paint)
- {
- WRAPCANVAS_LOG_ENTRY("");
- m_isSolidColor = false;
- SkCanvas::drawTextOnPath(text, byteLength, path, matrix, paint);
- }
-
- virtual void drawPicture(SkPicture& picture)
- {
- WRAPCANVAS_LOG_ENTRY("");
- m_isSolidColor = false;
- SkCanvas::drawPicture(picture);
- }
-
- virtual void drawVertices(VertexMode mode, int vertexCount,
- const SkPoint vertices[], const SkPoint texs[],
- const SkColor colors[], SkXfermode* xfermode,
- const uint16_t indices[], int indexCount, const SkPaint& paint)
- {
- WRAPCANVAS_LOG_ENTRY("");
- m_isSolidColor = false;
- SkCanvas::drawVertices(mode, vertexCount, vertices, texs, colors, xfermode, indices, indexCount, paint);
- }
-
- virtual void drawData(const void* data, size_t size)
- {
- WRAPCANVAS_LOG_ENTRY("");
- m_isSolidColor = false;
- SkCanvas::drawData(data, size);
- }
-
-private:
- Color solidColor(const SkPaint& paint)
- {
- if (paint.getStyle() != SkPaint::kFill_Style)
- return Color();
- if (paint.getLooper() || paint.getShader())
- return Color();
-
- SkXfermode::Mode mode;
- SkXfermode::AsMode(paint.getXfermode(), &mode);
- if (mode == SkXfermode::kClear_Mode)
- return Color(0, 0, 0, 0);
-
- if ((mode == SkXfermode::kSrcOver_Mode && paint.getAlpha() == 255) || mode == SkXfermode::kSrc_Mode)
- return Color(paint.getColor());
- return Color();
- }
-
- IntSize m_size;
- bool m_isSolidColor;
- Color m_solidColor;
- SkPaint m_solidPaint;
-};
-
-} // namespace WebCore
-
-#endif // InstrumentedPlatformCanvas_h
diff --git a/Source/WebCore/platform/graphics/blackberry/IntRectBlackBerry.cpp b/Source/WebCore/platform/graphics/blackberry/IntRectBlackBerry.cpp
index 979ceaf6d..02c45ff34 100644
--- a/Source/WebCore/platform/graphics/blackberry/IntRectBlackBerry.cpp
+++ b/Source/WebCore/platform/graphics/blackberry/IntRectBlackBerry.cpp
@@ -24,7 +24,7 @@
namespace WebCore {
IntRect::IntRect(const BlackBerry::Platform::IntRect& rect)
- : m_location(rect.x(), rect.y()), m_size(rect.width(), rect.height())
+ : m_location(rect.x(), rect.y()), m_size(rect.width(), rect.height())
{
}
diff --git a/Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.cpp b/Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.cpp
index 454af1a0c..ffba7f2ff 100644
--- a/Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.cpp
+++ b/Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010, 2011, 2012 Research In Motion Limited. All rights reserved.
+ * Copyright (C) 2010, 2011, 2012, 2013 Research In Motion Limited. All rights reserved.
* Copyright (C) 2010 Google Inc. All rights reserved.
* Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved.
*
@@ -39,19 +39,23 @@
#include "LayerCompositingThreadClient.h"
#include "LayerMessage.h"
#include "LayerRenderer.h"
+#include "LayerRendererClient.h"
+#include "LayerUtilities.h"
#include "LayerWebKitThread.h"
#if ENABLE(VIDEO)
#include "MediaPlayer.h"
#include "MediaPlayerPrivateBlackBerry.h"
#endif
#include "PluginView.h"
+#include "StdLibExtras.h"
#include "TextureCacheCompositingThread.h"
+#include <BlackBerryPlatformGLES2ContextState.h>
#include <BlackBerryPlatformGraphics.h>
#include <BlackBerryPlatformLog.h>
#include <wtf/Assertions.h>
-#define DEBUG_VIDEO_CLIPPING 0
+using BlackBerry::Platform::Graphics::GLES2Program;
namespace WebCore {
@@ -74,6 +78,7 @@ LayerCompositingThread::LayerCompositingThread(LayerType type, LayerCompositingT
: LayerData(type)
, m_layerRenderer(0)
, m_superlayer(0)
+ , m_centerW(0)
, m_pluginBuffer(0)
, m_drawOpacity(0)
, m_visible(false)
@@ -125,92 +130,103 @@ void LayerCompositingThread::deleteTextures()
m_client->deleteTextures(this);
}
-void LayerCompositingThread::setDrawTransform(double scale, const TransformationMatrix& matrix)
-{
- m_drawTransform = matrix;
-
- float bx = m_bounds.width() / 2.0;
- float by = m_bounds.height() / 2.0;
-
- if (sizeIsScaleInvariant()) {
- bx /= scale;
- by /= scale;
- }
+void LayerCompositingThread::setDrawTransform(double scale, const TransformationMatrix& matrix, const TransformationMatrix& projectionMatrix)
+{
+ m_drawTransform = projectionMatrix * matrix;
+
+ FloatRect boundsRect(-origin(), bounds());
+
+ if (sizeIsScaleInvariant())
+ boundsRect.scale(1 / scale);
+
+ m_centerW = 0;
+ m_transformedBounds.clear();
+ m_ws.clear();
+ m_textureCoordinates.clear();
+ if (matrix.hasPerspective() && !m_layerRendererSurface) {
+ // Perform processing according to http://www.w3.org/TR/css3-transforms 6.2
+ // If w < 0 for all four corners of the transformed box, the box is not rendered.
+ // If w < 0 for one to three corners of the transformed box, the box
+ // must be replaced by a polygon that has any parts with w < 0 cut out.
+ // If w = 0, (x′, y′, z′) = (x ⋅ n, y ⋅ n, z ⋅ n)
+ // We implement this by intersecting with the image plane, i.e. the last row of the column-major matrix.
+ // To avoid problems with w close to 0, we use w = epsilon as the near plane by subtracting epsilon from matrix.m44().
+ const float epsilon = 1e-3;
+ Vector<FloatPoint3D, 4> quad = toVector<FloatPoint3D, 4>(boundsRect);
+ Vector<FloatPoint3D, 4> polygon = intersect(quad, LayerClipPlane(FloatPoint3D(matrix.m14(), matrix.m24(), matrix.m34()), matrix.m44() - epsilon));
+
+ // Compute the clipped texture coordinates.
+ if (polygon != quad) {
+ for (size_t i = 0; i < polygon.size(); ++i) {
+ FloatPoint3D& p = polygon[i];
+ m_textureCoordinates.append(FloatPoint(p.x() / boundsRect.width() + 0.5f, p.y() / boundsRect.height() + 0.5f));
+ }
+ }
- m_transformedBounds.setP1(matrix.mapPoint(FloatPoint(-bx, -by)));
- m_transformedBounds.setP2(matrix.mapPoint(FloatPoint(-bx, by)));
- m_transformedBounds.setP3(matrix.mapPoint(FloatPoint(bx, by)));
- m_transformedBounds.setP4(matrix.mapPoint(FloatPoint(bx, -by)));
+ // If w > 0, (x′, y′, z′) = (x/w, y/w, z/w)
+ for (size_t i = 0; i < polygon.size(); ++i) {
+ float w;
+ FloatPoint3D p = multVecMatrix(matrix, polygon[i], w);
+ if (w != 1) {
+ p.setX(p.x() / w);
+ p.setY(p.y() / w);
+ p.setZ(p.z() / w);
+ }
- m_drawRect = m_transformedBounds.boundingBox();
-}
+ FloatPoint3D q = projectionMatrix.mapPoint(p);
+ m_transformedBounds.append(FloatPoint(q.x(), q.y()));
+ m_ws.append(w);
+ }
-static FloatQuad getTransformedRect(const IntSize& bounds, const IntRect& rect, const TransformationMatrix& drawTransform)
-{
- float x = -bounds.width() / 2.0 + rect.x();
- float y = -bounds.height() / 2.0 + rect.y();
- float w = rect.width();
- float h = rect.height();
- FloatQuad result;
- result.setP1(drawTransform.mapPoint(FloatPoint(x, y)));
- result.setP2(drawTransform.mapPoint(FloatPoint(x, y + h)));
- result.setP3(drawTransform.mapPoint(FloatPoint(x + w, y + h)));
- result.setP4(drawTransform.mapPoint(FloatPoint(x + w, y)));
+ m_centerW = matrix.m44();
+ } else
+ m_transformedBounds = toVector<FloatPoint, 4>(m_drawTransform.mapQuad(boundsRect));
- return result;
+ m_boundingBox = WebCore::boundingBox(m_transformedBounds);
}
-
-FloatQuad LayerCompositingThread::getTransformedHolePunchRect() const
+const Vector<FloatPoint>& LayerCompositingThread::textureCoordinates(TextureCoordinateOrientation orientation) const
{
- // FIXME: the following line disables clipping a video in an iframe i.e. the fix associated with PR 99638.
- // Some revised test case (e.g. video-iframe.html) show that the original fix works correctly when scrolling
- // the contents of the frame, but fails to clip correctly if the page (main frame) is scrolled.
- static bool enableVideoClipping = false;
+ if (m_textureCoordinates.size()) {
+ if (orientation == UpsideDown) {
+ static Vector<FloatPoint> upsideDownCoordinates;
+ upsideDownCoordinates = m_textureCoordinates;
+ for (size_t i = 0; i < upsideDownCoordinates.size(); ++i)
+ upsideDownCoordinates[i].setY(1 - upsideDownCoordinates[i].y());
+ return upsideDownCoordinates;
+ }
- if (!mediaPlayer() || !enableVideoClipping) {
- // m_holePunchClipRect is valid only when there's a media player.
- return getTransformedRect(m_bounds, m_holePunchRect, m_drawTransform);
+ return m_textureCoordinates;
}
- // The hole punch rectangle may need to be clipped,
- // e.g. if the <video> is on a layer that's included and clipped by an <iframe>.
-
- // In order to clip we need to determine the current position of this layer, which
- // is encoded in the m_drawTransform value, which was used to initialize m_drawRect.
- IntRect drawRect = m_layerRenderer->toWebKitDocumentCoordinates(m_drawRect);
-
- // Assert that in this case, where the hole punch rectangle equals the size of the layer,
- // the drawRect has the same size as the hole punch.
- // ASSERT(drawRect.size() == m_holePunchRect.size());
- // Don't assert it programtically though because there may be off-by-one error due to rounding when there's zooming.
-
- // The difference between drawRect and m_holePunchRect is that drawRect has an accurate position
- // in WebKit document coordinates, whereas the m_holePunchRect location is (0,0) i.e. it's relative to this layer.
-
- // Clip the drawRect.
- // Both drawRect and m_holePunchClipRect already have correct locations, in WebKit document coordinates.
- IntPoint location = drawRect.location();
- drawRect.intersect(m_holePunchClipRect);
-
- // Shift the clipped drawRect to have the same kind of located-at-zero position as the original holePunchRect.
- drawRect.move(-location.x(), -location.y());
-
-#if DEBUG_VIDEO_CLIPPING
- IntRect drawRectInWebKitDocumentCoordination = m_layerRenderer->toWebKitDocumentCoordinates(m_drawRect);
- BBLOG(BlackBerry::Platform::LogLevelInfo, "LayerCompositingThread::getTransformedHolePunchRect() - drawRect=(x=%d,y=%d,width=%d,height=%d) clipRect=(x=%d,y=%d,width=%d,height=%d) clippedRect=(x=%d,y=%d,width=%d,height=%d).",
- drawRectInWebKitDocumentCoordination.x(), drawRectInWebKitDocumentCoordination.y(), drawRectInWebKitDocumentCoordination.width(), drawRectInWebKitDocumentCoordination.height(),
- m_holePunchClipRect.x(), m_holePunchClipRect.y(), m_holePunchClipRect.width(), m_holePunchClipRect.height(),
- drawRect.x(), drawRect.y(), drawRect.width(), drawRect.height());
-#endif
+ if (orientation == UpsideDown) {
+ static FloatPoint data[4] = { FloatPoint(0, 1), FloatPoint(1, 1), FloatPoint(1, 0), FloatPoint(0, 0) };
+ static Vector<FloatPoint>* upsideDownCoordinates = 0;
+ if (!upsideDownCoordinates) {
+ upsideDownCoordinates = new Vector<FloatPoint>();
+ upsideDownCoordinates->append(data, 4);
+ }
+ return *upsideDownCoordinates;
+ }
- return getTransformedRect(m_bounds, drawRect, m_drawTransform);
+ static FloatPoint data[4] = { FloatPoint(0, 0), FloatPoint(1, 0), FloatPoint(1, 1), FloatPoint(0, 1) };
+ static Vector<FloatPoint>* coordinates = 0;
+ if (!coordinates) {
+ coordinates = new Vector<FloatPoint>();
+ coordinates->append(data, 4);
+ }
+ return *coordinates;
}
-void LayerCompositingThread::drawTextures(double scale, int positionLocation, int texCoordLocation, const FloatRect& visibleRect)
+FloatQuad LayerCompositingThread::transformedHolePunchRect() const
{
- static float texcoords[4 * 2] = { 0, 0, 0, 1, 1, 1, 1, 0 };
+ FloatRect holePunchRect(m_holePunchRect);
+ holePunchRect.moveBy(-origin());
+ return m_drawTransform.mapQuad(holePunchRect);
+}
+void LayerCompositingThread::drawTextures(const GLES2Program& program, double scale, const FloatRect& visibleRect, const FloatRect& clipRect)
+{
if (m_pluginView) {
if (m_isVisible) {
// The layer contains Flash, video, or other plugin contents.
@@ -226,71 +242,85 @@ void LayerCompositingThread::drawTextures(double scale, int positionLocation, in
m_layerRenderer->addLayerToReleaseTextureResourcesList(this);
- glVertexAttribPointer(positionLocation, 2, GL_FLOAT, GL_FALSE, 0, &m_transformedBounds);
- glVertexAttribPointer(texCoordLocation, 2, GL_FLOAT, GL_FALSE, 0, texcoords);
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ glUniform1f(program.opacityLocation(), drawOpacity());
+ glVertexAttribPointer(program.positionLocation(), 2, GL_FLOAT, GL_FALSE, 0, m_transformedBounds.data());
+ glVertexAttribPointer(program.texCoordLocation(), 2, GL_FLOAT, GL_FALSE, 0, textureCoordinates().data());
+ glDrawArrays(GL_TRIANGLE_FAN, 0, m_transformedBounds.size());
}
return;
}
#if ENABLE(VIDEO)
if (m_mediaPlayer) {
if (m_isVisible) {
- // We need to specify the media player location in contents coordinates. The 'visibleRect'
- // specifies the content region covered by our viewport. So we transform from our
- // normalized device coordinates [-1, 1] to the 'visibleRect'.
- float vrw2 = visibleRect.width() / 2.0;
- float vrh2 = visibleRect.height() / 2.0;
- float x = m_transformedBounds.p1().x() * vrw2 + vrw2 + visibleRect.x();
- float y = -m_transformedBounds.p1().y() * vrh2 + vrh2 + visibleRect.y();
- m_mediaPlayer->paint(0, IntRect((int)(x + 0.5), (int)(y + 0.5), m_bounds.width(), m_bounds.height()));
+ IntRect paintRect;
+ if (m_layerRenderer->client()->shouldChildWindowsUseDocumentCoordinates()) {
+ // We need to specify the media player location in contents coordinates. The 'visibleRect'
+ // specifies the content region covered by our viewport. So we transform from our
+ // normalized device coordinates [-1, 1] to the 'visibleRect'.
+ float vrw2 = visibleRect.width() / 2.0;
+ float vrh2 = visibleRect.height() / 2.0;
+ FloatPoint p(m_transformedBounds[0].x() * vrw2 + vrw2 + visibleRect.x(),
+ -m_transformedBounds[0].y() * vrh2 + vrh2 + visibleRect.y());
+ paintRect = IntRect(roundedIntPoint(p), m_bounds);
+ } else
+ paintRect = m_layerRenderer->toWindowCoordinates(m_boundingBox);
+
+ m_mediaPlayer->paint(0, paintRect);
MediaPlayerPrivate* mpp = static_cast<MediaPlayerPrivate*>(m_mediaPlayer->platformMedia().media.qnxMediaPlayer);
- mpp->drawBufferingAnimation(m_drawTransform, positionLocation, texCoordLocation);
+ mpp->drawBufferingAnimation(m_drawTransform, program);
}
return;
}
#endif
if (m_client)
- m_client->drawTextures(this, scale, positionLocation, texCoordLocation);
+ m_client->drawTextures(this, program, scale, clipRect);
}
-void LayerCompositingThread::drawSurface(const TransformationMatrix& drawTransform, LayerCompositingThread* mask, int positionLocation, int texCoordLocation)
+void LayerCompositingThread::drawSurface(const GLES2Program& program, const TransformationMatrix& drawTransform, LayerCompositingThread* mask)
{
+ using namespace BlackBerry::Platform::Graphics;
+
if (m_layerRenderer->layerAlreadyOnSurface(this)) {
- unsigned texID = layerRendererSurface()->texture()->textureId();
- if (!texID) {
+ LayerTexture* surfaceTexture = layerRendererSurface()->texture();
+ if (!surfaceTexture) {
ASSERT_NOT_REACHED();
return;
}
textureCacheCompositingThread()->textureAccessed(layerRendererSurface()->texture());
- glBindTexture(GL_TEXTURE_2D, texID);
+ GLuint surfaceTexID = surfaceTexture->platformTexture();
+
+ if (!surfaceTexID) {
+ ASSERT_NOT_REACHED();
+ return;
+ }
if (mask) {
- glActiveTexture(GL_TEXTURE1);
- mask->bindContentsTexture();
- glActiveTexture(GL_TEXTURE0);
+ if (LayerTexture* maskTexture = mask->contentsTexture()) {
+ GLuint maskTexID = maskTexture->platformTexture();
+
+ glActiveTexture(GL_TEXTURE1);
+ glBindTexture(GL_TEXTURE_2D, maskTexID);
+ glActiveTexture(GL_TEXTURE0);
+ }
}
- FloatQuad surfaceQuad = getTransformedRect(m_bounds, IntRect(IntPoint::zero(), m_bounds), drawTransform);
- glVertexAttribPointer(positionLocation, 2, GL_FLOAT, GL_FALSE, 0, &surfaceQuad);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ glBindTexture(GL_TEXTURE_2D, surfaceTexID);
- static float texcoords[4 * 2] = { 0, 0, 0, 1, 1, 1, 1, 0 };
- glVertexAttribPointer(texCoordLocation, 2, GL_FLOAT, GL_FALSE, 0, texcoords);
+ FloatQuad surfaceQuad = drawTransform.mapQuad(FloatRect(-origin(), bounds()));
+ glUniform1f(program.opacityLocation(), layerRendererSurface()->drawOpacity());
+ glVertexAttribPointer(program.positionLocation(), 2, GL_FLOAT, GL_FALSE, 0, &surfaceQuad);
+
+ static float texcoords[4 * 2] = { 0, 0, 1, 0, 1, 1, 0, 1 };
+ glVertexAttribPointer(program.texCoordLocation(), 2, GL_FLOAT, GL_FALSE, 0, texcoords);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
}
}
-bool LayerCompositingThread::hasMissingTextures() const
-{
- return m_client ? m_client->hasMissingTextures(this) : false;
-}
-
-void LayerCompositingThread::drawMissingTextures(double scale, int positionLocation, int texCoordLocation, const FloatRect& /*visibleRect*/)
-{
- if (m_client)
- m_client->drawMissingTextures(this, scale, positionLocation, texCoordLocation);
-}
-
void LayerCompositingThread::releaseTextureResources()
{
if (m_pluginView && m_pluginBuffer) {
@@ -397,10 +427,12 @@ void LayerCompositingThread::updateTextureContentsIfNeeded()
m_client->uploadTexturesIfNeeded(this);
}
-void LayerCompositingThread::bindContentsTexture()
+LayerTexture* LayerCompositingThread::contentsTexture()
{
if (m_client)
- m_client->bindContentsTexture(this);
+ return m_client->contentsTexture(this);
+
+ return 0;
}
void LayerCompositingThread::setVisible(bool visible)
@@ -440,6 +472,12 @@ void LayerCompositingThread::scheduleCommit()
m_client->scheduleCommit();
}
+void LayerCompositingThread::commitPendingTextureUploads()
+{
+ if (m_client)
+ m_client->commitPendingTextureUploads(this);
+}
+
bool LayerCompositingThread::updateAnimations(double currentTime)
{
// The commit mechanism always overwrites our state with state from the
diff --git a/Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.h b/Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.h
index 85385ed2c..8bee2668b 100644
--- a/Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.h
+++ b/Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.h
@@ -50,6 +50,7 @@ namespace BlackBerry {
namespace Platform {
namespace Graphics {
class Buffer;
+class GLES2Program;
}
}
}
@@ -119,6 +120,7 @@ class LayerCompositingThread : public ThreadSafeRefCounted<LayerCompositingThrea
public:
static PassRefPtr<LayerCompositingThread> create(LayerType, LayerCompositingThreadClient*);
+ LayerCompositingThreadClient* client() const { return m_client; }
void setClient(LayerCompositingThreadClient* client) { m_client = client; }
// Thread safe
@@ -142,21 +144,27 @@ public:
void removeFromSuperlayer();
void setNeedsTexture(bool needsTexture) { m_needsTexture = needsTexture; }
+ void commitPendingTextureUploads();
+
// Returns true if we have an animation
bool updateAnimations(double currentTime);
void updateTextureContentsIfNeeded();
- void bindContentsTexture();
+ LayerTexture* contentsTexture();
const LayerCompositingThread* rootLayer() const;
void setSublayers(const Vector<RefPtr<LayerCompositingThread> >&);
- const Vector<RefPtr<LayerCompositingThread> >& getSublayers() const { return m_sublayers; }
+ const Vector<RefPtr<LayerCompositingThread> >& sublayers() const { return m_sublayers; }
void setSuperlayer(LayerCompositingThread* superlayer) { m_superlayer = superlayer; }
LayerCompositingThread* superlayer() const { return m_superlayer; }
// The layer renderer must be set if the layer has been rendered
+ LayerRenderer* layerRenderer() const { return m_layerRenderer; }
void setLayerRenderer(LayerRenderer*);
- void setDrawTransform(double scale, const TransformationMatrix&);
+ // The draw transform expects the origin to be located at the center of the layer.
+ FloatPoint origin() const { return FloatPoint(m_bounds.width() / 2.0f, m_bounds.height() / 2.0f); }
+
+ void setDrawTransform(double scale, const TransformationMatrix& modelViewMatrix, const TransformationMatrix& projectionMatrix);
const TransformationMatrix& drawTransform() const { return m_drawTransform; }
void setDrawOpacity(float opacity) { m_drawOpacity = opacity; }
@@ -172,16 +180,25 @@ public:
void setReplicaLayer(LayerCompositingThread* layer) { m_replicaLayer = layer; }
LayerCompositingThread* replicaLayer() const { return m_replicaLayer.get(); }
- FloatRect getDrawRect() const { return m_drawRect; }
- const FloatQuad& getTransformedBounds() const { return m_transformedBounds; }
- FloatQuad getTransformedHolePunchRect() const;
+ // These use normalized device coordinates
+ FloatRect boundingBox() const { return m_boundingBox; }
+ // The bounds are processed according to http://www.w3.org/TR/css3-transforms paragraph 6.2, which can result in a polygon with more than 4 sides.
+ const Vector<FloatPoint, 4>& transformedBounds() const { return m_transformedBounds; }
+ const Vector<float, 4>& ws() const { return m_ws; }
+
+ enum TextureCoordinateOrientation {
+ RightSideUp = 0,
+ UpsideDown
+ };
+
+ const Vector<FloatPoint>& textureCoordinates(TextureCoordinateOrientation = RightSideUp) const;
+ FloatQuad transformedHolePunchRect() const;
+ float centerW() const { return m_centerW; }
void deleteTextures();
- void drawTextures(double scale, int positionLocation, int texCoordLocation, const FloatRect& visibleRect);
- bool hasMissingTextures() const;
- void drawMissingTextures(double scale, int positionLocation, int texCoordLocation, const FloatRect& visibleRect);
- void drawSurface(const TransformationMatrix&, LayerCompositingThread* mask, int positionLocation, int texCoordLocation);
+ void drawTextures(const BlackBerry::Platform::Graphics::GLES2Program&, double scale, const FloatRect& visibleRect, const FloatRect& clipRect);
+ void drawSurface(const BlackBerry::Platform::Graphics::GLES2Program&, const TransformationMatrix&, LayerCompositingThread* mask);
void releaseTextureResources();
@@ -242,9 +259,11 @@ private:
LayerCompositingThread* m_superlayer;
// Vertex data for the bounds of this layer
- FloatQuad m_transformedBounds;
- // The bounding rectangle of the transformed layer
- FloatRect m_drawRect;
+ Vector<FloatPoint, 4> m_transformedBounds;
+ Vector<float, 4> m_ws;
+ Vector<FloatPoint> m_textureCoordinates; // Only used when a 3D layer is clipped against z = 0
+ float m_centerW;
+ FloatRect m_boundingBox;
OwnPtr<LayerRendererSurface> m_layerRendererSurface;
@@ -287,8 +306,8 @@ inline void ThreadSafeRefCounted<WebCore::LayerCompositingThread>::deref()
if (derefBase()) {
// Delete on the compositing thread.
BlackBerry::Platform::GuardedPointerDeleter::deleteOnThread(
- BlackBerry::Platform::userInterfaceThreadMessageClient(),
- static_cast<WebCore::LayerCompositingThread*>(this));
+ BlackBerry::Platform::userInterfaceThreadMessageClient(),
+ static_cast<WebCore::LayerCompositingThread*>(this));
}
}
diff --git a/Source/WebCore/platform/graphics/blackberry/LayerCompositingThreadClient.h b/Source/WebCore/platform/graphics/blackberry/LayerCompositingThreadClient.h
index 746adea49..08cfe1aa5 100644
--- a/Source/WebCore/platform/graphics/blackberry/LayerCompositingThreadClient.h
+++ b/Source/WebCore/platform/graphics/blackberry/LayerCompositingThreadClient.h
@@ -21,9 +21,18 @@
#if USE(ACCELERATED_COMPOSITING)
+namespace BlackBerry {
+namespace Platform {
+namespace Graphics {
+class GLES2Program;
+}
+}
+}
namespace WebCore {
+class FloatRect;
class LayerCompositingThread;
+class LayerTexture;
class LayerCompositingThreadClient {
public:
@@ -34,15 +43,14 @@ public:
virtual void layerVisibilityChanged(LayerCompositingThread*, bool visible) = 0;
virtual void uploadTexturesIfNeeded(LayerCompositingThread*) = 0;
- virtual void drawTextures(LayerCompositingThread*, double scale, int positionLocation, int texCoordLocation) = 0;
+ virtual void drawTextures(LayerCompositingThread*, const BlackBerry::Platform::Graphics::GLES2Program&, double scale, const FloatRect& clipRect) = 0;
virtual void deleteTextures(LayerCompositingThread*) = 0;
// Optional. Allows layers to serve as a mask for other layers
- virtual void bindContentsTexture(LayerCompositingThread*) { }
+ virtual LayerTexture* contentsTexture(LayerCompositingThread*) { return 0; }
- // Optional. Allows layers to have uncached regions, typically drawn as checkerboard
- virtual bool hasMissingTextures(const LayerCompositingThread*) const { return false; }
- virtual void drawMissingTextures(LayerCompositingThread*, double scale, int positionLocation, int texCoordLocation) { }
+ // Optional. Allow the layer to commit thread sensitive content during a sync point
+ virtual void commitPendingTextureUploads(LayerCompositingThread*) { }
// Unlike the other methods here, this one will be called on the WebKit thread
virtual void scheduleCommit() { }
diff --git a/Source/WebCore/platform/graphics/blackberry/LayerData.h b/Source/WebCore/platform/graphics/blackberry/LayerData.h
index 50be08af5..03a4a341c 100644
--- a/Source/WebCore/platform/graphics/blackberry/LayerData.h
+++ b/Source/WebCore/platform/graphics/blackberry/LayerData.h
@@ -56,27 +56,31 @@ class LayerData {
public:
enum LayerType { Layer, TransformLayer, WebGLLayer, CanvasLayer, CustomLayer };
enum FilterType { Linear, Nearest, Trilinear, Lanczos };
- enum LayerProgramShader { LayerProgramShaderRGBA = 0,
- LayerProgramShaderBGRA,
- NumberOfLayerProgramShaders };
+ enum LayerProgram {
+ LayerProgramRGBA = 0,
+ LayerProgramBGRA,
+ NumberOfLayerPrograms
+ };
#if ENABLE(CSS_FILTERS)
- enum CSSFilterShaders { CSSFilterShaderGrayscale = 0,
- CSSFilterShaderSepia,
- CSSFilterShaderSaturate,
- CSSFilterShaderHueRotate,
- CSSFilterShaderInvert,
- CSSFilterShaderBrightness,
- CSSFilterShaderContrast,
- CSSFilterShaderOpacity,
- CSSFilterShaderBlurY,
- CSSFilterShaderBlurX,
- CSSFilterShaderShadow,
- CSSFilterShaderPassthrough,
+ enum CSSFilterShaders {
+ CSSFilterShaderGrayscale = 0,
+ CSSFilterShaderSepia,
+ CSSFilterShaderSaturate,
+ CSSFilterShaderHueRotate,
+ CSSFilterShaderInvert,
+ CSSFilterShaderBrightness,
+ CSSFilterShaderContrast,
+ CSSFilterShaderOpacity,
+ CSSFilterShaderBlurY,
+ CSSFilterShaderBlurX,
+ CSSFilterShaderShadow,
+ CSSFilterShaderPassthrough,
#if ENABLE(CSS_SHADERS)
- CSSFilterShaderCustom,
+ CSSFilterShaderCustom,
#endif
- NumberOfCSSFilterShaders };
+ NumberOfCSSFilterShaders
+ };
#endif
LayerData(LayerType type)
@@ -87,12 +91,13 @@ public:
, m_opacity(1.0)
, m_anchorPointZ(0.0)
, m_borderWidth(0.0)
- , m_layerProgramShader(LayerProgramShaderBGRA)
+ , m_layerProgram(LayerProgramBGRA)
, m_pluginView(0)
#if ENABLE(VIDEO)
, m_mediaPlayer(0)
#endif
, m_suspendTime(0)
+ , m_contentsScale(1.0)
, m_doubleSided(true)
, m_masksToBounds(false)
, m_isOpaque(false)
@@ -102,8 +107,10 @@ public:
, m_isFixedPosition(false)
, m_hasFixedContainer(false)
, m_hasFixedAncestorInDOMTree(false)
- , m_isVisible(true)
+ , m_isContainerForFixedPositionLayers(false)
, m_sizeIsScaleInvariant(false)
+ , m_contentsResolutionIndependent(false)
+ , m_isVisible(true)
{
}
@@ -125,6 +132,8 @@ public:
bool sizeIsScaleInvariant() const { return m_sizeIsScaleInvariant; }
+ bool contentsResolutionIndependent() const { return m_contentsResolutionIndependent; }
+
bool doubleSided() const { return m_doubleSided; }
FloatRect frame() const { return m_frame; }
@@ -150,17 +159,25 @@ public:
bool needsTexture() const { return m_layerType == WebGLLayer || m_layerType == CanvasLayer || m_needsTexture; }
- LayerProgramShader layerProgramShader() const { return m_layerProgramShader; }
+ LayerProgram layerProgram() const { return m_layerProgram; }
bool isFixedPosition() const { return m_isFixedPosition; }
bool hasFixedContainer() const { return m_hasFixedContainer; }
bool hasFixedAncestorInDOMTree() const { return m_hasFixedAncestorInDOMTree; }
+ bool isContainerForFixedPositionLayers() const { return m_isContainerForFixedPositionLayers; }
+ bool isFixedToTop() const { return m_isFixedToTop; }
+ bool isFixedToLeft() const { return m_isFixedToLeft; }
+
+ IntRect frameVisibleRect() const { return m_frameVisibleRect; }
+ IntSize frameContentsSize() const { return m_frameContentsSize; }
PluginView* pluginView() const { return m_pluginView; }
IntRect holePunchRect() const { return m_holePunchRect; }
bool hasHolePunchRect() const { return !m_holePunchRect.isEmpty(); }
+ double contentsScale() const { return m_contentsScale; }
+
#if ENABLE(VIDEO)
MediaPlayer* mediaPlayer() const { return m_mediaPlayer; }
#endif
@@ -202,16 +219,19 @@ protected:
float m_anchorPointZ;
float m_borderWidth;
- LayerProgramShader m_layerProgramShader;
+ LayerProgram m_layerProgram;
PluginView* m_pluginView;
#if ENABLE(VIDEO)
MediaPlayer* m_mediaPlayer;
- IntRect m_holePunchClipRect;
#endif
IntRect m_holePunchRect;
+ IntRect m_frameVisibleRect;
+ IntSize m_frameContentsSize;
+
double m_suspendTime;
+ double m_contentsScale;
unsigned m_doubleSided : 1;
unsigned m_masksToBounds : 1;
@@ -223,10 +243,15 @@ protected:
unsigned m_isFixedPosition : 1;
unsigned m_hasFixedContainer : 1;
unsigned m_hasFixedAncestorInDOMTree : 1;
+ unsigned m_isContainerForFixedPositionLayers: 1;
+ unsigned m_isFixedToTop : 1;
+ unsigned m_isFixedToLeft : 1;
+
+ unsigned m_sizeIsScaleInvariant : 1;
+ unsigned m_contentsResolutionIndependent : 1;
// The following is only available for media (video) and plugin layers.
unsigned m_isVisible : 1;
- unsigned m_sizeIsScaleInvariant : 1;
// CAUTION: all the data members are copied from one instance to another
// i.e. from one thread to another in the replicate method.
diff --git a/Source/WebCore/platform/graphics/blackberry/LayerFilterRenderer.cpp b/Source/WebCore/platform/graphics/blackberry/LayerFilterRenderer.cpp
index 60d2687f4..e6662183b 100644
--- a/Source/WebCore/platform/graphics/blackberry/LayerFilterRenderer.cpp
+++ b/Source/WebCore/platform/graphics/blackberry/LayerFilterRenderer.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ * Copyright (C) 2012, 2013 Research In Motion Limited. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -38,6 +38,31 @@
namespace WebCore {
+class SurfaceFunctor {
+public:
+ SurfaceFunctor(LayerRendererSurface* surface)
+ : m_surface(surface)
+ {
+ }
+
+protected:
+ LayerRendererSurface* m_surface;
+};
+
+class InverseSurfaceWidth : public SurfaceFunctor {
+public:
+ InverseSurfaceWidth(LayerRendererSurface* surface) : SurfaceFunctor(surface) { }
+
+ float operator() () { return 1.0f / m_surface->size().width(); }
+};
+
+class InverseSurfaceHeight : public SurfaceFunctor {
+public:
+ InverseSurfaceHeight(LayerRendererSurface* surface) : SurfaceFunctor(surface) { }
+
+ float operator() () { return 1.0f / m_surface->size().height(); }
+};
+
static int operationTypeToProgramID(const FilterOperation::OperationType& t)
{
switch (t) {
@@ -242,7 +267,6 @@ PassRefPtr<LayerFilterRendererAction> LayerFilterRendererAction::create(int prog
LayerFilterRendererAction::LayerFilterRendererAction(int c_programId)
: m_programId(c_programId)
- , m_customId(-1)
, m_pushSnapshot(false)
, m_popSnapshot(false)
, m_drawingMode(DrawTriangleFanArrays)
@@ -302,7 +326,7 @@ bool LayerFilterRenderer::initializeSharedGLObjects()
{
// See also TextureMapperShaderManager.cpp
- char vertexShaderString[] =
+ char standardVertexShaderString[] =
"attribute vec4 a_position; \n"
"attribute vec2 a_texCoord; \n"
"varying vec2 v_texCoord; \n"
@@ -312,25 +336,26 @@ bool LayerFilterRenderer::initializeSharedGLObjects()
" v_texCoord = a_texCoord; \n"
"} \n";
+ char offsetVertexShaderString[] =
+ "attribute vec4 a_position; \n"
+ "attribute vec2 a_texCoord; \n"
+ "uniform mediump vec2 u_offset; \n"
+ "varying vec2 v_texCoord; \n"
+ "void main() \n"
+ "{ \n"
+ " gl_Position = a_position; \n"
+ " v_texCoord = a_texCoord - u_offset; \n"
+ "} \n";
+
#define STANDARD_FILTER(x...) \
"precision mediump float; \n"\
"\n"\
"varying mediump vec2 v_texCoord;\n"\
"uniform lowp sampler2D s_texture;\n"\
"uniform highp float u_amount;\n"\
- #x\
+#x\
"void main(void)\n { gl_FragColor = shade(texture2D(s_texture, v_texCoord)); }"
-#define OFFSET_FILTER(x...) \
- "precision mediump float; \n"\
- "\n"\
- "varying mediump vec2 v_texCoord;\n"\
- "uniform lowp sampler2D s_texture;\n"\
- "uniform highp float u_amount;\n"\
- "uniform mediump vec2 u_offset;\n"\
- #x\
- "void main(void)\n { gl_FragColor = shade(texture2D(s_texture, v_texCoord - u_offset)); }"
-
#define BLUR_FILTER(x...) \
"precision highp float; \n"\
"\n"\
@@ -339,7 +364,7 @@ bool LayerFilterRenderer::initializeSharedGLObjects()
"uniform highp float u_amount;\n"\
"uniform highp float u_blurSize;\n"\
"const float pi = 3.1415927;\n"\
- #x\
+#x\
"void main(void)\n"\
"{\n"\
"vec3 incr;\n"\
@@ -354,7 +379,7 @@ bool LayerFilterRenderer::initializeSharedGLObjects()
"coefficientSum += incr.x;\n"\
"incr.xy *= incr.yz;\n"\
"\n"\
- "for (float i = 1.0; i <= numBlurPixelsPerSide; i++) {\n"\
+ "for (float i = 1.0; i <= u_amount; i++) {\n"\
" avg += texture2D(s_texture, v_texCoord.xy - i * u_blurSize * blurMultiplyVec) * incr.x;\n"\
" avg += texture2D(s_texture, v_texCoord.xy + i * u_blurSize * blurMultiplyVec) * incr.x;\n"\
" coefficientSum += 2.0 * incr.x;\n"\
@@ -371,9 +396,9 @@ bool LayerFilterRenderer::initializeSharedGLObjects()
{
lowp float amount = 1.0 - u_amount;
return vec4((0.2126 + 0.7874 * amount) * color.r + (0.7152 - 0.7152 * amount) * color.g + (0.0722 - 0.0722 * amount) * color.b,
- (0.2126 - 0.2126 * amount) * color.r + (0.7152 + 0.2848 * amount) * color.g + (0.0722 - 0.0722 * amount) * color.b,
- (0.2126 - 0.2126 * amount) * color.r + (0.7152 - 0.7152 * amount) * color.g + (0.0722 + 0.9278 * amount) * color.b,
- color.a);
+ (0.2126 - 0.2126 * amount) * color.r + (0.7152 + 0.2848 * amount) * color.g + (0.0722 - 0.0722 * amount) * color.b,
+ (0.2126 - 0.2126 * amount) * color.r + (0.7152 - 0.7152 * amount) * color.g + (0.0722 + 0.9278 * amount) * color.b,
+ color.a);
}
);
@@ -382,19 +407,19 @@ bool LayerFilterRenderer::initializeSharedGLObjects()
{
lowp float amount = 1.0 - u_amount;
return vec4((0.393 + 0.607 * amount) * color.r + (0.769 - 0.769 * amount) * color.g + (0.189 - 0.189 * amount) * color.b,
- (0.349 - 0.349 * amount) * color.r + (0.686 + 0.314 * amount) * color.g + (0.168 - 0.168 * amount) * color.b,
- (0.272 - 0.272 * amount) * color.r + (0.534 - 0.534 * amount) * color.g + (0.131 + 0.869 * amount) * color.b,
- color.a);
- }
+ (0.349 - 0.349 * amount) * color.r + (0.686 + 0.314 * amount) * color.g + (0.168 - 0.168 * amount) * color.b,
+ (0.272 - 0.272 * amount) * color.r + (0.534 - 0.534 * amount) * color.g + (0.131 + 0.869 * amount) * color.b,
+ color.a);
+ }
);
shaderStrs[LayerData::CSSFilterShaderSaturate] = STANDARD_FILTER(
lowp vec4 shade(lowp vec4 color)
{
return vec4((0.213 + 0.787 * u_amount) * color.r + (0.715 - 0.715 * u_amount) * color.g + (0.072 - 0.072 * u_amount) * color.b,
- (0.213 - 0.213 * u_amount) * color.r + (0.715 + 0.285 * u_amount) * color.g + (0.072 - 0.072 * u_amount) * color.b,
- (0.213 - 0.213 * u_amount) * color.r + (0.715 - 0.715 * u_amount) * color.g + (0.072 + 0.928 * u_amount) * color.b,
- color.a);
+ (0.213 - 0.213 * u_amount) * color.r + (0.715 + 0.285 * u_amount) * color.g + (0.072 - 0.072 * u_amount) * color.b,
+ (0.213 - 0.213 * u_amount) * color.r + (0.715 - 0.715 * u_amount) * color.g + (0.072 + 0.928 * u_amount) * color.b,
+ color.a);
}
);
@@ -405,9 +430,9 @@ bool LayerFilterRenderer::initializeSharedGLObjects()
highp float c = cos(u_amount * pi / 180.0);
highp float s = sin(u_amount * pi / 180.0);
return vec4(color.r * (0.213 + c * 0.787 - s * 0.213) + color.g * (0.715 - c * 0.715 - s * 0.715) + color.b * (0.072 - c * 0.072 + s * 0.928),
- color.r * (0.213 - c * 0.213 + s * 0.143) + color.g * (0.715 + c * 0.285 + s * 0.140) + color.b * (0.072 - c * 0.072 - s * 0.283),
- color.r * (0.213 - c * 0.213 - s * 0.787) + color.g * (0.715 - c * 0.715 + s * 0.715) + color.b * (0.072 + c * 0.928 + s * 0.072),
- color.a);
+ color.r * (0.213 - c * 0.213 + s * 0.143) + color.g * (0.715 + c * 0.285 + s * 0.140) + color.b * (0.072 - c * 0.072 - s * 0.283),
+ color.r * (0.213 - c * 0.213 - s * 0.787) + color.g * (0.715 - c * 0.715 + s * 0.715) + color.b * (0.072 + c * 0.928 + s * 0.072),
+ color.a);
}
);
@@ -442,16 +467,14 @@ bool LayerFilterRenderer::initializeSharedGLObjects()
);
shaderStrs[LayerData::CSSFilterShaderBlurX] = BLUR_FILTER(
- const float numBlurPixelsPerSide = 2.0;
const vec2 blurMultiplyVec = vec2(1.0, 0.0);
);
shaderStrs[LayerData::CSSFilterShaderBlurY] = BLUR_FILTER(
- const float numBlurPixelsPerSide = 2.0;
const vec2 blurMultiplyVec = vec2(0.0, 1.0);
);
- shaderStrs[LayerData::CSSFilterShaderShadow] = OFFSET_FILTER(
+ shaderStrs[LayerData::CSSFilterShaderShadow] = STANDARD_FILTER(
uniform lowp vec3 u_color;
lowp vec4 shade(lowp vec4 color)
{
@@ -469,7 +492,10 @@ bool LayerFilterRenderer::initializeSharedGLObjects()
);
for (int i = 0; i < LayerData::NumberOfCSSFilterShaders; i++) {
- m_cssFilterProgramObject[i] = LayerRenderer::loadShaderProgram(vertexShaderString, shaderStrs[i]);
+ if (i == LayerData::CSSFilterShaderShadow)
+ m_cssFilterProgramObject[i] = LayerRenderer::loadShaderProgram(offsetVertexShaderString, shaderStrs[i]);
+ else
+ m_cssFilterProgramObject[i] = LayerRenderer::loadShaderProgram(standardVertexShaderString, shaderStrs[i]);
if (!m_cssFilterProgramObject[i]) {
BlackBerry::Platform::logAlways(BlackBerry::Platform::LogLevelWarn, "Could not load CSS Filter Shader %i", i);
return false;
@@ -499,19 +525,47 @@ bool LayerFilterRenderer::initializeSharedGLObjects()
void LayerFilterRenderer::ping(LayerRendererSurface* surface)
{
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texture->textureId(), 0);
- glBindTexture(GL_TEXTURE_2D, surface->texture()->textureId());
+ GLuint texid = m_texture->platformTexture();
+
+ glFramebufferTexture2D(
+ GL_FRAMEBUFFER,
+ GL_COLOR_ATTACHMENT0,
+ GL_TEXTURE_2D,
+ texid,
+ 0
+ );
+ glBindTexture(
+ GL_TEXTURE_2D,
+ surface->texture()->platformTexture()
+ );
}
void LayerFilterRenderer::pong(LayerRendererSurface* surface)
{
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, surface->texture()->textureId(), 0);
- glBindTexture(GL_TEXTURE_2D, m_texture->textureId());
+ glFramebufferTexture2D(
+ GL_FRAMEBUFFER,
+ GL_COLOR_ATTACHMENT0,
+ GL_TEXTURE_2D,
+ surface->texture()->platformTexture(),
+ 0
+ );
+ glBindTexture(
+ GL_TEXTURE_2D,
+ m_texture->platformTexture()
+ );
}
void LayerFilterRenderer::pushSnapshot(LayerRendererSurface* surface, int sourceId)
{
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_snapshotTexture->textureId(), 0);
+ GLuint texid = m_snapshotTexture->platformTexture();
+
+ glFramebufferTexture2D(
+ GL_FRAMEBUFFER,
+ GL_COLOR_ATTACHMENT0,
+ GL_TEXTURE_2D,
+ texid,
+ 0
+ );
glBindTexture(GL_TEXTURE_2D, sourceId);
glClear(GL_COLOR_BUFFER_BIT); // to transparency
@@ -529,13 +583,16 @@ void LayerFilterRenderer::popSnapshot()
// to the snapshot texture. Next time glDrawArrays is called, the snapshot will be drawn.
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
- glBindTexture(GL_TEXTURE_2D, m_snapshotTexture->textureId());
+ glBindTexture(
+ GL_TEXTURE_2D,
+ m_snapshotTexture->platformTexture()
+ );
}
Vector<RefPtr<LayerFilterRendererAction> > LayerFilterRenderer::actionsForOperations(LayerRendererSurface* surface, const Vector<RefPtr<FilterOperation> >& ops)
{
Vector<RefPtr<LayerFilterRendererAction> > ret;
- for (unsigned int i = 0; i < ops.size(); ++i) {
+ for (unsigned i = 0; i < ops.size(); ++i) {
const FilterOperation& operation = *ops[i].get();
if (operation.getOperationType() == FilterOperation::BLUR && static_cast<const BlurFilterOperation&>(operation).stdDeviation().value() < 0.1)
continue;
@@ -569,14 +626,12 @@ Vector<RefPtr<LayerFilterRendererAction> > LayerFilterRenderer::actionsForOperat
// BLUR Y:
ret.last()->appendParameter(Uniform1f::create(m_amountLocation[LayerData::CSSFilterShaderBlurY], amount));
- ret.last()->appendParameter(Uniform1f::create(m_blurAmountLocation[0]
- , 1.0f / float(surface->size().height())));
+ ret.last()->appendParameter(Uniform1f::createWithFunctor(m_blurAmountLocation[0], InverseSurfaceHeight(surface)));
// BLUR X:
ret.append(LayerFilterRendererAction::create(LayerData::CSSFilterShaderBlurX));
ret.last()->appendParameter(Uniform1f::create(m_amountLocation[LayerData::CSSFilterShaderBlurX], amount));
- ret.last()->appendParameter(Uniform1f::create(m_blurAmountLocation[1]
- , 1.0f / float(surface->size().width())));
+ ret.last()->appendParameter(Uniform1f::createWithFunctor(m_blurAmountLocation[1], InverseSurfaceWidth(surface)));
}
break;
@@ -602,15 +657,13 @@ Vector<RefPtr<LayerFilterRendererAction> > LayerFilterRenderer::actionsForOperat
ret.append(LayerFilterRendererAction::create(LayerData::CSSFilterShaderBlurY));
ret.last()->appendParameter(Uniform1f::create(m_amountLocation[LayerData::CSSFilterShaderBlurY]
, dsfo.stdDeviation()));
- ret.last()->appendParameter(Uniform1f::create(m_blurAmountLocation[0]
- , 1.0f / float(surface->size().height())));
+ ret.last()->appendParameter(Uniform1f::createWithFunctor(m_blurAmountLocation[0], InverseSurfaceHeight(surface)));
// BLUR X
ret.append(LayerFilterRendererAction::create(LayerData::CSSFilterShaderBlurX));
ret.last()->appendParameter(Uniform1f::create(m_amountLocation[LayerData::CSSFilterShaderBlurX]
, dsfo.stdDeviation()));
- ret.last()->appendParameter(Uniform1f::create(m_blurAmountLocation[1]
- , 1.0f / float(surface->size().width())));
+ ret.last()->appendParameter(Uniform1f::createWithFunctor(m_blurAmountLocation[1], InverseSurfaceWidth(surface)));
// Repaint original image
ret.append(LayerFilterRendererAction::create(LayerData::CSSFilterShaderPassthrough));
@@ -629,8 +682,6 @@ Vector<RefPtr<LayerFilterRendererAction> > LayerFilterRenderer::actionsForOperat
return ret;
}
-static float texcoords[4 * 2] = { 0, 0, 0, 1, 1, 1, 1, 0 };
-
void LayerFilterRenderer::applyActions(unsigned& fbo, LayerCompositingThread* layer, Vector<RefPtr<LayerFilterRendererAction> > actions)
{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
@@ -656,19 +707,28 @@ void LayerFilterRenderer::applyActions(unsigned& fbo, LayerCompositingThread* la
LayerRendererSurface* surface = layer->layerRendererSurface();
- glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, &layer->getTransformedBounds() );
- glVertexAttribPointer(m_texCoordLocation, 2, GL_FLOAT, GL_FALSE, 0, texcoords);
+ // From the code in LayerRenderer, we see that the layer will have a trivial transform that will
+ // result in the transformed bounds being a polygon with 4 vertices, i.e. a quad.
+ // The LayerFilterRenderer depends on the layer being a quad, so assert to make sure.
+ ASSERT(layer->transformedBounds().size() == 4);
+ if (layer->transformedBounds().size() != 4)
+ return;
+
+ glVertexAttribPointer(m_positionLocation, 2, GL_FLOAT, GL_FALSE, 0, layer->transformedBounds().data());
+ glEnableVertexAttribArray(m_positionLocation);
+ glVertexAttribPointer(m_texCoordLocation, 2, GL_FLOAT, GL_FALSE, 0, layer->textureCoordinates().data());
+ glEnableVertexAttribArray(m_texCoordLocation);
- m_texture->protect(surface->texture()->size());
+ m_texture->protect(surface->texture()->size(), BlackBerry::Platform::Graphics::AlwaysBacked);
if (requireSnapshot)
- m_snapshotTexture->protect(surface->texture()->size());
+ m_snapshotTexture->protect(surface->texture()->size(), BlackBerry::Platform::Graphics::AlwaysBacked);
if (!fbo)
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
- for (unsigned int i = 0; i < actions.size(); ++i) {
+ for (unsigned i = 0; i < actions.size(); ++i) {
// NOTE ABOUT PING-PONGING
// =======================
// Under OpenGL ES 2.0, we cannot use the fbo we are writting to as a texture, so we need to play ping-pong:
@@ -678,9 +738,10 @@ void LayerFilterRenderer::applyActions(unsigned& fbo, LayerCompositingThread* la
// Because we eventually have to end on the parent texture, we need an even number of actions.
// actionsForOperations takes care of that.
- if (actions[i]->shouldPushSnapshot())
- pushSnapshot(surface, (!(i % 2) ? surface->texture()->textureId() : m_texture->textureId()));
-
+ if (actions[i]->shouldPushSnapshot()) {
+ RefPtr<LayerTexture> currentTexture = (!(i % 2) ? surface->texture() : m_texture);
+ pushSnapshot(surface, currentTexture->platformTexture());
+ }
if (!(i % 2))
ping(surface); // Set framebuffer to ours, and texture to parent
else
@@ -708,9 +769,9 @@ void LayerFilterRenderer::applyActions(unsigned& fbo, LayerCompositingThread* la
actions[i]->restoreState();
- glVertexAttribPointer(m_positionLocation, 2, GL_FLOAT, GL_FALSE, 0, &layer->getTransformedBounds() );
+ glVertexAttribPointer(m_positionLocation, 2, GL_FLOAT, GL_FALSE, 0, layer->transformedBounds().data());
glEnableVertexAttribArray(m_positionLocation);
- glVertexAttribPointer(m_texCoordLocation, 2, GL_FLOAT, GL_FALSE, 0, texcoords);
+ glVertexAttribPointer(m_texCoordLocation, 2, GL_FLOAT, GL_FALSE, 0, layer->textureCoordinates().data());
glEnableVertexAttribArray(m_texCoordLocation);
}
diff --git a/Source/WebCore/platform/graphics/blackberry/LayerFilterRenderer.h b/Source/WebCore/platform/graphics/blackberry/LayerFilterRenderer.h
index 3b28d08ab..ee2540a76 100644
--- a/Source/WebCore/platform/graphics/blackberry/LayerFilterRenderer.h
+++ b/Source/WebCore/platform/graphics/blackberry/LayerFilterRenderer.h
@@ -23,7 +23,7 @@
#include "IntRect.h"
#include "LayerData.h"
-#include "Texture.h"
+#include "LayerTexture.h"
#include "TransformationMatrix.h"
#include <BlackBerryPlatformGLES2Context.h>
@@ -69,14 +69,47 @@ class Uniform1f : public Uniform {
public:
static PassRefPtr<Uniform> create(int location, float val);
+ template<typename Functor>
+ static PassRefPtr<Uniform> createWithFunctor(int location, Functor);
+
protected:
Uniform1f(int location, float val);
-private:
virtual void apply();
+
float m_val;
};
+template<typename Functor>
+class Uniform1fWithFunctor : public Uniform1f {
+public:
+ static PassRefPtr<Uniform> create(int location, Functor functor)
+ {
+ return adoptRef(new Uniform1fWithFunctor(location, functor));
+ }
+
+protected:
+ Uniform1fWithFunctor(int location, Functor functor)
+ : Uniform1f(location, 0)
+ , m_functor(functor)
+ {
+ }
+
+ virtual void apply()
+ {
+ m_val = m_functor();
+ Uniform1f::apply();
+ }
+
+ Functor m_functor;
+};
+
+template<typename Functor>
+inline PassRefPtr<Uniform> Uniform1f::createWithFunctor(int location, Functor functor)
+{
+ return Uniform1fWithFunctor<Functor>::create(location, functor);
+}
+
class Uniform1i : public Uniform {
public:
static PassRefPtr<Uniform> create(int location, int val);
@@ -256,8 +289,8 @@ private:
int m_offsetLocation;
// Textures for playing ping-pong - see note in applyActions()
- RefPtr<Texture> m_texture;
- RefPtr<Texture> m_snapshotTexture;
+ RefPtr<LayerTexture> m_texture;
+ RefPtr<LayerTexture> m_snapshotTexture;
friend class LayerFilterRendererAction;
};
diff --git a/Source/WebCore/platform/graphics/blackberry/LayerRenderer.cpp b/Source/WebCore/platform/graphics/blackberry/LayerRenderer.cpp
index ff86f38e1..013bfd0aa 100644
--- a/Source/WebCore/platform/graphics/blackberry/LayerRenderer.cpp
+++ b/Source/WebCore/platform/graphics/blackberry/LayerRenderer.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010, 2011, 2012 Research In Motion Limited. All rights reserved.
+ * Copyright (C) 2010, 2011, 2012, 2013 Research In Motion Limited. All rights reserved.
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -33,11 +33,11 @@
#include "config.h"
#if USE(ACCELERATED_COMPOSITING)
-
#include "LayerRenderer.h"
#include "LayerCompositingThread.h"
#include "LayerFilterRenderer.h"
+#include "LayerRendererClient.h"
#include "TextureCacheCompositingThread.h"
#include <BlackBerryPlatformGraphics.h>
@@ -51,17 +51,20 @@
#define DEBUG_CLIPPING 0
using BlackBerry::Platform::Graphics::GLES2Context;
+using BlackBerry::Platform::Graphics::GLES2Program;
using namespace std;
namespace WebCore {
-static void checkGLError()
-{
#ifndef NDEBUG
- if (GLenum error = glGetError())
- LOG_ERROR("GL Error: 0x%x " , error);
-#endif
+#define checkGLError() \
+{ \
+ if (GLenum error = glGetError()) \
+ BlackBerry::Platform::logAlways(BlackBerry::Platform::LogLevelCritical, "%s:%d GL Error: 0x%x ", __FILE__, __LINE__, error); \
}
+#else
+#define checkGLError()
+#endif
GLuint LayerRenderer::loadShader(GLenum type, const char* shaderSource)
{
@@ -139,36 +142,29 @@ static Vector<LayerCompositingThread*> rawPtrVectorFromRefPtrVector(const Vector
return sublayerList;
}
-PassOwnPtr<LayerRenderer> LayerRenderer::create(GLES2Context* context)
+PassOwnPtr<LayerRenderer> LayerRenderer::create(LayerRendererClient* client)
{
- return adoptPtr(new LayerRenderer(context));
+ return adoptPtr(new LayerRenderer(client));
}
-LayerRenderer::LayerRenderer(GLES2Context* context)
- : m_colorProgramObject(0)
- , m_checkerProgramObject(0)
- , m_positionLocation(0)
- , m_texCoordLocation(1)
+LayerRenderer::LayerRenderer(LayerRendererClient* client)
+ : m_client(client)
, m_scale(1.0)
, m_animationTime(-numeric_limits<double>::infinity())
, m_fbo(0)
, m_currentLayerRendererSurface(0)
- , m_clearSurfaceOnDrawLayers(true)
- , m_context(context)
, m_isRobustnessSupported(false)
, m_needsCommit(false)
, m_stencilCleared(false)
{
- if (makeContextCurrent()) {
+ // We're now initializing lazily, so a check if the context can be made current
+ // will have to suffice to determine if hardware compositing is possible.
+ m_hardwareCompositing = makeContextCurrent();
+ if (m_hardwareCompositing) {
m_isRobustnessSupported = String(reinterpret_cast<const char*>(::glGetString(GL_EXTENSIONS))).contains("GL_EXT_robustness");
if (m_isRobustnessSupported)
m_glGetGraphicsResetStatusEXT = reinterpret_cast<PFNGLGETGRAPHICSRESETSTATUSEXTPROC>(eglGetProcAddress("glGetGraphicsResetStatusEXT"));
}
-
- for (int i = 0; i < LayerData::NumberOfLayerProgramShaders; ++i)
- m_layerProgramObject[i] = 0;
-
- m_hardwareCompositing = initializeSharedGLObjects();
}
LayerRenderer::~LayerRenderer()
@@ -177,10 +173,9 @@ LayerRenderer::~LayerRenderer()
makeContextCurrent();
if (m_fbo)
glDeleteFramebuffers(1, &m_fbo);
- glDeleteProgram(m_colorProgramObject);
- glDeleteProgram(m_checkerProgramObject);
- for (int i = 0; i < LayerData::NumberOfLayerProgramShaders; ++i)
- glDeleteProgram(m_layerProgramObject[i]);
+
+ for (size_t i = 0; i < NumberOfPrograms; ++i)
+ glDeleteProgram(m_programs[i].m_program);
// Free up all GL textures.
while (m_layers.begin() != m_layers.end()) {
@@ -206,12 +201,9 @@ void LayerRenderer::releaseLayerResources()
}
}
-static inline bool compareLayerZ(const LayerCompositingThread* a, const LayerCompositingThread* b)
+static inline bool compareLayerW(const LayerCompositingThread* a, const LayerCompositingThread* b)
{
- const TransformationMatrix& transformA = a->drawTransform();
- const TransformationMatrix& transformB = b->drawTransform();
-
- return transformA.m43() < transformB.m43();
+ return a->centerW() > b->centerW();
}
void LayerRenderer::prepareFrame(double animationTime, LayerCompositingThread* rootLayer)
@@ -246,9 +238,9 @@ void LayerRenderer::setViewport(const IntRect& targetRect, const IntRect& clipRe
m_clipRect = clipRect;
m_clipRect.intersect(targetRect);
m_clipRect = FloatRect(-1 + 2 * (m_clipRect.x() - targetRect.x()) / targetRect.width(),
- -1 + 2 * (m_clipRect.y() - targetRect.y()) / targetRect.height(),
- 2 * m_clipRect.width() / targetRect.width(),
- 2 * m_clipRect.height() / targetRect.height());
+ -1 + 2 * (m_clipRect.y() - targetRect.y()) / targetRect.height(),
+ 2 * m_clipRect.width() / targetRect.width(),
+ 2 * m_clipRect.height() / targetRect.height());
#if DEBUG_CLIPPING
printf("LayerRenderer::setViewport() m_visibleRect=(%.2f,%.2f %.2fx%.2f), m_layoutRect=(%d,%d %dx%d), m_contentsSize=(%dx%d), m_viewport=(%d,%d %dx%d), m_scissorRect=(%d,%d %dx%d), m_clipRect=(%.2f,%.2f %.2fx%.2f)\n",
@@ -273,8 +265,6 @@ void LayerRenderer::setViewport(const IntRect& targetRect, const IntRect& clipRe
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
- glEnableVertexAttribArray(m_positionLocation);
- glEnableVertexAttribArray(m_texCoordLocation);
glActiveTexture(GL_TEXTURE0);
glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
@@ -282,18 +272,9 @@ void LayerRenderer::setViewport(const IntRect& targetRect, const IntRect& clipRe
// If culling is enabled then we will cull the backface.
glCullFace(GL_BACK);
- // The orthographic projection is setup such that Y starts at zero and
- // increases going down the page which flips the winding order of triangles.
- // The layer quads are drawn in clock-wise order so the front face is CCW.
- glFrontFace(GL_CCW);
- // Update the parameters for the checkerboard drawing.
- glUseProgram(m_checkerProgramObject);
- float bitmapScale = static_cast<float>(m_layoutRect.width()) / static_cast<float>(m_visibleRect.width());
- glUniform1f(m_checkerScaleLocation, bitmapScale);
- float scale = static_cast<float>(m_viewport.width()) / static_cast<float>(m_visibleRect.width());
- glUniform2f(m_checkerOriginLocation, m_visibleRect.x()*scale, m_visibleRect.y()*scale);
- glUniform1f(m_checkerSurfaceHeightLocation, m_context->surfaceSize().height());
+ // The BlackBerry::Platform::GraphicsContext uses OpenGL conventions, so everything is upside down
+ glFrontFace(GL_CW);
checkGLError();
@@ -306,10 +287,6 @@ void LayerRenderer::setViewport(const IntRect& targetRect, const IntRect& clipRe
#endif
glScissor(m_scissorRect.x(), m_scissorRect.y(), m_scissorRect.width(), m_scissorRect.height());
- if (m_clearSurfaceOnDrawLayers) {
- glClearColor(0, 0, 0, 0);
- glClear(GL_COLOR_BUFFER_BIT);
- }
m_stencilCleared = false;
}
@@ -329,11 +306,11 @@ void LayerRenderer::compositeLayers(const TransformationMatrix& matrix, LayerCom
m_scale = matrix.m11() * m_viewport.width() / 2;
Vector<RefPtr<LayerCompositingThread> > surfaceLayers;
- const Vector<RefPtr<LayerCompositingThread> >& sublayers = rootLayer->getSublayers();
+ const Vector<RefPtr<LayerCompositingThread> >& sublayers = rootLayer->sublayers();
for (size_t i = 0; i < sublayers.size(); i++) {
float opacity = 1;
FloatRect clipRect(m_clipRect);
- updateLayersRecursive(sublayers[i].get(), matrix, surfaceLayers, opacity, clipRect);
+ updateLayersRecursive(sublayers[i].get(), TransformationMatrix(), matrix, surfaceLayers, opacity, clipRect);
}
// Decompose the dirty rect into a set of non-overlaping rectangles
@@ -351,13 +328,9 @@ void LayerRenderer::compositeLayers(const TransformationMatrix& matrix, LayerCom
if (!makeContextCurrent())
return;
- // The shader used to render layers returns pre-multiplied alpha colors
- // so we need to send the blending mode appropriately.
- glEnable(GL_BLEND);
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-
- // If some layers should be drawed on temporary surfaces, we should do it first.
- drawLayersOnSurfaces(surfaceLayers);
+ // If some layers should be drawn on temporary surfaces, we should do it first.
+ if (!surfaceLayers.isEmpty())
+ drawLayersOnSurfaces(surfaceLayers);
// Don't render the root layer, the BlackBerry port uses the BackingStore to draw the
// root layer.
@@ -372,7 +345,7 @@ void LayerRenderer::compositeLayers(const TransformationMatrix& matrix, LayerCom
if (m_layersLockingTextureResources.size())
glFinish();
- m_context->swapBuffers();
+ m_client->context()->swapBuffers();
glDisable(GL_SCISSOR_TEST);
glDisable(GL_STENCIL_TEST);
@@ -383,9 +356,6 @@ void LayerRenderer::compositeLayers(const TransformationMatrix& matrix, LayerCom
// driver by unbinding early (when the pixmap is hopefully still around).
glBindTexture(GL_TEXTURE_2D, 0);
- // Turn off blending again
- glDisable(GL_BLEND);
-
LayerSet::iterator iter = m_layersLockingTextureResources.begin();
for (; iter != m_layersLockingTextureResources.end(); ++iter)
(*iter)->releaseTextureResources();
@@ -400,7 +370,7 @@ void LayerRenderer::compositeLayers(const TransformationMatrix& matrix, LayerCom
textureCacheCompositingThread()->collectGarbage();
}
-static float texcoords[4 * 2] = { 0, 0, 0, 1, 1, 1, 1, 0 };
+static float texcoords[4 * 2] = { 0, 0, 1, 0, 1, 1, 0, 1 };
void LayerRenderer::compositeBuffer(const TransformationMatrix& transform, const FloatRect& contents, BlackBerry::Platform::Graphics::Buffer* buffer, bool contentsOpaque, float opacity)
{
@@ -408,48 +378,51 @@ void LayerRenderer::compositeBuffer(const TransformationMatrix& transform, const
return;
FloatQuad vertices(transform.mapPoint(contents.minXMinYCorner()),
- transform.mapPoint(contents.minXMaxYCorner()),
- transform.mapPoint(contents.maxXMaxYCorner()),
- transform.mapPoint(contents.maxXMinYCorner()));
+ transform.mapPoint(contents.minXMaxYCorner()),
+ transform.mapPoint(contents.maxXMaxYCorner()),
+ transform.mapPoint(contents.maxXMinYCorner()));
if (!vertices.boundingBox().intersects(m_clipRect))
return;
- bool blending = !contentsOpaque || opacity < 1.0f;
- if (blending) {
+ if (!contentsOpaque || opacity < 1.0f) {
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- }
+ } else
+ glDisable(GL_BLEND);
- glUseProgram(m_layerProgramObject[LayerData::LayerProgramShaderRGBA]);
- glUniform1f(m_alphaLocation[LayerData::LayerProgramShaderRGBA], opacity);
+ if (BlackBerry::Platform::Graphics::lockAndBindBufferGLTexture(buffer, GL_TEXTURE_2D)) {
+ const GLES2Program& program = useProgram(LayerProgramRGBA);
+ glUniform1f(program.opacityLocation(), opacity);
- glVertexAttribPointer(m_positionLocation, 2, GL_FLOAT, GL_FALSE, 0, &vertices);
- glVertexAttribPointer(m_texCoordLocation, 2, GL_FLOAT, GL_FALSE, 0, texcoords);
+ glVertexAttribPointer(program.positionLocation(), 2, GL_FLOAT, GL_FALSE, 0, &vertices);
+ glVertexAttribPointer(program.texCoordLocation(), 2, GL_FLOAT, GL_FALSE, 0, texcoords);
- if (BlackBerry::Platform::Graphics::lockAndBindBufferGLTexture(buffer, GL_TEXTURE_2D)) {
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
BlackBerry::Platform::Graphics::releaseBufferGLTexture(buffer);
}
-
- if (blending)
- glDisable(GL_BLEND);
}
-void LayerRenderer::drawCheckerboardPattern(const TransformationMatrix& transform, const FloatRect& contents)
+void LayerRenderer::drawColor(const TransformationMatrix& transform, const FloatRect& contents, const Color& color)
{
FloatQuad vertices(transform.mapPoint(contents.minXMinYCorner()),
- transform.mapPoint(contents.minXMaxYCorner()),
- transform.mapPoint(contents.maxXMaxYCorner()),
- transform.mapPoint(contents.maxXMinYCorner()));
+ transform.mapPoint(contents.minXMaxYCorner()),
+ transform.mapPoint(contents.maxXMaxYCorner()),
+ transform.mapPoint(contents.maxXMinYCorner()));
if (!vertices.boundingBox().intersects(m_clipRect))
return;
- glUseProgram(m_checkerProgramObject);
+ const GLES2Program& program = useProgram(ColorProgram);
+
+ if (color.alpha() < 255) {
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ } else
+ glDisable(GL_BLEND);
- glVertexAttribPointer(m_positionLocation, 2, GL_FLOAT, GL_FALSE, 0, &vertices);
- glVertexAttribPointer(m_texCoordLocation, 2, GL_FLOAT, GL_FALSE, 0, texcoords);
+ glUniform4f(m_colorColorLocation, color.red() / 255.0, color.green() / 255.0, color.blue() / 255.0, color.alpha() / 255.0);
+ glVertexAttribPointer(program.positionLocation(), 2, GL_FLOAT, GL_FALSE, 0, &vertices);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
}
@@ -468,10 +441,13 @@ bool LayerRenderer::useSurface(LayerRendererSurface* surface)
surface->ensureTexture();
+ GLuint texid = surface->texture()->platformTexture();
+
if (!m_fbo)
glGenFramebuffers(1, &m_fbo);
+ glBindTexture(GL_TEXTURE_2D, 0);
glBindFramebuffer(GL_FRAMEBUFFER, m_fbo);
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, surface->texture()->textureId(), 0);
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texid, 0);
#ifndef NDEBUG
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
@@ -487,6 +463,11 @@ bool LayerRenderer::useSurface(LayerRendererSurface* surface)
void LayerRenderer::drawLayersOnSurfaces(const Vector<RefPtr<LayerCompositingThread> >& surfaceLayers)
{
+ // Normally, an upside-down transform is used, as is the GL custom. However, when drawing
+ // layers to surfaces, a right-side-up transform is used, so we need to switch the winding order
+ // for culling.
+ glFrontFace(GL_CCW);
+
for (int i = surfaceLayers.size() - 1; i >= 0; i--) {
LayerCompositingThread* layer = surfaceLayers[i].get();
LayerRendererSurface* surface = layer->layerRendererSurface();
@@ -503,7 +484,7 @@ void LayerRenderer::drawLayersOnSurfaces(const Vector<RefPtr<LayerCompositingThr
#if ENABLE(CSS_FILTERS)
if (!m_filterRenderer)
- m_filterRenderer = LayerFilterRenderer::create(m_positionLocation, m_texCoordLocation);
+ m_filterRenderer = LayerFilterRenderer::create(GLES2Program::PositionAttributeIndex, GLES2Program::TexCoordAttributeIndex);
if (layer->filterOperationsChanged()) {
layer->setFilterOperationsChanged(false);
layer->setFilterActions(m_filterRenderer->actionsForOperations(surface, layer->filters().operations()));
@@ -513,13 +494,13 @@ void LayerRenderer::drawLayersOnSurfaces(const Vector<RefPtr<LayerCompositingThr
#endif
}
- // If there are layers drawed on surfaces, we need to switch to default framebuffer.
+ glFrontFace(GL_CW);
+
+ // If there are layers drawn on surfaces, we need to switch to default framebuffer.
// Otherwise, we just need to set viewport.
- if (surfaceLayers.size()) {
- useSurface(0);
- glEnable(GL_SCISSOR_TEST);
- glScissor(m_scissorRect.x(), m_scissorRect.y(), m_scissorRect.width(), m_scissorRect.height());
- }
+ useSurface(0);
+ glEnable(GL_SCISSOR_TEST);
+ glScissor(m_scissorRect.x(), m_scissorRect.y(), m_scissorRect.width(), m_scissorRect.height());
}
void LayerRenderer::addLayer(LayerCompositingThread* layer)
@@ -541,6 +522,11 @@ void LayerRenderer::addLayerToReleaseTextureResourcesList(LayerCompositingThread
m_layersLockingTextureResources.add(layer);
}
+static int glRound(float f)
+{
+ return floorf(f + 0.5f);
+}
+
// Transform normalized device coordinates to window coordinates
// as specified in the OpenGL ES 2.0 spec section 2.12.1.
IntRect LayerRenderer::toOpenGLWindowCoordinates(const FloatRect& r) const
@@ -549,7 +535,16 @@ IntRect LayerRenderer::toOpenGLWindowCoordinates(const FloatRect& r) const
float vh2 = m_viewport.height() / 2.0;
float ox = m_viewport.x() + vw2;
float oy = m_viewport.y() + vh2;
- return enclosingIntRect(FloatRect(r.x() * vw2 + ox, r.y() * vh2 + oy, r.width() * vw2, r.height() * vh2));
+ return IntRect(glRound(r.x() * vw2 + ox), glRound(r.y() * vh2 + oy), glRound(r.width() * vw2), glRound(r.height() * vh2));
+}
+
+static FloatRect toPixelCoordinates(const FloatRect& rect, const IntRect& viewport, int surfaceHeight)
+{
+ float vw2 = viewport.width() / 2.0;
+ float vh2 = viewport.height() / 2.0;
+ float ox = viewport.x() + vw2;
+ float oy = surfaceHeight - (viewport.y() + vh2);
+ return FloatRect(rect.x() * vw2 + ox, -(rect.y() + rect.height()) * vh2 + oy, rect.width() * vw2, rect.height() * vh2);
}
// Transform normalized device coordinates to window coordinates as WebKit understands them.
@@ -557,26 +552,45 @@ IntRect LayerRenderer::toOpenGLWindowCoordinates(const FloatRect& r) const
// The OpenGL surface may be larger than the WebKit window, and OpenGL window coordinates
// have origin in bottom left while WebKit window coordinates origin is in top left.
// The viewport is setup to cover the upper portion of the larger OpenGL surface.
-IntRect LayerRenderer::toWebKitWindowCoordinates(const FloatRect& r) const
+IntRect LayerRenderer::toWindowCoordinates(const FloatRect& rect) const
{
- float vw2 = m_viewport.width() / 2.0;
- float vh2 = m_viewport.height() / 2.0;
- float ox = m_viewport.x() + vw2;
- float oy = m_context->surfaceSize().height() - (m_viewport.y() + vh2);
- return enclosingIntRect(FloatRect(r.x() * vw2 + ox, -(r.y()+r.height()) * vh2 + oy, r.width() * vw2, r.height() * vh2));
+ return enclosingIntRect(toPixelCoordinates(rect, m_viewport, m_client->context()->surfaceSize().height()));
}
-// Similar to toWebKitWindowCoordinates except that this also takes any zoom into account.
-IntRect LayerRenderer::toWebKitDocumentCoordinates(const FloatRect& r) const
+IntRect LayerRenderer::toPixelViewportCoordinates(const FloatRect& rect) const
{
- // The zoom is the ratio between visibleRect (or layoutRect) and dstRect parameters which are passed to drawLayers
- float zoom = m_visibleRect.width() / m_viewport.width();
- // Could assert here that it doesn't matter whether we choose width or height in the above statement:
- // because both rectangles should have very similar shapes (subject only to pixel rounding error).
-
- IntRect result = toWebKitWindowCoordinates(r);
- result.scale(zoom);
- return result;
+ // The clip rect defines the web page's pixel viewport (to use ViewportAccessor terminology),
+ // not to be confused with the GL viewport. So translate from window coordinates to pixel
+ // viewport coordinates.
+ int surfaceHeight = m_client->context()->surfaceSize().height();
+ FloatRect pixelViewport = toPixelCoordinates(m_clipRect, m_viewport, surfaceHeight);
+ FloatRect result = toPixelCoordinates(rect, m_viewport, surfaceHeight);
+ result.move(-pixelViewport.x(), -pixelViewport.y());
+ return enclosingIntRect(result);
+}
+
+IntRect LayerRenderer::toDocumentViewportCoordinates(const FloatRect& rect) const
+{
+ // Similar to toPixelViewportCoordinates except that this also takes any zoom into account.
+ FloatRect result = toPixelViewportCoordinates(rect);
+ result.scale(1 / m_scale);
+ return enclosingIntRect(result);
+}
+
+void LayerRenderer::drawDebugBorder(const Vector<FloatPoint>& transformedBounds, const Color& borderColor, float borderWidth)
+{
+ if (borderColor.alpha() < 255) {
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ } else
+ glDisable(GL_BLEND);
+
+ const GLES2Program& program = useProgram(ColorProgram);
+ glVertexAttribPointer(program.positionLocation(), 2, GL_FLOAT, GL_FALSE, 0, transformedBounds.data());
+ glUniform4f(m_colorColorLocation, borderColor.red() / 255.0, borderColor.green() / 255.0, borderColor.blue() / 255.0, borderColor.alpha() / 255.0);
+
+ glLineWidth(borderWidth);
+ glDrawArrays(GL_LINE_LOOP, 0, transformedBounds.size());
}
// Draws a debug border around the layer's bounds.
@@ -592,29 +606,31 @@ void LayerRenderer::drawDebugBorder(LayerCompositingThread* layer)
if (!borderColor.alpha())
return;
- glUseProgram(m_colorProgramObject);
- glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, &layer->getTransformedBounds());
- glUniform4f(m_colorColorLocation, borderColor.red() / 255.0, borderColor.green() / 255.0, borderColor.blue() / 255.0, 1);
+ // If we're rendering to a surface, don't include debug border inside the surface.
+ if (m_currentLayerRendererSurface)
+ return;
- glLineWidth(layer->borderWidth());
- glDrawArrays(GL_LINE_LOOP, 0, 4);
+ Vector<FloatPoint> transformedBounds;
+ if (layerAlreadyOnSurface(layer))
+ transformedBounds = layer->layerRendererSurface()->transformedBounds();
+ else
+ transformedBounds = layer->transformedBounds();
+
+ drawDebugBorder(transformedBounds, borderColor, std::max(1.0f, layer->borderWidth()));
}
// Clears a rectangle inside the layer's bounds.
void LayerRenderer::drawHolePunchRect(LayerCompositingThread* layer)
{
- glUseProgram(m_colorProgramObject);
+ const GLES2Program& program = useProgram(ColorProgram);
glUniform4f(m_colorColorLocation, 0, 0, 0, 0);
+ glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ZERO);
- FloatQuad hole = layer->getTransformedHolePunchRect();
- glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, &hole);
+ FloatQuad hole = layer->transformedHolePunchRect();
+ glVertexAttribPointer(program.positionLocation(), 2, GL_FLOAT, GL_FALSE, 0, &hole);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
checkGLError();
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-
- IntRect holeWC = toWebKitWindowCoordinates(hole.boundingBox());
- m_lastRenderingResults.addHolePunchRect(holeWC);
}
void LayerRenderer::prepareFrameRecursive(LayerCompositingThread* layer, double animationTime, bool isContextCurrent)
@@ -638,12 +654,12 @@ void LayerRenderer::prepareFrameRecursive(LayerCompositingThread* layer, double
}
}
- const Vector<RefPtr<LayerCompositingThread> >& sublayers = layer->getSublayers();
+ const Vector<RefPtr<LayerCompositingThread> >& sublayers = layer->sublayers();
for (size_t i = 0; i < sublayers.size(); i++)
prepareFrameRecursive(sublayers[i].get(), animationTime, isContextCurrent);
}
-void LayerRenderer::updateLayersRecursive(LayerCompositingThread* layer, const TransformationMatrix& matrix, Vector<RefPtr<LayerCompositingThread> >& surfaceLayers, float opacity, FloatRect clipRect)
+void LayerRenderer::updateLayersRecursive(LayerCompositingThread* layer, const TransformationMatrix& matrix, const TransformationMatrix& projectionMatrix, Vector<RefPtr<LayerCompositingThread> >& surfaceLayers, float opacity, FloatRect clipRect)
{
// The contract for LayerCompositingThread::setLayerRenderer is it must be set if the layer has been rendered.
// So do it now, before we render it in compositeLayersRecursive.
@@ -684,25 +700,58 @@ void LayerRenderer::updateLayersRecursive(LayerCompositingThread* layer, const T
// Layer whose hasFixedContainer is true will get scrolled relative to
// the fixed positioned parent.
if (!layer->hasFixedContainer() && (layer->isFixedPosition() || layer->hasFixedAncestorInDOMTree())) {
- // The basic idea here is to set visible y to the value we want, and
- // layout y to the value WebCore layouted the fixed element to.
- float maximumScrollY = m_contentsSize.height() - m_visibleRect.height();
- float visibleY = max(0.0f, m_visibleRect.y());
- float layoutY = max(0.0f, min(maximumScrollY, (float)m_layoutRect.y()));
-
- // For stuff located on the lower half of the screen, we zoom relative to bottom.
- // This trick allows us to display fixed positioned elements aligned to top or
- // bottom correctly when panning and zooming, without actually knowing the
- // numeric values of the top and bottom CSS attributes.
- // In fact, the position is the location of the anchor, so to find the top left
- // we have to subtract the anchor times the bounds. The anchor defaults to
- // (0.5, 0.5) for most layers.
- if (position.y() - anchorPoint.y() * bounds.height() > layoutY + m_layoutRect.height() / 2) {
- visibleY = min<float>(m_contentsSize.height(), m_visibleRect.y() + m_visibleRect.height());
- layoutY = min(m_contentsSize.height(), max(0, m_layoutRect.y()) + m_layoutRect.height());
+ FloatRect layoutRect = m_layoutRect;
+ FloatSize contentsSize = m_contentsSize;
+ FloatRect visibleRect = m_visibleRect;
+ for (LayerCompositingThread* curr = layer->superlayer(); curr; curr = curr->superlayer()) {
+
+ if (curr->isContainerForFixedPositionLayers()) {
+ layoutRect = curr->frameVisibleRect();
+ contentsSize = curr->frameContentsSize();
+
+ // If we reach a container for fixed position layers, and it has its override's position set, it means it is a scrollable iframe
+ // currently being scrolled. Otherwise, use the WebKit-thread scroll position stored in frameVisibleRect().
+ if (curr->override()->isPositionSet()) {
+ // Inverted logic of
+ // FloatPoint layerPosition(-scrollPosition.x() + anchor.x() * bounds.width(),
+ // -scrollPosition.y() + anchor.y() * bounds.height());
+ FloatPoint scrollPosition(
+ -(curr->override()->position().x() - (curr->anchorPoint().x() * curr->bounds().width())),
+ -(curr->override()->position().y() - (curr->anchorPoint().y() * curr->bounds().height())));
+ visibleRect = FloatRect(scrollPosition, layoutRect.size());
+ } else
+ visibleRect = layoutRect;
+
+ break;
+ }
}
+ FloatPoint maximumScrollPosition = FloatPoint(0, 0) + (contentsSize - visibleRect.size());
+ FloatPoint maximumLayoutScrollPosition = FloatPoint(0, 0) + (contentsSize - layoutRect.size());
+
+ // The basic idea here is to set visible x/y to the value we want, and
+ // layout x/y to the value WebCore layouted the fixed element to.
+ float visibleY;
+ float layoutY;
+ if (layer->isFixedToTop()) {
+ visibleY = max(0.0f, min(maximumScrollPosition.y(), visibleRect.y()));
+ layoutY = max(0.0f, min(maximumLayoutScrollPosition.y(), layoutRect.y()));
+ } else {
+ visibleY = min(contentsSize.height(), visibleRect.y() + visibleRect.height());
+ layoutY = min(contentsSize.height(), max(0.0f, layoutRect.y()) + layoutRect.height());
+ }
position.setY(position.y() + (visibleY - layoutY));
+
+ float visibleX;
+ float layoutX;
+ if (layer->isFixedToLeft()) {
+ visibleX = max(0.0f, min(maximumScrollPosition.x(), visibleRect.x()));
+ layoutX = max(0.0f, min(maximumLayoutScrollPosition.x(), layoutRect.x()));
+ } else {
+ visibleX = min(contentsSize.width(), visibleRect.x() + visibleRect.width());
+ layoutX = min(contentsSize.width(), max(0.0f, layoutRect.x()) + layoutRect.width());
+ }
+ position.setX(position.x() + (visibleX - layoutX));
}
// Offset between anchor point and the center of the quad.
@@ -721,6 +770,7 @@ void LayerRenderer::updateLayersRecursive(LayerCompositingThread* layer, const T
// Calculate the layer's opacity.
opacity *= layer->opacity();
+ TransformationMatrix localProjectionMatrix = projectionMatrix;
#if ENABLE(CSS_FILTERS)
bool useLayerRendererSurface = layer->maskLayer() || layer->replicaLayer() || layer->filters().size();
#else
@@ -738,44 +788,44 @@ void LayerRenderer::updateLayersRecursive(LayerCompositingThread* layer, const T
layer->setDrawOpacity(1.0);
surface->setDrawOpacity(opacity);
- surface->setDrawTransform(localMatrix);
+ surface->setDrawTransform(localMatrix, projectionMatrix);
if (layer->replicaLayer()) {
TransformationMatrix replicaMatrix = localMatrix;
replicaMatrix.translate3d(-0.5 * bounds.width(), -0.5 * bounds.height(), 0);
replicaMatrix.translate3d(layer->replicaLayer()->position().x(), layer->replicaLayer()->position().y(), 0);
replicaMatrix.multiply(layer->replicaLayer()->transform());
replicaMatrix.translate3d(centerOffsetX, centerOffsetY, 0);
- surface->setReplicaDrawTransform(replicaMatrix);
+ surface->setReplicaDrawTransform(replicaMatrix, projectionMatrix);
}
- IntRect drawRect = enclosingIntRect(FloatRect(FloatPoint(), bounds));
- surface->setContentRect(drawRect);
+ IntRect contentRect = enclosingIntRect(FloatRect(FloatPoint::zero(), bounds));
+ surface->setContentRect(contentRect);
- TransformationMatrix projectionMatrix = orthoMatrix(drawRect.x(), drawRect.maxX(), drawRect.y(), drawRect.maxY(), -1000, 1000);
+ localProjectionMatrix = orthoMatrix(contentRect.x(), contentRect.maxX(), contentRect.y(), contentRect.maxY(), -1000, 1000);
// The origin of the new surface is the upper left corner of the layer.
TransformationMatrix drawTransform;
drawTransform.translate3d(0.5 * bounds.width(), 0.5 * bounds.height(), 0);
// This layer will start using new transformation.
- localMatrix = projectionMatrix * drawTransform;
+ localMatrix = drawTransform;
surfaceLayers.append(layer);
}
- layer->setDrawTransform(m_scale, localMatrix);
+ layer->setDrawTransform(m_scale, localMatrix, localProjectionMatrix);
#if ENABLE(VIDEO)
- bool layerVisible = clipRect.intersects(layer->getDrawRect()) || layer->mediaPlayer();
+ bool layerVisible = clipRect.intersects(layer->boundingBox()) || layer->mediaPlayer();
#else
- bool layerVisible = clipRect.intersects(layer->getDrawRect());
+ bool layerVisible = clipRect.intersects(layer->boundingBox());
#endif
if (layer->needsTexture() && layerVisible) {
- IntRect dirtyRect = toWebKitWindowCoordinates(intersection(layer->getDrawRect(), clipRect));
+ IntRect dirtyRect = toWindowCoordinates(intersection(layer->boundingBox(), clipRect));
m_lastRenderingResults.addDirtyRect(dirtyRect);
}
if (layer->masksToBounds())
- clipRect.intersect(layer->getDrawRect());
+ clipRect.intersect(layer->boundingBox());
// Flatten to 2D if the layer doesn't preserve 3D.
if (!layer->preserves3D()) {
@@ -783,8 +833,7 @@ void LayerRenderer::updateLayersRecursive(LayerCompositingThread* layer, const T
localMatrix.setM23(0);
localMatrix.setM31(0);
localMatrix.setM32(0);
- // This corresponds to the depth range specified in the original orthographic projection matrix
- localMatrix.setM33(0.001);
+ localMatrix.setM33(1);
localMatrix.setM34(0);
localMatrix.setM43(0);
}
@@ -798,9 +847,9 @@ void LayerRenderer::updateLayersRecursive(LayerCompositingThread* layer, const T
// M[s] = M * Tr[-center]
localMatrix.translate3d(-bounds.width() * 0.5, -bounds.height() * 0.5, 0);
- const Vector<RefPtr<LayerCompositingThread> >& sublayers = layer->getSublayers();
+ const Vector<RefPtr<LayerCompositingThread> >& sublayers = layer->sublayers();
for (size_t i = 0; i < sublayers.size(); i++)
- updateLayersRecursive(sublayers[i].get(), localMatrix, surfaceLayers, opacity, clipRect);
+ updateLayersRecursive(sublayers[i].get(), localMatrix, localProjectionMatrix, surfaceLayers, opacity, clipRect);
}
static bool hasRotationalComponent(const TransformationMatrix& m)
@@ -817,10 +866,10 @@ static void collect3DPreservingLayers(Vector<LayerCompositingThread*>& layers)
{
for (size_t i = 0; i < layers.size(); ++i) {
LayerCompositingThread* layer = layers[i];
- if (!layer->preserves3D() || !layer->getSublayers().size())
+ if (!layer->preserves3D() || !layer->sublayers().size())
continue;
- Vector<LayerCompositingThread*> sublayers = rawPtrVectorFromRefPtrVector(layer->getSublayers());
+ Vector<LayerCompositingThread*> sublayers = rawPtrVectorFromRefPtrVector(layer->sublayers());
collect3DPreservingLayers(sublayers);
layers.insert(i+1, sublayers);
i += sublayers.size();
@@ -831,9 +880,9 @@ void LayerRenderer::compositeLayersRecursive(LayerCompositingThread* layer, int
{
FloatRect rect;
if (layerAlreadyOnSurface(layer))
- rect = layer->layerRendererSurface()->drawRect();
+ rect = layer->layerRendererSurface()->boundingBox();
else
- rect = layer->getDrawRect();
+ rect = layer->boundingBox();
#if ENABLE(VIDEO)
bool layerVisible = clipRect.intersects(rect) || layer->mediaPlayer();
@@ -866,12 +915,11 @@ void LayerRenderer::compositeLayersRecursive(LayerCompositingThread* layer, int
// Draw the surface onto another surface or screen.
bool drawSurface = layerAlreadyOnSurface(layer);
// The texture format for the surface is RGBA.
- LayerData::LayerProgramShader shader = drawSurface ? LayerData::LayerProgramShaderRGBA : layer->layerProgramShader();
+ LayerData::LayerProgram layerProgram = drawSurface ? LayerData::LayerProgramRGBA : layer->layerProgram();
if (!drawSurface) {
- glUseProgram(m_layerProgramObject[shader]);
- glUniform1f(m_alphaLocation[shader], layer->drawOpacity());
- layer->drawTextures(m_scale, m_positionLocation, m_texCoordLocation, m_visibleRect);
+ const GLES2Program& program = useLayerProgram(layerProgram);
+ layer->drawTextures(program, m_scale, m_visibleRect, clipRect);
} else {
// Draw the reflection if it exists.
if (layer->replicaLayer()) {
@@ -882,29 +930,19 @@ void LayerRenderer::compositeLayersRecursive(LayerCompositingThread* layer, int
if (!mask && layer->replicaLayer())
mask = layer->replicaLayer()->maskLayer();
- glUseProgram(mask ? m_layerMaskProgramObject[shader] : m_layerProgramObject[shader]);
- glUniform1f(mask ? m_maskAlphaLocation[shader] : m_alphaLocation[shader], layer->layerRendererSurface()->drawOpacity());
- layer->drawSurface(layer->layerRendererSurface()->replicaDrawTransform(), mask, m_positionLocation, m_texCoordLocation);
+ const GLES2Program& program = useLayerProgram(layerProgram, mask);
+ layer->drawSurface(program, layer->layerRendererSurface()->replicaDrawTransform(), mask);
}
- glUseProgram(layer->maskLayer() ? m_layerMaskProgramObject[shader] : m_layerProgramObject[shader]);
- glUniform1f(layer->maskLayer() ? m_maskAlphaLocation[shader] : m_alphaLocation[shader], layer->layerRendererSurface()->drawOpacity());
- layer->drawSurface(layer->layerRendererSurface()->drawTransform(), layer->maskLayer(), m_positionLocation, m_texCoordLocation);
- }
-
- if (layer->hasMissingTextures()) {
- glDisable(GL_BLEND);
- glUseProgram(m_checkerProgramObject);
- layer->drawMissingTextures(m_scale, m_positionLocation, m_texCoordLocation, m_visibleRect);
- glEnable(GL_BLEND);
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ const GLES2Program& program = useLayerProgram(layerProgram, layer->maskLayer());
+ layer->drawSurface(program, layer->layerRendererSurface()->drawTransform(), layer->maskLayer());
}
}
// Draw the debug border if there is one.
drawDebugBorder(layer);
- // The texture for the LayerRendererSurface can be released after the surface was drawed on another surface.
+ // The texture for the LayerRendererSurface can be released after the surface was drawn on another surface.
if (layerAlreadyOnSurface(layer)) {
layer->layerRendererSurface()->releaseTexture();
return;
@@ -916,6 +954,7 @@ void LayerRenderer::compositeLayersRecursive(LayerCompositingThread* layer, int
if (stencilClip) {
if (!m_stencilCleared) {
+ glStencilMask(0xffffffff);
glClearStencil(0);
glClear(GL_STENCIL_BUFFER_BIT);
m_stencilCleared = true;
@@ -926,20 +965,20 @@ void LayerRenderer::compositeLayersRecursive(LayerCompositingThread* layer, int
glStencilOp(GL_KEEP, GL_INCR, GL_INCR);
updateScissorIfNeeded(clipRect);
- glUseProgram(m_colorProgramObject);
+ const GLES2Program& program = useProgram(ColorProgram);
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
- glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, &layer->getTransformedBounds());
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+ glVertexAttribPointer(program.positionLocation(), 2, GL_FLOAT, GL_FALSE, 0, layer->transformedBounds().data());
+ glDrawArrays(GL_TRIANGLE_FAN, 0, layer->transformedBounds().size());
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
}
if (layer->masksToBounds())
- clipRect.intersect(layer->getDrawRect());
+ clipRect.intersect(layer->boundingBox());
// Here, we need to sort the whole subtree of layers with preserve-3d. It
// affects all children, and the children of any children with preserve-3d,
// and so on.
- Vector<LayerCompositingThread*> sublayers = rawPtrVectorFromRefPtrVector(layer->getSublayers());
+ Vector<LayerCompositingThread*> sublayers = rawPtrVectorFromRefPtrVector(layer->sublayers());
bool preserves3D = layer->preserves3D();
bool superlayerPreserves3D = layer->superlayer() && layer->superlayer()->preserves3D();
@@ -949,7 +988,7 @@ void LayerRenderer::compositeLayersRecursive(LayerCompositingThread* layer, int
// children, so bail.
if (preserves3D && !superlayerPreserves3D) {
collect3DPreservingLayers(sublayers);
- std::stable_sort(sublayers.begin(), sublayers.end(), compareLayerZ);
+ std::stable_sort(sublayers.begin(), sublayers.end(), compareLayerW);
}
int newStencilValue = stencilClip ? stencilValue+1 : stencilValue;
@@ -961,7 +1000,7 @@ void LayerRenderer::compositeLayersRecursive(LayerCompositingThread* layer, int
if (preserves3D && superlayerPreserves3D)
continue;
- compositeLayersRecursive(sublayer, newStencilValue, clipRect);
+ compositeLayersRecursive(sublayer, newStencilValue, clipRect);
}
if (stencilClip) {
@@ -969,10 +1008,10 @@ void LayerRenderer::compositeLayersRecursive(LayerCompositingThread* layer, int
glStencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE);
updateScissorIfNeeded(clipRect);
- glUseProgram(m_colorProgramObject);
+ const GLES2Program& program = useProgram(ColorProgram);
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
- glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, &layer->getTransformedBounds());
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+ glVertexAttribPointer(program.positionLocation(), 2, GL_FLOAT, GL_FALSE, 0, layer->transformedBounds().data());
+ glDrawArrays(GL_TRIANGLE_FAN, 0, layer->transformedBounds().size());
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
if (!stencilValue)
@@ -1000,7 +1039,7 @@ void LayerRenderer::updateScissorIfNeeded(const FloatRect& clipRect)
bool LayerRenderer::makeContextCurrent()
{
- bool ret = m_context->makeCurrent();
+ bool ret = m_client->context()->makeCurrent();
if (ret && m_isRobustnessSupported) {
if (m_glGetGraphicsResetStatusEXT() != GL_NO_ERROR) {
BlackBerry::Platform::logAlways(BlackBerry::Platform::LogLevelCritical, "Robust OpenGL context has been reset. Aborting.");
@@ -1010,24 +1049,10 @@ bool LayerRenderer::makeContextCurrent()
return ret;
}
-// Binds the given attribute name to a common location across all programs
-// used by the compositor. This allows the code to bind the attributes only once
-// even when switching between programs.
-void LayerRenderer::bindCommonAttribLocation(int location, const char* attribName)
-{
- for (int i = 0; i < LayerData::NumberOfLayerProgramShaders; ++i) {
- glBindAttribLocation(m_layerProgramObject[i], location, attribName);
- glBindAttribLocation(m_layerMaskProgramObject[i], location, attribName);
- }
-
- glBindAttribLocation(m_colorProgramObject, location, attribName);
- glBindAttribLocation(m_checkerProgramObject, location, attribName);
-}
-
-bool LayerRenderer::initializeSharedGLObjects()
+bool LayerRenderer::createProgram(ProgramIndex program)
{
// Shaders for drawing the layer contents.
- char vertexShaderString[] =
+ const char* vertexShaderString =
"attribute vec4 a_position; \n"
"attribute vec2 a_texCoord; \n"
"varying vec2 v_texCoord; \n"
@@ -1037,7 +1062,7 @@ bool LayerRenderer::initializeSharedGLObjects()
" v_texCoord = a_texCoord; \n"
"} \n";
- char fragmentShaderStringRGBA[] =
+ const char* fragmentShaderStringRGBA =
"varying mediump vec2 v_texCoord; \n"
"uniform lowp sampler2D s_texture; \n"
"uniform lowp float alpha; \n"
@@ -1046,7 +1071,7 @@ bool LayerRenderer::initializeSharedGLObjects()
" gl_FragColor = texture2D(s_texture, v_texCoord) * alpha; \n"
"} \n";
- char fragmentShaderStringBGRA[] =
+ const char* fragmentShaderStringBGRA =
"varying mediump vec2 v_texCoord; \n"
"uniform lowp sampler2D s_texture; \n"
"uniform lowp float alpha; \n"
@@ -1055,7 +1080,7 @@ bool LayerRenderer::initializeSharedGLObjects()
" gl_FragColor = texture2D(s_texture, v_texCoord).bgra * alpha; \n"
"} \n";
- char fragmentShaderStringMaskRGBA[] =
+ const char* fragmentShaderStringMaskRGBA =
"varying mediump vec2 v_texCoord; \n"
"uniform lowp sampler2D s_texture; \n"
"uniform lowp sampler2D s_mask; \n"
@@ -1067,7 +1092,7 @@ bool LayerRenderer::initializeSharedGLObjects()
" gl_FragColor = vec4(texColor.x, texColor.y, texColor.z, texColor.w) * alpha * maskColor.w; \n"
"} \n";
- char fragmentShaderStringMaskBGRA[] =
+ const char* fragmentShaderStringMaskBGRA =
"varying mediump vec2 v_texCoord; \n"
"uniform lowp sampler2D s_texture; \n"
"uniform lowp sampler2D s_mask; \n"
@@ -1080,137 +1105,133 @@ bool LayerRenderer::initializeSharedGLObjects()
"} \n";
// Shaders for drawing the debug borders around the layers.
- char colorVertexShaderString[] =
+ const char* colorVertexShaderString =
"attribute vec4 a_position; \n"
"void main() \n"
"{ \n"
" gl_Position = a_position; \n"
"} \n";
- char colorFragmentShaderString[] =
+ const char* colorFragmentShaderString =
"uniform lowp vec4 color; \n"
"void main() \n"
"{ \n"
" gl_FragColor = color; \n"
"} \n";
- // FIXME: get screen size, get light/dark color, use
- // string manipulation methods to insert those constants into
- // the shader source.
- static Color lightColor(0xfb, 0xfd, 0xff);
- // checkerboardColorDark()
- static Color darkColor(0xe8, 0xee, 0xf7);
- int checkerSize = 20;
- String tmp(
- "uniform mediump float scale; \n"
- "uniform mediump vec2 origin; \n"
- "uniform mediump float surfaceHeight; \n"
- "void main() \n"
- "{ \n"
- " const mediump float grid = GRID; \n"
- " const lowp vec4 lightColor = LIGHT_COLOR; \n"
- " const lowp vec4 darkColor = DARK_COLOR; \n"
- " mediump float tmp = grid * scale; \n"
- " gl_FragColor = mod(floor((gl_FragCoord.x + origin.x) / tmp) + floor((surfaceHeight - gl_FragCoord.y + origin.y) / tmp), 2.0) > 0.99 \n"
- " ? lightColor : darkColor; \n"
- "} \n");
-
- // Let WTF::String be our preprocessor
- tmp.replace("LIGHT_COLOR", String::format("vec4(%.4f, %.4f, %.4f, 1.0)", lightColor.red() / 255.0, lightColor.green() / 255.0, lightColor.blue() / 255.0));
- tmp.replace("DARK_COLOR", String::format("vec4(%.4f, %.4f, %.4f, 1.0)", darkColor.red() / 255.0, darkColor.green() / 255.0, darkColor.blue() / 255.0));
- tmp.replace("GRID", String::format("%.3f", (float)checkerSize));
- CString checkerFragmentShaderString = tmp.latin1();
-
- if (!makeContextCurrent())
+ const char* vertexShader = 0;
+ const char* fragmentShader = 0;
+
+ switch (program) {
+ case LayerProgramRGBA:
+ case LayerProgramBGRA:
+ case LayerMaskProgramRGBA:
+ case LayerMaskProgramBGRA:
+ vertexShader = vertexShaderString;
+ break;
+ case ColorProgram:
+ vertexShader = colorVertexShaderString;
+ break;
+ case NumberOfPrograms:
return false;
+ }
- m_layerProgramObject[LayerData::LayerProgramShaderRGBA] =
- loadShaderProgram(vertexShaderString, fragmentShaderStringRGBA);
- if (!m_layerProgramObject[LayerData::LayerProgramShaderRGBA])
- LOG_ERROR("Failed to create shader program for RGBA layers");
-
- m_layerProgramObject[LayerData::LayerProgramShaderBGRA] =
- loadShaderProgram(vertexShaderString, fragmentShaderStringBGRA);
- if (!m_layerProgramObject[LayerData::LayerProgramShaderBGRA])
- LOG_ERROR("Failed to create shader program for BGRA layers");
-
- m_layerMaskProgramObject[LayerData::LayerProgramShaderRGBA] =
- loadShaderProgram(vertexShaderString, fragmentShaderStringMaskRGBA);
- if (!m_layerMaskProgramObject[LayerData::LayerProgramShaderRGBA])
- LOG_ERROR("Failed to create shader mask program for RGBA layers");
+ switch (program) {
+ case LayerProgramRGBA:
+ fragmentShader = fragmentShaderStringRGBA;
+ break;
+ case LayerProgramBGRA:
+ fragmentShader = fragmentShaderStringBGRA;
+ break;
+ case LayerMaskProgramRGBA:
+ fragmentShader = fragmentShaderStringMaskRGBA;
+ break;
+ case LayerMaskProgramBGRA:
+ fragmentShader = fragmentShaderStringMaskBGRA;
+ break;
+ case ColorProgram:
+ fragmentShader = colorFragmentShaderString;
+ break;
+ case NumberOfPrograms:
+ return false;
+ }
- m_layerMaskProgramObject[LayerData::LayerProgramShaderBGRA] =
- loadShaderProgram(vertexShaderString, fragmentShaderStringMaskBGRA);
- if (!m_layerMaskProgramObject[LayerData::LayerProgramShaderBGRA])
- LOG_ERROR("Failed to create shader mask program for BGRA layers");
+ if (!vertexShader || !fragmentShader)
+ return false;
- m_colorProgramObject = loadShaderProgram(colorVertexShaderString, colorFragmentShaderString);
- if (!m_colorProgramObject)
- LOG_ERROR("Failed to create shader program for debug borders");
+ GLuint programObject = loadShaderProgram(vertexShader, fragmentShader);
+ if (!programObject) {
+ LOG_ERROR("Failed to create program %u", program);
+ return false;
+ }
- m_checkerProgramObject = loadShaderProgram(colorVertexShaderString, checkerFragmentShaderString.data());
- if (!m_checkerProgramObject)
- LOG_ERROR("Failed to create shader program for checkerboard pattern");
+ m_programs[program].m_program = programObject;
- // Specify the attrib location for the position and make it the same for all programs to
- // avoid binding re-binding the vertex attributes.
- bindCommonAttribLocation(m_positionLocation, "a_position");
- bindCommonAttribLocation(m_texCoordLocation, "a_texCoord");
+ // Binds the given attribute name to a common location across all programs
+ // used by the compositor. This allows the code to bind the attributes only once
+ // even when switching between programs.
+ glBindAttribLocation(programObject, GLES2Program::PositionAttributeIndex, "a_position");
+ glBindAttribLocation(programObject, GLES2Program::TexCoordAttributeIndex, "a_texCoord");
checkGLError();
- // Re-link the shaders to get the new attrib location to take effect.
- for (int i = 0; i < LayerData::NumberOfLayerProgramShaders; ++i) {
- glLinkProgram(m_layerProgramObject[i]);
- glLinkProgram(m_layerMaskProgramObject[i]);
- }
-
- glLinkProgram(m_colorProgramObject);
- glLinkProgram(m_checkerProgramObject);
+ // Re-link the shader to get the new attrib location to take effect.
+ glLinkProgram(programObject);
checkGLError();
// Get locations of uniforms for the layer content shader program.
- for (int i = 0; i < LayerData::NumberOfLayerProgramShaders; ++i) {
- m_samplerLocation[i] = glGetUniformLocation(m_layerProgramObject[i], "s_texture");
- m_alphaLocation[i] = glGetUniformLocation(m_layerProgramObject[i], "alpha");
- glUseProgram(m_layerProgramObject[i]);
- glUniform1i(m_samplerLocation[i], 0);
- m_maskSamplerLocation[i] = glGetUniformLocation(m_layerMaskProgramObject[i], "s_texture");
- m_maskSamplerLocationMask[i] = glGetUniformLocation(m_layerMaskProgramObject[i], "s_mask");
- m_maskAlphaLocation[i] = glGetUniformLocation(m_layerMaskProgramObject[i], "alpha");
- glUseProgram(m_layerMaskProgramObject[i]);
- glUniform1i(m_maskSamplerLocation[i], 0);
- glUniform1i(m_maskSamplerLocationMask[i], 1);
+ m_programs[program].m_locations[GLES2Program::OpacityUniform] = glGetUniformLocation(programObject, "alpha");
+ switch (program) {
+ case LayerProgramRGBA:
+ case LayerProgramBGRA: {
+ GLint samplerLocation = glGetUniformLocation(programObject, "s_texture");
+ glUseProgram(programObject);
+ glUniform1i(samplerLocation, 0);
+ break;
+ }
+ case LayerMaskProgramRGBA:
+ case LayerMaskProgramBGRA: {
+ GLint maskSamplerLocation = glGetUniformLocation(programObject, "s_texture");
+ GLint maskSamplerLocationMask = glGetUniformLocation(programObject, "s_mask");
+ glUseProgram(programObject);
+ glUniform1i(maskSamplerLocation, 0);
+ glUniform1i(maskSamplerLocationMask, 1);
+ break;
+ }
+ case ColorProgram:
+ // Get locations of uniforms for the debug border shader program.
+ m_colorColorLocation = glGetUniformLocation(programObject, "color");
+ break;
+ case NumberOfPrograms:
+ return false;
}
-
- // Get locations of uniforms for the debug border shader program.
- m_colorColorLocation = glGetUniformLocation(m_colorProgramObject, "color");
-
- // Get locations of uniforms for the checkerboard shader program.
- m_checkerScaleLocation = glGetUniformLocation(m_checkerProgramObject, "scale");
- m_checkerOriginLocation = glGetUniformLocation(m_checkerProgramObject, "origin");
- m_checkerSurfaceHeightLocation = glGetUniformLocation(m_checkerProgramObject, "surfaceHeight");
return true;
}
-IntRect LayerRenderingResults::holePunchRect(unsigned index) const
+const GLES2Program& LayerRenderer::useProgram(ProgramIndex index)
{
- if (index >= m_holePunchRects.size())
- return IntRect();
+ ASSERT(index < NumberOfPrograms);
+ const GLES2Program& program = m_programs[index];
+ if (!program.isValid() && !createProgram(index))
+ return program;
+
+ glUseProgram(program.m_program);
+
+ glEnableVertexAttribArray(program.positionLocation());
+ if (index != ColorProgram)
+ glEnableVertexAttribArray(program.texCoordLocation());
- return m_holePunchRects.at(index);
+ return program;
}
-void LayerRenderingResults::addHolePunchRect(const IntRect& rect)
+const GLES2Program& LayerRenderer::useLayerProgram(LayerData::LayerProgram layerProgram, bool isMask /* = false */)
{
-#if DEBUG_CLIPPING
- printf("LayerRenderingResults::addHolePunchRect (%d,%d %dx%d)\n", rect.x(), rect.y(), rect.width(), rect.height());
- fflush(stdout);
-#endif
- if (!rect.isEmpty())
- m_holePunchRects.append(rect);
+ int program = layerProgram;
+ if (isMask)
+ program += MaskPrograms;
+ return useProgram(static_cast<ProgramIndex>(program));
}
void LayerRenderingResults::addDirtyRect(const IntRect& rect)
diff --git a/Source/WebCore/platform/graphics/blackberry/LayerRenderer.h b/Source/WebCore/platform/graphics/blackberry/LayerRenderer.h
index 671c4a18d..4957ec633 100644
--- a/Source/WebCore/platform/graphics/blackberry/LayerRenderer.h
+++ b/Source/WebCore/platform/graphics/blackberry/LayerRenderer.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010, 2011, 2012 Research In Motion Limited. All rights reserved.
+ * Copyright (C) 2010, 2011, 2012, 2013 Research In Motion Limited. All rights reserved.
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -41,6 +41,7 @@
#include "TransformationMatrix.h"
#include <BlackBerryPlatformGLES2Context.h>
+#include <BlackBerryPlatformGLES2Program.h>
#include <BlackBerryPlatformIntRectRegion.h>
#include <wtf/HashSet.h>
#include <wtf/Noncopyable.h>
@@ -49,17 +50,15 @@
namespace WebCore {
+class Color;
class LayerCompositingThread;
+class LayerRendererClient;
class LayerRendererSurface;
class LayerRenderingResults {
public:
LayerRenderingResults() : wasEmpty(true), needsAnimationFrame(false) { }
- void addHolePunchRect(const IntRect&);
- IntRect holePunchRect(size_t index) const;
- size_t holePunchRectSize() { return m_holePunchRects.size(); }
-
static const int NumberOfDirtyRects = 3;
const IntRect& dirtyRect(int i) const { return m_dirtyRects[i]; }
void addDirtyRect(const IntRect& dirtyRect);
@@ -72,7 +71,6 @@ public:
bool needsAnimationFrame;
private:
- Vector<IntRect> m_holePunchRects; // Rects are in compositing surface coordinates.
IntRect m_dirtyRects[NumberOfDirtyRects];
};
@@ -82,11 +80,13 @@ class LayerRenderer {
public:
static TransformationMatrix orthoMatrix(float left, float right, float bottom, float top, float nearZ, float farZ);
- static PassOwnPtr<LayerRenderer> create(BlackBerry::Platform::Graphics::GLES2Context*);
+ static PassOwnPtr<LayerRenderer> create(LayerRendererClient*);
- LayerRenderer(BlackBerry::Platform::Graphics::GLES2Context*);
+ LayerRenderer(LayerRendererClient*);
~LayerRenderer();
+ LayerRendererClient* client() const { return m_client; }
+
void releaseLayerResources();
// In order to render the layers, you must do the following 3 operations, in order.
@@ -108,7 +108,7 @@ public:
// transform is the model-view-project matrix that goes all the way from contents to normalized device coordinates.
void compositeLayers(const TransformationMatrix&, LayerCompositingThread* rootLayer);
void compositeBuffer(const TransformationMatrix&, const FloatRect& contents, BlackBerry::Platform::Graphics::Buffer*, bool contentsOpaque, float opacity);
- void drawCheckerboardPattern(const TransformationMatrix&, const FloatRect& contents);
+ void drawColor(const TransformationMatrix&, const FloatRect& contents, const Color&);
// Keep track of layers that need cleanup when the LayerRenderer is destroyed
void addLayer(LayerCompositingThread*);
@@ -119,10 +119,7 @@ public:
bool hardwareCompositing() const { return m_hardwareCompositing; }
- void setClearSurfaceOnDrawLayers(bool clear) { m_clearSurfaceOnDrawLayers = clear; }
- bool clearSurfaceOnDrawLayers() const { return m_clearSurfaceOnDrawLayers; }
-
- BlackBerry::Platform::Graphics::GLES2Context* context() const { return m_context; }
+ BlackBerry::Platform::Graphics::GLES2Context* context() const;
const LayerRenderingResults& lastRenderingResults() const { return m_lastRenderingResults; }
@@ -130,17 +127,21 @@ public:
// Used when a layer discovers during rendering that it needs a commit.
void setNeedsCommit() { m_needsCommit = true; }
- IntRect toWebKitDocumentCoordinates(const FloatRect&) const;
+ IntRect toWindowCoordinates(const FloatRect&) const;
+ IntRect toPixelViewportCoordinates(const FloatRect&) const;
+ IntRect toDocumentViewportCoordinates(const FloatRect&) const;
// If the layer has already been drawed on a surface.
bool layerAlreadyOnSurface(LayerCompositingThread*) const;
+ void drawDebugBorder(const Vector<FloatPoint>&, const Color&, float borderWidth);
+
static GLuint loadShader(GLenum type, const char* shaderSource);
static GLuint loadShaderProgram(const char* vertexShaderSource, const char* fragmentShaderSource);
private:
void prepareFrameRecursive(LayerCompositingThread*, double animationTime, bool isContextCurrent);
- void updateLayersRecursive(LayerCompositingThread*, const TransformationMatrix& parentMatrix, Vector<RefPtr<LayerCompositingThread> >& surfaceLayers, float opacity, FloatRect clipRect);
+ void updateLayersRecursive(LayerCompositingThread*, const TransformationMatrix& parentMatrix, const TransformationMatrix& projectionMatrix, Vector<RefPtr<LayerCompositingThread> >& surfaceLayers, float opacity, FloatRect clipRect);
void compositeLayersRecursive(LayerCompositingThread*, int stencilValue, FloatRect clipRect);
void updateScissorIfNeeded(const FloatRect& clipRect);
@@ -151,37 +152,37 @@ private:
void drawHolePunchRect(LayerCompositingThread*);
IntRect toOpenGLWindowCoordinates(const FloatRect&) const;
- IntRect toWebKitWindowCoordinates(const FloatRect&) const;
-
- void bindCommonAttribLocation(int location, const char* attribName);
bool makeContextCurrent();
- bool initializeSharedGLObjects();
+ enum ProgramIndex {
+ LayerProgramRGBA = LayerData::LayerProgramRGBA,
+ LayerProgramBGRA = LayerData::LayerProgramBGRA,
+
+ MaskPrograms,
+ LayerMaskProgramRGBA = MaskPrograms + LayerData::LayerProgramRGBA,
+ LayerMaskProgramBGRA = MaskPrograms + LayerData::LayerProgramBGRA,
- // GL shader program object IDs.
- unsigned m_layerProgramObject[LayerData::NumberOfLayerProgramShaders];
- unsigned m_layerMaskProgramObject[LayerData::NumberOfLayerProgramShaders];
- unsigned m_colorProgramObject;
- unsigned m_checkerProgramObject;
+ InternalPrograms,
+ ColorProgram = InternalPrograms,
+
+ NumberOfPrograms
+ };
+
+ bool createProgram(ProgramIndex);
+ const BlackBerry::Platform::Graphics::GLES2Program& useProgram(ProgramIndex);
+ const BlackBerry::Platform::Graphics::GLES2Program& useLayerProgram(LayerData::LayerProgram, bool isMask = false);
+
+ LayerRendererClient* m_client;
+
+ BlackBerry::Platform::Graphics::GLES2Program m_programs[NumberOfPrograms];
// Shader uniform and attribute locations.
- const int m_positionLocation;
- const int m_texCoordLocation;
#if ENABLE(CSS_FILTERS)
OwnPtr<LayerFilterRenderer> m_filterRenderer;
#endif
- int m_samplerLocation[LayerData::NumberOfLayerProgramShaders];
- int m_alphaLocation[LayerData::NumberOfLayerProgramShaders];
- int m_maskSamplerLocation[LayerData::NumberOfLayerProgramShaders];
- int m_maskSamplerLocationMask[LayerData::NumberOfLayerProgramShaders];
- int m_maskAlphaLocation[LayerData::NumberOfLayerProgramShaders];
-
int m_colorColorLocation;
- int m_checkerScaleLocation;
- int m_checkerOriginLocation;
- int m_checkerSurfaceHeightLocation;
// Current draw configuration.
double m_scale;
@@ -198,15 +199,12 @@ private:
LayerRendererSurface* m_currentLayerRendererSurface;
bool m_hardwareCompositing;
- bool m_clearSurfaceOnDrawLayers;
// Map associating layers with textures ids used by the GL compositor.
typedef HashSet<LayerCompositingThread*> LayerSet;
LayerSet m_layers;
LayerSet m_layersLockingTextureResources;
- BlackBerry::Platform::Graphics::GLES2Context* m_context;
-
bool m_isRobustnessSupported;
PFNGLGETGRAPHICSRESETSTATUSEXTPROC m_glGetGraphicsResetStatusEXT;
diff --git a/Source/WebCore/platform/graphics/blackberry/LayerRendererClient.h b/Source/WebCore/platform/graphics/blackberry/LayerRendererClient.h
new file mode 100644
index 000000000..a6e0655e4
--- /dev/null
+++ b/Source/WebCore/platform/graphics/blackberry/LayerRendererClient.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2013 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef LayerRendererClient_h
+#define LayerRendererClient_h
+
+#if USE(ACCELERATED_COMPOSITING)
+
+namespace BlackBerry {
+namespace Platform {
+namespace Graphics {
+class GLES2Context;
+}
+}
+}
+
+namespace WebCore {
+
+class LayerRendererClient {
+public:
+ virtual ~LayerRendererClient() { }
+
+ virtual void layerRendererDestroyed() { }
+
+ virtual BlackBerry::Platform::Graphics::GLES2Context* context() const = 0;
+
+ virtual bool shouldChildWindowsUseDocumentCoordinates() = 0;
+};
+
+} // namespace WebCore
+
+#endif // USE(ACCELERATED_COMPOSITING)
+
+#endif
diff --git a/Source/WebCore/platform/graphics/blackberry/LayerRendererSurface.cpp b/Source/WebCore/platform/graphics/blackberry/LayerRendererSurface.cpp
index dea1dd002..33f7f4129 100644
--- a/Source/WebCore/platform/graphics/blackberry/LayerRendererSurface.cpp
+++ b/Source/WebCore/platform/graphics/blackberry/LayerRendererSurface.cpp
@@ -24,6 +24,7 @@
#include "LayerCompositingThread.h"
#include "LayerRenderer.h"
+#include "LayerUtilities.h"
#include "TextureCacheCompositingThread.h"
namespace WebCore {
@@ -45,37 +46,27 @@ void LayerRendererSurface::setContentRect(const IntRect& contentRect)
m_size = contentRect.size();
}
-FloatRect LayerRendererSurface::drawRect() const
+FloatRect LayerRendererSurface::boundingBox() const
{
- float bx = m_size.width() / 2.0;
- float by = m_size.height() / 2.0;
-
- FloatQuad transformedBounds;
- transformedBounds.setP1(m_drawTransform.mapPoint(FloatPoint(-bx, -by)));
- transformedBounds.setP2(m_drawTransform.mapPoint(FloatPoint(-bx, by)));
- transformedBounds.setP3(m_drawTransform.mapPoint(FloatPoint(bx, by)));
- transformedBounds.setP4(m_drawTransform.mapPoint(FloatPoint(bx, -by)));
-
- FloatRect rect = transformedBounds.boundingBox();
-
- if (m_ownerLayer->replicaLayer()) {
- FloatQuad bounds;
- bounds.setP1(m_replicaDrawTransform.mapPoint(FloatPoint(-bx, -by)));
- bounds.setP2(m_replicaDrawTransform.mapPoint(FloatPoint(-bx, by)));
- bounds.setP3(m_replicaDrawTransform.mapPoint(FloatPoint(bx, by)));
- bounds.setP4(m_replicaDrawTransform.mapPoint(FloatPoint(bx, -by)));
- rect.unite(bounds.boundingBox());
- }
+ FloatRect rect = WebCore::boundingBox(transformedBounds());
+
+ if (m_ownerLayer->replicaLayer())
+ rect.unite(m_replicaDrawTransform.mapQuad(FloatRect(-origin(), size())).boundingBox());
return rect;
}
+Vector<FloatPoint, 4> LayerRendererSurface::transformedBounds() const
+{
+ return toVector<FloatPoint, 4>(m_drawTransform.mapQuad(FloatRect(-origin(), size())));
+}
+
bool LayerRendererSurface::ensureTexture()
{
if (!m_texture)
m_texture = textureCacheCompositingThread()->createTexture();
- return m_texture->protect(m_size);
+ return m_texture->protect(m_size, BlackBerry::Platform::Graphics::AlwaysBacked);
}
void LayerRendererSurface::releaseTexture()
diff --git a/Source/WebCore/platform/graphics/blackberry/LayerRendererSurface.h b/Source/WebCore/platform/graphics/blackberry/LayerRendererSurface.h
index 20bcfad6c..cbffa9aff 100644
--- a/Source/WebCore/platform/graphics/blackberry/LayerRendererSurface.h
+++ b/Source/WebCore/platform/graphics/blackberry/LayerRendererSurface.h
@@ -24,7 +24,7 @@
#include "FloatRect.h"
#include "IntRect.h"
#include "IntSize.h"
-#include "Texture.h"
+#include "LayerTexture.h"
#include "TransformationMatrix.h"
namespace WebCore {
@@ -45,22 +45,26 @@ public:
FloatRect clipRect() const { return m_clipRect; }
void setClipRect(const FloatRect& rect) { m_clipRect = rect; }
- void setDrawTransform(const TransformationMatrix& matrix) { m_drawTransform = matrix; }
+ FloatPoint origin() const { return FloatPoint(m_size.width() / 2.0f, m_size.height() / 2.0f); }
+
+ void setDrawTransform(const TransformationMatrix& matrix, const TransformationMatrix& projectionMatrix) { m_drawTransform = projectionMatrix * matrix; }
const TransformationMatrix& drawTransform() const { return m_drawTransform; }
- void setReplicaDrawTransform(const TransformationMatrix& matrix) { m_replicaDrawTransform = matrix; }
+ void setReplicaDrawTransform(const TransformationMatrix& matrix, const TransformationMatrix& projectionMatrix) { m_replicaDrawTransform = projectionMatrix * matrix; }
const TransformationMatrix& replicaDrawTransform() const { return m_replicaDrawTransform; }
- FloatRect drawRect() const;
+ // These use normalized device coordinates
+ FloatRect boundingBox() const;
+ Vector<FloatPoint, 4> transformedBounds() const;
bool ensureTexture();
void releaseTexture();
- Texture* texture() const { return m_texture.get(); }
+ LayerTexture* texture() const { return m_texture.get(); }
float drawOpacity() { return m_opacity; }
void setDrawOpacity(float opacity) { m_opacity = opacity; }
private:
- RefPtr<Texture> m_texture;
+ RefPtr<LayerTexture> m_texture;
FloatRect m_contentRect;
FloatRect m_clipRect;
diff --git a/Source/WebCore/platform/graphics/blackberry/LayerTexture.cpp b/Source/WebCore/platform/graphics/blackberry/LayerTexture.cpp
new file mode 100644
index 000000000..db3c9d5ba
--- /dev/null
+++ b/Source/WebCore/platform/graphics/blackberry/LayerTexture.cpp
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2011, 2012, 2013 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "LayerTexture.h"
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "Color.h"
+#include "IntRect.h"
+#include "TextureCacheCompositingThread.h"
+
+#include <BlackBerryPlatformGLES2ContextState.h>
+#include <BlackBerryPlatformGraphicsContext.h>
+#include <GLES2/gl2.h>
+#include <wtf/CurrentTime.h>
+#include <wtf/OwnArrayPtr.h>
+
+namespace WebCore {
+
+LayerTexture::LayerTexture(bool isColor)
+ : m_protectionCount(0)
+ , m_buffer(0)
+ , m_isColor(isColor)
+ , m_bufferSizeInBytes(0)
+{
+ textureCacheCompositingThread()->install(this, IntSize(), BlackBerry::Platform::Graphics::BackedWhenNecessary);
+}
+
+LayerTexture::~LayerTexture()
+{
+ textureCacheCompositingThread()->textureDestroyed(this);
+}
+
+void LayerTexture::updateContents(BlackBerry::Platform::Graphics::Buffer* buffer)
+{
+ if (m_buffer)
+ BlackBerry::Platform::Graphics::destroyBuffer(m_buffer);
+ m_buffer = buffer;
+ size_t newBufferSizeInBytes = BlackBerry::Platform::Graphics::bufferSizeInBytes(m_buffer);
+ textureCacheCompositingThread()->textureSizeInBytesChanged(this, newBufferSizeInBytes - m_bufferSizeInBytes);
+ m_bufferSizeInBytes = newBufferSizeInBytes;
+}
+
+void LayerTexture::setContentsToColor(const Color& color)
+{
+ RGBA32 rgba = color.rgb();
+
+ if (m_buffer)
+ BlackBerry::Platform::Graphics::destroyBuffer(m_buffer);
+
+ m_buffer = BlackBerry::Platform::Graphics::createBuffer(IntSize(1, 1), BlackBerry::Platform::Graphics::BackedWhenNecessary);
+ if (BlackBerry::Platform::Graphics::PlatformGraphicsContext* gc = lockBufferDrawable(m_buffer)) {
+ gc->setFillColor(rgba);
+ gc->addFillRect(BlackBerry::Platform::FloatRect(0, 0, 1, 1));
+ }
+ releaseBufferDrawable(m_buffer);
+
+ IntSize oldSize = m_size;
+ m_size = IntSize(1, 1);
+ if (m_size != oldSize)
+ textureCacheCompositingThread()->textureResized(this, oldSize);
+}
+
+bool LayerTexture::protect(const IntSize& size, BlackBerry::Platform::Graphics::BufferType type)
+{
+ if (!m_buffer) {
+ // We may have been evicted by the TextureCacheCompositingThread,
+ // attempt to install us again.
+ if (!textureCacheCompositingThread()->install(this, size, type))
+ return false;
+ }
+
+ ++m_protectionCount;
+
+ if (m_size == size)
+ return true;
+
+ textureCacheCompositingThread()->resizeTexture(this, size, type);
+
+ return true;
+}
+
+Platform3DObject LayerTexture::platformTexture() const
+{
+ using namespace BlackBerry::Platform::Graphics;
+
+ Platform3DObject platformTexture = reinterpret_cast<Platform3DObject>(platformBufferHandle(m_buffer));
+
+ // Force creation if it's 0.
+ if (!platformTexture) {
+ // This call can cause display list to render to backing, which can mutate a lot of GL state.
+ GLES2ContextState::VertexAttributeStateSaver vertexAttribStateSaver;
+ GLES2ContextState::ProgramStateSaver programSaver;
+ GLES2ContextState::TextureAndFBOStateSaver textureSaver;
+
+ lockAndBindBufferGLTexture(m_buffer, GL_TEXTURE_2D);
+ platformTexture = reinterpret_cast<Platform3DObject>(platformBufferHandle(m_buffer));
+ }
+
+ return platformTexture;
+}
+
+} // namespace WebCore
+
+#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebCore/platform/graphics/blackberry/Texture.h b/Source/WebCore/platform/graphics/blackberry/LayerTexture.h
index 6dc4fdbcc..eff417b9c 100644
--- a/Source/WebCore/platform/graphics/blackberry/Texture.h
+++ b/Source/WebCore/platform/graphics/blackberry/LayerTexture.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011, 2012 Research In Motion Limited. All rights reserved.
+ * Copyright (C) 2011, 2012, 2013 Research In Motion Limited. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -16,52 +16,54 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef Texture_h
-#define Texture_h
+#ifndef LayerTexture_h
+#define LayerTexture_h
#if USE(ACCELERATED_COMPOSITING)
+#include "GraphicsTypes3D.h"
#include "IntSize.h"
+#include <BlackBerryPlatformGraphics.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
-class SkBitmap;
-
namespace WebCore {
class Color;
class IntRect;
class TextureCacheCompositingThread;
-// Texture encapsulates a volatile texture - at any time, the underlying OpenGL
+// LayerTexture encapsulates a volatile texture - at any time, the underlying OpenGL
// texture may be deleted by the TextureCacheCompositingThread. The user must
-// check using Texture::isDirty() immediately before using it, every time.
-// The only way to prevent eviction this is to call Texture::protect().
+// check using LayerTexture::isDirty() immediately before using it, every time.
+// The only way to prevent eviction this is to call LayerTexture::protect().
// If the texture isDirty(), you must updateContents() before you can use it.
-class Texture : public RefCounted<Texture> {
+class LayerTexture : public RefCounted<LayerTexture> {
public:
- static PassRefPtr<Texture> create(bool isColor = false)
+ static PassRefPtr<LayerTexture> create(bool isColor = false)
{
- return adoptRef(new Texture(isColor));
+ return adoptRef(new LayerTexture(isColor));
}
- ~Texture();
+ ~LayerTexture();
- unsigned textureId() const { return m_textureId; }
+ bool isDirty() const { return !m_buffer; }
- bool isDirty() const { return !m_textureId; }
- bool hasTexture() const { return m_textureId; }
+ BlackBerry::Platform::Graphics::Buffer* buffer() const { return m_buffer; }
bool isColor() const { return m_isColor; }
- bool isOpaque() const { return m_isOpaque; }
bool isProtected() const { return m_protectionCount > 0; }
void protect() { ++m_protectionCount; }
void unprotect() { --m_protectionCount; }
- bool protect(const IntSize&);
- void updateContents(const SkBitmap& contents, const IntRect& dirtyRect, const IntRect& tile, bool isOpaque);
+ // This will ensure a buffer is allocated for this texture with the requested backing and size.
+ bool protect(const IntSize&, BlackBerry::Platform::Graphics::BufferType = BlackBerry::Platform::Graphics::BackedWhenNecessary);
+
+ Platform3DObject platformTexture() const;
+
+ void updateContents(BlackBerry::Platform::Graphics::Buffer*);
void setContentsToColor(const Color&);
IntSize size() const { return m_size; }
@@ -69,30 +71,34 @@ public:
int height() const { return m_size.height(); }
static int bytesPerPixel() { return 4; }
+ size_t sizeInBytes() const { return m_bufferSizeInBytes; }
+
private:
friend class TextureCacheCompositingThread;
- Texture(bool isColor = false);
-
- void setTextureId(unsigned id)
+ LayerTexture(bool isColor = false);
+ void setBuffer(BlackBerry::Platform::Graphics::Buffer* buffer)
{
- m_textureId = id;
+ m_buffer = buffer;
- // We assume it is a newly allocated texture,
+ // We assume it is a newly allocated buffer,
// and thus empty, or 0, which would of course
// be empty.
m_size = IntSize();
+ m_bufferSizeInBytes = 0;
}
+ void setSize(const IntSize& size) { m_size = size; }
+
int m_protectionCount;
- unsigned m_textureId;
+ BlackBerry::Platform::Graphics::Buffer* m_buffer;
IntSize m_size;
bool m_isColor;
- bool m_isOpaque;
+ size_t m_bufferSizeInBytes;
};
} // namespace WebCore
#endif // USE(ACCELERATED_COMPOSITING)
-#endif // Texture_h
+#endif // LayerTexture_h
diff --git a/Source/WebCore/platform/graphics/blackberry/LayerTile.cpp b/Source/WebCore/platform/graphics/blackberry/LayerTile.cpp
index 9eb6f836b..7e9332d7c 100644
--- a/Source/WebCore/platform/graphics/blackberry/LayerTile.cpp
+++ b/Source/WebCore/platform/graphics/blackberry/LayerTile.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011, 2012 Research In Motion Limited. All rights reserved.
+ * Copyright (C) 2011, 2012, 2013 Research In Motion Limited. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -27,7 +27,8 @@
namespace WebCore {
LayerTile::LayerTile()
- : m_contentsDirty(false)
+ : m_scale(0)
+ , m_contentsDirty(false)
, m_visible(false)
{
}
@@ -38,23 +39,21 @@ LayerTile::~LayerTile()
setVisible(false);
}
-void LayerTile::setContents(const SkBitmap& contents, const IntRect& tileRect, const TileIndex& index, bool isOpaque)
+void LayerTile::setContents(BlackBerry::Platform::Graphics::Buffer* contents)
{
- setTexture(textureCacheCompositingThread()->textureForTiledContents(contents, tileRect, index, isOpaque));
+ m_scale = 0; // Resolution independent
+ setTexture(textureCacheCompositingThread()->textureForContents(contents));
}
-void LayerTile::setContentsToColor(const Color& color)
+void LayerTile::updateContents(BlackBerry::Platform::Graphics::Buffer* contents, double scale)
{
- setTexture(textureCacheCompositingThread()->textureForColor(color));
-}
-
-void LayerTile::updateContents(const SkBitmap& contents, const IntRect& dirtyRect, const IntRect& tileRect, bool isOpaque)
-{
- setTexture(textureCacheCompositingThread()->updateContents(m_texture, contents, dirtyRect, tileRect, isOpaque));
+ m_scale = scale;
+ setTexture(textureCacheCompositingThread()->updateContents(m_texture, contents));
}
void LayerTile::discardContents()
{
+ m_scale = 0; // Unknown scale
setTexture(0);
}
@@ -76,7 +75,7 @@ void LayerTile::setVisible(bool visible)
m_texture->unprotect();
}
-void LayerTile::setTexture(PassRefPtr<Texture> texture)
+void LayerTile::setTexture(PassRefPtr<LayerTexture> texture)
{
// Clear this flag regardless of the value of the texture parameter.
// If it's 0, isDirty() will return true anyway.
diff --git a/Source/WebCore/platform/graphics/blackberry/LayerTile.h b/Source/WebCore/platform/graphics/blackberry/LayerTile.h
index ce97d21e9..83a365435 100644
--- a/Source/WebCore/platform/graphics/blackberry/LayerTile.h
+++ b/Source/WebCore/platform/graphics/blackberry/LayerTile.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011, 2012 Research In Motion Limited. All rights reserved.
+ * Copyright (C) 2011, 2012, 2013 Research In Motion Limited. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -21,15 +21,12 @@
#if USE(ACCELERATED_COMPOSITING)
-#include "Texture.h"
+#include "LayerTexture.h"
#include <wtf/RefPtr.h>
-class SkBitmap;
-
namespace WebCore {
-class Color;
class IntRect;
class TileIndex;
@@ -39,30 +36,31 @@ public:
LayerTile();
~LayerTile();
- Texture* texture() const { return m_texture.get(); }
+ LayerTexture* texture() const { return m_texture.get(); }
bool isVisible() const { return m_visible; }
void setVisible(bool);
bool isDirty() const { return m_contentsDirty || !m_texture || m_texture->isDirty(); }
- bool hasTexture() const { return m_texture && m_texture->hasTexture(); }
+ bool hasTexture() const { return m_texture && m_texture->buffer(); }
- void setContents(const SkBitmap& contents, const IntRect& tileRect, const TileIndex&, bool isOpaque);
- void setContentsToColor(const Color&);
- void updateContents(const SkBitmap& contents, const IntRect& dirtyRect, const IntRect& tileRect, bool isOpaque);
+ void setContents(BlackBerry::Platform::Graphics::Buffer*);
+ void updateContents(BlackBerry::Platform::Graphics::Buffer*, double scale);
void discardContents();
- // The current texture is an accurate preview of this layer, but a more
- // detailed texture could be obtained by repainting the layer. Used when
- // zoom level changes.
+ // Returns 0 if contents are resolution independent or scale is simply unknown.
+ double contentsScale() const { return m_scale; }
+
+ // The texture contents are dirty due to appearance of page changing, or a change in contents scale.
void setContentsDirty() { m_contentsDirty = true; }
private:
- void setTexture(PassRefPtr<Texture>);
+ void setTexture(PassRefPtr<LayerTexture>);
// Never assign to m_texture directly, use setTexture() above.
- RefPtr<Texture> m_texture;
+ RefPtr<LayerTexture> m_texture;
+ double m_scale;
bool m_contentsDirty : 1;
bool m_visible : 1;
};
diff --git a/Source/WebCore/platform/graphics/blackberry/LayerTileIndex.h b/Source/WebCore/platform/graphics/blackberry/LayerTileIndex.h
index 574e372d3..4df008728 100644
--- a/Source/WebCore/platform/graphics/blackberry/LayerTileIndex.h
+++ b/Source/WebCore/platform/graphics/blackberry/LayerTileIndex.h
@@ -66,7 +66,7 @@ inline bool operator!=(const TileIndex& a, const TileIndex& b)
namespace WTF {
template<> struct IntHash<WebCore::TileIndex> {
- static unsigned hash(const WebCore::TileIndex& key) { return pairIntHash(key.i(), key.j()); }
+ static unsigned hash(const WebCore::TileIndex& key) { return intHash((static_cast<uint64_t>(key.i()) << 32 | key.j())); }
static bool equal(const WebCore::TileIndex& a, const WebCore::TileIndex& b) { return a == b; }
static const bool safeToCompareToEmptyOrDeleted = true;
};
diff --git a/Source/WebCore/platform/graphics/blackberry/LayerTiler.cpp b/Source/WebCore/platform/graphics/blackberry/LayerTiler.cpp
index cd2801e2d..5e4b22fc4 100644
--- a/Source/WebCore/platform/graphics/blackberry/LayerTiler.cpp
+++ b/Source/WebCore/platform/graphics/blackberry/LayerTiler.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011, 2012 Research In Motion Limited. All rights reserved.
+ * Copyright (C) 2011, 2012, 2013 Research In Motion Limited. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -22,59 +22,93 @@
#include "LayerTiler.h"
+#include "AffineTransform.h"
#include "BitmapImage.h"
#include "LayerCompositingThread.h"
#include "LayerMessage.h"
+#include "LayerRenderer.h"
+#include "LayerUtilities.h"
#include "LayerWebKitThread.h"
-#include "NativeImageSkia.h"
#include "TextureCacheCompositingThread.h"
+#include <BlackBerryPlatformGLES2Program.h>
#include <BlackBerryPlatformScreen.h>
#include <BlackBerryPlatformSettings.h>
#include <GLES2/gl2.h>
+#include _NTO_CPU_HDR_(smpxchg.h)
+
+#define DEBUG_LAYER_VISIBILITY 0 // Show visible region of layers as a thick border, and print visible rect.
+#if DEBUG_LAYER_VISIBILITY
+#include <stdlib.h>
+#endif
using namespace std;
+using BlackBerry::Platform::Graphics::GLES2Program;
namespace WebCore {
-// This is used to make the viewport as used in texture visibility calculations
-// slightly larger so textures are uploaded before becoming really visible.
-const float viewportInflationFactor = 1.1f;
+class LayerVisibility {
+public:
+ LayerVisibility(const FloatRect& visibleRect, const HashSet<TileIndex>& tilesNeedingRender)
+ : m_visibleRect(visibleRect)
+ , m_tilesNeedingRender(tilesNeedingRender)
+ {
+ }
-// The tileMultiplier indicates how many tiles will fit in the largest dimension
-// of the screen, if drawn using identity transform.
-// We use half the screen size as tile size, to reduce the texture upload time
-// for small repaint rects. Compared to using screen size directly, this should
-// make most small invalidations 16x faster, unless they're unfortunate enough
-// to intersect two or more tiles, where it would be 8x-1x faster.
-const int tileMultiplier = 4;
+ FloatRect visibleRect() const { return m_visibleRect; }
+ void setVisibleRect(const FloatRect& visibleRect) { m_visibleRect = visibleRect; }
-static void transformPoint(float x, float y, const TransformationMatrix& m, float* result)
-{
- // Squash the Z coordinate so that layers aren't clipped against the near and
- // far plane. Note that the perspective is maintained as we're still passing
- // down the W coordinate.
- result[0] = x * m.m11() + y * m.m21() + m.m41();
- result[1] = x * m.m12() + y * m.m22() + m.m42();
- result[2] = 0;
- result[3] = x * m.m14() + y * m.m24() + m.m44();
-}
+ bool needsRender() const { return !m_tilesNeedingRender.isEmpty(); }
+ bool tileNeedsRender(const TileIndex& index) const { return m_tilesNeedingRender.contains(index); }
+ void markTileAsRendered(const TileIndex& index) { m_tilesNeedingRender.remove(index); m_tilesRendered.add(index); }
+ void swapTilesNeedingRender(HashSet<TileIndex>& tilesNeedingRender) { m_tilesNeedingRender.swap(tilesNeedingRender); }
+
+ void merge(LayerVisibility* visibility)
+ {
+ if (!visibility)
+ return;
+ m_tilesRendered.swap(visibility->m_tilesRendered);
+ for (HashSet<TileIndex>::iterator it = m_tilesRendered.begin(); it != m_tilesRendered.end(); ++it)
+ m_tilesNeedingRender.remove(*it);
+ }
+
+private:
+ FloatRect m_visibleRect;
+ HashSet<TileIndex> m_tilesNeedingRender;
+ HashSet<TileIndex> m_tilesRendered;
+};
+
+// This is used to make the viewport as used in texture visibility calculations
+// slightly larger so textures are uploaded before becoming really visible.
+// Inflation is greater in Y direction (one screenful in either direction) since
+// scrolling vertically is more common, and easily reaches higher velocity, than
+// scrolling horizontally.
+// The viewportInflation is expressed as a fraction to multiply the viewport by, and
+// it is centered.
+// A height of 3 means to consider one screenful above and one screenful below the
+// current viewport as visible.
+const FloatSize viewportInflation(1.2f, 3.0f);
+
+// This is a small optimization to cut down on calls to operator new.
+// Since the compositing thread normally swaps in new visibility objects much more
+// often than the WebKit thread swaps them out, it's likely that it will swap out
+// the previous visibility object and we can reuse that.
+static LayerVisibility* s_spareVisibility = 0;
static IntSize defaultTileSize()
{
- static IntSize screenSize = BlackBerry::Platform::Graphics::Screen::primaryScreen()->nativeSize();
- static int dim = max(screenSize.width(), screenSize.height()) / tileMultiplier;
- return IntSize(dim, dim);
+ static IntSize size(BlackBerry::Platform::Settings::instance()->tileSize());
+ return size;
}
LayerTiler::LayerTiler(LayerWebKitThread* layer)
: m_layer(layer)
- , m_tilingDisabled(false)
+ , m_needsBacking(false)
, m_contentsDirty(false)
, m_tileSize(defaultTileSize())
, m_clearTextureJobs(false)
- , m_hasMissingTextures(false)
- , m_contentsScale(0.0)
+ , m_frontVisibility(0)
+ , m_backVisibility(0)
{
ref(); // This ref() is matched by a deref in layerCompositingThreadDestroyed();
}
@@ -85,6 +119,9 @@ LayerTiler::~LayerTiler()
// before now. We can't call it here because we have no
// OpenGL context.
ASSERT(m_tiles.isEmpty());
+
+ delete m_frontVisibility;
+ delete m_backVisibility;
}
void LayerTiler::layerWebKitThreadDestroyed()
@@ -115,26 +152,40 @@ void LayerTiler::updateTextureContentsIfNeeded(double scale)
{
updateTileSize();
- HashSet<TileIndex> renderJobs;
- {
- MutexLocker locker(m_renderJobsMutex);
- if (!m_contentsDirty && m_renderJobs.isEmpty())
- return;
- renderJobs = m_renderJobs;
+ LayerVisibility* frontVisibility = takeFrontVisibility();
+ if (frontVisibility) {
+ // If we're dirty, start fresh. Otherwise, keep track of tiles rendered so far, to avoid re-rendering the same content.
+ if (!m_contentsDirty)
+ frontVisibility->merge(m_backVisibility);
+ delete m_backVisibility;
+ m_backVisibility = frontVisibility;
}
+ bool needsRender = m_backVisibility && m_backVisibility->needsRender();
+
+ // Check if update is needed
+ if (!m_contentsDirty && !needsRender)
+ return;
+
+#if DEBUG_LAYER_VISIBILITY
+ if (m_backVisibility && !m_backVisibility->visibleRect().isEmpty())
+ printf("Layer 0x%p local visible rect %s\n", m_layer, BlackBerry::Platform::FloatRect(m_backVisibility->visibleRect()).toString().c_str());
+#endif
// There's no point in drawing contents at a higher resolution for scale
// invariant layers.
if (m_layer->sizeIsScaleInvariant())
- scale = 1.0;
-
- bool isZoomJob = false;
- if (scale != m_contentsScale) {
- // The first time around, it does not count as a zoom job.
- if (m_contentsScale)
- isZoomJob = true;
- m_contentsScale = scale;
- }
+ scale = 1;
+
+ // Render only visible tiles. Mask layers are a special case, because they're never considered
+ // visible. Workaround this by always rendering them (a very fast operation with the
+ // BlackBerry::Platform::GraphicsContext since it will just result in ref'ing the mask image).
+ FloatRect visibleRect;
+ if (m_layer->isMask() || m_layer->filters().size())
+ visibleRect = FloatRect(IntPoint::zero(), m_layer->bounds());
+ else if (m_backVisibility)
+ visibleRect = m_backVisibility->visibleRect();
+ else
+ visibleRect = FloatRect(BlackBerry::Platform::FloatRect(BlackBerry::Platform::Settings::instance()->layerTilerPrefillRect()));
IntRect dirtyRect = enclosingIntRect(m_dirtyRect);
IntSize requiredTextureSize;
@@ -146,13 +197,16 @@ void LayerTiler::updateTextureContentsIfNeeded(double scale)
IntRect untransformedBoundsRect(boundsRect);
requiredTextureSize = boundsRect.size();
- if (scale != 1.0) {
+ if (scale != 1) {
TransformationMatrix matrix;
matrix.scale(scale);
dirtyRect = matrix.mapRect(untransformedDirtyRect);
requiredTextureSize = matrix.mapRect(IntRect(IntPoint::zero(), requiredTextureSize)).size();
boundsRect = matrix.mapRect(untransformedBoundsRect);
+ // The visible rect is using unscaled coordinates in most cases.
+ if (m_backVisibility || m_layer->isMask() || m_layer->filters().size())
+ visibleRect = matrix.mapRect(visibleRect);
}
if (requiredTextureSize != m_pendingTextureSize)
@@ -168,12 +222,19 @@ void LayerTiler::updateTextureContentsIfNeeded(double scale)
dirtyRect = IntRect(IntPoint::zero(), requiredTextureSize);
}
- // If the new size is empty, clear the visibility jobs
- if (requiredTextureSize.isEmpty() && renderJobs.size()) {
- renderJobs.clear();
+ IntRect previousTextureRect(IntPoint::zero(), m_pendingTextureSize);
+ if (m_pendingTextureSize != requiredTextureSize) {
+ m_pendingTextureSize = requiredTextureSize;
+ addTextureJob(TextureJob::resizeContents(m_pendingTextureSize));
+ }
- MutexLocker locker(m_renderJobsMutex);
- m_renderJobs.clear();
+ bool contentsDirty = m_contentsDirty;
+ if (m_contentsDirty) {
+ // If we're not going to re-render all the covered tiles, mark those not covered as dirty.
+ if (!visibleRect.contains(dirtyRect))
+ addTextureJob(TextureJob::dirtyContents(dirtyRect));
+ m_contentsDirty = false;
+ m_dirtyRect = FloatRect();
}
// If we need display because we no longer need to be displayed, due to texture size becoming 0 x 0,
@@ -181,154 +242,65 @@ void LayerTiler::updateTextureContentsIfNeeded(double scale)
if (requiredTextureSize.isEmpty() || dirtyRect == IntRect(IntPoint::zero(), requiredTextureSize))
clearTextureJobs();
- HashSet<TileIndex> finishedJobs;
- if (!renderJobs.isEmpty()) {
- if (Image* image = m_layer->contents()) {
- bool isOpaque = false;
- if (image->isBitmapImage())
- isOpaque = !static_cast<BitmapImage*>(image)->currentFrameHasAlpha();
- if (NativeImagePtr nativeImage = image->nativeImageForCurrentFrame()) {
- SkBitmap bitmap = SkBitmap(nativeImage->bitmap());
- addTextureJob(TextureJob::setContents(bitmap, isOpaque));
- }
- } else {
- // There might still be some pending render jobs due to visibility changes.
- for (HashSet<TileIndex>::iterator it = renderJobs.begin(); it != renderJobs.end(); ++it) {
- {
- // Check if the job has been cancelled.
- MutexLocker locker(m_renderJobsMutex);
- if (!m_renderJobs.contains(*it))
- continue;
- m_renderJobs.remove(*it);
- }
+ if (visibleRect.isEmpty())
+ return;
- IntRect tileRect = rectForTile(*it, requiredTextureSize);
- if (tileRect.isEmpty())
- continue;
-
- bool isSolidColor = false;
- Color color;
- SkBitmap bitmap = m_layer->paintContents(tileRect, scale, &isSolidColor, &color);
- // bitmap can be null here. Make requiredTextureSize empty so that we
- // will not try to update and draw the layer.
- if (!bitmap.isNull()) {
- if (isSolidColor)
- addTextureJob(TextureJob::setContentsToColor(color, *it));
- else
- addTextureJob(TextureJob::updateContents(bitmap, tileRect, m_layer->isOpaque()));
- }
-
- finishedJobs.add(*it);
- }
- }
+ HashSet<TileIndex> renderJobs;
+ TileIndex first;
+ TileIndex last;
+ if (m_layer->contentsResolutionIndependent()) {
+ // Resolution independent layers have all the needed data in the first tile.
+ first = last = TileIndex(0, 0);
+ } else {
+ first = indexOfTile(flooredIntPoint(visibleRect.minXMinYCorner()));
+ last = indexOfTile(ceiledIntPoint(visibleRect.maxXMaxYCorner()));
}
+ for (unsigned i = first.i(); i <= last.i(); ++i) {
+ for (unsigned j = first.j(); j <= last.j(); ++j) {
+ TileIndex index(i, j);
+ IntRect tileRect = rectForTile(index, requiredTextureSize);
+ if (tileRect.isEmpty())
+ continue;
- bool didResize = false;
- IntRect previousTextureRect(IntPoint::zero(), m_pendingTextureSize);
- if (m_pendingTextureSize != requiredTextureSize) {
- didResize = true;
- m_pendingTextureSize = requiredTextureSize;
- addTextureJob(TextureJob::resizeContents(m_pendingTextureSize));
+ if (m_backVisibility && m_backVisibility->tileNeedsRender(index)) {
+#if DEBUG_LAYER_VISIBILITY
+ printf("Tile at (%d, %d) needs render\n", index.i(), index.j());
+#endif
+ renderJobs.add(index);
+ m_backVisibility->markTileAsRendered(index);
+ } else if (contentsDirty && dirtyRect.intersects(tileRect))
+ renderJobs.add(index);
+ }
}
- m_contentsDirty = false;
- m_dirtyRect = FloatRect();
- if (dirtyRect.isEmpty() || requiredTextureSize.isEmpty())
+ if (renderJobs.isEmpty())
return;
if (Image* image = m_layer->contents()) {
- bool isOpaque = false;
- if (image->isBitmapImage())
- isOpaque = !static_cast<BitmapImage*>(image)->currentFrameHasAlpha();
- // No point in tiling an image layer, the image is already stored as an SkBitmap
- NativeImagePtr nativeImage = m_layer->contents()->nativeImageForCurrentFrame();
- if (nativeImage) {
- SkBitmap bitmap = SkBitmap(nativeImage->bitmap());
- addTextureJob(TextureJob::setContents(bitmap, isOpaque));
+ // If we need backing, we have no choice but to enforce the tile size, which could cause clipping.
+ // Otherwise, don't clip - include the whole image.
+ IntSize bufferSize = m_needsBacking ? tileSize() : image->size();
+ if (BlackBerry::Platform::Graphics::Buffer* buffer = createBuffer(bufferSize)) {
+ IntRect contentsRect(IntPoint::zero(), image->size());
+ m_layer->paintContents(buffer, contentsRect, scale);
+ addTextureJob(TextureJob::setContents(buffer, contentsRect));
}
- return;
- }
-
- IntPoint topLeft = dirtyRect.minXMinYCorner();
- IntPoint bottomRight = dirtyRect.maxXMaxYCorner(); // This is actually a pixel below and to the right of the dirtyRect.
-
- IntSize tileMaximumSize(tileSize());
- IntRect rectForOneTile(IntPoint::zero(), tileMaximumSize);
- bool wasOneTile = rectForOneTile.contains(previousTextureRect);
- bool isOneTile = rectForOneTile.contains(IntRect(IntPoint::zero(), m_pendingTextureSize));
- IntPoint origin = originOfTile(indexOfTile(topLeft));
- IntRect tileRect;
- for (tileRect.setX(origin.x()); tileRect.x() < bottomRight.x(); tileRect.setX(tileRect.x() + tileMaximumSize.width())) {
- for (tileRect.setY(origin.y()); tileRect.y() < bottomRight.y(); tileRect.setY(tileRect.y() + tileMaximumSize.height())) {
- tileRect.setWidth(min(requiredTextureSize.width() - tileRect.x(), tileMaximumSize.width()));
- tileRect.setHeight(min(requiredTextureSize.height() - tileRect.y(), tileMaximumSize.height()));
-
- IntRect localDirtyRect(dirtyRect);
- localDirtyRect.intersect(tileRect);
- if (localDirtyRect.isEmpty())
- continue;
-
- TileIndex index = indexOfTile(tileRect.location());
-
- // If we already did this as part of one of the render jobs due to
- // visibility changes, don't render that tile again.
- if (finishedJobs.contains(index))
- continue;
-
- if (!shouldPerformRenderJob(index, !isZoomJob)) {
- // Avoid checkerboarding unless the layer is resized. When
- // resized, the contents are likely to change appearance, for
- // example due to aspect ratio change. However, if it is a
- // resize due to zooming, the aspect ratio and content will
- // stay the same, and we can keep the old texture content as a
- // preview.
- // FIXME: the zoom preview only works if we don't re-tile the
- // layer. We need to store texture coordinates in
- // WebCore::Texture to be able to fix that.
- if (didResize && !(isZoomJob && wasOneTile && isOneTile))
- addTextureJob(TextureJob::discardContents(tileRect));
- else
- addTextureJob(TextureJob::dirtyContents(tileRect));
- continue;
- }
-
- // Just in case a new job for this tile has just been inserted by compositing thread.
- removeRenderJob(index);
-
- // FIXME: We are always drawing whole tiles at the moment, because
- // we currently can't keep track of which part of a tile is
- // rendered and which is not. Sending only a subrectangle of a tile
- // to the compositing thread might cause it to be uploaded using
- // glTexImage, if the texture was previously evicted from the cache.
- // The result would be that a subrectangle of the tile was stretched
- // to fit the tile geometry, appearing as a glaring misrendering of
- // the web page.
- bool isSolidColor = false;
- Color color;
- SkBitmap bitmap = m_layer->paintContents(tileRect, scale, &isSolidColor, &color);
- // bitmap can be null here. Make requiredTextureSize empty so that we
- // will not try to update and draw the layer.
- if (!bitmap.isNull()) {
- if (isSolidColor)
- addTextureJob(TextureJob::setContentsToColor(color, index));
- else
- addTextureJob(TextureJob::updateContents(bitmap, tileRect, m_layer->isOpaque()));
+ } else if (m_layer->drawsContent()) {
+ for (HashSet<TileIndex>::iterator it = renderJobs.begin(); it != renderJobs.end(); ++it) {
+ if (BlackBerry::Platform::Graphics::Buffer* buffer = createBuffer(tileSize())) {
+ IntRect tileRect = rectForTile(*it, requiredTextureSize);
+ m_layer->paintContents(buffer, tileRect, scale);
+ addTextureJob(TextureJob::updateContents(buffer, tileRect));
}
}
}
}
-bool LayerTiler::shouldPerformRenderJob(const TileIndex& index, bool allowPrefill)
+BlackBerry::Platform::Graphics::Buffer* LayerTiler::createBuffer(const IntSize& size)
{
- // Tiles that are not currently visible on the compositing thread may still
- // deserve to be rendered if they should be prefilled...
- if (allowPrefill && shouldPrefillTile(index))
- return true;
-
- // Or if they are visible according to the state that's about to be
- // committed. We do a visibility test using the current transform state.
- IntRect contentRect = rectForTile(index, m_pendingTextureSize);
- return m_layer->contentsVisible(LayerWebKitThread::mapFromTransformed(contentRect, m_contentsScale));
+ BlackBerry::Platform::Graphics::BufferType bufferType = m_needsBacking ? BlackBerry::Platform::Graphics::AlwaysBacked : BlackBerry::Platform::Graphics::BackedWhenNecessary;
+ BlackBerry::Platform::Graphics::Buffer* buffer = BlackBerry::Platform::Graphics::createBuffer(size, bufferType);
+ return buffer;
}
void LayerTiler::addTextureJob(const TextureJob& job)
@@ -344,18 +316,53 @@ void LayerTiler::clearTextureJobs()
removeUpdateContentsJobs(m_pendingTextureJobs);
}
-void LayerTiler::commitPendingTextureUploads()
+static size_t backingSizeInBytes = 0;
+
+void LayerTiler::willCommit()
+{
+ backingSizeInBytes = 0;
+}
+
+void LayerTiler::commitPendingTextureUploads(LayerCompositingThread*)
{
if (m_clearTextureJobs) {
removeUpdateContentsJobs(m_textureJobs);
m_clearTextureJobs = false;
}
- for (Vector<TextureJob>::iterator it = m_pendingTextureJobs.begin(); it != m_pendingTextureJobs.end(); ++it)
- m_textureJobs.append(*it);
+ // There's no point in rendering more than the cache capacity during one frame.
+ const size_t maxBackingPerFrame = textureCacheCompositingThread()->memoryLimit();
+
+ for (Vector<TextureJob>::iterator it = m_pendingTextureJobs.begin(); it != m_pendingTextureJobs.end(); ++it) {
+ TextureJob& textureJob = *it;
+
+ // Update backing surface for backed tiles now, to avoid dropping frames during animation.
+ if (textureJob.m_contents && backingSizeInBytes < maxBackingPerFrame) {
+ BlackBerry::Platform::Graphics::updateBufferBackingSurface(textureJob.m_contents);
+ backingSizeInBytes += BlackBerry::Platform::Graphics::bufferSizeInBytes(textureJob.m_contents);
+ }
+
+ m_textureJobs.append(textureJob);
+ }
m_pendingTextureJobs.clear();
}
+LayerVisibility* LayerTiler::swapFrontVisibility(LayerVisibility* visibility)
+{
+ return reinterpret_cast<LayerVisibility*>(_smp_xchg(reinterpret_cast<unsigned*>(&m_frontVisibility), reinterpret_cast<unsigned>(visibility)));
+}
+
+void LayerTiler::setFrontVisibility(const FloatRect& visibleRect, HashSet<TileIndex>& tilesNeedingRender)
+{
+ LayerVisibility* visibility = s_spareVisibility;
+ if (visibility) {
+ visibility->setVisibleRect(visibleRect);
+ visibility->swapTilesNeedingRender(tilesNeedingRender);
+ } else
+ visibility = new LayerVisibility(visibleRect, tilesNeedingRender);
+ s_spareVisibility = swapFrontVisibility(visibility);
+}
+
void LayerTiler::layerVisibilityChanged(LayerCompositingThread*, bool visible)
{
// For visible layers, we handle the tile-level visibility
@@ -363,20 +370,11 @@ void LayerTiler::layerVisibilityChanged(LayerCompositingThread*, bool visible)
if (visible)
return;
- {
- // All tiles are invisible now.
- MutexLocker locker(m_renderJobsMutex);
- m_renderJobs.clear();
- }
-
- for (TileMap::iterator it = m_tiles.begin(); it != m_tiles.end(); ++it) {
- TileIndex index = (*it).key;
- LayerTile* tile = (*it).value;
- tile->setVisible(false);
- }
+ HashSet<TileIndex> emptyTileSet;
+ setFrontVisibility(FloatRect(), emptyTileSet);
}
-void LayerTiler::uploadTexturesIfNeeded(LayerCompositingThread*)
+void LayerTiler::uploadTexturesIfNeeded(LayerCompositingThread* layer)
{
TileJobsMap tileJobsMap;
Deque<TextureJob>::const_iterator textureJobIterEnd = m_textureJobs.end();
@@ -391,15 +389,12 @@ void LayerTiler::uploadTexturesIfNeeded(LayerCompositingThread*)
if (!tile) {
if (origin.x() >= m_requiredTextureSize.width() || origin.y() >= m_requiredTextureSize.height())
continue;
+
tile = new LayerTile();
m_tiles.add(tileJobsIter->key, tile);
}
- IntRect tileRect(origin, tileSize());
- tileRect.setWidth(min(m_requiredTextureSize.width() - tileRect.x(), tileRect.width()));
- tileRect.setHeight(min(m_requiredTextureSize.height() - tileRect.y(), tileRect.height()));
-
- performTileJob(tile, *tileJobsIter->value, tileRect);
+ performTileJob(layer, tile, *tileJobsIter->value);
}
m_textureJobs.clear();
@@ -414,22 +409,18 @@ void LayerTiler::processTextureJob(const TextureJob& job, TileJobsMap& tileJobsM
m_requiredTextureSize = pendingTextureSize;
return;
- }
-
- if (job.m_type == TextureJob::SetContentsToColor) {
- addTileJob(job.m_index, job, tileJobsMap);
+ } else if (job.m_type == TextureJob::DirtyContents) {
+ TileIndex first = indexOfTile(job.m_dirtyRect.minXMinYCorner());
+ TileIndex last = indexOfTile(job.m_dirtyRect.maxXMaxYCorner());
+ for (TileMap::iterator it = m_tiles.begin(); it != m_tiles.end(); ++it) {
+ TileIndex index = (*it).key;
+ if (index.i() >= first.i() && index.j() >= first.j() && index.i() <= last.i() && index.j() <= last.j())
+ (*it).value->setContentsDirty();
+ }
return;
- }
-
- IntSize tileMaximumSize = tileSize();
- IntPoint topLeft = job.m_dirtyRect.minXMinYCorner();
- IntPoint bottomRight = job.m_dirtyRect.maxXMaxYCorner(); // This is actually a pixel below and to the right of the dirtyRect.
- IntPoint origin = originOfTile(indexOfTile(topLeft));
- IntRect tileRect;
- for (tileRect.setX(origin.x()); tileRect.x() < bottomRight.x(); tileRect.setX(tileRect.x() + tileMaximumSize.width())) {
- for (tileRect.setY(origin.y()); tileRect.y() < bottomRight.y(); tileRect.setY(tileRect.y() + tileMaximumSize.height()))
- addTileJob(indexOfTile(tileRect.location()), job, tileJobsMap);
}
+
+ addTileJob(indexOfTile(job.m_dirtyRect.minXMinYCorner()), job, tileJobsMap);
}
void LayerTiler::addTileJob(const TileIndex& index, const TextureJob& job, TileJobsMap& tileJobsMap)
@@ -441,186 +432,184 @@ void LayerTiler::addTileJob(const TileIndex& index, const TextureJob& job, TileJ
if (result.isNewEntry)
return;
- // In this case we leave the previous job.
- if (job.m_type == TextureJob::DirtyContents && result.iterator->value->m_type == TextureJob::DiscardContents)
- return;
-
// Override the previous job.
+ if (result.iterator->value && result.iterator->value->m_contents)
+ BlackBerry::Platform::Graphics::destroyBuffer(result.iterator->value->m_contents);
+
result.iterator->value = &job;
}
-void LayerTiler::performTileJob(LayerTile* tile, const TextureJob& job, const IntRect& tileRect)
+void LayerTiler::performTileJob(LayerCompositingThread* layer, LayerTile* tile, const TextureJob& job)
{
switch (job.m_type) {
- case TextureJob::SetContentsToColor:
- tile->setContentsToColor(job.m_color);
- return;
case TextureJob::SetContents:
- tile->setContents(job.m_contents, tileRect, indexOfTile(tileRect.location()), job.m_isOpaque);
+ tile->setContents(job.m_contents);
return;
case TextureJob::UpdateContents:
- tile->updateContents(job.m_contents, job.m_dirtyRect, tileRect, job.m_isOpaque);
- return;
- case TextureJob::DiscardContents:
- tile->discardContents();
- return;
- case TextureJob::DirtyContents:
- tile->setContentsDirty();
+ tile->updateContents(job.m_contents, layer->contentsScale());
return;
case TextureJob::Unknown:
case TextureJob::ResizeContents:
+ case TextureJob::DirtyContents:
ASSERT_NOT_REACHED();
return;
}
ASSERT_NOT_REACHED();
}
-void LayerTiler::drawTextures(LayerCompositingThread* layer, double scale, int pos, int texCoord)
+bool LayerTiler::drawTile(LayerCompositingThread* layer, LayerTile* tile, const TileIndex& index, double scale, const FloatRect& dst, const FloatRect& dstClip)
{
- drawTexturesInternal(layer, scale, pos, texCoord, false /* drawMissing */);
+ unsigned char globalAlpha = static_cast<unsigned char>(layer->drawOpacity() * 255);
+ bool shouldDrawTile = dst.intersects(dstClip) && globalAlpha;
+
+ // Even if the tile has wrong scale, it can be used as a "preview" if there is no risk of overlap with other tiles.
+ bool tileHasCorrectScale = tile->contentsScale() == 0.0 || tile->contentsScale() == layer->contentsScale();
+ if (!tileHasCorrectScale)
+ shouldDrawTile = shouldDrawTile && (m_tiles.size() == 1 && !index.i() && !index.j());
+
+ if (tile->hasTexture()) {
+ LayerTexture* texture = tile->texture();
+ textureCacheCompositingThread()->textureAccessed(texture);
+
+ if (shouldDrawTile) {
+ TransformationMatrix drawTransform = layer->drawTransform();
+ drawTransform.translate(dst.x(), dst.y());
+ if (layer->contentsResolutionIndependent())
+ drawTransform.scaleNonUniform(dst.width() / m_requiredTextureSize.width(), dst.height() / m_requiredTextureSize.height());
+ else if (tile->contentsScale())
+ drawTransform.scale(1 / tile->contentsScale());
+ if (layer->sizeIsScaleInvariant())
+ drawTransform.scale(1 / scale);
+ blitToBuffer(0, texture->buffer(), reinterpret_cast<BlackBerry::Platform::TransformationMatrix&>(drawTransform),
+ BlackBerry::Platform::Graphics::SourceOver, globalAlpha);
+ }
+ }
+
+ // Return false if the tile needs to be (re-)rendered.
+ return !tile->isDirty() && tileHasCorrectScale;
}
-void LayerTiler::drawMissingTextures(LayerCompositingThread* layer, double scale, int pos, int texCoord)
+static FloatRect inflateViewport(const FloatRect& viewport)
{
- drawTexturesInternal(layer, scale, pos, texCoord, true /* drawMissing */);
+ // Everything is expressed in normalized device coordinates.
+ FloatSize viewportSize(viewport.size());
+ viewportSize.scale(viewportInflation.width(), viewportInflation.height());
+
+ FloatSize viewportOffset(viewport.size());
+ viewportOffset.scale(viewportInflation.width() - 1, viewportInflation.height() - 1);
+ viewportOffset.scale(0.5);
+
+ return FloatRect(viewport.location() - viewportOffset, viewportSize);
}
-void LayerTiler::drawTexturesInternal(LayerCompositingThread* layer, double scale, int positionLocation, int texCoordLocation, bool drawMissing)
+void LayerTiler::drawTextures(LayerCompositingThread* layer, const GLES2Program&, double scale, const FloatRect& clipRect)
{
- const TransformationMatrix& drawTransform = layer->drawTransform();
- FloatSize bounds = layer->bounds();
-
- if (layer->sizeIsScaleInvariant()) {
- bounds.setWidth(bounds.width() / scale);
- bounds.setHeight(bounds.width() / scale);
- }
+ FloatRect boundsRect(-layer->origin(), layer->bounds());
+ if (layer->sizeIsScaleInvariant())
+ boundsRect.scale(1 / scale);
- float texcoords[4 * 2] = { 0, 0, 0, 1, 1, 1, 1, 0 };
- float vertices[4 * 4];
+ FloatRect inflatedViewport = inflateViewport(clipRect);
- glVertexAttribPointer(positionLocation, 4, GL_FLOAT, GL_FALSE, 0, vertices);
- glVertexAttribPointer(texCoordLocation, 2, GL_FLOAT, GL_FALSE, 0, texcoords);
+ // Unprojecting points outside the transformed bounds gives poor numerical stability if there's a perspective effect,
+ // so unproject the clipped transformed bounds instead.
+ Vector<FloatPoint, 4> clipPolygon = intersectPolygonWithRect(layer->transformedBounds(), clipRect);
+ if (clipPolygon.isEmpty()) {
+ // The LayerRenderer figures we're visible, or it wouldn't have called into this method, but we beg to differ.
+ layer->setVisible(false);
+ return;
+ }
- m_hasMissingTextures = false;
+ FloatRect normalizedLayerClipRect = FloatRect(0, 0, 1, 1);
+ FloatRect normalizedLayerVisibleRect = FloatRect(0, 0, 1, 1);
- int maxw = tileSize().width();
- int maxh = tileSize().height();
- float sx = static_cast<float>(bounds.width()) / m_requiredTextureSize.width();
- float sy = static_cast<float>(bounds.height()) / m_requiredTextureSize.height();
+ if (clipPolygon != layer->transformedBounds()) {
+ Vector<FloatPoint, 4> normalizedLayerClipPolygon = unproject(layer, clipPolygon);
+ normalizedLayerClipRect.intersect(boundingBox(normalizedLayerClipPolygon));
- bool needsDisplay = false;
+ Vector<FloatPoint, 4> visiblePolygon = intersectPolygonWithRect(layer->transformedBounds(), inflatedViewport);
+ Vector<FloatPoint, 4> normalizedLayerVisiblePolygon = unproject(layer, visiblePolygon);
+ normalizedLayerVisibleRect.intersect(boundingBox(normalizedLayerVisiblePolygon));
+ }
- bool blending = !drawMissing;
+ FloatSize tileSize;
+ FloatRect dstClip;
+ TileIndex first;
+ TileIndex last;
+ if (layer->contentsResolutionIndependent()) {
+ // Resolution independent layers have all the needed data in the first tile
+ tileSize = boundsRect.size();
+ dstClip = boundsRect;
+ first = last = TileIndex(0, 0);
+ } else {
+ FloatRect destinationRect = normalizedLayerVisibleRect;
+ destinationRect.scale(m_requiredTextureSize.width(), m_requiredTextureSize.height());
+
+ tileSize = m_tileSize;
+ tileSize.scale(boundsRect.width() / m_requiredTextureSize.width(), boundsRect.height() / m_requiredTextureSize.height());
+
+ dstClip = normalizedLayerClipRect;
+ dstClip.scale(boundsRect.width(), boundsRect.height());
+ dstClip.moveBy(boundsRect.location());
+
+ // The layer contains pixels with coordinates (0 ... m_requiredTextureSize.width() - 1, 0 ... m_requiredTextureSize.height() - 1),
+ // so clamp the destinationRect-to-tileindex calculation appropriately.
+ first = indexOfTile(flooredIntPoint(destinationRect.minXMinYCorner()));
+ last = indexOfTile(ceiledIntPoint(destinationRect.maxXMaxYCorner()).shrunkTo(IntPoint(-1, -1) + m_requiredTextureSize));
+ }
- IntRect tileRect;
- for (tileRect.setX(0); tileRect.x() < m_requiredTextureSize.width(); tileRect.setX(tileRect.x() + maxw)) {
- for (tileRect.setY(0); tileRect.y() < m_requiredTextureSize.height(); tileRect.setY(tileRect.y() + maxh)) {
- TileIndex index = indexOfTile(tileRect.location());
+ HashSet<TileIndex> tilesNeedingRender;
+ for (unsigned i = first.i(); i <= last.i(); ++i) {
+ for (unsigned j = first.j(); j <= last.j(); ++j) {
+ TileIndex index(i, j);
LayerTile* tile = m_tiles.get(index);
if (!tile) {
tile = new LayerTile();
m_tiles.add(index, tile);
}
-
- float x = index.i() * maxw * sx;
- float y = index.j() * maxh * sy;
- float w = min(bounds.width() - x, maxw * sx);
- float h = min(bounds.height() - y, maxh * sy);
- float ox = x - bounds.width() / 2.0;
- float oy = y - bounds.height() / 2.0;
-
- // We apply the transformation by hand, since we need the z coordinate
- // as well (to do perspective correct texturing) and we don't need
- // to divide by w by hand, the GPU will do that for us
- transformPoint(ox, oy, drawTransform, &vertices[0]);
- transformPoint(ox, oy + h, drawTransform, &vertices[4]);
- transformPoint(ox + w, oy + h, drawTransform, &vertices[8]);
- transformPoint(ox + w, oy, drawTransform, &vertices[12]);
-
- // Inflate the rect somewhat to attempt to make textures render before they show
- // up on screen.
- float d = viewportInflationFactor;
- FloatRect rect(-d, -d, 2 * d, 2 * d);
- FloatQuad quad(FloatPoint(vertices[0] / vertices[3], vertices[1] / vertices[3]),
- FloatPoint(vertices[4] / vertices[7], vertices[5] / vertices[7]),
- FloatPoint(vertices[8] / vertices[11], vertices[9] / vertices[11]),
- FloatPoint(vertices[12] / vertices[15], vertices[13] / vertices[15]));
- bool visible = quad.boundingBox().intersects(rect);
-
- bool wasVisible = tile->isVisible();
- tile->setVisible(visible);
-
- // This method is called in two passes. The first pass draws all
- // visible tiles with textures.
- // If a visible tile has no texture, set the m_hasMissingTextures
- // flag, to indicate that we need a second pass.
- // The second "drawMissing" pass draws all visible tiles without
- // textures as checkerboard.
- // However, don't draw brand new tiles as checkerboard. The checker-
- // board indicates that a tile has dirty contents, but that's not
- // the case if it's brand new.
- if (visible) {
- bool hasTexture = tile->hasTexture();
- if (!hasTexture)
- m_hasMissingTextures = true;
-
- if (hasTexture && !drawMissing) {
- Texture* texture = tile->texture();
- if (texture->isOpaque() && layer->drawOpacity() == 1.0f && !layer->maskLayer()) {
- if (blending) {
- blending = false;
- glDisable(GL_BLEND);
- }
- } else if (!blending) {
- blending = true;
- glEnable(GL_BLEND);
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- }
-
- textureCacheCompositingThread()->textureAccessed(texture);
- glBindTexture(GL_TEXTURE_2D, texture->textureId());
- }
-
- if (hasTexture != drawMissing)
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
-
- if (tile->isDirty()) {
- addRenderJob(index);
- needsDisplay = true;
- }
- } else if (wasVisible)
- removeRenderJob(index);
+ tile->setVisible(true);
+ FloatPoint tileOrigin(index.i() * tileSize.width(), index.j() * tileSize.height());
+ FloatRect dst(tileOrigin - 0.5 * boundsRect.size(), tileSize.shrunkTo(boundsRect.size() - toFloatSize(tileOrigin)));
+ if (!drawTile(layer, tile, index, scale, dst, dstClip))
+ tilesNeedingRender.add(index);
}
}
- // Return early for the drawMissing case, don't flag us as needing commit.
- if (drawMissing)
- return;
+ for (TileMap::iterator it = m_tiles.begin(); it != m_tiles.end(); ++it) {
+ TileIndex index = (*it).key;
+ if (index.i() < first.i() || index.j() < first.j() || index.i() > last.i() || index.j() > last.j())
+ (*it).value->setVisible(false);
+ }
- // Switch on blending again (we know that drawMissing == false).
- if (!blending) {
- glEnable(GL_BLEND);
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ // The visible rect will be used on the WebKit thread and should use the bounds expressed in
+ // document coordinates, not corrected for scale invariance. So use "layer->bounds()" instead
+ // of the local variable "boundsRect.size()".
+ FloatRect layerVisibleRect = normalizedLayerVisibleRect;
+ layerVisibleRect.scale(layer->bounds().width(), layer->bounds().height());
+
+#if DEBUG_LAYER_VISIBILITY
+ Vector<FloatPoint> v = unproject(layer, clipPolygon);
+ for (size_t i = 0; i < v.size(); ++i) {
+ v[i].scale(layer->bounds().width(), layer->bounds().height());
+ v[i].move(toFloatSize(boundsRect.location()));
+ v[i] = layer->drawTransform().mapPoint(v[i]);
}
+ // Use a thick border to make the border visible even for the root layer (which typically covers the screen width and/or height).
+ unsigned tmp = reinterpret_cast<unsigned>(this);
+ int t = rand_r(&tmp);
+ glDisable(GL_SCISSOR_TEST);
+ // When debugging, draw first layer->transformedBounds(), then clipPolygon, then v
+ // to find out where the problem is (clipping to image plane, clipping to viewport or unprojecting).
+ layer->layerRenderer()->drawDebugBorder(/* layer->transformedBounds() */ /* clipPolygon */ v, makeRGBAFromHSLA(static_cast<double>(t) / RAND_MAX, 1, 0.5, 1), 5);
+ glEnable(GL_SCISSOR_TEST);
+#endif
+
// If we schedule a commit, visibility will be updated, and display will
// happen if there are any visible and dirty textures.
- if (needsDisplay)
+ if (!tilesNeedingRender.isEmpty())
layer->setNeedsCommit();
-}
-void LayerTiler::addRenderJob(const TileIndex& index)
-{
- ASSERT(isCompositingThread());
-
- MutexLocker locker(m_renderJobsMutex);
- m_renderJobs.add(index);
-}
-
-void LayerTiler::removeRenderJob(const TileIndex& index)
-{
- MutexLocker locker(m_renderJobsMutex);
- m_renderJobs.remove(index);
+ setFrontVisibility(layerVisibleRect, tilesNeedingRender);
}
void LayerTiler::deleteTextures(LayerCompositingThread*)
@@ -656,15 +645,14 @@ void LayerTiler::pruneTextures()
}
for (Vector<TileIndex>::iterator it = tilesToDelete.begin(); it != tilesToDelete.end(); ++it) {
- LayerTile* tile = m_tiles.take(*it);
+ OwnPtr<LayerTile> tile = adoptPtr(m_tiles.take(*it));
tile->discardContents();
- delete tile;
}
}
void LayerTiler::updateTileSize()
{
- IntSize size = m_tilingDisabled ? m_layer->bounds() : defaultTileSize();
+ IntSize size = m_layer->isMask() ? m_layer->bounds() : defaultTileSize();
const IntSize maxTextureSize(2048, 2048);
size = size.shrunkTo(maxTextureSize);
@@ -676,12 +664,12 @@ void LayerTiler::updateTileSize()
m_tileSize = size;
}
-void LayerTiler::disableTiling(bool disable)
+void LayerTiler::setNeedsBacking(bool needsBacking)
{
- if (m_tilingDisabled == disable)
+ if (m_needsBacking == needsBacking)
return;
- m_tilingDisabled = disable;
+ m_needsBacking = needsBacking;
updateTileSize();
}
@@ -693,13 +681,6 @@ void LayerTiler::scheduleCommit()
m_layer->setNeedsCommit();
}
-bool LayerTiler::shouldPrefillTile(const TileIndex& index)
-{
- IntRect prefillTargetRect = BlackBerry::Platform::Settings::instance()->layerTilerPrefillRect();
- IntRect tileRect = IntRect(originOfTile(index), tileSize());
- return prefillTargetRect.intersects(tileRect);
-}
-
TileIndex LayerTiler::indexOfTile(const WebCore::IntPoint& origin)
{
int offsetX = origin.x();
@@ -719,24 +700,23 @@ IntPoint LayerTiler::originOfTile(const TileIndex& index)
IntRect LayerTiler::rectForTile(const TileIndex& index, const IntSize& bounds)
{
IntPoint origin = originOfTile(index);
- IntSize offset(origin.x(), origin.y());
- IntSize size = tileSize().shrunkTo(bounds - offset);
+ IntSize size = tileSize().shrunkTo(bounds - toIntSize(origin));
return IntRect(origin, size);
}
-void LayerTiler::bindContentsTexture(LayerCompositingThread*)
+LayerTexture* LayerTiler::contentsTexture(LayerCompositingThread*)
{
ASSERT(m_tiles.size() == 1);
if (m_tiles.size() != 1)
- return;
+ return 0;
const LayerTile* tile = m_tiles.begin()->value;
ASSERT(tile->hasTexture());
if (!tile->hasTexture())
- return;
+ return 0;
- glBindTexture(GL_TEXTURE_2D, tile->texture()->textureId());
+ return tile->texture();
}
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/blackberry/LayerTiler.h b/Source/WebCore/platform/graphics/blackberry/LayerTiler.h
index 04e40ee5f..5d3d75737 100644
--- a/Source/WebCore/platform/graphics/blackberry/LayerTiler.h
+++ b/Source/WebCore/platform/graphics/blackberry/LayerTiler.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011, 2012 Research In Motion Limited. All rights reserved.
+ * Copyright (C) 2011, 2012, 2013 Research In Motion Limited. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -21,14 +21,13 @@
#if USE(ACCELERATED_COMPOSITING)
-#include "Color.h"
#include "FloatRect.h"
#include "IntRect.h"
#include "LayerCompositingThreadClient.h"
#include "LayerTile.h"
#include "LayerTileIndex.h"
-#include <SkBitmap.h>
+#include <BlackBerryPlatformGLES2Program.h>
#include <wtf/Deque.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
@@ -37,6 +36,7 @@
namespace WebCore {
class LayerCompositingThread;
+class LayerVisibility;
class LayerWebKitThread;
class LayerTiler : public ThreadSafeRefCounted<LayerTiler>, public LayerCompositingThreadClient {
@@ -52,42 +52,40 @@ public:
virtual ~LayerTiler();
+ IntSize tileSize() const { return m_tileSize; }
+
// WebKit thread
LayerWebKitThread* layer() const { return m_layer; }
void layerWebKitThreadDestroyed();
void setNeedsDisplay(const FloatRect& dirtyRect);
void setNeedsDisplay();
void updateTextureContentsIfNeeded(double scale);
- void disableTiling(bool);
+ void setNeedsBacking(bool);
virtual void scheduleCommit();
// Compositing thread
virtual void layerCompositingThreadDestroyed(LayerCompositingThread*);
virtual void layerVisibilityChanged(LayerCompositingThread*, bool visible);
virtual void uploadTexturesIfNeeded(LayerCompositingThread*);
- virtual void bindContentsTexture(LayerCompositingThread*);
- virtual void drawTextures(LayerCompositingThread*, double scale, int positionLocation, int texCoordLocation);
- virtual bool hasMissingTextures(const LayerCompositingThread*) const { return m_hasMissingTextures; }
- virtual void drawMissingTextures(LayerCompositingThread*, double scale, int positionLocation, int texCoordLocation);
+ virtual LayerTexture* contentsTexture(LayerCompositingThread*);
+ virtual void drawTextures(LayerCompositingThread*, const BlackBerry::Platform::Graphics::GLES2Program&, double scale, const FloatRect& clipRect);
virtual void deleteTextures(LayerCompositingThread*);
- void commitPendingTextureUploads();
-
- // Thread safe
- void addRenderJob(const TileIndex&);
- void removeRenderJob(const TileIndex&);
+ static void willCommit();
+ virtual void commitPendingTextureUploads(LayerCompositingThread*);
private:
struct TextureJob {
- enum Type { Unknown, SetContents, SetContentsToColor, UpdateContents, DiscardContents, ResizeContents, DirtyContents };
+ enum Type { Unknown, SetContents, UpdateContents, ResizeContents, DirtyContents };
TextureJob()
: m_type(Unknown)
+ , m_contents(0)
{
}
TextureJob(Type type, const IntSize& newSize)
: m_type(type)
- , m_isOpaque(false)
+ , m_contents(0)
, m_dirtyRect(IntPoint::zero(), newSize)
{
ASSERT(type == ResizeContents);
@@ -95,70 +93,61 @@ private:
TextureJob(Type type, const IntRect& dirtyRect)
: m_type(type)
- , m_isOpaque(false)
+ , m_contents(0)
, m_dirtyRect(dirtyRect)
{
- ASSERT(type == DiscardContents || type == DirtyContents);
+ ASSERT(type == DirtyContents);
}
- TextureJob(Type type, const SkBitmap& contents, const IntRect& dirtyRect, bool isOpaque)
+ TextureJob(Type type, BlackBerry::Platform::Graphics::Buffer* contents, const IntRect& dirtyRect)
: m_type(type)
, m_contents(contents)
- , m_isOpaque(isOpaque)
, m_dirtyRect(dirtyRect)
{
ASSERT(type == UpdateContents || type == SetContents);
- ASSERT(!contents.isNull());
+ ASSERT(contents);
}
- TextureJob(Type type, const Color& color, const TileIndex& index)
- : m_type(type)
- , m_isOpaque(false)
- , m_color(color)
- , m_index(index)
+ static TextureJob setContents(BlackBerry::Platform::Graphics::Buffer* contents, const IntRect& contentsRect)
{
- ASSERT(type == SetContentsToColor);
+ return TextureJob(SetContents, contents, contentsRect);
}
-
- static TextureJob setContents(const SkBitmap& contents, bool isOpaque) { return TextureJob(SetContents, contents, IntRect(IntPoint::zero(), IntSize(contents.width(), contents.height())), isOpaque); }
- static TextureJob setContentsToColor(const Color& color, const TileIndex& index) { return TextureJob(SetContentsToColor, color, index); }
- static TextureJob updateContents(const SkBitmap& contents, const IntRect& dirtyRect, bool isOpaque) { return TextureJob(UpdateContents, contents, dirtyRect, isOpaque); }
- static TextureJob discardContents(const IntRect& dirtyRect) { return TextureJob(DiscardContents, dirtyRect); }
+ static TextureJob updateContents(BlackBerry::Platform::Graphics::Buffer* contents, const IntRect& dirtyRect) { return TextureJob(UpdateContents, contents, dirtyRect); }
static TextureJob resizeContents(const IntSize& newSize) { return TextureJob(ResizeContents, newSize); }
static TextureJob dirtyContents(const IntRect& dirtyRect) { return TextureJob(DirtyContents, dirtyRect); }
bool isNull() { return m_type == Unknown; }
Type m_type;
- SkBitmap m_contents;
- bool m_isOpaque;
+ BlackBerry::Platform::Graphics::Buffer* m_contents;
IntRect m_dirtyRect;
- Color m_color;
TileIndex m_index;
};
typedef HashMap<TileIndex, LayerTile*> TileMap;
typedef HashMap<TileIndex, const TextureJob*> TileJobsMap;
- IntSize tileSize() const { return m_tileSize; }
- void updateTileSize();
-
LayerTiler(LayerWebKitThread*);
+ // Swaps in a new front visibility and returns the current one, atomically.
+ LayerVisibility* swapFrontVisibility(LayerVisibility*);
+
// WebKit thread
+ void updateTileSize();
void addTextureJob(const TextureJob&);
void clearTextureJobs();
- bool shouldPerformRenderJob(const TileIndex&, bool allowPrefill);
- bool shouldPrefillTile(const TileIndex&);
+ BlackBerry::Platform::Graphics::Buffer* createBuffer(const IntSize&);
+ LayerVisibility* takeFrontVisibility() { return swapFrontVisibility(0); }
// Compositing thread
void updateTileContents(const TextureJob&, const IntRect&);
void addTileJob(const TileIndex&, const TextureJob&, TileJobsMap&);
- void performTileJob(LayerTile*, const TextureJob&, const IntRect&);
+ void performTileJob(LayerCompositingThread*, LayerTile*, const TextureJob&);
void processTextureJob(const TextureJob&, TileJobsMap&);
- void drawTexturesInternal(LayerCompositingThread*, double scale, int positionLocation, int texCoordLocation, bool missing);
void pruneTextures();
void visibilityChanged(bool needsDisplay);
+ bool drawTile(LayerCompositingThread*, LayerTile*, const TileIndex&, double scale, const FloatRect& dst, const FloatRect& dstClip);
+ void setFrontVisibility(const FloatRect& visibleRect, HashSet<TileIndex>& tilesNeedingRender);
// Clear all pending update content texture jobs
template<typename T>
@@ -169,15 +158,17 @@ private:
for (typename T::iterator it = jobs.begin(); it != jobs.end(); ++it) {
if ((*it).m_type != TextureJob::UpdateContents)
list.append(*it);
+ else
+ BlackBerry::Platform::Graphics::destroyBuffer((*it).m_contents);
}
jobs = list;
}
LayerWebKitThread* m_layer;
- TileMap m_tiles; // Compositing thread only
+ TileMap m_tiles;
- bool m_tilingDisabled;
+ bool m_needsBacking;
bool m_contentsDirty;
FloatRect m_dirtyRect;
@@ -189,11 +180,9 @@ private:
bool m_clearTextureJobs;
Vector<TextureJob> m_pendingTextureJobs; // Added, but not committed yet.
Deque<TextureJob> m_textureJobs;
- bool m_hasMissingTextures;
- HashSet<TileIndex> m_renderJobs;
- Mutex m_renderJobsMutex;
- double m_contentsScale;
+ LayerVisibility* m_frontVisibility;
+ LayerVisibility* m_backVisibility;
};
}
diff --git a/Source/WebCore/platform/graphics/blackberry/LayerUtilities.h b/Source/WebCore/platform/graphics/blackberry/LayerUtilities.h
new file mode 100644
index 000000000..19aa1995f
--- /dev/null
+++ b/Source/WebCore/platform/graphics/blackberry/LayerUtilities.h
@@ -0,0 +1,308 @@
+/*
+ * Copyright (C) 2013 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef LayerUtilities_h
+#define LayerUtilities_h
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "FloatPoint.h"
+#include "FloatPoint3D.h"
+#include "FloatQuad.h"
+#include "FloatSize.h"
+#include "LayerCompositingThread.h"
+#include "TransformationMatrix.h"
+
+#include <algorithm>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+// determinant of column vectors
+inline float determinant(const FloatSize& a, const FloatSize& b)
+{
+ return a.width() * b.height() - a.height() * b.width();
+}
+
+// dot product
+inline float dot(const FloatSize& a, const FloatSize& b)
+{
+ return a.width() * b.width() + a.height() * b.height();
+}
+
+// Represents a line, not a finite line segment
+class LayerClipEdge {
+public:
+ LayerClipEdge(const FloatPoint& first, const FloatPoint& second)
+ : m_first(first)
+ , m_second(second)
+ {
+ }
+
+ inline bool isPointInside(const FloatPoint& p) const
+ {
+ // For numeric robustness, we prefer to consider a point to be inside rather than
+ // clip it again.
+ const float epsilon = 1e-6;
+ return determinant(m_second - m_first, p - m_first) > -epsilon;
+ }
+
+ inline FloatPoint computeIntersection(const FloatPoint& p1, const FloatPoint& p2) const
+ {
+ const FloatPoint& p3 = m_first;
+ const FloatPoint& p4 = m_second;
+ float denominator = determinant(p1 - p2, p3 - p4);
+ FloatSize determinants(determinant(toFloatSize(p1), toFloatSize(p2)), determinant(toFloatSize(p3), toFloatSize(p4)));
+ FloatPoint result(
+ determinant(determinants, FloatSize(p1.x() - p2.x(), p3.x() - p4.x())) / denominator,
+ determinant(determinants, FloatSize(p1.y() - p2.y(), p3.y() - p4.y())) / denominator);
+ return result;
+ }
+
+private:
+ FloatPoint m_first;
+ FloatPoint m_second;
+};
+
+// Specifies a clip plane with normal n and containing point p_0
+// as p * n + d = 0, d = -p_0 * n. The asterisk is dot product.
+class LayerClipPlane {
+public:
+ LayerClipPlane(FloatPoint3D n, float d)
+ : m_n(n)
+ , m_d(d)
+ {
+ }
+
+ inline bool isPointInside(const FloatPoint3D& p) const
+ {
+ return p * m_n + m_d > 0;
+ }
+
+ inline FloatPoint3D computeIntersection(const FloatPoint3D& p1, const FloatPoint3D& p2) const
+ {
+ float u = (-m_d - p1 * m_n) / ((p2 - p1) * m_n);
+ return p1 + u * (p2 - p1);
+ }
+
+protected:
+ FloatPoint3D m_n;
+ float m_d;
+};
+
+// Sutherland - Hodgman, inner loop
+template<typename Point, size_t inlineCapacity, typename ClipPrimitive>
+inline Vector<Point, inlineCapacity> intersect(const Vector<Point, inlineCapacity>& inputList, const ClipPrimitive& clipPrimitive)
+{
+ Vector<Point, inlineCapacity> outputList;
+ Point s;
+ if (!inputList.isEmpty())
+ s = inputList.last();
+ for (typename Vector<Point, inlineCapacity>::const_iterator eIterator = inputList.begin(); eIterator != inputList.end(); ++eIterator) {
+ const Point& e = *eIterator;
+ if (clipPrimitive.isPointInside(e)) {
+ if (!clipPrimitive.isPointInside(s))
+ outputList.append(clipPrimitive.computeIntersection(s, e));
+ outputList.append(e);
+ } else if (clipPrimitive.isPointInside(s))
+ outputList.append(clipPrimitive.computeIntersection(s, e));
+ s = e;
+ }
+ return outputList;
+}
+
+// Sutherland - Hodgman, main driver
+template<size_t inlineCapacity>
+inline Vector<FloatPoint, inlineCapacity> intersectPolygonWithRect(const Vector<FloatPoint, inlineCapacity>& subjectPolygon, const FloatRect& clipRect)
+{
+ FloatQuad clipQuad(clipRect);
+ Vector<LayerClipEdge> edges;
+ edges.append(LayerClipEdge(clipQuad.p1(), clipQuad.p2()));
+ edges.append(LayerClipEdge(clipQuad.p2(), clipQuad.p3()));
+ edges.append(LayerClipEdge(clipQuad.p3(), clipQuad.p4()));
+ edges.append(LayerClipEdge(clipQuad.p4(), clipQuad.p1()));
+
+ Vector<FloatPoint> outputList = subjectPolygon;
+ for (Vector<LayerClipEdge>::const_iterator clipEdgeIterator = edges.begin(); clipEdgeIterator != edges.end(); ++clipEdgeIterator) {
+ const LayerClipEdge& clipEdge = *clipEdgeIterator;
+ Vector<FloatPoint> inputList = outputList;
+ outputList = intersect(inputList, clipEdge);
+ }
+ return outputList;
+}
+
+template<size_t inlineCapacity>
+inline FloatRect boundingBox(const Vector<FloatPoint, inlineCapacity>& points)
+{
+ if (points.isEmpty())
+ return FloatRect();
+ float xmin, xmax, ymin, ymax;
+ xmin = ymin = std::numeric_limits<float>::infinity();
+ xmax = ymax = -std::numeric_limits<float>::infinity();
+ for (size_t i = 0; i < points.size(); ++i) {
+ const FloatPoint& p = points[i];
+ if (p.x() < xmin)
+ xmin = p.x();
+ if (p.x() > xmax)
+ xmax = p.x();
+ if (p.y() < ymin)
+ ymin = p.y();
+ if (p.y() > ymax)
+ ymax = p.y();
+ }
+ return FloatRect(xmin, ymin, xmax - xmin, ymax - ymin);
+}
+
+inline FloatPoint3D computeBarycentricCoordinates(const FloatPoint& p, const FloatPoint& t1, const FloatPoint& t2, const FloatPoint& t3, bool& ok)
+{
+ // Compute vectors
+ FloatSize v0 = t2 - t1;
+ FloatSize v1 = t3 - t1;
+ FloatSize v2 = p - t1;
+
+ // Compute dot products
+ float dot00 = dot(v0, v0);
+ float dot01 = dot(v0, v1);
+ float dot02 = dot(v0, v2);
+ float dot11 = dot(v1, v1);
+ float dot12 = dot(v1, v2);
+
+ // Compute barycentric coordinates
+ float denominator = (dot00 * dot11 - dot01 * dot01);
+ ok = (denominator != 0.0);
+ if (!ok)
+ return FloatPoint3D();
+
+ float v = (dot11 * dot02 - dot01 * dot12) / denominator;
+ float w = (dot00 * dot12 - dot01 * dot02) / denominator;
+
+ return FloatPoint3D(1.0f - v - w, v, w);
+}
+
+inline float manhattanDistanceToViewport(const FloatPoint& p)
+{
+ float d = 0;
+ if (fabsf(p.x()) > 1)
+ d += fabsf(p.x()) - 1;
+ if (fabsf(p.y()) > 1)
+ d += fabsf(p.y()) - 1;
+ return d;
+}
+
+struct UnprojectionVertex {
+ FloatPoint xy;
+ float w;
+ FloatSize uv;
+};
+
+inline bool compareManhattanDistanceToViewport(const UnprojectionVertex& a, const UnprojectionVertex& b)
+{
+ return manhattanDistanceToViewport(a.xy) < manhattanDistanceToViewport(b.xy);
+}
+
+template<size_t inlineCapacity>
+inline Vector<FloatPoint, inlineCapacity> unproject(LayerCompositingThread* layer, const Vector<FloatPoint, inlineCapacity>& points)
+{
+ // Use perspective correct texturing logic to find the locations of these points in normalized layer coordinates
+ Vector<FloatPoint, 4> bounds = layer->transformedBounds();
+ Vector<float, 4> ws = layer->ws();
+ if (ws.isEmpty())
+ ws.fill(0.0f, bounds.size());
+ const Vector<FloatPoint>& texCoords = layer->textureCoordinates();
+ if (bounds.size() < 3)
+ return Vector<FloatPoint, inlineCapacity>();
+
+ Vector<UnprojectionVertex, 4> vertices(bounds.size());
+ for (size_t i = 0; i < bounds.size(); ++i) {
+ vertices[i].xy = bounds[i];
+ vertices[i].w = ws[i];
+ vertices[i].uv = toFloatSize(texCoords[i]);
+ }
+ // Each point needs to be qualified as lying in one of the triangles formed by the "bounds" triangle strip
+ // Try to use only points that are onscreen, for numerical stability
+ std::sort(vertices.begin(), vertices.end(), compareManhattanDistanceToViewport);
+
+ Vector<FloatPoint, inlineCapacity> result;
+
+ size_t i0 = 0;
+
+ const FloatPoint& p0 = vertices[i0].xy;
+ float w0 = vertices[i0].w;
+ FloatSize uv0 = vertices[i0].uv;
+
+ for (size_t j = 0; j < points.size(); ++j) {
+ const FloatPoint& p = points[j];
+ FloatPoint texCoord;
+ for (size_t di = 1; di + 1 < vertices.size(); ++di) {
+ size_t i = (i0 + di) % vertices.size();
+ const FloatPoint& p1 = vertices[i].xy;
+ const FloatPoint& p2 = vertices[i + 1].xy;
+ float w1 = vertices[i].w;
+ float w2 = vertices[i + 1].w;
+ FloatSize uv1 = vertices[i].uv;
+ FloatSize uv2 = vertices[i + 1].uv;
+
+ bool ok;
+ FloatPoint3D b = computeBarycentricCoordinates(p, p0, p1, p2, ok);
+ if (!ok)
+ continue;
+
+ if (w0 && w1 && w2) {
+ // Perspective correct interpolation
+ FloatPoint3D bw(b.x() / w0, b.y() / w1, b.z() / w2);
+ float denominator = bw.x() + bw.y() + bw.z();
+ texCoord = FloatPoint::zero() + (bw.x() * uv0 + bw.y() * uv1 + bw.z() * uv2);
+ texCoord.setX(texCoord.x() / denominator);
+ texCoord.setY(texCoord.y() / denominator);
+ } else {
+ // Linear interpolation
+ texCoord = FloatPoint::zero() + (b.x() * uv0 + b.y() * uv1 + b.z() * uv2);
+ }
+ break;
+ }
+ result.append(texCoord);
+ }
+ return result;
+}
+
+inline FloatPoint3D multVecMatrix(const TransformationMatrix& matrix, const FloatPoint3D& p, float& w)
+{
+ FloatPoint3D result(
+ matrix.m41() + p.x() * matrix.m11() + p.y() * matrix.m21() + p.z() * matrix.m31(),
+ matrix.m42() + p.x() * matrix.m12() + p.y() * matrix.m22() + p.z() * matrix.m32(),
+ matrix.m43() + p.x() * matrix.m13() + p.y() * matrix.m23() + p.z() * matrix.m33());
+ w = matrix.m44() + p.x() * matrix.m14() + p.y() * matrix.m24() + p.z() * matrix.m34();
+ return result;
+}
+
+template<typename Point, size_t inlineCapacity>
+inline Vector<Point, inlineCapacity> toVector(const FloatQuad& quad)
+{
+ Vector<Point, inlineCapacity> result;
+ result.append(quad.p1());
+ result.append(quad.p2());
+ result.append(quad.p3());
+ result.append(quad.p4());
+ return result;
+}
+
+} // namespace WebCore
+
+#endif // USE(ACCELERATED_COMPOSITING)
+
+#endif // LayerUtilities_h
diff --git a/Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.cpp b/Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.cpp
index 5c0375356..76618a5e6 100644
--- a/Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.cpp
+++ b/Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.cpp
@@ -36,10 +36,8 @@
#include "LayerWebKitThread.h"
#include "GraphicsContext.h"
-#include "InstrumentedPlatformCanvas.h"
#include "LayerCompositingThread.h"
#include "LayerMessage.h"
-#include "PlatformContextSkia.h"
#include "RenderLayerBacking.h"
#include "TransformationMatrix.h"
@@ -60,7 +58,6 @@ LayerWebKitThread::LayerWebKitThread(LayerType type, GraphicsLayerBlackBerry* ow
, m_owner(owner)
, m_superlayer(0)
, m_contents(0)
- , m_scale(1.0)
, m_isDrawable(false)
, m_isMask(false)
, m_animationsChanged(false)
@@ -68,6 +65,7 @@ LayerWebKitThread::LayerWebKitThread(LayerType type, GraphicsLayerBlackBerry* ow
#if ENABLE(CSS_FILTERS)
, m_filtersChanged(false)
#endif
+ , m_didStartAnimations(false)
{
if (type == Layer)
m_tiler = LayerTiler::create(this);
@@ -84,76 +82,46 @@ LayerWebKitThread::~LayerWebKitThread()
ASSERT(!superlayer());
// Remove the superlayer reference from all sublayers.
- removeAllSublayers();
+ removeAll(m_sublayers);
+ removeAll(m_overlays);
}
-SkBitmap LayerWebKitThread::paintContents(const IntRect& contentsRect, double scale, bool* isSolidColor, Color* color)
+void LayerWebKitThread::paintContents(BlackBerry::Platform::Graphics::Buffer* buffer, const IntRect& contentsRect, double scale)
{
- // Don't try to allocate image data bigger than this. This should be big
- // enough to accomodate a huge iScroll use case.
- // FIXME: This is a hack to work around a crash bug on maps.bing.com where
- // a (visually empty) layer becomes too big.
- static const int maximumBitmapSizeInBytes = 40 * 1024 * 1024;
- static const int bytesPerPixel = 4;
-
- if (isSolidColor)
- *isSolidColor = false;
-
- if (contentsRect.width() * contentsRect.height() * bytesPerPixel > maximumBitmapSizeInBytes)
- return SkBitmap();
-
- SkBitmap bitmap;
-
- // Keep the canvas alive until we're done extracting its pixels
- OwnPtr<InstrumentedPlatformCanvas> canvas;
+ if (!drawsContent() && !contents())
+ return;
- if (drawsContent()) { // Layer contents must be drawn into a canvas.
- IntRect untransformedContentsRect = mapFromTransformed(contentsRect, scale);
+ if (!buffer)
+ return;
- SkBitmap canvasBitmap;
- canvasBitmap.setConfig(SkBitmap::kARGB_8888_Config, contentsRect.width(), contentsRect.height());
- if (!canvasBitmap.allocPixels())
- return SkBitmap();
- canvasBitmap.setIsOpaque(false);
- canvasBitmap.eraseColor(0);
+ IntRect untransformedContentsRect = contentsRect;
+ FloatRect clipRect = contentsRect;
+ if (scale != 1.0) {
+ TransformationMatrix matrix;
+ matrix.scale(1.0 / scale);
+ untransformedContentsRect = matrix.mapRect(contentsRect);
+ clipRect = matrix.mapRect(clipRect);
- canvas = adoptPtr(new InstrumentedPlatformCanvas(canvasBitmap));
- PlatformContextSkia skiaContext(canvas.get());
+ // We extract from the contentsRect but draw a slightly larger region than
+ // we were told to, in order to avoid pixels being rendered only partially.
+ const int atLeastOneDevicePixel = static_cast<int>(ceilf(1.0 / scale));
+ untransformedContentsRect.inflate(atLeastOneDevicePixel);
+ }
- GraphicsContext graphicsContext(&skiaContext);
+ PlatformGraphicsContext* platformContext = lockBufferDrawable(buffer);
+ GraphicsContext graphicsContext(platformContext);
+ if (contents()) {
+ // Images needs to be centered and will be scaled to fit the bounds on the compositing thread
+ if (!contents()->size().isEmpty())
+ graphicsContext.drawImage(contents(), ColorSpaceDeviceRGB, IntPoint(0, 0));
+ } else {
graphicsContext.translate(-contentsRect.x(), -contentsRect.y());
-
- if (scale != 1.0)
- graphicsContext.scale(FloatSize(scale, scale));
-
- // RenderLayerBacking doesn't always clip, so we need to do this by ourselves.
- graphicsContext.clip(untransformedContentsRect);
+ graphicsContext.scale(FloatSize(scale, scale));
+ graphicsContext.clip(clipRect);
m_owner->paintGraphicsLayerContents(graphicsContext, untransformedContentsRect);
-
- bitmap = canvas->getDevice()->accessBitmap(false);
- if (isSolidColor) {
- *isSolidColor = canvas->isSolidColor();
- if (color)
- *color = canvas->solidColor();
- }
}
- ASSERT(!bitmap.isNull());
-
- // FIXME: do we need to support more image configurations?
- ASSERT(bitmap.config() == SkBitmap::kARGB_8888_Config);
- if (bitmap.config() != SkBitmap::kARGB_8888_Config)
- return SkBitmap();
-
- return bitmap;
-}
-
-bool LayerWebKitThread::contentsVisible(const IntRect& contentsRect) const
-{
- if (!m_owner)
- return false;
-
- return m_owner->contentsVisible(contentsRect);
+ releaseBufferDrawable(buffer);
}
void LayerWebKitThread::updateTextureContentsIfNeeded()
@@ -164,15 +132,18 @@ void LayerWebKitThread::updateTextureContentsIfNeeded()
void LayerWebKitThread::commitPendingTextureUploads()
{
- if (m_tiler)
- m_tiler->commitPendingTextureUploads();
+ layerCompositingThread()->commitPendingTextureUploads();
}
void LayerWebKitThread::setContents(Image* contents)
{
// Check if the image has changed.
- if (m_contents == contents)
+ if (m_contents == contents) {
+ // Set needs display for animated images.
+ if (contents)
+ setNeedsDisplay();
return;
+ }
m_contents = contents;
setNeedsTexture(m_isDrawable && (this->contents() || drawsContent() || pluginView()));
@@ -180,6 +151,9 @@ void LayerWebKitThread::setContents(Image* contents)
setNeedsDisplay();
else
setNeedsCommit();
+
+ // If this layer contains a bitmap image it isn't rerendered at different scale (it is resolution independent)
+ m_contentsResolutionIndependent = static_cast<bool>(m_contents);
}
void LayerWebKitThread::setDrawable(bool isDrawable)
@@ -202,43 +176,54 @@ void LayerWebKitThread::setNeedsCommit()
m_owner->notifyFlushRequired();
}
-void LayerWebKitThread::notifyAnimationStarted(double time)
+void LayerWebKitThread::notifyAnimationsStarted(double time)
{
- if (m_owner)
- m_owner->notifyAnimationStarted(time);
+ if (m_didStartAnimations) {
+ m_didStartAnimations = false;
+ if (m_owner)
+ m_owner->notifyAnimationStarted(time);
+ }
+
+ size_t listSize = m_sublayers.size();
+ for (size_t i = 0; i < listSize; ++i)
+ m_sublayers[i]->notifyAnimationsStarted(time);
+
+ listSize = m_overlays.size();
+ for (size_t i = 0; i < listSize; ++i)
+ m_overlays[i]->notifyAnimationsStarted(time);
}
void LayerWebKitThread::commitOnWebKitThread(double scale)
{
// Updating texture contents require the latest visibility info.
updateTextureContents(scale);
-
- // Make sure all animations are started at the same time
- // to avoid showing animations out-of-sync.
- // Do this after updating texture contents, because that can be a slow
- // operation.
- startAnimations(currentTime());
}
-void LayerWebKitThread::startAnimations(double time)
+bool LayerWebKitThread::startAnimations(double time)
{
+ bool didStartAnimations = false;
for (size_t i = 0; i < m_runningAnimations.size(); ++i) {
if (!m_runningAnimations[i]->startTime()) {
- m_animationsChanged = true;
m_runningAnimations[i]->setStartTime(time);
- notifyAnimationStarted(time);
+ m_didStartAnimations = didStartAnimations = true;
}
}
size_t listSize = m_sublayers.size();
- for (size_t i = 0; i < listSize; i++)
- m_sublayers[i]->startAnimations(time);
+ for (size_t i = 0; i < listSize; ++i)
+ didStartAnimations |= m_sublayers[i]->startAnimations(time);
+
+ listSize = m_overlays.size();
+ for (size_t i = 0; i < listSize; ++i)
+ didStartAnimations |= m_overlays[i]->startAnimations(time);
+
+ return didStartAnimations;
}
void LayerWebKitThread::updateTextureContents(double scale)
{
- if (m_scale != scale) {
- m_scale = scale;
+ if (m_contentsScale != scale) {
+ m_contentsScale = scale;
// Only web content can redraw at the new scale.
// Canvas, images, video etc can't.
@@ -261,9 +246,13 @@ void LayerWebKitThread::updateTextureContents(double scale)
}
size_t listSize = m_sublayers.size();
- for (size_t i = 0; i < listSize; i++)
+ for (size_t i = 0; i < listSize; ++i)
m_sublayers[i]->updateTextureContents(scale);
+ listSize = m_overlays.size();
+ for (size_t i = 0; i < listSize; ++i)
+ m_overlays[i]->updateTextureContents(scale);
+
if (maskLayer())
maskLayer()->updateTextureContents(scale);
@@ -294,12 +283,17 @@ void LayerWebKitThread::commitOnCompositingThread()
}
m_position = oldPosition;
updateLayerHierarchy();
+
commitPendingTextureUploads();
size_t listSize = m_sublayers.size();
- for (size_t i = 0; i < listSize; i++)
+ for (size_t i = 0; i < listSize; ++i)
m_sublayers[i]->commitOnCompositingThread();
+ listSize = m_overlays.size();
+ for (size_t i = 0; i < listSize; ++i)
+ m_overlays[i]->commitOnCompositingThread();
+
if (maskLayer()) {
maskLayer()->commitOnCompositingThread();
layerCompositingThread()->setMaskLayer(maskLayer()->layerCompositingThread());
@@ -315,15 +309,20 @@ void LayerWebKitThread::commitOnCompositingThread()
void LayerWebKitThread::addSublayer(PassRefPtr<LayerWebKitThread> sublayer)
{
- insertSublayer(sublayer, numSublayers());
+ insert(m_sublayers, sublayer, m_sublayers.size());
}
-void LayerWebKitThread::insertSublayer(PassRefPtr<LayerWebKitThread> sublayer, size_t index)
+void LayerWebKitThread::addOverlay(PassRefPtr<LayerWebKitThread> overlay)
+{
+ insert(m_overlays, overlay, m_overlays.size());
+}
+
+void LayerWebKitThread::insert(Vector<RefPtr<LayerWebKitThread> >& list, PassRefPtr<LayerWebKitThread> sublayer, size_t index)
{
sublayer->removeFromSuperlayer();
- index = min(index, m_sublayers.size());
+ index = min(index, list.size());
sublayer->setSuperlayer(this);
- m_sublayers.insert(index, sublayer);
+ list.insert(index, sublayer);
setNeedsCommit();
}
@@ -331,17 +330,23 @@ void LayerWebKitThread::insertSublayer(PassRefPtr<LayerWebKitThread> sublayer, s
void LayerWebKitThread::removeFromSuperlayer()
{
if (m_superlayer)
- m_superlayer->removeSublayer(this);
+ m_superlayer->removeSublayerOrOverlay(this);
+}
+
+void LayerWebKitThread::removeSublayerOrOverlay(LayerWebKitThread* sublayer)
+{
+ remove(m_sublayers, sublayer);
+ remove(m_overlays, sublayer);
}
-void LayerWebKitThread::removeSublayer(LayerWebKitThread* sublayer)
+void LayerWebKitThread::remove(Vector<RefPtr<LayerWebKitThread> >& vector, LayerWebKitThread* sublayer)
{
- int foundIndex = indexOfSublayer(sublayer);
- if (foundIndex == -1)
+ size_t foundIndex = vector.find(sublayer);
+ if (foundIndex == notFound)
return;
sublayer->setSuperlayer(0);
- m_sublayers.remove(foundIndex);
+ vector.remove(foundIndex);
setNeedsCommit();
}
@@ -354,8 +359,8 @@ void LayerWebKitThread::replaceSublayer(LayerWebKitThread* reference, PassRefPtr
if (reference == newLayer)
return;
- int referenceIndex = indexOfSublayer(reference);
- if (referenceIndex == -1) {
+ size_t referenceIndex = m_sublayers.find(reference);
+ if (referenceIndex == notFound) {
ASSERT_NOT_REACHED();
return;
}
@@ -368,15 +373,6 @@ void LayerWebKitThread::replaceSublayer(LayerWebKitThread* reference, PassRefPtr
}
}
-int LayerWebKitThread::indexOfSublayer(const LayerWebKitThread* reference)
-{
- for (size_t i = 0; i < m_sublayers.size(); i++) {
- if (m_sublayers[i] == reference)
- return i;
- }
- return -1;
-}
-
void LayerWebKitThread::setBounds(const IntSize& size)
{
if (m_bounds == size)
@@ -397,7 +393,7 @@ void LayerWebKitThread::setBounds(const IntSize& size)
void LayerWebKitThread::setFrame(const FloatRect& rect)
{
if (rect == m_frame)
- return;
+ return;
m_frame = rect;
setNeedsDisplay();
@@ -417,7 +413,6 @@ bool LayerWebKitThread::filtersCanBeComposited(const FilterOperations& filters)
case FilterOperation::REFERENCE:
#if ENABLE(CSS_SHADERS)
case FilterOperation::CUSTOM:
- case FilterOperation::VALIDATED_CUSTOM:
#endif
return false;
default:
@@ -441,13 +436,17 @@ const LayerWebKitThread* LayerWebKitThread::rootLayer() const
return layer;
}
-void LayerWebKitThread::removeAllSublayers()
+void LayerWebKitThread::removeAll(Vector<RefPtr<LayerWebKitThread> >& vector)
{
- while (m_sublayers.size()) {
- RefPtr<LayerWebKitThread> layer = m_sublayers[0].get();
- ASSERT(layer->superlayer());
+ if (!vector.size())
+ return;
+
+ while (vector.size()) {
+ RefPtr<LayerWebKitThread> layer = vector[0].get();
+ ASSERT(layer->superlayer() == this);
layer->removeFromSuperlayer();
}
+
setNeedsCommit();
}
@@ -458,7 +457,7 @@ void LayerWebKitThread::setSublayers(const Vector<RefPtr<LayerWebKitThread> >& s
removeAllSublayers();
size_t listSize = sublayers.size();
- for (size_t i = 0; i < listSize; i++)
+ for (size_t i = 0; i < listSize; ++i)
addSublayer(sublayers[i]);
}
@@ -481,8 +480,11 @@ void LayerWebKitThread::updateLayerHierarchy()
m_layerCompositingThread->setSuperlayer(superlayer() ? superlayer()->m_layerCompositingThread.get() : 0);
Vector<RefPtr<LayerCompositingThread> > sublayers;
- size_t listSize = m_sublayers.size();
- for (size_t i = 0; i < listSize; i++)
+ size_t listSize = m_overlays.size();
+ for (size_t i = 0; i < listSize; ++i)
+ sublayers.append(m_overlays[i]->m_layerCompositingThread.get());
+ listSize = m_sublayers.size();
+ for (size_t i = 0; i < listSize; ++i)
sublayers.append(m_sublayers[i]->m_layerCompositingThread.get());
m_layerCompositingThread->setSublayers(sublayers);
}
@@ -491,7 +493,7 @@ void LayerWebKitThread::setIsMask(bool isMask)
{
m_isMask = isMask;
if (isMask && m_tiler)
- m_tiler->disableTiling(true);
+ m_tiler->setNeedsBacking(true);
}
void LayerWebKitThread::setRunningAnimations(const Vector<RefPtr<LayerAnimation> >& animations)
@@ -513,9 +515,13 @@ void LayerWebKitThread::releaseLayerResources()
deleteTextures();
size_t listSize = m_sublayers.size();
- for (size_t i = 0; i < listSize; i++)
+ for (size_t i = 0; i < listSize; ++i)
m_sublayers[i]->releaseLayerResources();
+ listSize = m_overlays.size();
+ for (size_t i = 0; i < listSize; ++i)
+ m_overlays[i]->releaseLayerResources();
+
if (maskLayer())
maskLayer()->releaseLayerResources();
diff --git a/Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.h b/Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.h
index b834d88c1..dd54fc6a6 100644
--- a/Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.h
+++ b/Source/WebCore/platform/graphics/blackberry/LayerWebKitThread.h
@@ -45,8 +45,6 @@
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
-class SkBitmap;
-
namespace WebCore {
class LayerCompositingThread;
@@ -58,10 +56,12 @@ public:
virtual ~LayerWebKitThread();
void addSublayer(PassRefPtr<LayerWebKitThread>);
- void insertSublayer(PassRefPtr<LayerWebKitThread>, size_t index);
+ void insertSublayer(PassRefPtr<LayerWebKitThread> layer, size_t index) { insert(m_sublayers, layer, index); }
void replaceSublayer(LayerWebKitThread* reference, PassRefPtr<LayerWebKitThread> newLayer);
void removeFromSuperlayer();
+ void addOverlay(PassRefPtr<LayerWebKitThread>);
+
void setAnchorPoint(const FloatPoint& anchorPoint) { m_anchorPoint = anchorPoint; setNeedsCommit(); }
void setAnchorPointZ(float anchorPointZ) { m_anchorPointZ = anchorPointZ; setNeedsCommit(); }
@@ -84,6 +84,8 @@ public:
void setMaskLayer(LayerWebKitThread* maskLayer) { m_maskLayer = maskLayer; }
LayerWebKitThread* maskLayer() const { return m_maskLayer.get(); }
+
+ bool isMask() const { return m_isMask; }
void setIsMask(bool);
void setReplicaLayer(LayerWebKitThread* layer) { m_replicaLayer = layer; }
@@ -109,11 +111,11 @@ public:
const LayerWebKitThread* rootLayer() const;
- void removeAllSublayers();
+ void removeAllSublayers() { removeAll(m_sublayers); }
void setSublayers(const Vector<RefPtr<LayerWebKitThread> >&);
- const Vector<RefPtr<LayerWebKitThread> >& getSublayers() const { return m_sublayers; }
+ const Vector<RefPtr<LayerWebKitThread> >& sublayers() const { return m_sublayers; }
void setSublayerTransform(const TransformationMatrix& transform) { m_sublayerTransform = transform; setNeedsCommit(); }
@@ -123,10 +125,57 @@ public:
void setPreserves3D(bool preserves3D) { m_preserves3D = preserves3D; setNeedsCommit(); }
- void setFixedPosition(bool fixed) { m_isFixedPosition = fixed; setNeedsCommit(); }
+ void setFixedPosition(bool fixed)
+ {
+ if (m_isFixedPosition == fixed)
+ return;
+ m_isFixedPosition = fixed;
+ setNeedsCommit();
+ }
+
void setHasFixedContainer(bool fixed) { m_hasFixedContainer = fixed; setNeedsCommit(); }
void setHasFixedAncestorInDOMTree(bool fixed) { m_hasFixedAncestorInDOMTree = fixed; setNeedsCommit(); }
+ void setIsContainerForFixedPositionLayers(bool fixed)
+ {
+ if (m_isContainerForFixedPositionLayers == fixed)
+ return;
+ m_isContainerForFixedPositionLayers = fixed;
+ setNeedsCommit();
+ }
+
+ void setFixedToTop(bool fixedToTop)
+ {
+ if (m_isFixedToTop == fixedToTop)
+ return;
+ m_isFixedToTop = fixedToTop;
+ setNeedsCommit();
+ }
+
+ void setFixedToLeft(bool fixedToLeft)
+ {
+ if (m_isFixedToLeft == fixedToLeft)
+ return;
+ m_isFixedToLeft = fixedToLeft;
+ setNeedsCommit();
+ }
+
+ void setFrameVisibleRect(const IntRect& rect)
+ {
+ if (m_frameVisibleRect == rect)
+ return;
+ m_frameVisibleRect = rect;
+ setNeedsCommit();
+ }
+
+ void setFrameContentsSize(const IntSize& size)
+ {
+ if (m_frameContentsSize == size)
+ return;
+ m_frameContentsSize = size;
+ setNeedsCommit();
+ }
+
void setContents(Image*);
Image* contents() const { return m_contents.get(); }
@@ -137,20 +186,24 @@ public:
bool drawsContent() const { return m_owner && m_owner->drawsContent(); }
void setDrawable(bool);
+ // 1. Commit on WebKit thread
void commitOnWebKitThread(double scale);
+
+ // 2. Commit on Compositing thread
void commitOnCompositingThread();
+ bool startAnimations(double time);
+
+ // 3. Notify when returning to WebKit thread
+ void notifyAnimationsStarted(double time);
+
LayerCompositingThread* layerCompositingThread() const { return m_layerCompositingThread.get(); }
// Only used when this layer is the root layer of a frame.
void setAbsoluteOffset(const FloatSize& offset) { m_absoluteOffset = offset; }
- double contentsScale() const { return m_scale; }
-
- SkBitmap paintContents(const IntRect& transformedContentsRect, double scale, bool* isSolidColor = 0, Color* = 0);
- bool contentsVisible(const IntRect& contentsRect) const;
+ void paintContents(BlackBerry::Platform::Graphics::Buffer*, const IntRect& transformedContentsRect, double scale);
void setNeedsCommit();
- void notifyAnimationStarted(double time);
void setRunningAnimations(const Vector<RefPtr<LayerAnimation> >&);
void setSuspendedAnimations(const Vector<RefPtr<LayerAnimation> >&);
@@ -166,10 +219,9 @@ protected:
LayerWebKitThread(LayerType, GraphicsLayerBlackBerry* owner);
void setNeedsTexture(bool needsTexture) { m_needsTexture = needsTexture; }
- void setLayerProgramShader(LayerData::LayerProgramShader shader) { m_layerProgramShader = shader; }
+ void setLayerProgram(LayerData::LayerProgram layerProgram) { m_layerProgram = layerProgram; }
bool isDrawable() const { return m_isDrawable; }
- void startAnimations(double time);
void updateVisibility();
void updateTextureContents(double scale);
@@ -183,16 +235,11 @@ private:
void setSuperlayer(LayerWebKitThread* superlayer) { m_superlayer = superlayer; }
- size_t numSublayers() const
- {
- return m_sublayers.size();
- }
-
- // Returns the index of the sublayer or -1 if not found.
- int indexOfSublayer(const LayerWebKitThread*);
-
// This should only be called from removeFromSuperlayer.
- void removeSublayer(LayerWebKitThread*);
+ void removeSublayerOrOverlay(LayerWebKitThread*);
+ void remove(Vector<RefPtr<LayerWebKitThread> >&, LayerWebKitThread*);
+ void removeAll(Vector<RefPtr<LayerWebKitThread> >&);
+ void insert(Vector<RefPtr<LayerWebKitThread> >&, PassRefPtr<LayerWebKitThread>, size_t index);
GraphicsLayerBlackBerry* m_owner;
@@ -200,6 +247,7 @@ private:
Vector<RefPtr<LayerAnimation> > m_suspendedAnimations;
Vector<RefPtr<LayerWebKitThread> > m_sublayers;
+ Vector<RefPtr<LayerWebKitThread> > m_overlays;
LayerWebKitThread* m_superlayer;
RefPtr<LayerWebKitThread> m_maskLayer;
RefPtr<LayerWebKitThread> m_replicaLayer;
@@ -209,7 +257,6 @@ private:
RefPtr<LayerCompositingThread> m_layerCompositingThread;
RefPtr<LayerTiler> m_tiler;
FloatSize m_absoluteOffset;
- double m_scale; // Scale applies only to content layers
unsigned m_isDrawable : 1;
unsigned m_isMask : 1;
unsigned m_animationsChanged : 1;
@@ -217,6 +264,7 @@ private:
#if ENABLE(CSS_FILTERS)
unsigned m_filtersChanged : 1;
#endif
+ unsigned m_didStartAnimations : 1;
};
}
diff --git a/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp b/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp
index 7e9a79cb0..e41be6f99 100644
--- a/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp
+++ b/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp
@@ -21,37 +21,28 @@
#if ENABLE(VIDEO)
#include "MediaPlayerPrivateBlackBerry.h"
-#include "AuthenticationChallengeManager.h"
#include "CookieManager.h"
-#include "Credential.h"
#include "CredentialStorage.h"
-#include "Frame.h"
-#include "FrameView.h"
-#include "GraphicsContext.h"
-#include "HTMLNames.h"
+#include "DOMFileSystemBase.h"
#include "HostWindow.h"
#include "MediaStreamDescriptor.h"
#include "MediaStreamRegistry.h"
-#include "NotImplemented.h"
-#include "PlatformContextSkia.h"
-#include "ProtectionSpace.h"
-#include "RenderBox.h"
-#include "TimeRanges.h"
-#include "WebPageClient.h"
+#include "SecurityOrigin.h"
#include <BlackBerryPlatformDeviceInfo.h>
#include <BlackBerryPlatformPrimitives.h>
#include <BlackBerryPlatformSettings.h>
+#include <BlackBerryPlatformWebFileSystem.h>
#include <FrameLoaderClientBlackBerry.h>
-#include <set>
-#include <wtf/text/CString.h>
#if USE(ACCELERATED_COMPOSITING)
-#include "NativeImageSkia.h"
#include "VideoLayerWebKitThread.h"
+#include <BlackBerryPlatformGLES2Program.h>
#include <GLES2/gl2.h>
#endif
+#include <TiledImage.h>
+
using namespace std;
using namespace BlackBerry::Platform;
@@ -113,7 +104,6 @@ MediaPlayerPrivate::MediaPlayerPrivate(MediaPlayer* player)
#if USE(ACCELERATED_COMPOSITING)
, m_bufferingTimer(this, &MediaPlayerPrivate::bufferingTimerFired)
, m_showBufferingImage(false)
- , m_mediaIsBuffering(false)
#endif
, m_userDrivenSeekTimer(this, &MediaPlayerPrivate::userDrivenSeekTimerFired)
, m_lastSeekTime(0)
@@ -130,16 +120,21 @@ MediaPlayerPrivate::~MediaPlayerPrivate()
if (m_isAuthenticationChallenging)
AuthenticationChallengeManager::instance()->cancelAuthenticationChallenge(this);
- if (isFullscreen()) {
+ if (isFullscreen())
m_webCorePlayer->mediaPlayerClient()->mediaPlayerExitFullscreen();
- }
#if USE(ACCELERATED_COMPOSITING)
// Remove media player from platform layer.
if (m_platformLayer)
static_cast<VideoLayerWebKitThread*>(m_platformLayer.get())->setMediaPlayer(0);
#endif
- deleteGuardedObject(m_platformPlayer);
+ if (m_platformPlayer) {
+ if (m_platformPlayer->dialogState() == PlatformPlayer::DialogShown) {
+ m_platformPlayer->setDialogState(PlatformPlayer::MediaPlayerPrivateDestroyed);
+ m_platformPlayer->stop();
+ } else
+ deleteGuardedObject(m_platformPlayer);
+ }
}
void MediaPlayerPrivate::load(const WTF::String& url)
@@ -154,28 +149,60 @@ void MediaPlayerPrivate::load(const WTF::String& url)
kurl.setPath(tempPath);
modifiedUrl = kurl.string();
}
- if (modifiedUrl.startsWith("file://")) {
- // The QNX Multimedia Framework cannot handle filenames containing URL escape sequences.
+ // filesystem: URLs refer to entities in the Web File System (WFS) and are
+ // intended to be useable by HTML 5 media elements directly. Unfortunately
+ // the loader for our media player is implemented in a separate process and
+ // does not have access to WFS, so we translate to a file:// URL. Normally
+ // this would be a security violation, but since the MediaElement has
+ // already done a security check on the filesystem: URL as part of the
+ // media resource selection algorithm, we should be OK here.
+ if (modifiedUrl.startsWith("filesystem:")) {
+ KURL kurl = KURL(KURL(), modifiedUrl);
+ KURL mediaURL;
+ WTF::String fsPath;
+ FileSystemType fsType;
+ WebFileSystem::Type type;
+
+ // Extract the root and file paths from WFS
+ DOMFileSystemBase::crackFileSystemURL(kurl, fsType, fsPath);
+ if (fsType == FileSystemTypeTemporary)
+ type = WebFileSystem::Temporary;
+ else
+ type = WebFileSystem::Persistent;
+ WTF::String fsRoot = BlackBerry::Platform::WebFileSystem::rootPathForWebFileSystem(type);
+
+ // Build a BlackBerry::Platform::SecurityOrigin from the document's
+ // WebCore::SecurityOrigin and serialize it to build the last
+ // path component
+ WebCore::SecurityOrigin* wkOrigin = m_webCorePlayer->mediaPlayerClient()->mediaPlayerOwningDocument()->securityOrigin();
+ BlackBerry::Platform::SecurityOrigin bbOrigin(wkOrigin->protocol(), wkOrigin->host(), wkOrigin->port());
+ WTF::String secOrigin(bbOrigin.serialize('_'));
+
+ // Build a file:// URL from the path components and extract it to
+ // a string for further processing
+ mediaURL.setProtocol("file");
+ mediaURL.setPath(fsRoot + "/" + secOrigin + "/" + fsPath);
+ modifiedUrl = mediaURL.string();
+ } else if (modifiedUrl.startsWith("file://") || modifiedUrl.startsWith("data:")) {
+ // The QNX Multimedia Framework cannot handle filenames or data containing URL escape sequences.
modifiedUrl = decodeURLEscapeSequences(modifiedUrl);
}
void* tabId = m_webCorePlayer->mediaPlayerClient()->mediaPlayerHostWindow()->platformPageClient();
int playerID = m_webCorePlayer->mediaPlayerClient()->mediaPlayerHostWindow()->platformPageClient()->playerID();
+ bool isVideo = m_webCorePlayer->mediaPlayerClient()->mediaPlayerIsVideo();
deleteGuardedObject(m_platformPlayer);
#if USE(ACCELERATED_COMPOSITING)
- m_platformPlayer = PlatformPlayer::create(this, tabId, true, modifiedUrl.utf8().data());
+ m_platformPlayer = PlatformPlayer::create(this, tabId, isVideo, true, modifiedUrl);
#else
- m_platformPlayer = PlatformPlayer::create(this, tabId, false, modifiedUrl.utf8().data());
+ m_platformPlayer = PlatformPlayer::create(this, tabId, isVideo, false, modifiedUrl);
#endif
WTF::String cookiePairs;
if (!url.isEmpty())
- cookiePairs = cookieManager().getCookie(KURL(ParsedURLString, url.utf8().data()), WithHttpOnlyCookies);
- if (!cookiePairs.isEmpty() && cookiePairs.utf8().data())
- m_platformPlayer->load(playerID, modifiedUrl.utf8().data(), m_webCorePlayer->userAgent().utf8().data(), cookiePairs.utf8().data());
- else
- m_platformPlayer->load(playerID, modifiedUrl.utf8().data(), m_webCorePlayer->userAgent().utf8().data(), 0);
+ cookiePairs = cookieManager().getCookie(KURL(ParsedURLString, url), WithHttpOnlyCookies);
+ m_platformPlayer->load(playerID, modifiedUrl, m_webCorePlayer->userAgent(), cookiePairs);
}
void MediaPlayerPrivate::cancelLoad()
@@ -192,11 +219,8 @@ void MediaPlayerPrivate::prepareToPlay()
void MediaPlayerPrivate::play()
{
- if (m_platformPlayer) {
+ if (m_platformPlayer)
m_platformPlayer->play();
- if (m_platformPlayer->isMetadataReady())
- conditionallyGoFullscreenAfterPlay();
- }
}
void MediaPlayerPrivate::pause()
@@ -207,7 +231,7 @@ void MediaPlayerPrivate::pause()
bool MediaPlayerPrivate::supportsFullscreen() const
{
- return true;
+ return hasVideo();
}
IntSize MediaPlayerPrivate::naturalSize() const
@@ -314,6 +338,19 @@ void MediaPlayerPrivate::setVolume(float volume)
m_platformPlayer->setVolume(volume);
}
+void MediaPlayerPrivate::setMuted(bool muted)
+{
+ if (m_platformPlayer)
+ m_platformPlayer->setMuted(muted);
+}
+
+bool MediaPlayerPrivate::muted() const
+{
+ if (m_platformPlayer)
+ return m_platformPlayer->muted();
+ return false;
+}
+
MediaPlayer::NetworkState MediaPlayerPrivate::networkState() const
{
return m_networkState;
@@ -386,13 +423,12 @@ void MediaPlayerPrivate::paintCurrentFrameInContext(GraphicsContext* context, co
if (!hasVideo() || context->paintingDisabled() || !m_webCorePlayer->visible())
return;
- PlatformGraphicsContext* graphics = context->platformContext();
- ASSERT(graphics);
+ BlackBerry::Platform::Graphics::Drawable* dst = context->platformContext();
BlackBerry::Platform::IntRect platformRect(rect.x(), rect.y(), rect.width(), rect.height());
IntRect clippedRect = m_webCorePlayer->mediaPlayerClient()->mediaPlayerWindowClipRect();
BlackBerry::Platform::IntRect platformWindowClipRect(clippedRect.x(), clippedRect.y(), clippedRect.width(), clippedRect.height());
- m_platformPlayer->paint(graphics->canvas(), platformRect, platformWindowClipRect);
+ m_platformPlayer->paint(dst, platformRect, platformWindowClipRect);
}
bool MediaPlayerPrivate::hasAvailableVideoFrame() const
@@ -414,6 +450,12 @@ MediaPlayer::MovieLoadType MediaPlayerPrivate::movieLoadType() const
return MediaPlayer::Unknown;
}
+void MediaPlayerPrivate::prepareForRendering()
+{
+ if (m_platformPlayer)
+ m_platformPlayer->prepareForRendering();
+}
+
void MediaPlayerPrivate::resizeSourceDimensions()
{
if (!m_webCorePlayer)
@@ -422,22 +464,10 @@ void MediaPlayerPrivate::resizeSourceDimensions()
if (!m_webCorePlayer->mediaPlayerClient()->mediaPlayerIsVideo())
return;
- // If we have an HTMLVideoElement but the source has no video, then we need to resize the media element.
- if (!hasVideo() && PlatformPlayer::MediaOK == m_platformPlayer->error()) {
- LayoutRect rect = m_webCorePlayer->mediaPlayerClient()->mediaPlayerContentBoxRect();
-
- static const int playbookMinAudioElementWidth = 300;
- static const int playbookMinAudioElementHeight = 32;
- // If the rect dimensions are less than the allowed minimum, use the minimum instead.
- int newWidth = max(rect.width().toInt(), playbookMinAudioElementWidth);
- int newHeight = max(rect.height().toInt(), playbookMinAudioElementHeight);
-
- m_webCorePlayer->mediaPlayerClient()->mediaPlayerSetSize(IntSize(newWidth, newHeight));
- }
-
// If we don't know what the width and height of the video source is, then we need to set it to something sane.
if (m_platformPlayer->sourceWidth() && m_platformPlayer->sourceHeight())
return;
+
LayoutRect rect = m_webCorePlayer->mediaPlayerClient()->mediaPlayerContentBoxRect();
m_platformPlayer->setSourceDimension(rect.width().toUnsigned(), rect.height().toUnsigned());
}
@@ -547,26 +577,10 @@ void MediaPlayerPrivate::updateStates()
switch (m_platformPlayer->state()) {
case PlatformPlayer::MP_STATE_IDLE:
-#if USE(ACCELERATED_COMPOSITING)
- setBuffering(false);
- m_mediaIsBuffering = false;
- // Remove media player from platform layer (remove hole punch rect).
- if (m_platformLayer) {
- static_cast<VideoLayerWebKitThread*>(m_platformLayer.get())->setMediaPlayer(0);
- m_platformLayer.clear();
- }
-#endif
if (isFullscreen())
m_webCorePlayer->mediaPlayerClient()->mediaPlayerExitFullscreen();
break;
case PlatformPlayer::MP_STATE_ACTIVE:
-#if USE(ACCELERATED_COMPOSITING)
- m_showBufferingImage = false;
- m_mediaIsBuffering = false;
- // Create platform layer for video (create hole punch rect).
- if (!m_platformLayer && supportsAcceleratedRendering())
- m_platformLayer = VideoLayerWebKitThread::create(m_webCorePlayer);
-#endif
break;
case PlatformPlayer::MP_STATE_UNSUPPORTED:
break;
@@ -595,12 +609,12 @@ void MediaPlayerPrivate::onMediaStatusChanged(PlatformPlayer::MMRPlayState)
updateStates();
}
-void MediaPlayerPrivate::onError(PlatformPlayer::Error type)
+void MediaPlayerPrivate::onError(PlatformPlayer::Error)
{
updateStates();
}
-void MediaPlayerPrivate::onDurationChanged(float duration)
+void MediaPlayerPrivate::onDurationChanged(float)
{
updateStates();
m_webCorePlayer->durationChanged();
@@ -679,9 +693,8 @@ void MediaPlayerPrivate::onWaitMetadataNotified(bool hasFinished, int timeWaited
void MediaPlayerPrivate::waitMetadataTimerFired(Timer<MediaPlayerPrivate>*)
{
if (m_platformPlayer->isMetadataReady()) {
- m_platformPlayer->playWithMetadataReady();
- conditionallyGoFullscreenAfterPlay();
m_waitMetadataPopDialogCounter = 0;
+ m_platformPlayer->playWithMetadataReady();
return;
}
@@ -693,14 +706,15 @@ void MediaPlayerPrivate::waitMetadataTimerFired(Timer<MediaPlayerPrivate>*)
}
m_waitMetadataPopDialogCounter = 0;
- int wait = showErrorDialog(PlatformPlayer::MediaMetaDataTimeoutError);
- if (!wait)
+ PlatformPlayer::DialogResult wait = m_platformPlayer->showErrorDialog(PlatformPlayer::MediaMetaDataTimeoutError);
+ if (wait == PlatformPlayer::DialogEmergencyExit)
+ return;
+ if (wait == PlatformPlayer::DialogResponse0)
onPauseNotified();
else {
- if (m_platformPlayer->isMetadataReady()) {
+ if (m_platformPlayer->isMetadataReady())
m_platformPlayer->playWithMetadataReady();
- conditionallyGoFullscreenAfterPlay();
- } else
+ else
m_waitMetadataTimer.startOneShot(checkMetadataReadyInterval);
}
}
@@ -718,9 +732,9 @@ static ProtectionSpace generateProtectionSpaceFromMMRAuthChallenge(const MMRAuth
ASSERT(url.isValid());
return ProtectionSpace(url.host(), url.port(),
- static_cast<ProtectionSpaceServerType>(authChallenge.serverType()),
- authChallenge.realm().c_str(),
- static_cast<ProtectionSpaceAuthenticationScheme>(authChallenge.authScheme()));
+ static_cast<ProtectionSpaceServerType>(authChallenge.serverType()),
+ authChallenge.realm().c_str(),
+ static_cast<ProtectionSpaceAuthenticationScheme>(authChallenge.authScheme()));
}
void MediaPlayerPrivate::onAuthenticationNeeded(MMRAuthChallenge& authChallenge)
@@ -736,24 +750,19 @@ void MediaPlayerPrivate::onAuthenticationNeeded(MMRAuthChallenge& authChallenge)
return;
}
- if (!frameView() || !frameView()->hostWindow())
- return;
-
m_isAuthenticationChallenging = true;
AuthenticationChallengeManager::instance()->authenticationChallenge(url, protectionSpace, credential,
- this, frameView()->hostWindow()->platformPageClient());
+ this, m_webCorePlayer->mediaPlayerClient()->mediaPlayerHostWindow()->platformPageClient());
}
-void MediaPlayerPrivate::notifyChallengeResult(const KURL& url, const ProtectionSpace& protectionSpace, AuthenticationChallengeResult result, const Credential& credential)
+void MediaPlayerPrivate::notifyChallengeResult(const KURL& url, const ProtectionSpace&, AuthenticationChallengeResult result, const Credential& credential)
{
m_isAuthenticationChallenging = false;
if (result != AuthenticationChallengeSuccess || !url.isValid())
return;
- m_platformPlayer->reloadWithCredential(credential.user().utf8(String::StrictConversion).data(),
- credential.password().utf8(String::StrictConversion).data(),
- static_cast<MMRAuthChallenge::CredentialPersistence>(credential.persistence()));
+ m_platformPlayer->reloadWithCredential(credential.user(), credential.password(), static_cast<MMRAuthChallenge::CredentialPersistence>(credential.persistence()));
}
void MediaPlayerPrivate::onAuthenticationAccepted(const MMRAuthChallenge& authChallenge) const
@@ -768,7 +777,7 @@ void MediaPlayerPrivate::onAuthenticationAccepted(const MMRAuthChallenge& authCh
CredentialStorage::set(Credential(authChallenge.username().c_str(), authChallenge.password().c_str(), static_cast<CredentialPersistence>(authChallenge.persistence())), protectionSpace, url);
}
-int MediaPlayerPrivate::showErrorDialog(PlatformPlayer::Error type)
+int MediaPlayerPrivate::onShowErrorDialog(PlatformPlayer::Error type)
{
using namespace BlackBerry::WebKit;
@@ -807,7 +816,7 @@ int MediaPlayerPrivate::showErrorDialog(PlatformPlayer::Error type)
static WebMediaStreamSource toWebMediaStreamSource(MediaStreamSource* src)
{
- return WebMediaStreamSource(src->id().utf8().data(), static_cast<WebMediaStreamSource::Type>(src->type()), src->name().utf8().data());
+ return WebMediaStreamSource(src->id(), static_cast<WebMediaStreamSource::Type>(src->type()), src->name());
}
static WebMediaStreamDescriptor toWebMediaStreamDescriptor(MediaStreamDescriptor* d)
@@ -820,7 +829,7 @@ static WebMediaStreamDescriptor toWebMediaStreamDescriptor(MediaStreamDescriptor
for (size_t i = 0; i < d->numberOfVideoComponents(); i++)
videoSources.push_back(toWebMediaStreamSource(d->videoComponent(i)->source()));
- return WebMediaStreamDescriptor(d->label().utf8().data(), audioSources, videoSources);
+ return WebMediaStreamDescriptor(d->id(), audioSources, videoSources);
}
WebMediaStreamDescriptor MediaPlayerPrivate::lookupMediaStream(const BlackBerry::Platform::String& url)
@@ -837,6 +846,11 @@ BlackBerry::Platform::Graphics::Window* MediaPlayerPrivate::platformWindow()
return m_webCorePlayer->mediaPlayerClient()->mediaPlayerHostWindow()->platformPageClient()->platformWindow();
}
+bool MediaPlayerPrivate::isProcessingUserGesture() const
+{
+ return m_webCorePlayer->mediaPlayerClient()->mediaPlayerIsProcessingUserGesture();
+}
+
bool MediaPlayerPrivate::isFullscreen() const
{
return m_fullscreenWebPageClient;
@@ -861,9 +875,8 @@ bool MediaPlayerPrivate::supportsAcceleratedRendering() const
#if USE(ACCELERATED_COMPOSITING)
static const double BufferingAnimationDelay = 1.0 / 24;
-static char* s_bufferingImageData = 0;
-static int s_bufferingImageWidth = 0;
-static int s_bufferingImageHeight = 0;
+static unsigned* s_bufferingImageData = 0;
+static IntSize s_bufferingImageSize;
PlatformMedia MediaPlayerPrivate::platformMedia() const
{
@@ -885,23 +898,18 @@ static void loadBufferingImageData()
static bool loaded = false;
if (!loaded) {
static Image* bufferingIcon = Image::loadPlatformResource("vidbuffer").leakRef();
- NativeImageSkia* nativeImage = bufferingIcon->nativeImageForCurrentFrame();
- if (!nativeImage)
- return;
- if (!nativeImage->isDataComplete())
+ NativeImagePtr nativeImage = bufferingIcon->nativeImageForCurrentFrame();
+ if (!nativeImage)
return;
loaded = true;
- nativeImage->bitmap().lockPixels();
+ s_bufferingImageSize = bufferingIcon->size();
+ int bufSize = bufferingIcon->decodedSize();
+ s_bufferingImageData = static_cast<unsigned*>(malloc(bufSize));
- int bufSize = nativeImage->bitmap().width() * nativeImage->bitmap().height() * 4;
- s_bufferingImageWidth = nativeImage->bitmap().width();
- s_bufferingImageHeight = nativeImage->bitmap().height();
- s_bufferingImageData = static_cast<char*>(malloc(bufSize));
- memcpy(s_bufferingImageData, nativeImage->bitmap().getPixels(), bufSize);
+ nativeImage->readPixels(s_bufferingImageData, s_bufferingImageSize.width() * s_bufferingImageSize.height());
- nativeImage->bitmap().unlockPixels();
bufferingIcon->deref();
}
}
@@ -917,8 +925,9 @@ void MediaPlayerPrivate::bufferingTimerFired(Timer<MediaPlayerPrivate>*)
void MediaPlayerPrivate::setBuffering(bool buffering)
{
- if (!hasVideo())
+ if (!m_webCorePlayer || !m_webCorePlayer->mediaPlayerClient() || !m_webCorePlayer->mediaPlayerClient()->mediaPlayerIsVideo())
buffering = false; // Buffering animation not visible for audio.
+
if (buffering != m_showBufferingImage) {
m_showBufferingImage = buffering;
if (buffering) {
@@ -932,9 +941,9 @@ void MediaPlayerPrivate::setBuffering(bool buffering)
}
}
-static unsigned int allocateTextureId()
+static unsigned allocateTextureId()
{
- unsigned int texid;
+ unsigned texid;
glGenTextures(1, &texid);
glBindTexture(GL_TEXTURE_2D, texid);
// Do basic linear filtering on resize.
@@ -946,65 +955,93 @@ static unsigned int allocateTextureId()
return texid;
}
-void MediaPlayerPrivate::drawBufferingAnimation(const TransformationMatrix& matrix, int positionLocation, int texCoordLocation)
+void MediaPlayerPrivate::drawBufferingAnimation(const TransformationMatrix& matrix, const Graphics::GLES2Program& program)
{
if (m_showBufferingImage && s_bufferingImageData && !isFullscreen()) {
TransformationMatrix renderMatrix = matrix;
// Rotate the buffering indicator so that it takes 1 second to do 1 revolution.
timespec time;
- clock_gettime(CLOCK_REALTIME, &time);
+ clock_gettime(CLOCK_MONOTONIC, &time);
renderMatrix.rotate(time.tv_nsec / 1000000000.0 * 360.0);
static bool initialized = false;
- static unsigned int texId = allocateTextureId();
+ static unsigned texId = allocateTextureId();
glBindTexture(GL_TEXTURE_2D, texId);
if (!initialized) {
initialized = true;
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, s_bufferingImageWidth, s_bufferingImageHeight,
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, s_bufferingImageSize.width(), s_bufferingImageSize.height(),
0, GL_RGBA, GL_UNSIGNED_BYTE, s_bufferingImageData);
free(s_bufferingImageData);
}
- float texcoords[] = { 0, 0, 0, 1, 1, 1, 1, 0 };
- FloatPoint vertices[4];
- float bx = s_bufferingImageWidth / 2.0;
- float by = s_bufferingImageHeight / 2.0;
- vertices[0] = renderMatrix.mapPoint(FloatPoint(-bx, -by));
- vertices[1] = renderMatrix.mapPoint(FloatPoint(-bx, by));
- vertices[2] = renderMatrix.mapPoint(FloatPoint(bx, by));
- vertices[3] = renderMatrix.mapPoint(FloatPoint(bx, -by));
-
- glVertexAttribPointer(positionLocation, 2, GL_FLOAT, GL_FALSE, 0, vertices);
- glVertexAttribPointer(texCoordLocation, 2, GL_FLOAT, GL_FALSE, 0, texcoords);
+ float texcoords[] = { 0, 0, 1, 0, 1, 1, 0, 1 };
+ FloatRect bufferingImageRect(FloatPoint(-s_bufferingImageSize.width() / 2.0f, -s_bufferingImageSize.height() / 2.0f), s_bufferingImageSize);
+ FloatQuad transformedQuad = renderMatrix.mapQuad(bufferingImageRect);
+
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ glUniform1f(program.opacityLocation(), 1.0);
+ glVertexAttribPointer(program.positionLocation(), 2, GL_FLOAT, GL_FALSE, 0, &transformedQuad);
+ glVertexAttribPointer(program.texCoordLocation(), 2, GL_FLOAT, GL_FALSE, 0, texcoords);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
}
}
#endif
-void MediaPlayerPrivate::conditionallyGoFullscreenAfterPlay()
+void MediaPlayerPrivate::onConditionallyEnterFullscreen()
{
+ Document* owningDocument = m_webCorePlayer->mediaPlayerClient()->mediaPlayerOwningDocument();
BlackBerry::Platform::DeviceInfo* info = BlackBerry::Platform::DeviceInfo::instance();
- if (hasVideo() && m_webCorePlayer->mediaPlayerClient()->mediaPlayerIsFullscreenPermitted() && info->isMobile()) {
+
+ // Don't allow video in <embed> and <object> containers to go fullscreen
+ // on play because this does not currently work. Detect this by checking
+ // for MediaDocument with a parent document.
+ if (owningDocument->isMediaDocument() && owningDocument->parentDocument())
+ return;
+
+ if (info->isMobile()) {
// This is a mobile device (small screen), not a tablet, so we
// enter fullscreen video on user-initiated plays.
bool nothingIsFullscreen = !m_webCorePlayer->mediaPlayerClient()->mediaPlayerIsFullscreen();
#if ENABLE(FULLSCREEN_API)
- if (m_webCorePlayer->mediaPlayerClient()->mediaPlayerOwningDocument()->webkitIsFullScreen())
+ if (owningDocument->webkitIsFullScreen())
nothingIsFullscreen = false;
#endif
- if (nothingIsFullscreen && currentTime() == 0.0f) {
- // Only enter fullscreen when playing from the beginning. Doing
- // so on every play is sure to annoy the user who does not want
- // to watch the video fullscreen. Note that the following call
- // will fail if we are not here due to a user gesture, as per the
- // check in Document::requestFullScreenForElement() to prevent
- // popups.
+ if (nothingIsFullscreen)
m_webCorePlayer->mediaPlayerClient()->mediaPlayerEnterFullscreen();
- }
}
}
+void MediaPlayerPrivate::onExitFullscreen()
+{
+ if (m_webCorePlayer->mediaPlayerClient()->mediaPlayerIsFullscreen())
+ m_webCorePlayer->mediaPlayerClient()->mediaPlayerExitFullscreen();
+}
+
+void MediaPlayerPrivate::onCreateHolePunchRect()
+{
+#if USE(ACCELERATED_COMPOSITING)
+ // Create platform layer for video (create hole punch rect).
+ if (!m_platformLayer && supportsAcceleratedRendering()) {
+ m_showBufferingImage = false;
+ m_platformLayer = VideoLayerWebKitThread::create(m_webCorePlayer);
+ }
+#endif
+}
+
+void MediaPlayerPrivate::onDestroyHolePunchRect()
+{
+#if USE(ACCELERATED_COMPOSITING)
+ setBuffering(false);
+ // Remove media player from platform layer (remove hole punch rect).
+ if (m_platformLayer) {
+ static_cast<VideoLayerWebKitThread*>(m_platformLayer.get())->setMediaPlayer(0);
+ m_platformLayer.clear();
+ }
+#endif
+}
+
} // namespace WebCore
#endif // ENABLE(VIDEO)
diff --git a/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h b/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h
index 303c57a51..b3465bb11 100644
--- a/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h
+++ b/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h
@@ -26,8 +26,13 @@
#include <BlackBerryPlatformPlayer.h>
namespace BlackBerry {
+
namespace Platform {
class IntRect;
+
+namespace Graphics {
+class GLES2Program;
+}
}
namespace WebKit {
@@ -55,7 +60,7 @@ public:
#if USE(ACCELERATED_COMPOSITING)
virtual PlatformMedia platformMedia() const;
virtual PlatformLayer* platformLayer() const;
- void drawBufferingAnimation(const TransformationMatrix&, int positionLocation, int texCoordLocation);
+ void drawBufferingAnimation(const TransformationMatrix&, const BlackBerry::Platform::Graphics::GLES2Program&);
#endif
virtual void play();
@@ -79,8 +84,11 @@ public:
virtual void setRate(float);
virtual bool paused() const;
+ virtual bool muted() const;
+ virtual bool supportsMuting() const { return true; }
virtual void setVolume(float);
+ virtual void setMuted(bool);
virtual MediaPlayer::NetworkState networkState() const;
virtual MediaPlayer::ReadyState readyState() const;
@@ -109,6 +117,8 @@ public:
virtual MediaPlayer::MovieLoadType movieLoadType() const;
+ virtual void prepareForRendering();
+
void resizeSourceDimensions();
void setFullscreenWebPageClient(BlackBerry::WebKit::WebPageClient*);
BlackBerry::Platform::Graphics::Window* getWindow();
@@ -139,13 +149,18 @@ public:
#endif
virtual void onAuthenticationNeeded(BlackBerry::Platform::MMRAuthChallenge&);
virtual void onAuthenticationAccepted(const BlackBerry::Platform::MMRAuthChallenge&) const;
+ virtual void onConditionallyEnterFullscreen();
+ virtual void onExitFullscreen();
+ virtual void onCreateHolePunchRect();
+ virtual void onDestroyHolePunchRect();
virtual void notifyChallengeResult(const KURL&, const ProtectionSpace&, AuthenticationChallengeResult, const Credential&);
+ virtual bool isProcessingUserGesture() const;
virtual bool isFullscreen() const;
virtual bool isElementPaused() const;
virtual bool isTabVisible() const;
- virtual int showErrorDialog(BlackBerry::Platform::PlatformPlayer::Error);
+ virtual int onShowErrorDialog(BlackBerry::Platform::PlatformPlayer::Error);
virtual BlackBerry::Platform::Graphics::Window* platformWindow();
virtual BlackBerry::Platform::WebMediaStreamDescriptor lookupMediaStream(const BlackBerry::Platform::String& url);
@@ -171,10 +186,8 @@ private:
Timer<MediaPlayerPrivate> m_bufferingTimer;
RefPtr<PlatformLayer> m_platformLayer;
bool m_showBufferingImage;
- bool m_mediaIsBuffering;
#endif
- void conditionallyGoFullscreenAfterPlay();
void userDrivenSeekTimerFired(Timer<MediaPlayerPrivate>*);
Timer<MediaPlayerPrivate> m_userDrivenSeekTimer;
float m_lastSeekTime;
diff --git a/Source/WebCore/platform/graphics/blackberry/PathBlackBerry.cpp b/Source/WebCore/platform/graphics/blackberry/PathBlackBerry.cpp
new file mode 100644
index 000000000..cd658914e
--- /dev/null
+++ b/Source/WebCore/platform/graphics/blackberry/PathBlackBerry.cpp
@@ -0,0 +1,285 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "Path.h"
+
+#include "AffineTransform.h"
+#include "FloatRect.h"
+#include "GraphicsContext.h"
+#include "NotImplemented.h"
+#include "StrokeStyleApplier.h"
+
+#include <BlackBerryPlatformGraphics.h>
+#include <BlackBerryPlatformGraphicsContext.h>
+#include <BlackBerryPlatformPath.h>
+#include <stdio.h>
+#include <wtf/MathExtras.h>
+
+namespace WebCore {
+
+static GraphicsContext* scratchContext()
+{
+ static BlackBerry::Platform::Graphics::Buffer* buffer = BlackBerry::Platform::Graphics::createBuffer(IntSize(), BlackBerry::Platform::Graphics::NeverBacked);
+ static PlatformGraphicsContext* pgc = lockBufferDrawable(buffer);
+ static GraphicsContext gc(pgc);
+ return &gc;
+}
+
+Path::Path() : m_path(new BlackBerry::Platform::Graphics::Path)
+{
+}
+
+Path::Path(const PlatformPath& path)
+ : m_path(new BlackBerry::Platform::Graphics::Path(path))
+{
+}
+
+Path::~Path()
+{
+ if (m_path) {
+ delete m_path;
+ m_path = 0;
+ }
+}
+
+Path::Path(const Path& other)
+{
+ m_path = new BlackBerry::Platform::Graphics::Path(*other.m_path);
+}
+
+Path& Path::operator=(const Path& other)
+{
+ if (m_path) {
+ delete m_path;
+ m_path = 0;
+ }
+ m_path = new BlackBerry::Platform::Graphics::Path(*other.m_path);
+ return *this;
+}
+
+FloatPoint Path::currentPoint() const
+{
+ return m_path->currentPoint();
+}
+
+bool Path::contains(const FloatPoint& point, WindRule rule) const
+{
+ return m_path->contains(point, (BlackBerry::Platform::Graphics::WindRule)(rule));
+}
+
+bool Path::strokeContains(StrokeStyleApplier* applier, const FloatPoint& point) const
+{
+ GraphicsContext* scratch = scratchContext();
+ scratch->save();
+
+ if (applier)
+ applier->strokeStyle(scratch);
+
+ bool result = scratchContext()->platformContext()->strokeContains(*m_path, point);
+ scratch->restore();
+ return result;
+}
+
+void Path::translate(const FloatSize& size)
+{
+ AffineTransform transformation;
+ transformation.translate(size.width(), size.height());
+ transform(transformation);
+}
+
+FloatRect Path::boundingRect() const
+{
+ return m_path->getBounds();
+}
+
+FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier) const
+{
+ GraphicsContext* scratch = scratchContext();
+ scratch->save();
+
+ if (applier)
+ applier->strokeStyle(scratch);
+
+ FloatRect result = scratch->platformContext()->getStrokeBounds(*m_path);
+
+ scratch->restore();
+ return result;
+}
+
+void Path::moveTo(const FloatPoint& point)
+{
+ m_path->moveTo(point);
+}
+
+void Path::addLineTo(const FloatPoint& point)
+{
+ m_path->addLineTo(point);
+}
+
+void Path::addQuadCurveTo(const FloatPoint& controlPoint, const FloatPoint& endPoint)
+{
+ m_path->addQuadCurveTo(controlPoint, endPoint);
+}
+
+void Path::addBezierCurveTo(const FloatPoint& controlPoint1, const FloatPoint& controlPoint2, const FloatPoint& endPoint)
+{
+ m_path->addBezierCurveTo(controlPoint1, controlPoint2, endPoint);
+}
+
+void Path::addArcTo(const FloatPoint& point1, const FloatPoint& point2, float radius)
+{
+ m_path->addArcTo(point1, point2, radius);
+}
+
+void Path::closeSubpath()
+{
+ m_path->closeSubpath();
+}
+
+void Path::addArc(const FloatPoint& center, float radius, float startAngle, float endAngle, bool anticlockwise)
+{
+ m_path->addArc(center, radius, startAngle, endAngle, anticlockwise);
+}
+
+void Path::addRect(const FloatRect& rect)
+{
+ m_path->addRect(rect);
+}
+
+void Path::addEllipse(const FloatRect& rect)
+{
+ m_path->addEllipse(rect);
+}
+
+void Path::platformAddPathForRoundedRect(const FloatRect& rect, const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius)
+{
+ if (rect.isEmpty())
+ return;
+
+ if (rect.width() < topLeftRadius.width() + topRightRadius.width()
+ || rect.width() < bottomLeftRadius.width() + bottomRightRadius.width()
+ || rect.height() < topLeftRadius.height() + bottomLeftRadius.height()
+ || rect.height() < topRightRadius.height() + bottomRightRadius.height()) {
+ // If all the radii cannot be accommodated, return a rect.
+ addRect(rect);
+ return;
+ }
+
+ BlackBerry::Platform::FloatRoundedRect rr(rect, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius);
+ // Make sure the generic path reflects the contents of the rounded rects
+ m_path->addRoundedRect(rr);
+}
+
+void Path::clear()
+{
+ m_path->reset();
+}
+
+bool Path::isEmpty() const
+{
+ return m_path->isEmpty();
+}
+
+bool Path::hasCurrentPoint() const
+{
+ return m_path->hasCurrentPoint();
+}
+
+void Path::apply(void* info, PathApplierFunction function) const
+{
+ m_path->apply(info, (void*)function);
+}
+
+void Path::transform(const AffineTransform& transformation)
+{
+ m_path->transform(reinterpret_cast<const double*>(&transformation));
+}
+
+void GraphicsContext::fillPath(const Path& path)
+{
+ BlackBerry::Platform::Graphics::Path* pp = path.platformPath();
+ if (!pp->isEmpty()) {
+ BlackBerry::Platform::Graphics::Gradient* platformGradient = fillGradient() ? fillGradient()->platformGradient() : 0;
+ BlackBerry::Platform::Graphics::Pattern* platformPattern = fillPattern() ? fillPattern()->platformPattern(AffineTransform()) : 0;
+ platformContext()->addFillPath(*pp, (BlackBerry::Platform::Graphics::WindRule)m_state.fillRule, platformGradient, platformPattern);
+ }
+}
+
+void GraphicsContext::strokePath(const Path& path)
+{
+ BlackBerry::Platform::Graphics::Path* pp = path.platformPath();
+ if (!pp->isEmpty()) {
+ BlackBerry::Platform::Graphics::Gradient* gradient = strokeGradient() ? strokeGradient()->platformGradient() : 0;
+ BlackBerry::Platform::Graphics::Pattern* pattern = strokePattern() ? strokePattern()->platformPattern(AffineTransform()) : 0;
+ platformContext()->addStrokePath(*pp, gradient, pattern);
+ }
+}
+
+void GraphicsContext::drawFocusRing(const Vector<IntRect>&, int, int, const Color&)
+{
+ notImplemented();
+}
+
+void GraphicsContext::drawFocusRing(const Path&, int, int, const Color&)
+{
+ notImplemented();
+}
+
+void GraphicsContext::drawLine(const IntPoint& from, const IntPoint& to)
+{
+ platformContext()->addDrawLine(from, to);
+}
+
+void GraphicsContext::drawLineForDocumentMarker(const FloatPoint& pt, float width, DocumentMarkerLineStyle style)
+{
+ platformContext()->addDrawLineForDocumentMarker(pt, width, (BlackBerry::Platform::Graphics::DocumentMarkerLineStyle)style);
+}
+
+void GraphicsContext::drawLineForText(const FloatPoint& pt, float width, bool printing)
+{
+ platformContext()->addDrawLineForText(pt, width, printing);
+}
+
+// FIXME: don't ignore the winding rule. https://bugs.webkit.org/show_bug.cgi?id=107064
+void GraphicsContext::clip(const Path& path, WindRule)
+{
+ BlackBerry::Platform::Graphics::Path* pp = path.platformPath();
+ pp->applyAsClip(platformContext());
+}
+
+void GraphicsContext::clipPath(const Path& path, WindRule)
+{
+ if (path.platformPath()->isRectangular())
+ platformContext()->clip(path.boundingRect());
+ else
+ clip(path);
+}
+
+void GraphicsContext::canvasClip(const Path& path, WindRule fillRule)
+{
+ clip(path, fillRule);
+}
+
+void GraphicsContext::clipOut(const Path& path)
+{
+ BlackBerry::Platform::Graphics::Path* pp = path.platformPath();
+ pp->applyAsClipOut(platformContext());
+}
+
+}
diff --git a/Source/WebCore/platform/graphics/blackberry/PatternBlackBerry.cpp b/Source/WebCore/platform/graphics/blackberry/PatternBlackBerry.cpp
new file mode 100644
index 000000000..4d99a1c33
--- /dev/null
+++ b/Source/WebCore/platform/graphics/blackberry/PatternBlackBerry.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "Pattern.h"
+
+#include "AffineTransform.h"
+#include "Image.h"
+#include "NativeImagePtr.h"
+#include "Path.h"
+
+#include <BlackBerryPlatformGraphicsContext.h>
+
+using namespace std;
+
+namespace WebCore {
+
+void Pattern::platformDestroy()
+{
+ delete m_pattern;
+ m_pattern = 0;
+}
+
+PlatformPatternPtr Pattern::platformPattern(const AffineTransform&)
+{
+ if (m_pattern)
+ return m_pattern;
+
+ const NativeImagePtr image = m_tileImage->nativeImageForCurrentFrame();
+
+ m_pattern = BlackBerry::Platform::Graphics::Pattern::create();
+
+ m_pattern->setImage(image, m_repeatX, m_repeatY);
+ m_pattern->setLocalMatrix(reinterpret_cast<const double*>(&m_patternSpaceTransformation));
+
+ return m_pattern;
+}
+
+void Pattern::setPlatformPatternSpaceTransform()
+{
+ if (m_pattern)
+ m_pattern->setLocalMatrix(reinterpret_cast<const double*>(&m_patternSpaceTransformation));
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/blackberry/PluginLayerWebKitThread.cpp b/Source/WebCore/platform/graphics/blackberry/PluginLayerWebKitThread.cpp
index c22254cb7..af71c10bf 100644
--- a/Source/WebCore/platform/graphics/blackberry/PluginLayerWebKitThread.cpp
+++ b/Source/WebCore/platform/graphics/blackberry/PluginLayerWebKitThread.cpp
@@ -41,7 +41,7 @@ void PluginLayerWebKitThread::setPluginView(PluginView* pluginView)
{
m_pluginView = pluginView;
setNeedsTexture(isDrawable() && pluginView);
- setLayerProgramShader(LayerProgramShaderRGBA);
+ setLayerProgram(LayerProgramRGBA);
if (m_pluginView)
setNeedsDisplay();
diff --git a/Source/WebCore/platform/graphics/blackberry/SimpleFontDataBlackBerry.cpp b/Source/WebCore/platform/graphics/blackberry/SimpleFontDataBlackBerry.cpp
new file mode 100644
index 000000000..e5631531f
--- /dev/null
+++ b/Source/WebCore/platform/graphics/blackberry/SimpleFontDataBlackBerry.cpp
@@ -0,0 +1,214 @@
+/*
+ * Copyright (C) 2012, 2013 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "SimpleFontData.h"
+
+#include "FloatRect.h"
+#include "Font.h"
+#include "FontCache.h"
+#include "FontDescription.h"
+#include "ITypeUtils.h"
+
+#include <fs_api.h>
+#include <unicode/normlzr.h>
+
+namespace WebCore {
+
+static inline float FSFixedToFloat(FS_FIXED n) { return n / 65536.0; }
+
+#define openTypeTag(a, b, c, d) (FS_ULONG)((a << 24) | (b << 16) | (c << 8) | d)
+
+void SimpleFontData::platformInit()
+{
+ FS_FIXED ascender = 0;
+ FS_FIXED descender = 0;
+ FS_FIXED leading = 0;
+ FsAscDescLeadSource source;
+ FS_LONG result;
+ if (m_platformData.size() > 0) {
+ // FIXME: hack! FS_get_ascender_descender_leading() returns ERR_NO_CURRENT_SFNT when size is 0, even though we called FS_set_scale and m_platformData.font()->cur_sfnt is not 0
+ result = FS_get_ascender_descender_leading(m_platformData.font(), &ascender, &descender, &leading, &source);
+ ASSERT_UNUSED(result, result == SUCCESS);
+ }
+
+ m_fontMetrics.setAscent(FS_ROUND(ascender));
+ m_fontMetrics.setDescent(FS_ROUND(descender));
+ m_fontMetrics.setLineGap(iTypeFixedToFloat(leading));
+ m_fontMetrics.setLineSpacing(lroundf(m_fontMetrics.ascent()) + lroundf(m_fontMetrics.descent()) + lroundf(m_fontMetrics.lineGap()));
+
+ FONT_METRICS metrics;
+ result = FS_font_metrics(m_platformData.font(), &metrics);
+ ASSERT_UNUSED(result, result == SUCCESS);
+
+ // m_fontMetrics.setUnitsPerEm(FS_get_design_units(m_platformData().font()));
+ m_fontMetrics.setUnitsPerEm(metrics.unitsPerEm);
+
+ FS_USHORT xRange = metrics.font_bbox.xMax - metrics.font_bbox.xMin;
+ m_maxCharWidth = roundf((xRange * roundf(m_platformData.size())) / metrics.unitsPerEm);
+
+ TTF_OS2 os2;
+ if (FS_get_table_structure(m_platformData.font(), TAG_OS2, &os2) == SUCCESS && os2.sxHeight && os2.xAvgCharWidth) {
+ FS_USHORT yppem = m_platformData.font()->lpm;
+ m_fontMetrics.setXHeight(static_cast<float>(os2.sxHeight) * yppem / metrics.unitsPerEm);
+ m_avgCharWidth = static_cast<float>(os2.xAvgCharWidth) * yppem / metrics.unitsPerEm;
+ } else {
+ // HACK
+ m_fontMetrics.setXHeight(m_fontMetrics.ascent() * 0.56);
+ m_fontMetrics.setHasXHeight(false);
+ m_avgCharWidth = m_fontMetrics.xHeight();
+
+ GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->page();
+
+ if (glyphPageZero) {
+ static const UChar32 xChar = 'x';
+ const Glyph xGlyph = glyphPageZero->glyphDataForCharacter(xChar).glyph;
+
+ if (xGlyph) {
+ // In widthForGlyph(), xGlyph will be compared with
+ // m_zeroWidthSpaceGlyph, which isn't initialized yet here.
+ // Initialize it with zero to make sure widthForGlyph() returns
+ // the right width.
+ m_zeroWidthSpaceGlyph = 0;
+ m_avgCharWidth = widthForGlyph(xGlyph);
+ }
+ }
+ }
+
+ if (m_platformData.orientation() == Vertical && !isTextOrientationFallback())
+ m_hasVerticalGlyphs = FS_get_table(m_platformData.font(), openTypeTag('v', 'h', 'e', 'a'), TBL_QUERY, 0)
+ || FS_get_table(m_platformData.font(), openTypeTag('V', 'O', 'R', 'G'), TBL_QUERY, 0);
+}
+
+void SimpleFontData::platformCharWidthInit()
+{
+}
+
+void SimpleFontData::platformDestroy()
+{
+}
+
+PassRefPtr<SimpleFontData> SimpleFontData::platformCreateScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
+{
+ const float scaledSize = lroundf(fontDescription.computedSize() * scaleFactor);
+ return adoptRef(new SimpleFontData(
+ FontPlatformData(m_platformData.font()->cur_lfnt->name,
+ scaledSize,
+ m_platformData.syntheticBold(),
+ m_platformData.syntheticOblique(),
+ m_platformData.orientation(),
+ m_platformData.widthVariant()),
+ isCustomFont(), false));
+}
+
+bool SimpleFontData::containsCharacters(const UChar* characters, int length) const
+{
+ int position = 0;
+
+ while (position < length) {
+ // FIXME: use shaper?
+ UChar32 character;
+ int nextPosition = position;
+ U16_NEXT(characters, nextPosition, length, character);
+
+ FS_USHORT glyph = FS_map_char(m_platformData.font(), static_cast<FS_ULONG>(character));
+ if (!glyph)
+ return false;
+
+ position = nextPosition;
+ }
+
+ return true;
+}
+
+void SimpleFontData::determinePitch()
+{
+ m_treatAsFixedPitch = m_platformData.isFixedPitch();
+}
+
+FloatRect SimpleFontData::platformBoundsForGlyph(Glyph glyph) const
+{
+ FS_GLYPHMAP* glyphmap = FS_get_glyphmap(m_platformData.font(), glyph, FS_MAP_DISTANCEFIELD | FS_MAP_GRAYMAP8);
+ if (!glyphmap)
+ return FloatRect();
+
+ FloatRect bounds(glyphmap->lo_x, glyphmap->height - glyphmap->hi_y, glyphmap->width, glyphmap->height);
+ FS_free_char(m_platformData.font(), glyphmap);
+
+ return bounds;
+}
+
+float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
+{
+ FS_SHORT idx, idy;
+ FS_FIXED dx, dy;
+ FS_FIXED s00, s01, s10, s11;
+ bool needsFakeBoldReset = m_platformData.syntheticBold() && m_treatAsFixedPitch;
+
+ if (needsFakeBoldReset) {
+ FS_get_scale(m_platformData.font(), &s00, &s01, &s10, &s11);
+ FS_set_bold_pct(m_platformData.font(), 0);
+ FS_set_scale(m_platformData.font(), s00, s01, s10, s11);
+ }
+
+ if (FS_get_advance(m_platformData.font(), glyph, FS_MAP_DISTANCEFIELD | FS_MAP_GRAYMAP8, &idx, &idy, &dx, &dy) != SUCCESS)
+ dx = 0;
+
+ if (needsFakeBoldReset) {
+ FS_set_bold_pct(m_platformData.font(), ITYPEFAKEBOLDAMOUNT);
+ FS_set_scale(m_platformData.font(), s00, s01, s10, s11);
+ }
+
+ return iTypeFixedToFloat(dx);
+}
+
+bool SimpleFontData::canRenderCombiningCharacterSequence(const UChar* characters, size_t length) const
+{
+ if (!m_combiningCharacterSequenceSupport)
+ m_combiningCharacterSequenceSupport = adoptPtr(new HashMap<String, bool>);
+
+ WTF::HashMap<String, bool>::AddResult addResult = m_combiningCharacterSequenceSupport->add(String(characters, length), false);
+ if (!addResult.isNewEntry)
+ return addResult.iterator->value;
+
+ UErrorCode error = U_ZERO_ERROR;
+ Vector<UChar, 4> normalizedCharacters(length);
+ int32_t normalizedLength = unorm_normalize(characters, length, UNORM_NFC, UNORM_UNICODE_3_2, &normalizedCharacters[0], length, &error);
+ if (U_FAILURE(error))
+ return false;
+
+ int position = 0;
+ while (position < normalizedLength) {
+ UChar32 character;
+ int nextPosition = position;
+ U16_NEXT(normalizedCharacters, nextPosition, normalizedLength, character);
+
+ if (!u_hasBinaryProperty(character, UCHAR_DEFAULT_IGNORABLE_CODE_POINT)) {
+ FS_USHORT glyph = FS_map_char(m_platformData.font(), static_cast<FS_ULONG>(character));
+ if (!glyph)
+ return false;
+ }
+
+ position = nextPosition;
+ }
+
+ addResult.iterator->value = true;
+ return true;
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/blackberry/Texture.cpp b/Source/WebCore/platform/graphics/blackberry/Texture.cpp
deleted file mode 100644
index 1324d1536..000000000
--- a/Source/WebCore/platform/graphics/blackberry/Texture.cpp
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Copyright (C) 2011, 2012 Research In Motion Limited. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "config.h"
-#include "Texture.h"
-
-#if USE(ACCELERATED_COMPOSITING)
-
-#include "Color.h"
-#include "IntRect.h"
-#include "TextureCacheCompositingThread.h"
-
-#include <GLES2/gl2.h>
-#include <SkBitmap.h>
-#include <wtf/CurrentTime.h>
-#include <wtf/OwnArrayPtr.h>
-
-#define DEBUG_TEXTURE_UPLOADS 0
-
-namespace WebCore {
-
-static void copyImageData(unsigned char* dst, int dstStride, int dstX, int dstY,
- const unsigned char* src, int srcStride, int srcX, int srcY, int width, int height)
-{
- dst += (dstY * dstStride) + (Texture::bytesPerPixel() * dstX);
- src += (srcY * srcStride) + (Texture::bytesPerPixel() * srcX);
- int length = Texture::bytesPerPixel() * width;
-
- for (int y = 0; y < height; ++y) {
- memcpy(dst, src, length);
- dst += dstStride;
- src += srcStride;
- }
-}
-
-Texture::Texture(bool isColor)
- : m_protectionCount(0)
- , m_textureId(0)
- , m_isColor(isColor)
- , m_isOpaque(false)
-{
- textureCacheCompositingThread()->install(this);
-}
-
-Texture::~Texture()
-{
- textureCacheCompositingThread()->textureDestroyed(this);
-}
-
-void Texture::updateContents(const SkBitmap& contents, const IntRect& dirtyRect, const IntRect& tile, bool isOpaque)
-{
- IntRect tileDirtyRect(dirtyRect);
-
- tileDirtyRect.intersect(tile);
- if (tileDirtyRect.isEmpty())
- return;
-
- m_isOpaque = isOpaque;
-
- int stride = bytesPerPixel() * contents.width();
- int x = tileDirtyRect.x() - dirtyRect.x();
- int y = tileDirtyRect.y() - dirtyRect.y();
- SkAutoLockPixels lock(contents);
- unsigned char* pixels = static_cast<unsigned char*>(contents.getPixels());
- pixels += (y * stride) + (bytesPerPixel() * x);
- if (!pixels)
- return;
-
- bool subImage = tile.size() == m_size;
- IntSize size = subImage ? tileDirtyRect.size() : tile.size();
- IntSize contentsSize(IntSize(contents.width(), contents.height()));
-
-#if DEBUG_TEXTURE_UPLOADS
- fprintf(stderr, "%s\n", subImage ? "SUBIMAGE" : "IMAGE");
- fprintf(stderr, " tile = (x=%d,y=%d,width=%d,height=%d), m_size = (%dx%d)\n", tile.x(), tile.y(), tile.width(), tile.height(), m_size.width(), m_size.height());
- fprintf(stderr, " tileDirtyRect = (x=%d,y=%d,width=%d,height=%d), contents.size() = (%dx%d)\n", tileDirtyRect.x(), tileDirtyRect.y(), tileDirtyRect.width(), tileDirtyRect.height(), contentsSize.width(), contentsSize.height());
- IntSize sizeBeforeShunk = size;
-#endif
-
- size = size.shrunkTo(contentsSize);
-
-#if DEBUG_TEXTURE_UPLOADS
- if (size != sizeBeforeShunk)
- fprintf(stderr, " SHRUNK!!!!\n");
-#endif
-
- if (!hasTexture()) {
- // We may have been evicted by the TextureCacheCompositingThread,
- // attempt to install us again.
- if (!textureCacheCompositingThread()->install(this))
- return;
- }
-
- glBindTexture(GL_TEXTURE_2D, m_textureId);
-
- ASSERT(size.width() >= 0);
- bool doesTileStrideEqualTextureStride = contents.width() == size.width();
-
- OwnArrayPtr<unsigned char> tmp;
- if (!doesTileStrideEqualTextureStride) {
-#if defined(GL_UNPACK_ROW_LENGTH)
- glPixelStorei(GL_UNPACK_ROW_LENGTH, contents.width());
-#else
- tmp = adoptArrayPtr(new unsigned char[size.width() * size.height() * bytesPerPixel()]);
- copyImageData(tmp.get(), bytesPerPixel() * size.width(), 0, 0,
- pixels, stride, 0, 0,
- size.width(), size.height());
- pixels = tmp.get();
-#endif
- }
-
- if (subImage) {
-#if DEBUG_TEXTURE_UPLOADS
- fprintf(stderr, "glTexSubImage2D(%d, %d, %d, %d)\n", tileDirtyRect.x() - tile.x(), tileDirtyRect.y() - tile.y(),
- size.width(), size.height());
- double t = currentTime();
-#endif
- glTexSubImage2D(GL_TEXTURE_2D, 0,
- tileDirtyRect.x() - tile.x(), tileDirtyRect.y() - tile.y(),
- size.width(), size.height(),
- GL_RGBA, GL_UNSIGNED_BYTE, pixels);
-#if DEBUG_TEXTURE_UPLOADS
- t = currentTime() - t;
- fprintf(stderr, " time = %f s (%d bytes)\n", t, size.width()*size.height()*4);
-#endif
- } else {
-#if DEBUG_TEXTURE_UPLOADS
- fprintf(stderr, "glTexImage2D(%d, %d)\n", size.width(), size.height());
- double t = currentTime();
-#endif
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size.width(), size.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
-#if DEBUG_TEXTURE_UPLOADS
- t = currentTime() - t;
- fprintf(stderr, " time = %f s (%d bytes)\n", t, size.width()*size.height()*4);
-#endif
- }
-
-#if defined(GL_UNPACK_ROW_LENGTH)
- if (!doesTileStrideEqualTextureStride)
- glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
-#endif
-
- IntSize oldSize = m_size;
- m_size = tile.size();
- if (m_size != oldSize)
- textureCacheCompositingThread()->textureResized(this, oldSize);
-}
-
-void Texture::setContentsToColor(const Color& color)
-{
- m_isOpaque = !color.hasAlpha();
- RGBA32 rgba = color.rgb();
- glBindTexture(GL_TEXTURE_2D, m_textureId);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &rgba);
-
- IntSize oldSize = m_size;
- m_size = IntSize(1, 1);
- if (m_size != oldSize)
- textureCacheCompositingThread()->textureResized(this, oldSize);
-}
-
-bool Texture::protect(const IntSize& size)
-{
- if (!hasTexture()) {
- // We may have been evicted by the TextureCacheCompositingThread,
- // attempt to install us again.
- if (!textureCacheCompositingThread()->install(this))
- return false;
- }
-
- ++m_protectionCount;
-
- if (m_size == size)
- return true;
-
- IntSize oldSize = m_size;
- m_size = size;
- textureCacheCompositingThread()->textureResized(this, oldSize);
-
- glBindTexture(GL_TEXTURE_2D, m_textureId);
- glTexImage2D(GL_TEXTURE_2D, 0 , GL_RGBA, size.width(), size.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
- return true;
-}
-
-} // namespace WebCore
-
-#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebCore/platform/graphics/blackberry/TextureCacheCompositingThread.cpp b/Source/WebCore/platform/graphics/blackberry/TextureCacheCompositingThread.cpp
index d65c4dadd..eeceee0b2 100644
--- a/Source/WebCore/platform/graphics/blackberry/TextureCacheCompositingThread.cpp
+++ b/Source/WebCore/platform/graphics/blackberry/TextureCacheCompositingThread.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011, 2012 Research In Motion Limited. All rights reserved.
+ * Copyright (C) 2011, 2012, 2013 Research In Motion Limited. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -24,7 +24,10 @@
#include "IntRect.h"
#include <GLES2/gl2.h>
-#include <SkBitmap.h>
+#include <wtf/Assertions.h>
+
+using BlackBerry::Platform::Graphics::Buffer;
+using BlackBerry::Platform::Graphics::BufferType;
#define DEBUG_TEXTURE_MEMORY_USAGE 0
@@ -36,7 +39,7 @@ static const int defaultMemoryLimit = 64 * 1024 * 1024; // Measured in bytes.
// before someone has a chance to protect it for legitimate reasons.
class TextureProtector {
public:
- TextureProtector(Texture* texture)
+ TextureProtector(LayerTexture* texture)
: m_texture(texture)
{
m_texture->protect();
@@ -48,7 +51,7 @@ public:
}
private:
- Texture* m_texture;
+ LayerTexture* m_texture;
};
TextureCacheCompositingThread::TextureCacheCompositingThread()
@@ -57,80 +60,78 @@ TextureCacheCompositingThread::TextureCacheCompositingThread()
{
}
-unsigned TextureCacheCompositingThread::allocateTextureId()
+Buffer* TextureCacheCompositingThread::createBuffer(const IntSize& size, BufferType type)
{
- unsigned texid;
- glGenTextures(1, &texid);
- glBindTexture(GL_TEXTURE_2D, texid);
- if (!glIsTexture(texid))
- return 0;
-
- // Do basic linear filtering on resize.
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- // NPOT textures in GL ES only work when the wrap mode is set to GL_CLAMP_TO_EDGE.
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- return texid;
-}
-
-void TextureCacheCompositingThread::freeTextureId(unsigned id)
-{
- if (id)
- glDeleteTextures(1, &id);
+ return BlackBerry::Platform::Graphics::createBuffer(size, type);
}
void TextureCacheCompositingThread::collectGarbage()
{
- int delta = 0;
+ for (Garbage::iterator it = m_garbage.begin(); it != m_garbage.end(); ++it)
+ BlackBerry::Platform::Graphics::destroyBuffer((*it).buffer);
- for (Garbage::iterator it = m_garbage.begin(); it != m_garbage.end(); ++it) {
- ZombieTexture& zombie = *it;
- freeTextureId(zombie.id);
- delta += zombie.size.width() * zombie.size.height() * Texture::bytesPerPixel();
- }
m_garbage.clear();
+}
- if (delta)
- decMemoryUsage(delta);
+void TextureCacheCompositingThread::textureResized(LayerTexture* texture, const IntSize& oldSize)
+{
+ int delta = (texture->width() * texture->height() - oldSize.width() * oldSize.height()) * LayerTexture::bytesPerPixel();
+ incMemoryUsage(delta);
+ if (delta > 0)
+ prune();
}
-void TextureCacheCompositingThread::textureResized(Texture* texture, const IntSize& oldSize)
+void TextureCacheCompositingThread::textureSizeInBytesChanged(LayerTexture*, int delta)
{
- int delta = (texture->width() * texture->height() - oldSize.width() * oldSize.height()) * Texture::bytesPerPixel();
incMemoryUsage(delta);
if (delta > 0)
prune();
}
-void TextureCacheCompositingThread::textureDestroyed(Texture* texture)
+void TextureCacheCompositingThread::textureDestroyed(LayerTexture* texture)
{
if (texture->isColor()) {
m_garbage.append(ZombieTexture(texture));
return;
}
- evict(m_textures.find(texture));
+ TextureSet::iterator it = m_textures.find(texture);
+ evict(it);
+ m_textures.remove(it);
}
-bool TextureCacheCompositingThread::install(Texture* texture)
+bool TextureCacheCompositingThread::install(LayerTexture* texture, const IntSize& size, BufferType type)
{
if (!texture)
return true;
- if (!texture->hasTexture()) {
- unsigned textureId = allocateTextureId();
- if (!textureId)
- return false;
+ if (!texture->buffer() && !size.isEmpty()) {
+ Buffer* buffer = createBuffer(size, type);
+ ASSERT(buffer);
- texture->setTextureId(textureId);
+ texture->setBuffer(buffer);
+ texture->setSize(size);
+ textureResized(texture, IntSize());
}
- if (!texture->isColor()) {
- if (!m_textures.contains(texture))
- m_textures.add(texture);
- }
+ if (!texture->isColor())
+ m_textures.add(texture);
+
+ return true;
+}
+
+bool TextureCacheCompositingThread::resizeTexture(LayerTexture* texture, const IntSize& size, BufferType type)
+{
+ IntSize oldSize = texture->size();
+ // Reallocate the buffer
+ Buffer* buffer = createBuffer(size, type);
+ ASSERT(buffer);
+
+ BlackBerry::Platform::Graphics::destroyBuffer(texture->buffer());
+ texture->setBuffer(buffer);
+ texture->setSize(size);
+ textureResized(texture, oldSize);
return true;
}
@@ -139,16 +140,20 @@ void TextureCacheCompositingThread::evict(const TextureSet::iterator& it)
if (it == m_textures.end())
return;
- Texture* texture = *it;
- if (texture->hasTexture())
+ LayerTexture* texture = *it;
+ if (texture->buffer()) {
+ int delta = 0;
+ delta += texture->width() * texture->height() * LayerTexture::bytesPerPixel();
+ delta += texture->sizeInBytes();
+ if (delta)
+ decMemoryUsage(delta);
m_garbage.append(ZombieTexture(texture));
+ }
- texture->setTextureId(0);
-
- m_textures.remove(it);
+ texture->setBuffer(0);
}
-void TextureCacheCompositingThread::textureAccessed(Texture* texture)
+void TextureCacheCompositingThread::textureAccessed(LayerTexture* texture)
{
if (texture->isColor())
return;
@@ -172,8 +177,8 @@ void TextureCacheCompositingThread::prune(size_t limit)
while (m_memoryUsage > limit) {
bool found = false;
for (TextureSet::iterator it = m_textures.begin(); it != m_textures.end(); ++it) {
- Texture* texture = *it;
- if (texture->isProtected())
+ LayerTexture* texture = *it;
+ if (texture->isProtected() || (texture->size().isEmpty() && !texture->sizeInBytes()))
continue;
evict(it);
found = true;
@@ -186,7 +191,6 @@ void TextureCacheCompositingThread::prune(size_t limit)
void TextureCacheCompositingThread::clear()
{
- m_cache.clear();
m_colors.clear();
collectGarbage();
}
@@ -199,36 +203,19 @@ void TextureCacheCompositingThread::setMemoryUsage(size_t memoryUsage)
#endif
}
-PassRefPtr<Texture> TextureCacheCompositingThread::textureForTiledContents(const SkBitmap& contents, const IntRect& tileRect, const TileIndex& index, bool isOpaque)
+PassRefPtr<LayerTexture> TextureCacheCompositingThread::textureForContents(Buffer* contents)
{
- HashMap<ContentsKey, TextureMap>::iterator it = m_cache.add(key(contents), TextureMap()).iterator;
- TextureMap& map = (*it).value;
-
- TextureMap::iterator jt = map.add(index, RefPtr<Texture>()).iterator;
- RefPtr<Texture> texture = (*jt).value;
- if (!texture) {
- texture = createTexture();
-#if DEBUG_TEXTURE_MEMORY_USAGE
- fprintf(stderr, "Creating texture 0x%x for 0x%x+%d @ (%d, %d)\n", texture.get(), contents.pixelRef(), contents.pixelRefOffset(), index.i(), index.j());
-#endif
- map.set(index, texture);
- }
+ RefPtr<LayerTexture> texture = createTexture();
// Protect newly created texture from being evicted.
TextureProtector protector(texture.get());
- IntSize contentsSize(contents.width(), contents.height());
- IntRect dirtyRect(IntPoint(), contentsSize);
- if (tileRect.size() != texture->size()) {
-#if DEBUG_TEXTURE_MEMORY_USAGE
- fprintf(stderr, "Updating texture 0x%x for 0x%x+%d @ (%d, %d)\n", texture.get(), contents.pixelRef(), contents.pixelRefOffset(), index.i(), index.j());
-#endif
- texture->updateContents(contents, dirtyRect, tileRect, isOpaque);
- }
+ texture->updateContents(contents);
+
return texture.release();
}
-PassRefPtr<Texture> TextureCacheCompositingThread::textureForColor(const Color& color)
+PassRefPtr<LayerTexture> TextureCacheCompositingThread::textureForColor(const Color& color)
{
// Just to make sure we don't get fooled by some malicious web page
// into caching millions of color textures.
@@ -236,9 +223,9 @@ PassRefPtr<Texture> TextureCacheCompositingThread::textureForColor(const Color&
m_colors.clear();
ColorTextureMap::iterator it = m_colors.find(color);
- RefPtr<Texture> texture;
+ RefPtr<LayerTexture> texture;
if (it == m_colors.end()) {
- texture = Texture::create(true /* isColor */);
+ texture = LayerTexture::create(true /* isColor */);
#if DEBUG_TEXTURE_MEMORY_USAGE
fprintf(stderr, "Creating texture 0x%x for color 0x%x\n", texture.get(), color.rgb());
#endif
@@ -254,9 +241,9 @@ PassRefPtr<Texture> TextureCacheCompositingThread::textureForColor(const Color&
return texture.release();
}
-PassRefPtr<Texture> TextureCacheCompositingThread::updateContents(const RefPtr<Texture>& textureIn, const SkBitmap& contents, const IntRect& dirtyRect, const IntRect& tileRect, bool isOpaque)
+PassRefPtr<LayerTexture> TextureCacheCompositingThread::updateContents(const RefPtr<LayerTexture>& textureIn, Buffer* contents)
{
- RefPtr<Texture> texture(textureIn);
+ RefPtr<LayerTexture> texture(textureIn);
// If the texture was 0, or needs to transition from a solid color texture to a contents texture,
// create a new texture.
@@ -266,36 +253,11 @@ PassRefPtr<Texture> TextureCacheCompositingThread::updateContents(const RefPtr<T
// Protect newly created texture from being evicted.
TextureProtector protector(texture.get());
- texture->updateContents(contents, dirtyRect, tileRect, isOpaque);
+ texture->updateContents(contents);
return texture.release();
}
-TextureCacheCompositingThread::ContentsKey TextureCacheCompositingThread::key(const SkBitmap& contents)
-{
- // The pixelRef is an address, and addresses can be reused by the allocator
- // so it's unsuitable to use as a key. Instead, grab the generation, which
- // is globally unique according to the current implementation in
- // SkPixelRef.cpp.
- uint32_t generation = contents.getGenerationID();
-
- // If the generation is equal to the deleted value, use something else that
- // is unlikely to correspond to a generation currently in use or soon to be
- // in use.
- uint32_t deletedValue = 0;
- HashTraits<uint32_t>::constructDeletedValue(deletedValue);
- if (generation == deletedValue) {
- // This strategy works as long as the deleted value is -1.
- ASSERT(deletedValue == static_cast<uint32_t>(-1));
- generation = deletedValue / 2;
- }
-
- // Now the generation alone does not uniquely identify the texture contents.
- // The same pixelref can be reused in another bitmap but with a different
- // offset (somewhat contrived, but possible).
- return std::make_pair(generation, contents.pixelRefOffset());
-}
-
} // namespace WebCore
#endif
diff --git a/Source/WebCore/platform/graphics/blackberry/TextureCacheCompositingThread.h b/Source/WebCore/platform/graphics/blackberry/TextureCacheCompositingThread.h
index df7792fa2..ccda324b0 100644
--- a/Source/WebCore/platform/graphics/blackberry/TextureCacheCompositingThread.h
+++ b/Source/WebCore/platform/graphics/blackberry/TextureCacheCompositingThread.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011, 2012 Research In Motion Limited. All rights reserved.
+ * Copyright (C) 2011, 2012, 2013 Research In Motion Limited. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -22,9 +22,10 @@
#if USE(ACCELERATED_COMPOSITING)
#include "Color.h"
+#include "LayerTexture.h"
#include "LayerTileIndex.h"
-#include "Texture.h"
+#include <BlackBerryPlatformGraphics.h>
#include <wtf/HashMap.h>
#include <wtf/ListHashSet.h>
#include <wtf/Noncopyable.h>
@@ -44,17 +45,17 @@ public:
friend TextureCacheCompositingThread* textureCacheCompositingThread();
// Creates a new texture managed by this cache.
- PassRefPtr<Texture> createTexture()
+ PassRefPtr<LayerTexture> createTexture()
{
- return Texture::create();
+ return LayerTexture::create();
}
// Retrieve a texture from the cache.
- PassRefPtr<Texture> textureForTiledContents(const SkBitmap& contents, const IntRect& tileRect, const TileIndex&, bool isOpaque);
- PassRefPtr<Texture> textureForColor(const Color&);
+ PassRefPtr<LayerTexture> textureForContents(BlackBerry::Platform::Graphics::Buffer*);
+ PassRefPtr<LayerTexture> textureForColor(const Color&);
// Update contents of an existing texture, or create a new one if texture is 0.
- PassRefPtr<Texture> updateContents(const RefPtr<Texture>&, const SkBitmap& contents, const IntRect& dirtyRect, const IntRect& tileRect, bool isOpaque);
+ PassRefPtr<LayerTexture> updateContents(const RefPtr<LayerTexture>&, BlackBerry::Platform::Graphics::Buffer*);
size_t memoryUsage() const { return m_memoryUsage; }
size_t memoryLimit() const { return m_memoryLimit; }
@@ -68,47 +69,47 @@ public:
void clear();
// Update the LRU list.
- void textureAccessed(Texture*);
+ void textureAccessed(LayerTexture*);
// Deleting destroyed textures is provided as a separate method, because
// there might not be an OpenGL context current when the texture destructor
// was called. Calling this makes sure to free any such textures.
void collectGarbage();
- void textureDestroyed(Texture*);
- void textureResized(Texture*, const IntSize& oldSize);
+ void textureDestroyed(LayerTexture*);
+ void textureResized(LayerTexture*, const IntSize& oldSize);
+ void textureSizeInBytesChanged(LayerTexture*, int delta);
// Undo the effects of eviction, if possible.
- bool install(Texture*);
+ bool install(LayerTexture*, const IntSize& textureSize = IntSize(0, 0), BlackBerry::Platform::Graphics::BufferType = BlackBerry::Platform::Graphics::BackedWhenNecessary);
+ bool resizeTexture(LayerTexture*, const IntSize& newSize, BlackBerry::Platform::Graphics::BufferType = BlackBerry::Platform::Graphics::BackedWhenNecessary);
private:
struct ZombieTexture {
- explicit ZombieTexture(Texture* texture)
- : id(texture->textureId())
+ explicit ZombieTexture(LayerTexture* texture)
+ : buffer(texture->buffer())
, size(texture->size())
+ , sizeInBytes(texture->sizeInBytes())
{
}
- unsigned id;
+ BlackBerry::Platform::Graphics::Buffer* buffer;
IntSize size;
+ size_t sizeInBytes;
};
- typedef ListHashSet<Texture* > TextureSet;
- typedef std::pair<uint32_t, size_t> ContentsKey;
- typedef HashMap<TileIndex, RefPtr<Texture> > TextureMap;
+ typedef ListHashSet<LayerTexture* > TextureSet;
+ typedef HashMap<TileIndex, RefPtr<LayerTexture> > TextureMap;
typedef Vector<ZombieTexture> Garbage;
TextureCacheCompositingThread();
~TextureCacheCompositingThread();
- unsigned allocateTextureId();
- void freeTextureId(unsigned id);
+ BlackBerry::Platform::Graphics::Buffer* createBuffer(const IntSize& textureSize, BlackBerry::Platform::Graphics::BufferType);
void incMemoryUsage(int delta) { setMemoryUsage(memoryUsage() + delta); }
void decMemoryUsage(int delta) { setMemoryUsage(memoryUsage() - delta); }
void setMemoryUsage(size_t);
- ContentsKey key(const SkBitmap& contents);
-
void evict(const TextureSet::iterator&);
// LRU set of weak pointers to textures.
@@ -116,8 +117,6 @@ private:
size_t m_memoryUsage;
size_t m_memoryLimit;
- // Map of refCounted pointers to textures.
- HashMap<ContentsKey, TextureMap> m_cache;
struct ColorHash {
static unsigned hash(const Color& key) { return WTF::intHash(key.rgb()); }
static bool equal(const Color& a, const Color& b) { return a == b; }
@@ -131,7 +130,7 @@ private:
static void constructDeletedValue(Color& slot) { new (&slot) Color(); *reinterpret_cast<RGBA32*>(&slot) = Color::white; }
static bool isDeletedValue(const Color& value) { return !value.isValid() && value.rgb() == Color::white; }
};
- typedef HashMap<Color, RefPtr<Texture>, ColorHash, ColorHashTraits> ColorTextureMap;
+ typedef HashMap<Color, RefPtr<LayerTexture>, ColorHash, ColorHashTraits> ColorTextureMap;
ColorTextureMap m_colors;
Garbage m_garbage;
};
diff --git a/Source/WebCore/platform/graphics/blackberry/VideoLayerWebKitThread.cpp b/Source/WebCore/platform/graphics/blackberry/VideoLayerWebKitThread.cpp
index 1fec120d2..d7a958adb 100644
--- a/Source/WebCore/platform/graphics/blackberry/VideoLayerWebKitThread.cpp
+++ b/Source/WebCore/platform/graphics/blackberry/VideoLayerWebKitThread.cpp
@@ -27,8 +27,6 @@
#include <BlackBerryPlatformLog.h>
-#define DEBUG_VIDEO_CLIPPING 0
-
namespace WebCore {
VideoLayerWebKitThread::VideoLayerWebKitThread(MediaPlayer* mediaPlayer)
@@ -64,9 +62,6 @@ void VideoLayerWebKitThread::setMediaPlayer(MediaPlayer* mediaPlayer)
void VideoLayerWebKitThread::setHolePunchRect(const IntRect& rect)
{
m_holePunchRect = rect;
-#if DEBUG_VIDEO_CLIPPING
- BBLOG(BlackBerry::Platform::LogLevelInfo, "VideoLayerWebKitThread m_holePunchRect=(x=%d,y=%d,width=%d,height=%d).", m_holePunchRect.x(), m_holePunchRect.y(), m_holePunchRect.width(), m_holePunchRect.height());
-#endif
setNeedsCommit();
}
@@ -87,16 +82,6 @@ void VideoLayerWebKitThread::boundsChanged()
// Note that although we know the *size* of this layer, we won't know the position of this layer
// until the LayerCompositingThread::setDrawTransform method is called from the LayerRenderer.
setHolePunchRect(IntRect(IntPoint::zero(), m_bounds));
-
- // Also set a clipping rectangle for this hole punch rectangle.
- if (FrameView* frameView = mediaPlayer()->frameView())
- m_holePunchClipRect = frameView->windowClipRect();
- else
- m_holePunchClipRect = holePunchRect();
-
-#if DEBUG_VIDEO_CLIPPING
- BBLOG(BlackBerry::Platform::LogLevelInfo, "VideoLayerWebKitThread m_holePunchClipRect=(x=%d,y=%d,width=%d,height=%d).", m_holePunchClipRect.x(), m_holePunchClipRect.y(), m_holePunchClipRect.width(), m_holePunchClipRect.height());
-#endif
}
void VideoLayerWebKitThread::updateTextureContentsIfNeeded()
diff --git a/Source/WebCore/platform/graphics/blackberry/WebGLLayerWebKitThread.cpp b/Source/WebCore/platform/graphics/blackberry/WebGLLayerWebKitThread.cpp
index fd159d33c..94c25af6e 100644
--- a/Source/WebCore/platform/graphics/blackberry/WebGLLayerWebKitThread.cpp
+++ b/Source/WebCore/platform/graphics/blackberry/WebGLLayerWebKitThread.cpp
@@ -34,8 +34,7 @@ WebGLLayerWebKitThread::WebGLLayerWebKitThread()
WebGLLayerWebKitThread::~WebGLLayerWebKitThread()
{
- if (m_webGLContext && m_webGLContext->makeContextCurrent())
- deleteFrontBuffer();
+ deleteTextures();
}
void WebGLLayerWebKitThread::updateTextureContentsIfNeeded()
@@ -54,6 +53,12 @@ void WebGLLayerWebKitThread::deleteTextures()
deleteFrontBuffer();
}
+void WebGLLayerWebKitThread::webGLContextDestroyed()
+{
+ deleteTextures();
+ m_webGLContext = 0;
+}
+
} // namespace WebCore
#endif // USE(ACCELERATED_COMPOSITING) && ENABLE(WEBGL)
diff --git a/Source/WebCore/platform/graphics/blackberry/WebGLLayerWebKitThread.h b/Source/WebCore/platform/graphics/blackberry/WebGLLayerWebKitThread.h
index 1480f255c..75fe0b305 100644
--- a/Source/WebCore/platform/graphics/blackberry/WebGLLayerWebKitThread.h
+++ b/Source/WebCore/platform/graphics/blackberry/WebGLLayerWebKitThread.h
@@ -37,6 +37,7 @@ public:
virtual ~WebGLLayerWebKitThread();
void setWebGLContext(GraphicsContext3D* context) { m_webGLContext = context; }
+ void webGLContextDestroyed();
protected:
virtual void updateTextureContentsIfNeeded();
diff --git a/Source/WebCore/platform/graphics/blackberry/skia/PlatformSupport.cpp b/Source/WebCore/platform/graphics/blackberry/skia/PlatformSupport.cpp
deleted file mode 100644
index 09cead825..000000000
--- a/Source/WebCore/platform/graphics/blackberry/skia/PlatformSupport.cpp
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (c) 2009-2010, Google Inc. All rights reserved.
- * Copyright (c) 2011, Research In Motion. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "PlatformSupport.h"
-
-#include "FontRenderStyle.h"
-
-#include <fontconfig/fontconfig.h>
-#include <string.h>
-#include <unicode/utf16.h>
-#include <wtf/text/CString.h>
-
-namespace WebCore {
-
-static void setFontRenderStyleDefaults(FontRenderStyle* style)
-{
- style->useBitmaps = 2;
- style->useAutoHint = 2;
- style->useHinting = 2;
- style->hintStyle = 0;
- style->useAntiAlias = 2;
- style->useSubpixelRendering = 2;
-}
-
-void PlatformSupport::getRenderStyleForStrike(const char* family, int sizeAndStyle, FontRenderStyle* out)
-{
- bool isBold = sizeAndStyle & 1;
- bool isItalic = sizeAndStyle & 2;
- int pixelSize = sizeAndStyle >> 2;
-
- FcPattern* pattern = FcPatternCreate();
- FcValue fcvalue;
-
- fcvalue.type = FcTypeString;
- fcvalue.u.s = reinterpret_cast<const FcChar8 *>(family);
- FcPatternAdd(pattern, FC_FAMILY, fcvalue, FcFalse);
-
- fcvalue.type = FcTypeInteger;
- fcvalue.u.i = isBold ? FC_WEIGHT_BOLD : FC_WEIGHT_NORMAL;
- FcPatternAdd(pattern, FC_WEIGHT, fcvalue, FcFalse);
-
- fcvalue.type = FcTypeInteger;
- fcvalue.u.i = isItalic ? FC_SLANT_ITALIC : FC_SLANT_ROMAN;
- FcPatternAdd(pattern, FC_SLANT, fcvalue, FcFalse);
-
- fcvalue.type = FcTypeBool;
- fcvalue.u.b = FcTrue;
- FcPatternAdd(pattern, FC_SCALABLE, fcvalue, FcFalse);
-
- fcvalue.type = FcTypeDouble;
- fcvalue.u.d = pixelSize;
- FcPatternAdd(pattern, FC_SIZE, fcvalue, FcFalse);
-
- FcConfigSubstitute(0, pattern, FcMatchPattern);
- FcDefaultSubstitute(pattern);
-
- FcResult result;
- // Some versions of fontconfig don't actually write a value into result.
- // However, it's not clear from the documentation if result should be a
- // non-0 pointer: future versions might expect to be able to write to
- // it. So we pass in a valid pointer and ignore it.
- FcPattern* match = FcFontMatch(0, pattern, &result);
- FcPatternDestroy(pattern);
-
- setFontRenderStyleDefaults(out);
-
- if (!match)
- return;
-
- FcBool boolValue;
- int intValue;
-
- if (FcPatternGetBool(match, FC_ANTIALIAS, 0, &boolValue) == FcResultMatch)
- out->useAntiAlias = boolValue;
- if (FcPatternGetBool(match, FC_EMBEDDED_BITMAP, 0, &boolValue) == FcResultMatch)
- out->useBitmaps = boolValue;
- if (FcPatternGetBool(match, FC_AUTOHINT, 0, &boolValue) == FcResultMatch)
- out->useAutoHint = boolValue;
- if (FcPatternGetBool(match, FC_HINTING, 0, &boolValue) == FcResultMatch)
- out->useHinting = boolValue;
-
- if (FcPatternGetInteger(match, FC_RGBA, 0, &intValue) == FcResultMatch) {
- switch (intValue) {
- case FC_RGBA_NONE:
- out->useSubpixelRendering = 0;
- break;
- case FC_RGBA_RGB:
- case FC_RGBA_BGR:
- case FC_RGBA_VRGB:
- case FC_RGBA_VBGR:
- out->useSubpixelRendering = 1;
- break;
- default:
- // This includes FC_RGBA_UNKNOWN.
- out->useSubpixelRendering = 2;
- break;
- }
- }
-
- FcPatternDestroy(match);
-}
-
-}; // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp b/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
index c13219eff..40f65bf75 100644
--- a/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
+++ b/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
@@ -33,10 +33,10 @@
#include "FloatConversion.h"
#include "FloatRect.h"
#include "GraphicsLayerFactory.h"
+#include "PlatformCAFilters.h"
#include "PlatformCALayer.h"
#include "RotateTransformOperation.h"
#include "ScaleTransformOperation.h"
-#include "SystemTime.h"
#include "TextStream.h"
#include "TiledBacking.h"
#include "TransformState.h"
@@ -59,6 +59,9 @@ namespace WebCore {
// texture size limit on all supported hardware.
static const int cMaxPixelDimension = 2000;
+// Derived empirically: <rdar://problem/13401861>
+static const int cMaxLayerTreeDepth = 250;
+
// If we send a duration of 0 to CA, then it will use the default duration
// of 250ms. So send a very small value instead.
static const float cAnimationAlmostZeroDuration = 1e-3f;
@@ -227,9 +230,9 @@ static String propertyIdToString(AnimatedPropertyID property)
return "";
}
-static String animationIdentifier(const String& animationName, AnimatedPropertyID property, int index)
+static String animationIdentifier(const String& animationName, AnimatedPropertyID property, int index, int subIndex)
{
- return animationName + '_' + String::number(property) + '_' + String::number(index);
+ return animationName + '_' + String::number(property) + '_' + String::number(index) + '_' + String::number(subIndex);
}
static bool animationHasStepsTimingFunction(const KeyframeValueList& valueList, const Animation* anim)
@@ -238,9 +241,10 @@ static bool animationHasStepsTimingFunction(const KeyframeValueList& valueList,
return true;
for (unsigned i = 0; i < valueList.size(); ++i) {
- const TimingFunction* timingFunction = valueList.at(i)->timingFunction();
- if (timingFunction && timingFunction->isStepsTimingFunction())
- return true;
+ if (const TimingFunction* timingFunction = valueList.at(i).timingFunction()) {
+ if (timingFunction->isStepsTimingFunction())
+ return true;
+ }
}
return false;
@@ -274,15 +278,14 @@ PassOwnPtr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerClient* client)
GraphicsLayerCA::GraphicsLayerCA(GraphicsLayerClient* client)
: GraphicsLayer(client)
, m_contentsLayerPurpose(NoContentsLayer)
- , m_contentsLayerHasBackgroundColor(false)
, m_allowTiledLayer(true)
- , m_isPageTileCacheLayer(false)
+ , m_isPageTiledBackingLayer(false)
, m_uncommittedChanges(0)
{
PlatformCALayer::LayerType layerType = PlatformCALayer::LayerTypeWebLayer;
- if (client && client->shouldUseTileCache(this)) {
- layerType = PlatformCALayer::LayerTypePageTileCacheLayer;
- m_isPageTileCacheLayer = true;
+ if (client && client->shouldUseTiledBacking(this)) {
+ layerType = PlatformCALayer::LayerTypePageTiledBackingLayer;
+ m_isPageTiledBackingLayer = true;
}
m_layer = PlatformCALayer::create(layerType, this);
@@ -498,7 +501,7 @@ void GraphicsLayerCA::moveOrCopyAnimations(MoveOrCopy operation, PlatformCALayer
|| currAnimation.m_property == AnimatedPropertyWebkitFilter
#endif
)
- moveOrCopyLayerAnimation(operation, animationIdentifier(currAnimation.m_name, currAnimation.m_property, currAnimation.m_index), fromLayer, toLayer);
+ moveOrCopyLayerAnimation(operation, animationIdentifier(currAnimation.m_name, currAnimation.m_property, currAnimation.m_index, currAnimation.m_subIndex), fromLayer, toLayer);
}
}
}
@@ -564,22 +567,10 @@ void GraphicsLayerCA::setAllowTiledLayer(bool allowTiledLayer)
void GraphicsLayerCA::setBackgroundColor(const Color& color)
{
- if (m_backgroundColorSet && m_backgroundColor == color)
+ if (m_backgroundColor == color)
return;
GraphicsLayer::setBackgroundColor(color);
-
- m_contentsLayerHasBackgroundColor = true;
- noteLayerPropertyChanged(BackgroundColorChanged);
-}
-
-void GraphicsLayerCA::clearBackgroundColor()
-{
- if (!m_backgroundColorSet)
- return;
-
- GraphicsLayer::clearBackgroundColor();
- m_contentsLayerHasBackgroundColor = false;
noteLayerPropertyChanged(BackgroundColorChanged);
}
@@ -756,10 +747,14 @@ void GraphicsLayerCA::platformCALayerAnimationStarted(CFTimeInterval startTime)
m_client->notifyAnimationStarted(this, startTime);
}
-void GraphicsLayerCA::setContentsToBackgroundColor(const Color& color)
+void GraphicsLayerCA::setContentsToSolidColor(const Color& color)
{
- setBackgroundColor(color);
- if (color != Color::transparent) {
+ if (color == m_contentsSolidColor)
+ return;
+
+ m_contentsSolidColor = color;
+
+ if (m_contentsSolidColor.isValid()) {
m_contentsLayerPurpose = ContentsLayerForBackgroundColor;
m_contentsLayer = PlatformCALayer::create(PlatformCALayer::LayerTypeLayer, this);
#ifndef NDEBUG
@@ -771,7 +766,7 @@ void GraphicsLayerCA::setContentsToBackgroundColor(const Color& color)
}
noteSublayersChanged();
- noteLayerPropertyChanged(BackgroundColorChanged);
+ noteLayerPropertyChanged(ContentsColorLayerChanged);
}
void GraphicsLayerCA::setContentsToImage(Image* image)
@@ -797,7 +792,7 @@ void GraphicsLayerCA::setContentsToImage(Image* image)
// CoreGraphics renders images tagged with DeviceRGB using the color space of the main display. When we hand such
// images to CA we need to tag them similarly so CA rendering matches CG rendering.
static CGColorSpaceRef genericRGB = CGDisplayCopyColorSpace(kCGDirectMainDisplay);
- m_pendingContentsImage.adoptCF(CGImageCreateCopyWithColorSpace(m_pendingContentsImage.get(), genericRGB));
+ m_pendingContentsImage = adoptCF(CGImageCreateCopyWithColorSpace(m_pendingContentsImage.get(), genericRGB));
}
#endif
m_contentsLayerPurpose = ContentsLayerForImage;
@@ -899,15 +894,67 @@ FloatPoint GraphicsLayerCA::computePositionRelativeToBase(float& pageScale) cons
void GraphicsLayerCA::flushCompositingState(const FloatRect& clipRect)
{
TransformState state(TransformState::UnapplyInverseTransformDirection, FloatQuad(clipRect));
- recursiveCommitChanges(state);
+ recursiveCommitChanges(CommitState(), state);
}
void GraphicsLayerCA::flushCompositingStateForThisLayerOnly()
{
float pageScaleFactor;
+ bool hadChanges = m_uncommittedChanges;
+
+ CommitState commitState;
+
FloatPoint offset = computePositionRelativeToBase(pageScaleFactor);
- commitLayerChangesBeforeSublayers(pageScaleFactor, offset, m_visibleRect);
- commitLayerChangesAfterSublayers();
+ commitLayerChangesBeforeSublayers(commitState, pageScaleFactor, offset, m_visibleRect);
+ commitLayerChangesAfterSublayers(commitState);
+
+ if (hadChanges && client())
+ client()->didCommitChangesForLayer(this);
+}
+
+bool GraphicsLayerCA::recursiveVisibleRectChangeRequiresFlush(const TransformState& state) const
+{
+ TransformState localState = state;
+
+ // This may be called at times when layout has not been updated, so we want to avoid calling out to the client
+ // for animating transforms.
+ FloatRect newVisibleRect = computeVisibleRect(localState, 0);
+ if (m_layer->layerType() == PlatformCALayer::LayerTypeTiledBackingLayer)
+ newVisibleRect = adjustTiledLayerVisibleRect(tiledBacking(), m_visibleRect, newVisibleRect, m_sizeAtLastVisibleRectUpdate, m_size);
+
+ if (newVisibleRect != m_visibleRect) {
+ if (TiledBacking* tiledBacking = this->tiledBacking()) {
+ if (tiledBacking->tilesWouldChangeForVisibleRect(newVisibleRect))
+ return true;
+ }
+ }
+
+ if (m_maskLayer) {
+ GraphicsLayerCA* maskLayerCA = static_cast<GraphicsLayerCA*>(m_maskLayer);
+ if (maskLayerCA->recursiveVisibleRectChangeRequiresFlush(localState))
+ return true;
+ }
+
+ const Vector<GraphicsLayer*>& childLayers = children();
+ size_t numChildren = childLayers.size();
+
+ for (size_t i = 0; i < numChildren; ++i) {
+ GraphicsLayerCA* curChild = static_cast<GraphicsLayerCA*>(childLayers[i]);
+ if (curChild->recursiveVisibleRectChangeRequiresFlush(localState))
+ return true;
+ }
+
+ if (m_replicaLayer)
+ if (static_cast<GraphicsLayerCA*>(m_replicaLayer)->recursiveVisibleRectChangeRequiresFlush(localState))
+ return true;
+
+ return false;
+}
+
+bool GraphicsLayerCA::visibleRectChangeRequiresFlush(const FloatRect& clipRect) const
+{
+ TransformState state(TransformState::UnapplyInverseTransformDirection, FloatQuad(clipRect));
+ return recursiveVisibleRectChangeRequiresFlush(state);
}
TiledBacking* GraphicsLayerCA::tiledBacking() const
@@ -915,16 +962,23 @@ TiledBacking* GraphicsLayerCA::tiledBacking() const
return m_layer->tiledBacking();
}
-FloatRect GraphicsLayerCA::computeVisibleRect(TransformState& state) const
+FloatRect GraphicsLayerCA::computeVisibleRect(TransformState& state, ComputeVisibleRectFlags flags) const
{
bool preserve3D = preserves3D() || (parent() ? parent()->preserves3D() : false);
TransformState::TransformAccumulation accumulation = preserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTransform;
TransformationMatrix layerTransform;
- layerTransform.translate(m_position.x(), m_position.y());
+ FloatPoint position = m_position;
+ if (client())
+ client()->customPositionForVisibleRectComputation(this, position);
+
+ layerTransform.translate(position.x(), position.y());
TransformationMatrix currentTransform;
- if (client() && client()->getCurrentTransform(this, currentTransform) && !currentTransform.isIdentity()) {
+ if (!(flags & RespectAnimatingTransforms) || !client() || !client()->getCurrentTransform(this, currentTransform))
+ currentTransform = m_transform;
+
+ if (!currentTransform.isIdentity()) {
FloatPoint3D absoluteAnchorPoint(anchorPoint());
absoluteAnchorPoint.scale(size().width(), size().height(), 1);
layerTransform.translate3d(absoluteAnchorPoint.x(), absoluteAnchorPoint.y(), absoluteAnchorPoint.z());
@@ -948,7 +1002,10 @@ FloatRect GraphicsLayerCA::computeVisibleRect(TransformState& state) const
bool mapWasClamped;
FloatRect clipRectForChildren = state.mappedQuad(&mapWasClamped).boundingBox();
- FloatRect clipRectForSelf(0, 0, m_size.width(), m_size.height());
+ FloatPoint boundsOrigin = m_boundsOrigin;
+ clipRectForChildren.move(boundsOrigin.x(), boundsOrigin.y());
+
+ FloatRect clipRectForSelf(boundsOrigin, m_size);
if (!applyWasClamped && !mapWasClamped)
clipRectForSelf.intersect(clipRectForChildren);
@@ -961,9 +1018,11 @@ FloatRect GraphicsLayerCA::computeVisibleRect(TransformState& state) const
return clipRectForSelf;
}
-void GraphicsLayerCA::recursiveCommitChanges(const TransformState& state, float pageScaleFactor, const FloatPoint& positionRelativeToBase, bool affectedByPageScale)
+void GraphicsLayerCA::recursiveCommitChanges(const CommitState& commitState, const TransformState& state, float pageScaleFactor, const FloatPoint& positionRelativeToBase, bool affectedByPageScale)
{
TransformState localState = state;
+ CommitState childCommitState = commitState;
+ bool affectedByTransformAnimation = commitState.ancestorHasTransformAnimation;
FloatRect visibleRect = computeVisibleRect(localState);
FloatRect oldVisibleRect = m_visibleRect;
@@ -975,7 +1034,7 @@ void GraphicsLayerCA::recursiveCommitChanges(const TransformState& state, float
#ifdef VISIBLE_TILE_WASH
// Use having a transform as a key to making the tile wash layer. If every layer gets a wash,
// they start to obscure useful information.
- if ((!m_transform.isIdentity() || m_usingTiledLayer) && !m_visibleTileWashLayer) {
+ if ((!m_transform.isIdentity() || m_usingTiledBacking) && !m_visibleTileWashLayer) {
static Color washFillColor(255, 0, 0, 50);
static Color washBorderColor(255, 0, 0, 100);
@@ -1005,11 +1064,16 @@ void GraphicsLayerCA::recursiveCommitChanges(const TransformState& state, float
if (affectedByPageScale)
baseRelativePosition += m_position;
- commitLayerChangesBeforeSublayers(pageScaleFactor, baseRelativePosition, oldVisibleRect);
+ commitLayerChangesBeforeSublayers(childCommitState, pageScaleFactor, baseRelativePosition, oldVisibleRect);
+
+ if (isRunningTransformAnimation()) {
+ childCommitState.ancestorHasTransformAnimation = true;
+ affectedByTransformAnimation = true;
+ }
if (m_maskLayer) {
GraphicsLayerCA* maskLayerCA = static_cast<GraphicsLayerCA*>(m_maskLayer);
- maskLayerCA->commitLayerChangesBeforeSublayers(pageScaleFactor, baseRelativePosition, maskLayerCA->visibleRect());
+ maskLayerCA->commitLayerChangesBeforeSublayers(childCommitState, pageScaleFactor, baseRelativePosition, maskLayerCA->visibleRect());
}
const Vector<GraphicsLayer*>& childLayers = children();
@@ -1017,18 +1081,18 @@ void GraphicsLayerCA::recursiveCommitChanges(const TransformState& state, float
for (size_t i = 0; i < numChildren; ++i) {
GraphicsLayerCA* curChild = static_cast<GraphicsLayerCA*>(childLayers[i]);
- curChild->recursiveCommitChanges(localState, pageScaleFactor, baseRelativePosition, affectedByPageScale);
+ curChild->recursiveCommitChanges(childCommitState, localState, pageScaleFactor, baseRelativePosition, affectedByPageScale);
}
if (m_replicaLayer)
- static_cast<GraphicsLayerCA*>(m_replicaLayer)->recursiveCommitChanges(localState, pageScaleFactor, baseRelativePosition, affectedByPageScale);
+ static_cast<GraphicsLayerCA*>(m_replicaLayer)->recursiveCommitChanges(childCommitState, localState, pageScaleFactor, baseRelativePosition, affectedByPageScale);
if (m_maskLayer)
- static_cast<GraphicsLayerCA*>(m_maskLayer)->commitLayerChangesAfterSublayers();
+ static_cast<GraphicsLayerCA*>(m_maskLayer)->commitLayerChangesAfterSublayers(childCommitState);
- commitLayerChangesAfterSublayers();
+ commitLayerChangesAfterSublayers(childCommitState);
- if (client() && m_layer->layerType() == PlatformCALayer::LayerTypeTileCacheLayer)
+ if (affectedByTransformAnimation && client() && m_layer->layerType() == PlatformCALayer::LayerTypeTiledBackingLayer)
client()->notifyFlushBeforeDisplayRefresh(this);
if (hadChanges && client())
@@ -1037,9 +1101,9 @@ void GraphicsLayerCA::recursiveCommitChanges(const TransformState& state, float
bool GraphicsLayerCA::platformCALayerShowRepaintCounter(PlatformCALayer* platformLayer) const
{
- // The repaint counters are painted into the TileCache tiles (which have no corresponding platform layer),
- // so we don't want to overpaint the repaint counter when called with the TileCache's own layer.
- if (m_isPageTileCacheLayer && platformLayer)
+ // The repaint counters are painted into the TileController tiles (which have no corresponding platform layer),
+ // so we don't want to overpaint the repaint counter when called with the TileController's own layer.
+ if (m_isPageTiledBackingLayer && platformLayer)
return false;
return isShowingRepaintCounter();
@@ -1052,14 +1116,12 @@ void GraphicsLayerCA::platformCALayerPaintContents(GraphicsContext& context, con
void GraphicsLayerCA::platformCALayerDidCreateTiles(const Vector<FloatRect>& dirtyRects)
{
- ASSERT(m_layer->usesTileCacheLayer());
+ ASSERT(m_layer->usesTiledBackingLayer());
for (size_t i = 0; i < dirtyRects.size(); ++i)
setNeedsDisplayInRect(dirtyRects[i]);
- // Ensure that the layout is up to date before any individual tiles are painted by telling the client
- // that it needs to flush its layer state, which will end up scheduling the layer flusher.
- client()->notifyFlushRequired(this);
+ noteLayerPropertyChanged(TilesAdded);
}
float GraphicsLayerCA::platformCALayerDeviceScaleFactor()
@@ -1067,20 +1129,32 @@ float GraphicsLayerCA::platformCALayerDeviceScaleFactor()
return deviceScaleFactor();
}
-void GraphicsLayerCA::commitLayerChangesBeforeSublayers(float pageScaleFactor, const FloatPoint& positionRelativeToBase, const FloatRect& oldVisibleRect)
+void GraphicsLayerCA::commitLayerChangesBeforeSublayers(CommitState& commitState, float pageScaleFactor, const FloatPoint& positionRelativeToBase, const FloatRect& oldVisibleRect)
{
- if (!m_uncommittedChanges)
+ ++commitState.treeDepth;
+ if (m_structuralLayer)
+ ++commitState.treeDepth;
+
+ if (!m_uncommittedChanges) {
+ // Ensure that we cap layer depth in commitLayerChangesAfterSublayers().
+ if (commitState.treeDepth > cMaxLayerTreeDepth)
+ m_uncommittedChanges |= ChildrenChanged;
return;
+ }
+
+ bool needTiledLayer = requiresTiledLayer(pageScaleFactor);
+ if (needTiledLayer != m_usingTiledBacking)
+ swapFromOrToTiledLayer(needTiledLayer);
// Need to handle Preserves3DChanged first, because it affects which layers subsequent properties are applied to
if (m_uncommittedChanges & (Preserves3DChanged | ReplicatedLayerChanged))
- updateStructuralLayer(pageScaleFactor, positionRelativeToBase);
+ updateStructuralLayer();
if (m_uncommittedChanges & GeometryChanged)
updateGeometry(pageScaleFactor, positionRelativeToBase);
if (m_uncommittedChanges & DrawsContentChanged)
- updateLayerDrawsContent(pageScaleFactor, positionRelativeToBase);
+ updateLayerDrawsContent();
if (m_uncommittedChanges & NameChanged)
updateLayerNames();
@@ -1093,9 +1167,12 @@ void GraphicsLayerCA::commitLayerChangesBeforeSublayers(float pageScaleFactor, c
if (m_uncommittedChanges & ContentsCanvasLayerChanged) // Needs to happen before ChildrenChanged
updateContentsCanvasLayer();
+
+ if (m_uncommittedChanges & ContentsColorLayerChanged) // Needs to happen before ChildrenChanged
+ updateContentsColorLayer();
- if (m_uncommittedChanges & BackgroundColorChanged) // Needs to happen before ChildrenChanged, and after updating image or video
- updateLayerBackgroundColor();
+ if (m_uncommittedChanges & BackgroundColorChanged)
+ updateBackgroundColor();
if (m_uncommittedChanges & TransformChanged)
updateTransform();
@@ -1124,12 +1201,12 @@ void GraphicsLayerCA::commitLayerChangesBeforeSublayers(float pageScaleFactor, c
#endif
if (m_uncommittedChanges & AnimationChanged)
- updateLayerAnimations();
+ updateAnimations();
// Updating the contents scale can cause parts of the layer to be invalidated,
// so make sure to update the contents scale before updating the dirty rects.
if (m_uncommittedChanges & ContentsScaleChanged)
- updateContentsScale(pageScaleFactor, positionRelativeToBase);
+ updateContentsScale(pageScaleFactor);
if (m_uncommittedChanges & VisibleRectChanged)
updateVisibleRect(oldVisibleRect);
@@ -1157,15 +1234,19 @@ void GraphicsLayerCA::commitLayerChangesBeforeSublayers(float pageScaleFactor, c
// Sublayers may set this flag again, so clear it to avoid always updating sublayers in commitLayerChangesAfterSublayers().
m_uncommittedChanges &= ~ChildrenChanged;
}
+
+ // Ensure that we cap layer depth in commitLayerChangesAfterSublayers().
+ if (commitState.treeDepth > cMaxLayerTreeDepth)
+ m_uncommittedChanges |= ChildrenChanged;
}
-void GraphicsLayerCA::commitLayerChangesAfterSublayers()
+void GraphicsLayerCA::commitLayerChangesAfterSublayers(CommitState& commitState)
{
if (!m_uncommittedChanges)
return;
if (m_uncommittedChanges & ChildrenChanged)
- updateSublayerList();
+ updateSublayerList(commitState.treeDepth > cMaxLayerTreeDepth);
if (m_uncommittedChanges & ReplicatedLayerChanged)
updateReplicatedLayers();
@@ -1188,8 +1269,13 @@ void GraphicsLayerCA::updateLayerNames()
m_layer->setName(name());
}
-void GraphicsLayerCA::updateSublayerList()
+void GraphicsLayerCA::updateSublayerList(bool maxLayerDepthReached)
{
+ if (maxLayerDepthReached) {
+ m_layer->setSublayers(PlatformCALayerList());
+ return;
+ }
+
const PlatformCALayerList* customSublayers = m_layer->customSublayers();
PlatformCALayerList structuralLayerChildren;
@@ -1198,7 +1284,7 @@ void GraphicsLayerCA::updateSublayerList()
PlatformCALayerList& childListForSublayers = m_structuralLayer ? structuralLayerChildren : primaryLayerChildren;
if (customSublayers)
- primaryLayerChildren.append(*customSublayers);
+ primaryLayerChildren.appendVector(*customSublayers);
if (m_structuralLayer) {
if (m_replicaLayer)
@@ -1241,16 +1327,11 @@ void GraphicsLayerCA::updateGeometry(float pageScaleFactor, const FloatPoint& po
FloatSize pixelAlignmentOffset;
computePixelAlignment(pageScaleFactor, positionRelativeToBase, scaledPosition, scaledSize, scaledAnchorPoint, pixelAlignmentOffset);
- bool needTiledLayer = requiresTiledLayer(pageScaleFactor);
- if (needTiledLayer != m_usingTiledLayer)
- swapFromOrToTiledLayer(needTiledLayer, pageScaleFactor, positionRelativeToBase);
-
- FloatSize usedSize = m_usingTiledLayer ? constrainedSize() : scaledSize;
- FloatRect adjustedBounds(m_boundsOrigin - pixelAlignmentOffset, usedSize);
+ FloatRect adjustedBounds(m_boundsOrigin - pixelAlignmentOffset, scaledSize);
// Update position.
// Position is offset on the layer by the layer anchor point.
- FloatPoint adjustedPosition(scaledPosition.x() + scaledAnchorPoint.x() * usedSize.width(), scaledPosition.y() + scaledAnchorPoint.y() * usedSize.height());
+ FloatPoint adjustedPosition(scaledPosition.x() + scaledAnchorPoint.x() * scaledSize.width(), scaledPosition.y() + scaledAnchorPoint.y() * scaledSize.height());
if (m_structuralLayer) {
FloatPoint layerPosition(m_position.x() + m_anchorPoint.x() * m_size.width(), m_position.y() + m_anchorPoint.y() * m_size.height());
@@ -1280,7 +1361,7 @@ void GraphicsLayerCA::updateGeometry(float pageScaleFactor, const FloatPoint& po
// If we have a structural layer, we just use 0.5, 0.5 for the anchor point of the main layer.
scaledAnchorPoint = FloatPoint(0.5f, 0.5f);
- adjustedPosition = FloatPoint(scaledAnchorPoint.x() * usedSize.width() - pixelAlignmentOffset.width(), scaledAnchorPoint.y() * usedSize.height() - pixelAlignmentOffset.height());
+ adjustedPosition = FloatPoint(scaledAnchorPoint.x() * scaledSize.width() - pixelAlignmentOffset.width(), scaledAnchorPoint.y() * scaledSize.height() - pixelAlignmentOffset.height());
}
m_layer->setPosition(adjustedPosition);
@@ -1412,12 +1493,12 @@ void GraphicsLayerCA::updateFilters()
}
#endif
-void GraphicsLayerCA::updateStructuralLayer(float pageScaleFactor, const FloatPoint& positionRelativeToBase)
+void GraphicsLayerCA::updateStructuralLayer()
{
- ensureStructuralLayer(structuralLayerPurpose(), pageScaleFactor, positionRelativeToBase);
+ ensureStructuralLayer(structuralLayerPurpose());
}
-void GraphicsLayerCA::ensureStructuralLayer(StructuralLayerPurpose purpose, float /*pageScaleFactor*/, const FloatPoint& /*positionRelativeToBase*/)
+void GraphicsLayerCA::ensureStructuralLayer(StructuralLayerPurpose purpose)
{
const LayerChangeFlags structuralLayerChangeFlags = NameChanged
| GeometryChanged
@@ -1511,12 +1592,8 @@ GraphicsLayerCA::StructuralLayerPurpose GraphicsLayerCA::structuralLayerPurpose(
return NoStructuralLayer;
}
-void GraphicsLayerCA::updateLayerDrawsContent(float pageScaleFactor, const FloatPoint& positionRelativeToBase)
+void GraphicsLayerCA::updateLayerDrawsContent()
{
- bool needTiledLayer = requiresTiledLayer(pageScaleFactor);
- if (needTiledLayer != m_usingTiledLayer)
- swapFromOrToTiledLayer(needTiledLayer, pageScaleFactor, positionRelativeToBase);
-
if (m_drawsContent)
m_layer->setNeedsDisplay();
else {
@@ -1542,24 +1619,24 @@ void GraphicsLayerCA::updateDebugBorder()
m_layer->setBorderWidth(0);
}
-FloatRect GraphicsLayerCA::adjustTiledLayerVisibleRect(TiledBacking* tiledBacking, const FloatRect& oldVisibleRect, const FloatSize& oldSize) const
+FloatRect GraphicsLayerCA::adjustTiledLayerVisibleRect(TiledBacking* tiledBacking, const FloatRect& oldVisibleRect, const FloatRect& newVisibleRect, const FloatSize& oldSize, const FloatSize& newSize)
{
// If the old visible rect is empty, we have no information about how the visible area is changing
// (maybe the layer was just created), so don't attempt to expand. Also don't attempt to expand
// if the size changed.
- if (oldVisibleRect.isEmpty() || m_size != oldSize)
- return m_visibleRect;
+ if (oldVisibleRect.isEmpty() || newSize != oldSize)
+ return newVisibleRect;
const float paddingMultiplier = 2;
- float leftEdgeDelta = paddingMultiplier * (m_visibleRect.x() - oldVisibleRect.x());
- float rightEdgeDelta = paddingMultiplier * (m_visibleRect.maxX() - oldVisibleRect.maxX());
+ float leftEdgeDelta = paddingMultiplier * (newVisibleRect.x() - oldVisibleRect.x());
+ float rightEdgeDelta = paddingMultiplier * (newVisibleRect.maxX() - oldVisibleRect.maxX());
- float topEdgeDelta = paddingMultiplier * (m_visibleRect.y() - oldVisibleRect.y());
- float bottomEdgeDelta = paddingMultiplier * (m_visibleRect.maxY() - oldVisibleRect.maxY());
+ float topEdgeDelta = paddingMultiplier * (newVisibleRect.y() - oldVisibleRect.y());
+ float bottomEdgeDelta = paddingMultiplier * (newVisibleRect.maxY() - oldVisibleRect.maxY());
FloatRect existingTileBackingRect = tiledBacking->visibleRect();
- FloatRect expandedRect = m_visibleRect;
+ FloatRect expandedRect = newVisibleRect;
// More exposed on left side.
if (leftEdgeDelta < 0) {
@@ -1604,35 +1681,21 @@ FloatRect GraphicsLayerCA::adjustTiledLayerVisibleRect(TiledBacking* tiledBackin
void GraphicsLayerCA::updateVisibleRect(const FloatRect& oldVisibleRect)
{
- if (!m_layer->usesTileCacheLayer())
+ if (!m_layer->usesTiledBackingLayer())
return;
FloatRect tileArea = m_visibleRect;
- if (m_layer->layerType() == PlatformCALayer::LayerTypeTileCacheLayer)
- tileArea = adjustTiledLayerVisibleRect(tiledBacking(), oldVisibleRect, m_sizeAtLastVisibleRectUpdate);
+ if (m_layer->layerType() == PlatformCALayer::LayerTypeTiledBackingLayer)
+ tileArea = adjustTiledLayerVisibleRect(tiledBacking(), oldVisibleRect, tileArea, m_sizeAtLastVisibleRectUpdate, m_size);
- tiledBacking()->setVisibleRect(enclosingIntRect(tileArea));
+ tiledBacking()->setVisibleRect(tileArea);
m_sizeAtLastVisibleRectUpdate = m_size;
}
-void GraphicsLayerCA::updateLayerBackgroundColor()
+void GraphicsLayerCA::updateBackgroundColor()
{
- if (m_isPageTileCacheLayer) {
- m_layer->setBackgroundColor(m_backgroundColor);
- return;
- }
-
- if (!m_contentsLayer)
- return;
-
- setupContentsLayer(m_contentsLayer.get());
- updateContentsRect();
-
- if (m_backgroundColorSet)
- m_contentsLayer->setBackgroundColor(m_backgroundColor);
- else
- m_contentsLayer->setBackgroundColor(Color::transparent);
+ m_layer->setBackgroundColor(m_backgroundColor);
}
void GraphicsLayerCA::updateContentsImage()
@@ -1686,6 +1749,23 @@ void GraphicsLayerCA::updateContentsCanvasLayer()
}
}
+void GraphicsLayerCA::updateContentsColorLayer()
+{
+ // Color layer was set as m_contentsLayer, and will get parented in updateSublayerList().
+ if (m_contentsLayer) {
+ setupContentsLayer(m_contentsLayer.get());
+ updateContentsRect();
+ ASSERT(m_contentsSolidColor.isValid()); // An invalid color should have removed the contents layer.
+ m_contentsLayer->setBackgroundColor(m_contentsSolidColor);
+
+ if (m_contentsLayerClones) {
+ LayerMap::const_iterator end = m_contentsLayerClones->end();
+ for (LayerMap::const_iterator it = m_contentsLayerClones->begin(); it != end; ++it)
+ it->value->setBackgroundColor(m_contentsSolidColor);
+ }
+ }
+}
+
void GraphicsLayerCA::updateContentsRect()
{
if (!m_contentsLayer)
@@ -1716,7 +1796,7 @@ void GraphicsLayerCA::updateMaskLayer()
if (LayerMap* layerCloneMap = m_layerClones.get()) {
LayerMap::const_iterator end = layerCloneMap->end();
for (LayerMap::const_iterator it = layerCloneMap->begin(); it != end; ++it) {
- PlatformCALayer* maskClone = maskLayerCloneMap ? maskLayerCloneMap->get(it->key).get() : 0;
+ PlatformCALayer* maskClone = maskLayerCloneMap ? maskLayerCloneMap->get(it->key) : 0;
it->value->setMask(maskClone);
}
}
@@ -1776,7 +1856,7 @@ PassRefPtr<PlatformCALayer> GraphicsLayerCA::replicatedLayerRoot(ReplicaState& r
return clonedLayerRoot;
}
-void GraphicsLayerCA::updateLayerAnimations()
+void GraphicsLayerCA::updateAnimations()
{
if (m_animationsToProcess.size()) {
AnimationsToProcessMap::const_iterator end = m_animationsToProcess.end();
@@ -1792,10 +1872,10 @@ void GraphicsLayerCA::updateLayerAnimations()
const LayerPropertyAnimation& currAnimation = animations[i];
switch (processingInfo.action) {
case Remove:
- removeCAAnimationFromLayer(currAnimation.m_property, currAnimationName, currAnimation.m_index);
+ removeCAAnimationFromLayer(currAnimation.m_property, currAnimationName, currAnimation.m_index, currAnimation.m_subIndex);
break;
case Pause:
- pauseCAAnimationOnLayer(currAnimation.m_property, currAnimationName, currAnimation.m_index, processingInfo.timeOffset);
+ pauseCAAnimationOnLayer(currAnimation.m_property, currAnimationName, currAnimation.m_index, currAnimation.m_subIndex, processingInfo.timeOffset);
break;
}
}
@@ -1811,7 +1891,7 @@ void GraphicsLayerCA::updateLayerAnimations()
if ((numAnimations = m_uncomittedAnimations.size())) {
for (size_t i = 0; i < numAnimations; ++i) {
const LayerPropertyAnimation& pendingAnimation = m_uncomittedAnimations[i];
- setAnimationOnLayer(pendingAnimation.m_animation.get(), pendingAnimation.m_property, pendingAnimation.m_name, pendingAnimation.m_index, pendingAnimation.m_timeOffset);
+ setAnimationOnLayer(pendingAnimation.m_animation.get(), pendingAnimation.m_property, pendingAnimation.m_name, pendingAnimation.m_index, pendingAnimation.m_subIndex, pendingAnimation.m_timeOffset);
AnimationsMap::iterator it = m_runningAnimations.find(pendingAnimation.m_name);
if (it == m_runningAnimations.end()) {
@@ -1828,14 +1908,29 @@ void GraphicsLayerCA::updateLayerAnimations()
}
}
-void GraphicsLayerCA::setAnimationOnLayer(PlatformCAAnimation* caAnim, AnimatedPropertyID property, const String& animationName, int index, double timeOffset)
+bool GraphicsLayerCA::isRunningTransformAnimation() const
+{
+ AnimationsMap::const_iterator end = m_runningAnimations.end();
+ for (AnimationsMap::const_iterator it = m_runningAnimations.begin(); it != end; ++it) {
+ const Vector<LayerPropertyAnimation>& propertyAnimations = it->value;
+ size_t numAnimations = propertyAnimations.size();
+ for (size_t i = 0; i < numAnimations; ++i) {
+ const LayerPropertyAnimation& currAnimation = propertyAnimations[i];
+ if (currAnimation.m_property == AnimatedPropertyWebkitTransform)
+ return true;
+ }
+ }
+ return false;
+}
+
+void GraphicsLayerCA::setAnimationOnLayer(PlatformCAAnimation* caAnim, AnimatedPropertyID property, const String& animationName, int index, int subIndex, double timeOffset)
{
PlatformCALayer* layer = animatedLayer(property);
if (timeOffset)
caAnim->setBeginTime(CACurrentMediaTime() - timeOffset);
- String animationID = animationIdentifier(animationName, property, index);
+ String animationID = animationIdentifier(animationName, property, index, subIndex);
layer->removeAnimationForKey(animationID);
layer->addAnimationForKey(animationID, caAnim);
@@ -1867,11 +1962,11 @@ static void bug7311367Workaround(PlatformCALayer* transformLayer, const Transfor
transformLayer->setTransform(caTransform);
}
-bool GraphicsLayerCA::removeCAAnimationFromLayer(AnimatedPropertyID property, const String& animationName, int index)
+bool GraphicsLayerCA::removeCAAnimationFromLayer(AnimatedPropertyID property, const String& animationName, int index, int subIndex)
{
PlatformCALayer* layer = animatedLayer(property);
- String animationID = animationIdentifier(animationName, property, index);
+ String animationID = animationIdentifier(animationName, property, index, subIndex);
if (!layer->animationForKey(animationID))
return false;
@@ -1892,11 +1987,11 @@ bool GraphicsLayerCA::removeCAAnimationFromLayer(AnimatedPropertyID property, co
return true;
}
-void GraphicsLayerCA::pauseCAAnimationOnLayer(AnimatedPropertyID property, const String& animationName, int index, double timeOffset)
+void GraphicsLayerCA::pauseCAAnimationOnLayer(AnimatedPropertyID property, const String& animationName, int index, int subIndex, double timeOffset)
{
PlatformCALayer* layer = animatedLayer(property);
- String animationID = animationIdentifier(animationName, property, index);
+ String animationID = animationIdentifier(animationName, property, index, subIndex);
RefPtr<PlatformCAAnimation> curAnim = layer->animationForKey(animationID);
if (!curAnim)
@@ -1962,7 +2057,7 @@ bool GraphicsLayerCA::createAnimationFromKeyframes(const KeyframeValueList& valu
if (!valuesOK)
return false;
- m_uncomittedAnimations.append(LayerPropertyAnimation(caAnimation, animationName, valueList.property(), animationIndex, timeOffset));
+ m_uncomittedAnimations.append(LayerPropertyAnimation(caAnimation, animationName, valueList.property(), animationIndex, 0, timeOffset));
return true;
}
@@ -1986,7 +2081,7 @@ bool GraphicsLayerCA::appendToUncommittedAnimations(const KeyframeValueList& val
if (!validMatrices)
return false;
- m_uncomittedAnimations.append(LayerPropertyAnimation(caAnimation, animationName, valueList.property(), animationIndex, timeOffset));
+ m_uncomittedAnimations.append(LayerPropertyAnimation(caAnimation, animationName, valueList.property(), animationIndex, 0, timeOffset));
return true;
}
@@ -1996,7 +2091,7 @@ bool GraphicsLayerCA::createTransformAnimationsFromKeyframes(const KeyframeValue
bool hasBigRotation;
int listIndex = validateTransformOperations(valueList, hasBigRotation);
- const TransformOperations* operations = (listIndex >= 0) ? static_cast<const TransformAnimationValue*>(valueList.at(listIndex))->value() : 0;
+ const TransformOperations* operations = (listIndex >= 0) ? &static_cast<const TransformAnimationValue&>(valueList.at(listIndex)).value() : 0;
// We need to fall back to software animation if we don't have setValueFunction:, and
// we would need to animate each incoming transform function separately. This is the
@@ -2048,7 +2143,7 @@ bool GraphicsLayerCA::appendToUncommittedAnimations(const KeyframeValueList& val
bool isKeyframe = valueList.size() > 2;
FilterOperation::OperationType filterOp = operation->getOperationType();
- int numAnimatedProperties = PlatformCAAnimation::numAnimatedFilterProperties(filterOp);
+ int numAnimatedProperties = PlatformCAFilters::numAnimatedFilterProperties(filterOp);
// Each filter might need to animate multiple properties, each with their own keyPath. The keyPath is always of the form:
//
@@ -2060,7 +2155,7 @@ bool GraphicsLayerCA::appendToUncommittedAnimations(const KeyframeValueList& val
for (int internalFilterPropertyIndex = 0; internalFilterPropertyIndex < numAnimatedProperties; ++internalFilterPropertyIndex) {
bool valuesOK;
RefPtr<PlatformCAAnimation> caAnimation;
- String keyPath = String::format("filters.filter_%d.%s", animationIndex, PlatformCAAnimation::animatedFilterPropertyName(filterOp, internalFilterPropertyIndex));
+ String keyPath = String::format("filters.filter_%d.%s", animationIndex, PlatformCAFilters::animatedFilterPropertyName(filterOp, internalFilterPropertyIndex));
if (isKeyframe) {
caAnimation = createKeyframeAnimation(animation, keyPath, false);
@@ -2072,7 +2167,7 @@ bool GraphicsLayerCA::appendToUncommittedAnimations(const KeyframeValueList& val
ASSERT(valuesOK);
- m_uncomittedAnimations.append(LayerPropertyAnimation(caAnimation, animationName, valueList.property(), animationIndex, timeOffset));
+ m_uncomittedAnimations.append(LayerPropertyAnimation(caAnimation, animationName, valueList.property(), animationIndex, internalFilterPropertyIndex, timeOffset));
}
return true;
@@ -2086,21 +2181,21 @@ bool GraphicsLayerCA::createFilterAnimationsFromKeyframes(const KeyframeValueLis
if (listIndex < 0)
return false;
- const FilterOperations* operations = static_cast<const FilterAnimationValue*>(valueList.at(listIndex))->value();
+ const FilterOperations& operations = static_cast<const FilterAnimationValue&>(valueList.at(listIndex)).value();
// Make sure the platform layer didn't fallback to using software filter compositing instead.
- if (!PlatformCALayer::filtersCanBeComposited(*operations))
+ if (!PlatformCALayer::filtersCanBeComposited(operations))
return false;
- int numAnimations = operations->size();
+ int numAnimations = operations.size();
// FIXME: We can't currently hardware animate shadows.
for (int i = 0; i < numAnimations; ++i) {
- if (operations->at(i)->getOperationType() == FilterOperation::DROP_SHADOW)
+ if (operations.at(i)->getOperationType() == FilterOperation::DROP_SHADOW)
return false;
}
for (int animationIndex = 0; animationIndex < numAnimations; ++animationIndex) {
- if (!appendToUncommittedAnimations(valueList, operations->operations().at(animationIndex).get(), animation, animationName, animationIndex, timeOffset))
+ if (!appendToUncommittedAnimations(valueList, operations.operations().at(animationIndex).get(), animation, animationName, animationIndex, timeOffset))
return false;
}
@@ -2158,12 +2253,12 @@ void GraphicsLayerCA::setupAnimation(PlatformCAAnimation* propertyAnim, const An
propertyAnim->setFillMode(fillMode);
}
-const TimingFunction* GraphicsLayerCA::timingFunctionForAnimationValue(const AnimationValue* animValue, const Animation* anim)
+const TimingFunction* GraphicsLayerCA::timingFunctionForAnimationValue(const AnimationValue& animValue, const Animation& anim)
{
- if (animValue->timingFunction())
- return animValue->timingFunction();
- if (anim->isTimingFunctionSet())
- return anim->timingFunction().get();
+ if (animValue.timingFunction())
+ return animValue.timingFunction();
+ if (anim.isTimingFunctionSet())
+ return anim.timingFunction().get();
return CubicBezierTimingFunction::defaultTimingFunction();
}
@@ -2177,8 +2272,8 @@ bool GraphicsLayerCA::setAnimationEndpoints(const KeyframeValueList& valueList,
switch (valueList.property()) {
case AnimatedPropertyOpacity: {
- basicAnim->setFromValue(static_cast<const FloatAnimationValue*>(valueList.at(fromIndex))->value());
- basicAnim->setToValue(static_cast<const FloatAnimationValue*>(valueList.at(toIndex))->value());
+ basicAnim->setFromValue(static_cast<const FloatAnimationValue&>(valueList.at(fromIndex)).value());
+ basicAnim->setToValue(static_cast<const FloatAnimationValue&>(valueList.at(toIndex)).value());
break;
}
default:
@@ -2188,7 +2283,7 @@ bool GraphicsLayerCA::setAnimationEndpoints(const KeyframeValueList& valueList,
// This codepath is used for 2-keyframe animations, so we still need to look in the start
// for a timing function. Even in the reversing animation case, the first keyframe provides the timing function.
- const TimingFunction* timingFunction = timingFunctionForAnimationValue(valueList.at(0), animation);
+ const TimingFunction* timingFunction = timingFunctionForAnimationValue(valueList.at(0), *animation);
if (timingFunction)
basicAnim->setTimingFunction(timingFunction, !forwards);
@@ -2205,13 +2300,13 @@ bool GraphicsLayerCA::setAnimationKeyframes(const KeyframeValueList& valueList,
for (unsigned i = 0; i < valueList.size(); ++i) {
unsigned index = forwards ? i : (valueList.size() - i - 1);
- const AnimationValue* curValue = valueList.at(index);
- keyTimes.append(forwards ? curValue->keyTime() : (1 - curValue->keyTime()));
+ const AnimationValue& curValue = valueList.at(index);
+ keyTimes.append(forwards ? curValue.keyTime() : (1 - curValue.keyTime()));
switch (valueList.property()) {
case AnimatedPropertyOpacity: {
- const FloatAnimationValue* floatValue = static_cast<const FloatAnimationValue*>(curValue);
- values.append(floatValue->value());
+ const FloatAnimationValue& floatValue = static_cast<const FloatAnimationValue&>(curValue);
+ values.append(floatValue.value());
break;
}
default:
@@ -2220,7 +2315,7 @@ bool GraphicsLayerCA::setAnimationKeyframes(const KeyframeValueList& valueList,
}
if (i < (valueList.size() - 1))
- timingFunctions.append(timingFunctionForAnimationValue(forwards ? curValue : valueList.at(index - 1), animation));
+ timingFunctions.append(timingFunctionForAnimationValue(forwards ? curValue : valueList.at(index - 1), *animation));
}
keyframeAnim->setKeyTimes(keyTimes);
@@ -2239,13 +2334,13 @@ bool GraphicsLayerCA::setTransformAnimationEndpoints(const KeyframeValueList& va
unsigned fromIndex = !forwards;
unsigned toIndex = forwards;
- const TransformAnimationValue* startValue = static_cast<const TransformAnimationValue*>(valueList.at(fromIndex));
- const TransformAnimationValue* endValue = static_cast<const TransformAnimationValue*>(valueList.at(toIndex));
+ const TransformAnimationValue& startValue = static_cast<const TransformAnimationValue&>(valueList.at(fromIndex));
+ const TransformAnimationValue& endValue = static_cast<const TransformAnimationValue&>(valueList.at(toIndex));
if (isMatrixAnimation) {
TransformationMatrix fromTransform, toTransform;
- startValue->value()->apply(boxSize, fromTransform);
- endValue->value()->apply(boxSize, toTransform);
+ startValue.value().apply(boxSize, fromTransform);
+ endValue.value().apply(boxSize, toTransform);
// If any matrix is singular, CA won't animate it correctly. So fall back to software animation
if (!fromTransform.isInvertible() || !toTransform.isInvertible())
@@ -2256,34 +2351,34 @@ bool GraphicsLayerCA::setTransformAnimationEndpoints(const KeyframeValueList& va
} else {
if (isTransformTypeNumber(transformOpType)) {
float fromValue;
- getTransformFunctionValue(startValue->value()->at(functionIndex), transformOpType, boxSize, fromValue);
+ getTransformFunctionValue(startValue.value().at(functionIndex), transformOpType, boxSize, fromValue);
basicAnim->setFromValue(fromValue);
float toValue;
- getTransformFunctionValue(endValue->value()->at(functionIndex), transformOpType, boxSize, toValue);
+ getTransformFunctionValue(endValue.value().at(functionIndex), transformOpType, boxSize, toValue);
basicAnim->setToValue(toValue);
} else if (isTransformTypeFloatPoint3D(transformOpType)) {
FloatPoint3D fromValue;
- getTransformFunctionValue(startValue->value()->at(functionIndex), transformOpType, boxSize, fromValue);
+ getTransformFunctionValue(startValue.value().at(functionIndex), transformOpType, boxSize, fromValue);
basicAnim->setFromValue(fromValue);
FloatPoint3D toValue;
- getTransformFunctionValue(endValue->value()->at(functionIndex), transformOpType, boxSize, toValue);
+ getTransformFunctionValue(endValue.value().at(functionIndex), transformOpType, boxSize, toValue);
basicAnim->setToValue(toValue);
} else {
TransformationMatrix fromValue;
- getTransformFunctionValue(startValue->value()->at(functionIndex), transformOpType, boxSize, fromValue);
+ getTransformFunctionValue(startValue.value().at(functionIndex), transformOpType, boxSize, fromValue);
basicAnim->setFromValue(fromValue);
TransformationMatrix toValue;
- getTransformFunctionValue(endValue->value()->at(functionIndex), transformOpType, boxSize, toValue);
+ getTransformFunctionValue(endValue.value().at(functionIndex), transformOpType, boxSize, toValue);
basicAnim->setToValue(toValue);
}
}
// This codepath is used for 2-keyframe animations, so we still need to look in the start
// for a timing function. Even in the reversing animation case, the first keyframe provides the timing function.
- const TimingFunction* timingFunction = timingFunctionForAnimationValue(valueList.at(0), animation);
+ const TimingFunction* timingFunction = timingFunctionForAnimationValue(valueList.at(0), *animation);
basicAnim->setTimingFunction(timingFunction, !forwards);
PlatformCAAnimation::ValueFunctionType valueFunction = getValueFunctionNameForTransformOperation(transformOpType);
@@ -2305,12 +2400,12 @@ bool GraphicsLayerCA::setTransformAnimationKeyframes(const KeyframeValueList& va
for (unsigned i = 0; i < valueList.size(); ++i) {
unsigned index = forwards ? i : (valueList.size() - i - 1);
- const TransformAnimationValue* curValue = static_cast<const TransformAnimationValue*>(valueList.at(index));
- keyTimes.append(forwards ? curValue->keyTime() : (1 - curValue->keyTime()));
+ const TransformAnimationValue& curValue = static_cast<const TransformAnimationValue&>(valueList.at(index));
+ keyTimes.append(forwards ? curValue.keyTime() : (1 - curValue.keyTime()));
if (isMatrixAnimation) {
TransformationMatrix transform;
- curValue->value()->apply(boxSize, transform);
+ curValue.value().apply(boxSize, transform);
// If any matrix is singular, CA won't animate it correctly. So fall back to software animation
if (!transform.isInvertible())
@@ -2318,7 +2413,7 @@ bool GraphicsLayerCA::setTransformAnimationKeyframes(const KeyframeValueList& va
transformationMatrixValues.append(transform);
} else {
- const TransformOperation* transformOp = curValue->value()->at(functionIndex);
+ const TransformOperation* transformOp = curValue.value().at(functionIndex);
if (isTransformTypeNumber(transformOpType)) {
float value;
getTransformFunctionValue(transformOp, transformOpType, boxSize, value);
@@ -2335,7 +2430,7 @@ bool GraphicsLayerCA::setTransformAnimationKeyframes(const KeyframeValueList& va
}
if (i < (valueList.size() - 1))
- timingFunctions.append(timingFunctionForAnimationValue(forwards ? curValue : valueList.at(index - 1), animation));
+ timingFunctions.append(timingFunctionForAnimationValue(forwards ? curValue : valueList.at(index - 1), *animation));
}
keyframeAnim->setKeyTimes(keyTimes);
@@ -2366,11 +2461,11 @@ bool GraphicsLayerCA::setFilterAnimationEndpoints(const KeyframeValueList& value
unsigned fromIndex = !forwards;
unsigned toIndex = forwards;
- const FilterAnimationValue* fromValue = static_cast<const FilterAnimationValue*>(valueList.at(fromIndex));
- const FilterAnimationValue* toValue = static_cast<const FilterAnimationValue*>(valueList.at(toIndex));
+ const FilterAnimationValue& fromValue = static_cast<const FilterAnimationValue&>(valueList.at(fromIndex));
+ const FilterAnimationValue& toValue = static_cast<const FilterAnimationValue&>(valueList.at(toIndex));
- const FilterOperation* fromOperation = fromValue->value()->at(functionIndex);
- const FilterOperation* toOperation = toValue->value()->at(functionIndex);
+ const FilterOperation* fromOperation = fromValue.value().at(functionIndex);
+ const FilterOperation* toOperation = toValue.value().at(functionIndex);
RefPtr<DefaultFilterOperation> defaultFromOperation;
RefPtr<DefaultFilterOperation> defaultToOperation;
@@ -2392,7 +2487,7 @@ bool GraphicsLayerCA::setFilterAnimationEndpoints(const KeyframeValueList& value
// This codepath is used for 2-keyframe animations, so we still need to look in the start
// for a timing function. Even in the reversing animation case, the first keyframe provides the timing function.
- basicAnim->setTimingFunction(timingFunctionForAnimationValue(valueList.at(0), animation), !forwards);
+ basicAnim->setTimingFunction(timingFunctionForAnimationValue(valueList.at(0), *animation), !forwards);
return true;
}
@@ -2408,11 +2503,11 @@ bool GraphicsLayerCA::setFilterAnimationKeyframes(const KeyframeValueList& value
for (unsigned i = 0; i < valueList.size(); ++i) {
unsigned index = forwards ? i : (valueList.size() - i - 1);
- const FilterAnimationValue* curValue = static_cast<const FilterAnimationValue*>(valueList.at(index));
- keyTimes.append(forwards ? curValue->keyTime() : (1 - curValue->keyTime()));
+ const FilterAnimationValue& curValue = static_cast<const FilterAnimationValue&>(valueList.at(index));
+ keyTimes.append(forwards ? curValue.keyTime() : (1 - curValue.keyTime()));
- if (curValue->value()->operations().size() > static_cast<size_t>(functionIndex))
- values.append(curValue->value()->operations()[functionIndex]);
+ if (curValue.value().operations().size() > static_cast<size_t>(functionIndex))
+ values.append(curValue.value().operations()[functionIndex]);
else {
if (!defaultOperation)
defaultOperation = DefaultFilterOperation::create(filterOp);
@@ -2420,7 +2515,7 @@ bool GraphicsLayerCA::setFilterAnimationKeyframes(const KeyframeValueList& value
}
if (i < (valueList.size() - 1))
- timingFunctions.append(timingFunctionForAnimationValue(forwards ? curValue : valueList.at(index - 1), animation));
+ timingFunctions.append(timingFunctionForAnimationValue(forwards ? curValue : valueList.at(index - 1), *animation));
}
keyframeAnim->setKeyTimes(keyTimes);
@@ -2491,12 +2586,8 @@ static float clampedContentsScaleForScale(float scale)
return max(minScale, min(scale, maxScale));
}
-void GraphicsLayerCA::updateContentsScale(float pageScaleFactor, const FloatPoint& positionRelativeToBase)
+void GraphicsLayerCA::updateContentsScale(float pageScaleFactor)
{
- bool needTiledLayer = requiresTiledLayer(pageScaleFactor);
- if (needTiledLayer != m_usingTiledLayer)
- swapFromOrToTiledLayer(needTiledLayer, pageScaleFactor, positionRelativeToBase);
-
float contentsScale = clampedContentsScaleForScale(pageScaleFactor * deviceScaleFactor());
m_layer->setContentsScale(contentsScale);
@@ -2532,7 +2623,7 @@ void GraphicsLayerCA::setDebugBackgroundColor(const Color& color)
void GraphicsLayerCA::getDebugBorderInfo(Color& color, float& width) const
{
- if (m_isPageTileCacheLayer) {
+ if (m_isPageTiledBackingLayer) {
color = Color(0, 0, 128, 128); // tile cache layer: dark blue
width = 0.5;
return;
@@ -2549,6 +2640,11 @@ void GraphicsLayerCA::dumpAdditionalProperties(TextStream& textStream, int inden
}
if (tiledBacking() && (behavior & LayerTreeAsTextIncludeTileCaches)) {
+ if (behavior & LayerTreeAsTextDebug) {
+ writeIndent(textStream, indent + 1);
+ textStream << "(tiled backing " << tiledBacking() << ")\n";
+ }
+
IntRect tileCoverageRect = tiledBacking()->tileCoverageRect();
writeIndent(textStream, indent + 1);
textStream << "(tile cache coverage " << tileCoverageRect.x() << ", " << tileCoverageRect.y() << " " << tileCoverageRect.width() << " x " << tileCoverageRect.height() << ")\n";
@@ -2574,47 +2670,23 @@ void GraphicsLayerCA::setDebugBorder(const Color& color, float borderWidth)
}
}
-FloatSize GraphicsLayerCA::constrainedSize() const
-{
- FloatSize constrainedSize = m_size;
-#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1060
- float tileColumns = ceilf(m_size.width() / kTiledLayerTileSize);
- float tileRows = ceilf(m_size.height() / kTiledLayerTileSize);
- double numTiles = tileColumns * tileRows;
-
- const unsigned cMaxTileCount = 512;
- while (numTiles > cMaxTileCount) {
- // Constrain the wider dimension.
- if (constrainedSize.width() >= constrainedSize.height()) {
- tileColumns = max(floorf(cMaxTileCount / tileRows), 1.0f);
- constrainedSize.setWidth(tileColumns * kTiledLayerTileSize);
- } else {
- tileRows = max(floorf(cMaxTileCount / tileColumns), 1.0f);
- constrainedSize.setHeight(tileRows * kTiledLayerTileSize);
- }
- numTiles = tileColumns * tileRows;
- }
-#endif
- return constrainedSize;
-}
-
bool GraphicsLayerCA::requiresTiledLayer(float pageScaleFactor) const
{
- if (!m_drawsContent || !m_allowTiledLayer || m_isPageTileCacheLayer)
+ if (!m_drawsContent || !m_allowTiledLayer || m_isPageTiledBackingLayer)
return false;
// FIXME: catch zero-size height or width here (or earlier)?
return m_size.width() * pageScaleFactor > cMaxPixelDimension || m_size.height() * pageScaleFactor > cMaxPixelDimension;
}
-void GraphicsLayerCA::swapFromOrToTiledLayer(bool useTiledLayer, float /*pageScaleFactor*/, const FloatPoint& /*positionRelativeToBase*/)
+void GraphicsLayerCA::swapFromOrToTiledLayer(bool useTiledLayer)
{
- ASSERT(m_layer->layerType() != PlatformCALayer::LayerTypePageTileCacheLayer);
- ASSERT(useTiledLayer != m_usingTiledLayer);
+ ASSERT(m_layer->layerType() != PlatformCALayer::LayerTypePageTiledBackingLayer);
+ ASSERT(useTiledLayer != m_usingTiledBacking);
RefPtr<PlatformCALayer> oldLayer = m_layer;
- m_layer = PlatformCALayer::create(useTiledLayer ? PlatformCALayer::LayerTypeTileCacheLayer : PlatformCALayer::LayerTypeWebLayer, this);
- m_usingTiledLayer = useTiledLayer;
+ m_layer = PlatformCALayer::create(useTiledLayer ? PlatformCALayer::LayerTypeTiledBackingLayer : PlatformCALayer::LayerTypeWebLayer, this);
+ m_usingTiledBacking = useTiledLayer;
m_layer->adoptSublayers(oldLayer.get());
@@ -2623,9 +2695,9 @@ void GraphicsLayerCA::swapFromOrToTiledLayer(bool useTiledLayer, float /*pageSca
m_layer->appendSublayer(m_visibleTileWashLayer.get());
#endif
- // FIXME: Skip this step if we don't have a superlayer. This is problably a benign
- // case that happens while restructuring the layer tree.
- ASSERT(oldLayer->superlayer());
+ // Skip this step if we don't have a superlayer. This is probably a benign
+ // case that happens while restructuring the layer tree, and also occurs with
+ // WebKit2 page overlays, which can become tiled but are out-of-tree.
if (oldLayer->superlayer())
oldLayer->superlayer()->replaceSublayer(oldLayer.get(), m_layer.get());
@@ -2643,6 +2715,9 @@ void GraphicsLayerCA::swapFromOrToTiledLayer(bool useTiledLayer, float /*pageSca
| OpacityChanged
| DebugIndicatorsChanged;
+ if (m_usingTiledBacking)
+ m_uncommittedChanges |= VisibleRectChanged;
+
#ifndef NDEBUG
String name = String::format("%sCALayer(%p) GraphicsLayer(%p) ", (m_layer->layerType() == PlatformCALayer::LayerTypeWebTiledLayer) ? "Tiled " : "", m_layer->platformLayer(), this) + m_name;
m_layer->setName(name);
@@ -2653,6 +2728,9 @@ void GraphicsLayerCA::swapFromOrToTiledLayer(bool useTiledLayer, float /*pageSca
// need to tell new layer to draw itself
setNeedsDisplay();
+
+ if (client())
+ client()->tiledBackingUsageChanged(this, m_usingTiledBacking);
}
GraphicsLayer::CompositingCoordinatesOrientation GraphicsLayerCA::defaultContentsOrientation() const
@@ -2849,22 +2927,7 @@ PassRefPtr<PlatformCALayer> GraphicsLayerCA::fetchCloneLayers(GraphicsLayer* rep
PassRefPtr<PlatformCALayer> GraphicsLayerCA::cloneLayer(PlatformCALayer *layer, CloneLevel cloneLevel)
{
- PlatformCALayer::LayerType layerType = (layer->layerType() == PlatformCALayer::LayerTypeTransformLayer) ?
- PlatformCALayer::LayerTypeTransformLayer : PlatformCALayer::LayerTypeLayer;
- RefPtr<PlatformCALayer> newLayer = PlatformCALayer::create(layerType, this);
-
- newLayer->setPosition(layer->position());
- newLayer->setBounds(layer->bounds());
- newLayer->setAnchorPoint(layer->anchorPoint());
- newLayer->setTransform(layer->transform());
- newLayer->setSublayerTransform(layer->sublayerTransform());
- newLayer->setContents(layer->contents());
- newLayer->setMasksToBounds(layer->masksToBounds());
- newLayer->setDoubleSided(layer->isDoubleSided());
- newLayer->setOpaque(layer->isOpaque());
- newLayer->setBackgroundColor(layer->backgroundColor());
- newLayer->setContentsScale(layer->contentsScale());
- newLayer->copyFiltersFrom(layer);
+ RefPtr<PlatformCALayer> newLayer = layer->clone(this);
if (cloneLevel == IntermediateCloneLevel) {
newLayer->setOpacity(layer->opacity());
@@ -2990,21 +3053,36 @@ void GraphicsLayerCA::noteSublayersChanged()
propagateLayerChangeToReplicas();
}
+bool GraphicsLayerCA::canThrottleLayerFlush() const
+{
+ // Tile layers are currently plain CA layers, attached directly by TileController. They require immediate flush as they may contain garbage.
+ return !(m_uncommittedChanges & TilesAdded);
+}
+
void GraphicsLayerCA::noteLayerPropertyChanged(LayerChangeFlags flags)
{
- if (!m_uncommittedChanges && m_client)
- m_client->notifyFlushRequired(this);
+ bool hadUncommittedChanges = !!m_uncommittedChanges;
+ bool oldCanThrottleLayerFlush = canThrottleLayerFlush();
m_uncommittedChanges |= flags;
+
+ bool needsFlush = !hadUncommittedChanges || oldCanThrottleLayerFlush != canThrottleLayerFlush();
+ if (needsFlush && m_client)
+ m_client->notifyFlushRequired(this);
}
double GraphicsLayerCA::backingStoreMemoryEstimate() const
{
if (!drawsContent())
return 0;
-
+
// contentsLayer is given to us, so we don't really know anything about its contents.
- return static_cast<double>(4 * size().width()) * size().height() * m_layer->contentsScale();
+ // FIXME: ignores layer clones.
+
+ if (TiledBacking* tiledBacking = this->tiledBacking())
+ return tiledBacking->retainedTileBackingStoreMemory();
+
+ return 4.0 * size().width() * m_layer->contentsScale() * size().height() * m_layer->contentsScale();
}
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h b/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h
index 2deb2e28c..09ccce451 100644
--- a/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h
+++ b/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h
@@ -89,7 +89,6 @@ public:
virtual void setAcceleratesDrawing(bool);
virtual void setBackgroundColor(const Color&);
- virtual void clearBackgroundColor();
virtual void setContentsOpaque(bool);
virtual void setBackfaceVisibility(bool);
@@ -117,7 +116,7 @@ public:
virtual void setContentsToImage(Image*);
virtual void setContentsToMedia(PlatformLayer*);
virtual void setContentsToCanvas(PlatformLayer*);
- virtual void setContentsToBackgroundColor(const Color&);
+ virtual void setContentsToSolidColor(const Color&);
virtual bool hasContentsLayer() const { return m_contentsLayer; }
@@ -132,11 +131,21 @@ public:
virtual void setMaintainsPixelAlignment(bool);
virtual void deviceOrPageScaleFactorChanged();
- void recursiveCommitChanges(const TransformState&, float pageScaleFactor = 1, const FloatPoint& positionRelativeToBase = FloatPoint(), bool affectedByPageScale = false);
+ struct CommitState {
+ bool ancestorHasTransformAnimation;
+ int treeDepth;
+ CommitState()
+ : ancestorHasTransformAnimation(false)
+ , treeDepth(0)
+ { }
+ };
+ void recursiveCommitChanges(const CommitState&, const TransformState&, float pageScaleFactor = 1, const FloatPoint& positionRelativeToBase = FloatPoint(), bool affectedByPageScale = false);
virtual void flushCompositingState(const FloatRect&);
virtual void flushCompositingStateForThisLayerOnly();
+ virtual bool visibleRectChangeRequiresFlush(const FloatRect& visibleRect) const OVERRIDE;
+
virtual TiledBacking* tiledBacking() const OVERRIDE;
bool allowTiledLayer() const { return m_allowTiledLayer; }
@@ -196,7 +205,7 @@ private:
PassRefPtr<PlatformCAAnimation> createKeyframeAnimation(const Animation*, const String&, bool additive);
void setupAnimation(PlatformCAAnimation*, const Animation*, bool additive);
- const TimingFunction* timingFunctionForAnimationValue(const AnimationValue*, const Animation*);
+ const TimingFunction* timingFunctionForAnimationValue(const AnimationValue&, const Animation&);
bool setAnimationEndpoints(const KeyframeValueList&, const Animation*, PlatformCAAnimation*);
bool setAnimationKeyframes(const KeyframeValueList&, const Animation*, PlatformCAAnimation*);
@@ -209,20 +218,20 @@ private:
bool setFilterAnimationKeyframes(const KeyframeValueList&, const Animation*, PlatformCAAnimation*, int functionIndex, int internalFilterPropertyIndex, FilterOperation::OperationType);
#endif
+ bool isRunningTransformAnimation() const;
+
bool animationIsRunning(const String& animationName) const
{
return m_runningAnimations.find(animationName) != m_runningAnimations.end();
}
- void commitLayerChangesBeforeSublayers(float pageScaleFactor, const FloatPoint& positionRelativeToBase, const FloatRect& oldVisibleRect);
- void commitLayerChangesAfterSublayers();
+ void commitLayerChangesBeforeSublayers(CommitState&, float pageScaleFactor, const FloatPoint& positionRelativeToBase, const FloatRect& oldVisibleRect);
+ void commitLayerChangesAfterSublayers(CommitState&);
FloatPoint computePositionRelativeToBase(float& pageScale) const;
- FloatSize constrainedSize() const;
-
bool requiresTiledLayer(float pageScaleFactor) const;
- void swapFromOrToTiledLayer(bool useTiledLayer, float pageScaleFactor, const FloatPoint& positionRelativeToBase);
+ void swapFromOrToTiledLayer(bool useTiledLayer);
CompositingCoordinatesOrientation defaultContentsOrientation() const;
@@ -236,10 +245,16 @@ private:
void computePixelAlignment(float pixelAlignmentScale, const FloatPoint& positionRelativeToBase,
FloatPoint& position, FloatSize&, FloatPoint3D& anchorPoint, FloatSize& alignmentOffset) const;
- FloatRect computeVisibleRect(TransformState&) const;
+ enum ComputeVisibleRectFlag { RespectAnimatingTransforms = 1 << 0 };
+ typedef unsigned ComputeVisibleRectFlags;
+ FloatRect computeVisibleRect(TransformState&, ComputeVisibleRectFlags = RespectAnimatingTransforms) const;
const FloatRect& visibleRect() const { return m_visibleRect; }
- FloatRect adjustTiledLayerVisibleRect(TiledBacking*, const FloatRect& oldVisibleRect, const FloatSize& oldSize) const;
+ static FloatRect adjustTiledLayerVisibleRect(TiledBacking*, const FloatRect& oldVisibleRect, const FloatRect& newVisibleRect, const FloatSize& oldSize, const FloatSize& newSize);
+
+ bool recursiveVisibleRectChangeRequiresFlush(const TransformState&) const;
+
+ virtual bool canThrottleLayerFlush() const;
// Used to track the path down the tree for replica layers.
struct ReplicaState {
@@ -307,7 +322,7 @@ private:
// All these "update" methods will be called inside a BEGIN_BLOCK_OBJC_EXCEPTIONS/END_BLOCK_OBJC_EXCEPTIONS block.
void updateLayerNames();
- void updateSublayerList();
+ void updateSublayerList(bool maxLayerDepthReached = false);
void updateGeometry(float pixelAlignmentScale, const FloatPoint& positionRelativeToBase);
void updateTransform();
void updateChildrenTransform();
@@ -315,35 +330,36 @@ private:
void updateContentsVisibility();
void updateContentsOpaque();
void updateBackfaceVisibility();
- void updateStructuralLayer(float pixelAlignmentScale, const FloatPoint& positionRelativeToBase);
- void updateLayerDrawsContent(float pixelAlignmentScale, const FloatPoint& positionRelativeToBase);
- void updateLayerBackgroundColor();
+ void updateStructuralLayer();
+ void updateLayerDrawsContent();
+ void updateBackgroundColor();
void updateContentsImage();
void updateContentsMediaLayer();
void updateContentsCanvasLayer();
+ void updateContentsColorLayer();
void updateContentsRect();
void updateMaskLayer();
void updateReplicatedLayers();
- void updateLayerAnimations();
+ void updateAnimations();
void updateContentsNeedsDisplay();
void updateAcceleratesDrawing();
void updateDebugBorder();
void updateVisibleRect(const FloatRect& oldVisibleRect);
- void updateContentsScale(float pixelAlignmentScale, const FloatPoint& positionRelativeToBase);
+ void updateContentsScale(float pageScaleFactor);
enum StructuralLayerPurpose {
NoStructuralLayer = 0,
StructuralLayerForPreserves3D,
StructuralLayerForReplicaFlattening
};
- void ensureStructuralLayer(StructuralLayerPurpose, float pixelAlignmentScale, const FloatPoint& positionRelativeToBase);
+ void ensureStructuralLayer(StructuralLayerPurpose);
StructuralLayerPurpose structuralLayerPurpose() const;
- void setAnimationOnLayer(PlatformCAAnimation*, AnimatedPropertyID, const String& animationName, int index, double timeOffset);
- bool removeCAAnimationFromLayer(AnimatedPropertyID, const String& animationName, int index);
- void pauseCAAnimationOnLayer(AnimatedPropertyID, const String& animationName, int index, double timeOffset);
+ void setAnimationOnLayer(PlatformCAAnimation*, AnimatedPropertyID, const String& animationName, int index, int subIndex, double timeOffset);
+ bool removeCAAnimationFromLayer(AnimatedPropertyID, const String& animationName, int index, int subINdex);
+ void pauseCAAnimationOnLayer(AnimatedPropertyID, const String& animationName, int index, int subIndex, double timeOffset);
enum MoveOrCopy { Move, Copy };
static void moveOrCopyLayerAnimation(MoveOrCopy, const String& animationIdentifier, PlatformCALayer *fromLayer, PlatformCALayer *toLayer);
@@ -373,16 +389,18 @@ private:
ContentsImageChanged = 1 << 15,
ContentsMediaLayerChanged = 1 << 16,
ContentsCanvasLayerChanged = 1 << 17,
- ContentsRectChanged = 1 << 18,
- MaskLayerChanged = 1 << 19,
- ReplicatedLayerChanged = 1 << 20,
- ContentsNeedsDisplay = 1 << 21,
- AcceleratesDrawingChanged = 1 << 22,
- ContentsScaleChanged = 1 << 23,
- ContentsVisibilityChanged = 1 << 24,
- VisibleRectChanged = 1 << 25,
- FiltersChanged = 1 << 26,
- DebugIndicatorsChanged = 1 << 27
+ ContentsColorLayerChanged = 1 << 18,
+ ContentsRectChanged = 1 << 19,
+ MaskLayerChanged = 1 << 20,
+ ReplicatedLayerChanged = 1 << 21,
+ ContentsNeedsDisplay = 1 << 22,
+ AcceleratesDrawingChanged = 1 << 23,
+ ContentsScaleChanged = 1 << 24,
+ ContentsVisibilityChanged = 1 << 25,
+ VisibleRectChanged = 1 << 26,
+ FiltersChanged = 1 << 27,
+ TilesAdded = 1 < 28,
+ DebugIndicatorsChanged = 1 << 29
};
typedef unsigned LayerChangeFlags;
void noteLayerPropertyChanged(LayerChangeFlags flags);
@@ -415,9 +433,10 @@ private:
};
ContentsLayerPurpose m_contentsLayerPurpose;
- bool m_contentsLayerHasBackgroundColor : 1;
bool m_allowTiledLayer : 1;
- bool m_isPageTileCacheLayer : 1;
+ bool m_isPageTiledBackingLayer : 1;
+
+ Color m_contentsSolidColor;
RetainPtr<CGImageRef> m_uncorrectedContentsImage;
RetainPtr<CGImageRef> m_pendingContentsImage;
@@ -425,11 +444,12 @@ private:
// This represents the animation of a single property. There may be multiple transform animations for
// a single transition or keyframe animation, so index is used to distinguish these.
struct LayerPropertyAnimation {
- LayerPropertyAnimation(PassRefPtr<PlatformCAAnimation> caAnimation, const String& animationName, AnimatedPropertyID property, int index, double timeOffset)
+ LayerPropertyAnimation(PassRefPtr<PlatformCAAnimation> caAnimation, const String& animationName, AnimatedPropertyID property, int index, int subIndex, double timeOffset)
: m_animation(caAnimation)
, m_name(animationName)
, m_property(property)
, m_index(index)
+ , m_subIndex(subIndex)
, m_timeOffset(timeOffset)
{ }
@@ -437,6 +457,7 @@ private:
String m_name;
AnimatedPropertyID m_property;
int m_index;
+ int m_subIndex;
double m_timeOffset;
};
diff --git a/Source/WebCore/platform/graphics/ca/LayerFlushScheduler.h b/Source/WebCore/platform/graphics/ca/LayerFlushScheduler.h
index 36b60418f..fe0b52d88 100644
--- a/Source/WebCore/platform/graphics/ca/LayerFlushScheduler.h
+++ b/Source/WebCore/platform/graphics/ca/LayerFlushScheduler.h
@@ -38,7 +38,7 @@ class LayerFlushScheduler {
WTF_MAKE_NONCOPYABLE(LayerFlushScheduler);
public:
LayerFlushScheduler(LayerFlushSchedulerClient*);
- ~LayerFlushScheduler();
+ virtual ~LayerFlushScheduler();
void schedule();
void invalidate();
@@ -55,7 +55,9 @@ private:
#if PLATFORM(MAC)
RetainPtr<CFRunLoopObserverRef> m_runLoopObserver;
static void runLoopObserverCallback(CFRunLoopObserverRef, CFRunLoopActivity, void* context);
- void runLoopObserverCallback();
+
+protected:
+ virtual void runLoopObserverCallback();
#endif
};
diff --git a/Source/WebCore/platform/graphics/ca/PlatformCAAnimation.h b/Source/WebCore/platform/graphics/ca/PlatformCAAnimation.h
index 6c1263114..090def56c 100644
--- a/Source/WebCore/platform/graphics/ca/PlatformCAAnimation.h
+++ b/Source/WebCore/platform/graphics/ca/PlatformCAAnimation.h
@@ -139,11 +139,6 @@ public:
void setTimingFunctions(const Vector<const TimingFunction*>&, bool reverse = false);
void copyTimingFunctionsFrom(const PlatformCAAnimation*);
-
-#if ENABLE(CSS_FILTERS)
- static int numAnimatedFilterProperties(FilterOperation::OperationType);
- static const char* animatedFilterPropertyName(FilterOperation::OperationType, int internalFilterPropertyIndex);
-#endif
protected:
PlatformCAAnimation(AnimationType, const String& keyPath);
diff --git a/Source/WebCore/platform/graphics/clutter/PlatformClutterLayerClient.h b/Source/WebCore/platform/graphics/ca/PlatformCAFilters.h
index 90b56ab6a..68a3edbd3 100644
--- a/Source/WebCore/platform/graphics/clutter/PlatformClutterLayerClient.h
+++ b/Source/WebCore/platform/graphics/ca/PlatformCAFilters.h
@@ -1,6 +1,5 @@
/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
- * Copyright (C) 2011 Collabora Ltd.
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -21,31 +20,47 @@
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef PlatformClutterLayerClient_h
-#define PlatformClutterLayerClient_h
+#ifndef PlatformCAFilters_h
+#define PlatformCAFilters_h
#if USE(ACCELERATED_COMPOSITING)
+#if ENABLE(CSS_FILTERS)
-#include "GraphicsContext.h"
-#include "GraphicsLayer.h"
+#include "FilterOperations.h"
+#include <wtf/RetainPtr.h>
+
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
+#define USE_CA_FILTERS 1
+#else
+#define USE_CA_FILTERS 0
+#endif
+
+OBJC_CLASS NSValue;
namespace WebCore {
+class PlatformCALayer;
-class PlatformClutterLayerClient {
+class PlatformCAFilters {
public:
- virtual void platformClutterLayerPaintContents(GraphicsContext&, const IntRect& inClip) = 0;
- virtual void platformClutterLayerAnimationStarted(double startTime) = 0;
+ static void setFiltersOnLayer(PlatformCALayer*, const FilterOperations&);
+ static int numAnimatedFilterProperties(FilterOperation::OperationType);
+ static const char* animatedFilterPropertyName(FilterOperation::OperationType, int internalFilterPropertyIndex);
-protected:
- virtual ~PlatformClutterLayerClient() { }
+#if PLATFORM(MAC)
+ static RetainPtr<NSValue> filterValueForOperation(const FilterOperation*, int internalFilterPropertyIndex);
+#endif
+
+#ifdef USE_CA_FILTERS
+ static RetainPtr<NSValue> colorMatrixValueForFilter(const FilterOperation&);
+#endif
};
}
+#endif // ENABLE(CSS_FILTERS)
#endif // USE(ACCELERATED_COMPOSITING)
-#endif // PlatformClutterLayerClient_h
-
+#endif // PlatformCAFilters_h
diff --git a/Source/WebCore/platform/graphics/ca/PlatformCALayer.h b/Source/WebCore/platform/graphics/ca/PlatformCALayer.h
index f63705176..156ab3683 100644
--- a/Source/WebCore/platform/graphics/ca/PlatformCALayer.h
+++ b/Source/WebCore/platform/graphics/ca/PlatformCALayer.h
@@ -41,6 +41,8 @@
#include <wtf/text/StringHash.h>
#include <wtf/text/WTFString.h>
+OBJC_CLASS AVPlayerLayer;
+
namespace WebCore {
class PlatformCALayer;
@@ -59,9 +61,10 @@ public:
LayerTypeWebLayer,
LayerTypeTransformLayer,
LayerTypeWebTiledLayer,
- LayerTypeTileCacheLayer,
- LayerTypePageTileCacheLayer,
+ LayerTypeTiledBackingLayer,
+ LayerTypePageTiledBackingLayer,
LayerTypeRootLayer,
+ LayerTypeAVPlayerLayer,
LayerTypeCustom
};
enum FilterType { Linear, Nearest, Trilinear };
@@ -72,6 +75,8 @@ public:
// is defined differently for Obj C and C++. This allows callers from both languages.
static PassRefPtr<PlatformCALayer> create(void* platformLayer, PlatformCALayerClient*);
+ PassRefPtr<PlatformCALayer> clone(PlatformCALayerClient*) const;
+
~PlatformCALayer();
// This function passes the layer as a void* rather than a PlatformLayer because PlatformLayer
@@ -81,9 +86,9 @@ public:
PlatformLayer* platformLayer() const;
#if PLATFORM(WIN)
- bool usesTileCacheLayer() const { return false; }
+ bool usesTiledBackingLayer() const { return false; }
#else
- bool usesTileCacheLayer() const { return m_layerType == LayerTypePageTileCacheLayer || m_layerType == LayerTypeTileCacheLayer; }
+ bool usesTiledBackingLayer() const { return m_layerType == LayerTypePageTiledBackingLayer || m_layerType == LayerTypeTiledBackingLayer; }
#endif
PlatformCALayer* rootLayer() const;
@@ -227,8 +232,10 @@ public:
protected:
PlatformCALayer(LayerType, PlatformLayer*, PlatformCALayerClient*);
-
+
private:
+ AVPlayerLayer* playerLayer() const;
+
PlatformCALayerClient* m_owner;
LayerType m_layerType;
diff --git a/Source/WebCore/platform/graphics/ca/mac/LayerFlushSchedulerMac.cpp b/Source/WebCore/platform/graphics/ca/mac/LayerFlushSchedulerMac.cpp
index 01805e701..1462d5e3b 100644
--- a/Source/WebCore/platform/graphics/ca/mac/LayerFlushSchedulerMac.cpp
+++ b/Source/WebCore/platform/graphics/ca/mac/LayerFlushSchedulerMac.cpp
@@ -29,7 +29,7 @@
#include "LayerFlushScheduler.h"
-#include "AutodrainedPool.h"
+#include <wtf/AutodrainedPool.h>
namespace WebCore {
@@ -77,7 +77,7 @@ void LayerFlushScheduler::schedule()
return;
CFRunLoopObserverContext context = { 0, this, 0, 0, 0 };
- m_runLoopObserver.adoptCF(CFRunLoopObserverCreate(0, kCFRunLoopBeforeWaiting | kCFRunLoopExit, true, LayerFlushRunLoopOrder, runLoopObserverCallback, &context));
+ m_runLoopObserver = adoptCF(CFRunLoopObserverCreate(0, kCFRunLoopBeforeWaiting | kCFRunLoopExit, true, LayerFlushRunLoopOrder, runLoopObserverCallback, &context));
CFRunLoopAddObserver(currentRunLoop, m_runLoopObserver.get(), kCFRunLoopCommonModes);
}
diff --git a/Source/WebCore/platform/graphics/ca/mac/LayerPool.mm b/Source/WebCore/platform/graphics/ca/mac/LayerPool.mm
index a845b1efc..1e1345b75 100644
--- a/Source/WebCore/platform/graphics/ca/mac/LayerPool.mm
+++ b/Source/WebCore/platform/graphics/ca/mac/LayerPool.mm
@@ -104,7 +104,7 @@ void LayerPool::schedulePrune()
{
if (m_pruneTimer.isActive())
return;
- m_pruneTimer.startOneShot(0);
+ m_pruneTimer.startOneShot(1);
}
void LayerPool::pruneTimerFired(Timer<LayerPool>*)
diff --git a/Source/WebCore/platform/graphics/ca/mac/PlatformCAAnimationMac.mm b/Source/WebCore/platform/graphics/ca/mac/PlatformCAAnimationMac.mm
index ac8675584..6cd350122 100644
--- a/Source/WebCore/platform/graphics/ca/mac/PlatformCAAnimationMac.mm
+++ b/Source/WebCore/platform/graphics/ca/mac/PlatformCAAnimationMac.mm
@@ -30,10 +30,9 @@
#import "PlatformCAAnimation.h"
#import "FloatConversion.h"
-#import "LengthFunctions.h"
+#import "PlatformCAFilters.h"
#import "TimingFunction.h"
#import <QuartzCore/QuartzCore.h>
-#import <wtf/UnusedParam.h>
#import <wtf/text/WTFString.h>
using namespace WebCore;
@@ -162,9 +161,9 @@ PlatformCAAnimation::PlatformCAAnimation(AnimationType type, const String& keyPa
: m_type(type)
{
if (type == Basic)
- m_animation.adoptNS([[CABasicAnimation animationWithKeyPath:keyPath] retain]);
+ m_animation = [CABasicAnimation animationWithKeyPath:keyPath];
else
- m_animation.adoptNS([[CAKeyframeAnimation animationWithKeyPath:keyPath] retain]);
+ m_animation = [CAKeyframeAnimation animationWithKeyPath:keyPath];
}
PlatformCAAnimation::PlatformCAAnimation(PlatformAnimationRef animation)
@@ -392,126 +391,9 @@ void PlatformCAAnimation::setFromValue(const WebCore::Color& value)
}
#if ENABLE(CSS_FILTERS)
-static double sepiaFullConstants[3][3] = {
- { 0.393, 0.769, 0.189 },
- { 0.349, 0.686, 0.168 },
- { 0.272, 0.534, 0.131 }
-};
-
-static double sepiaNoneConstants[3][3] = {
- { 1, 0, 0 },
- { 0, 1, 0 },
- { 0, 0, 1 }
-};
-
-static double invertConstants[3][3] = {
- { 1, 0, 0 },
- { 0, 1, 0 },
- { 0, 0, 1 }
-};
-
-static RetainPtr<id> filterValueForOperation(const FilterOperation* operation, int internalFilterPropertyIndex)
-{
- FilterOperation::OperationType type = operation->getOperationType();
- RetainPtr<id> value;
-
- switch(type) {
- case FilterOperation::GRAYSCALE:
- case FilterOperation::SATURATE:
- case FilterOperation::HUE_ROTATE: {
- double amount = 0;
-
- if (!operation->isDefault()) {
- const BasicColorMatrixFilterOperation* op = static_cast<const BasicColorMatrixFilterOperation*>(operation);
- amount = op->amount();
- }
-
- if (type == FilterOperation::HUE_ROTATE)
- amount = deg2rad(amount);
-
- value.adoptNS([[NSNumber numberWithDouble:amount] retain]);
- break;
- }
- case FilterOperation::SEPIA: {
- double amount = 0;
-
- if (!operation->isDefault()) {
- const BasicColorMatrixFilterOperation* op = static_cast<const BasicColorMatrixFilterOperation*>(operation);
- amount = op->amount();
- }
-
- value.adoptNS([[NSArray arrayWithObjects:
- [NSNumber numberWithDouble:WebCore::blend(sepiaNoneConstants[internalFilterPropertyIndex][0], sepiaFullConstants[0][internalFilterPropertyIndex], amount)],
- [NSNumber numberWithDouble:WebCore::blend(sepiaNoneConstants[internalFilterPropertyIndex][1], sepiaFullConstants[1][internalFilterPropertyIndex], amount)],
- [NSNumber numberWithDouble:WebCore::blend(sepiaNoneConstants[internalFilterPropertyIndex][2], sepiaFullConstants[2][internalFilterPropertyIndex], amount)],
- [NSNumber numberWithDouble:0],
- nil] retain]);
- break;
- }
- case FilterOperation::INVERT: {
- double amount = 0;
-
- if (!operation->isDefault()) {
- const BasicComponentTransferFilterOperation* op = static_cast<const BasicComponentTransferFilterOperation*>(operation);
- amount = op->amount();
- }
-
- // The color matrix animation for invert does a scale of each color component by a value that goes from
- // 1 (when amount is 0) to -1 (when amount is 1). Then the color values are offset by amount. This has the
- // effect of performing the operation: c' = c * -1 + 1, which inverts the color.
- if (internalFilterPropertyIndex < 3) {
- // the first 3 properties are the red, green and blue multipliers
- double multiplier = 1 - amount * 2;
- value.adoptNS([[NSArray arrayWithObjects:
- [NSNumber numberWithDouble:invertConstants[internalFilterPropertyIndex][0] * multiplier],
- [NSNumber numberWithDouble:invertConstants[internalFilterPropertyIndex][1] * multiplier],
- [NSNumber numberWithDouble:invertConstants[internalFilterPropertyIndex][2] * multiplier],
- [NSNumber numberWithDouble:0],
- nil] retain]);
- } else {
- // the last property is the color offset
- value.adoptNS([[NSArray arrayWithObjects:
- [NSNumber numberWithDouble:amount],
- [NSNumber numberWithDouble:amount],
- [NSNumber numberWithDouble:amount],
- [NSNumber numberWithDouble:0],
- nil] retain]);
- }
- break;
- }
- case FilterOperation::OPACITY:
- case FilterOperation::CONTRAST:
- case FilterOperation::BRIGHTNESS: {
- double amount = 0;
-
- if (!operation->isDefault()) {
- const BasicComponentTransferFilterOperation* op = static_cast<const BasicComponentTransferFilterOperation*>(operation);
- amount = op->amount();
- }
-
- value.adoptNS([[NSNumber numberWithDouble:amount] retain]);
- break;
- }
- case FilterOperation::BLUR: {
- double amount = 0;
-
- if (!operation->isDefault()) {
- const BlurFilterOperation* op = static_cast<const BlurFilterOperation*>(operation);
- amount = floatValueForLength(op->stdDeviation(), 0);
- }
-
- value.adoptNS([[NSNumber numberWithDouble:amount] retain]);
- break;
- }
- default: break;
- }
-
- return value;
-}
-
void PlatformCAAnimation::setFromValue(const FilterOperation* operation, int internalFilterPropertyIndex)
{
- RetainPtr<id> value = filterValueForOperation(operation, internalFilterPropertyIndex);
+ RetainPtr<id> value = PlatformCAFilters::filterValueForOperation(operation, internalFilterPropertyIndex);
[static_cast<CABasicAnimation*>(m_animation.get()) setFromValue:value.get()];
}
#endif
@@ -570,7 +452,7 @@ void PlatformCAAnimation::setToValue(const WebCore::Color& value)
#if ENABLE(CSS_FILTERS)
void PlatformCAAnimation::setToValue(const FilterOperation* operation, int internalFilterPropertyIndex)
{
- RetainPtr<id> value = filterValueForOperation(operation, internalFilterPropertyIndex);
+ RetainPtr<id> value = PlatformCAFilters::filterValueForOperation(operation, internalFilterPropertyIndex);
[static_cast<CABasicAnimation*>(m_animation.get()) setToValue:value.get()];
}
#endif
@@ -656,7 +538,7 @@ void PlatformCAAnimation::setValues(const Vector<RefPtr<FilterOperation> >& valu
NSMutableArray* array = [NSMutableArray array];
for (size_t i = 0; i < values.size(); ++i) {
- RetainPtr<id> value = filterValueForOperation(values[i].get(), internalFilterPropertyIndex);
+ RetainPtr<id> value = PlatformCAFilters::filterValueForOperation(values[i].get(), internalFilterPropertyIndex);
[array addObject:value.get()];
}
[static_cast<CAKeyframeAnimation*>(m_animation.get()) setValues:array];
@@ -704,51 +586,4 @@ void PlatformCAAnimation::copyTimingFunctionsFrom(const PlatformCAAnimation* val
[static_cast<CAKeyframeAnimation*>(m_animation.get()) setTimingFunctions:[other timingFunctions]];
}
-#if ENABLE(CSS_FILTERS)
-int PlatformCAAnimation::numAnimatedFilterProperties(FilterOperation::OperationType type)
-{
- switch(type) {
- case FilterOperation::GRAYSCALE: return 1;
- case FilterOperation::SEPIA: return 3;
- case FilterOperation::SATURATE: return 1;
- case FilterOperation::HUE_ROTATE: return 1;
- case FilterOperation::INVERT: return 4;
- case FilterOperation::OPACITY: return 1;
- case FilterOperation::BLUR: return 1;
- case FilterOperation::CONTRAST: return 1;
- case FilterOperation::BRIGHTNESS: return 1;
- default: return 0;
- }
-}
-
-const char* PlatformCAAnimation::animatedFilterPropertyName(FilterOperation::OperationType type, int internalFilterPropertyIndex)
-{
- switch(type) {
- case FilterOperation::GRAYSCALE: return "inputIntensity";
- case FilterOperation::SEPIA:
- switch(internalFilterPropertyIndex) {
- case 0: return "inputRVector";
- case 1: return "inputGVector";
- case 2: return "inputBVector";
- default: return "";
- }
- case FilterOperation::SATURATE: return "inputSaturation";
- case FilterOperation::HUE_ROTATE: return "inputAngle";
- case FilterOperation::INVERT:
- switch(internalFilterPropertyIndex) {
- case 0: return "inputRVector";
- case 1: return "inputGVector";
- case 2: return "inputBVector";
- case 3: return "inputBiasVector";
- default: return "";
- }
- case FilterOperation::OPACITY: return "inputAVector";
- case FilterOperation::BLUR: return "inputRadius";
- case FilterOperation::CONTRAST: return "inputContrast";
- case FilterOperation::BRIGHTNESS: return "inputBrightness";
- default: return "";
- }
-}
-#endif
-
#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebCore/platform/graphics/ca/mac/PlatformCAFiltersMac.mm b/Source/WebCore/platform/graphics/ca/mac/PlatformCAFiltersMac.mm
new file mode 100644
index 000000000..5e21715c7
--- /dev/null
+++ b/Source/WebCore/platform/graphics/ca/mac/PlatformCAFiltersMac.mm
@@ -0,0 +1,681 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if USE(ACCELERATED_COMPOSITING)
+#if ENABLE(CSS_FILTERS)
+
+#import "PlatformCAFilters.h"
+
+#import "BlockExceptions.h"
+#import "FloatConversion.h"
+#import "LengthFunctions.h" // This is a layering violation.
+#import "PlatformCALayer.h"
+#import <QuartzCore/QuartzCore.h>
+
+using namespace WebCore;
+
+#if USE_CA_FILTERS
+struct CAColorMatrix
+{
+ float m11, m12, m13, m14, m15;
+ float m21, m22, m23, m24, m25;
+ float m31, m32, m33, m34, m35;
+ float m41, m42, m43, m44, m45;
+};
+
+typedef struct CAColorMatrix CAColorMatrix;
+
+@interface NSValue (Details)
++ (NSValue *)valueWithCAColorMatrix:(CAColorMatrix)t;
+@end
+
+@interface CAFilter : NSObject <NSCopying, NSMutableCopying, NSCoding>
+@end
+
+@interface CAFilter (Details)
+@property(copy) NSString *name;
++ (CAFilter *)filterWithType:(NSString *)type;
+@end
+
+extern NSString * const kCAFilterColorMatrix;
+extern NSString * const kCAFilterColorMonochrome;
+extern NSString * const kCAFilterColorHueRotate;
+extern NSString * const kCAFilterColorSaturate;
+extern NSString * const kCAFilterGaussianBlur;
+#endif
+
+// FIXME: Should share these values with FilterEffectRenderer::build() (https://bugs.webkit.org/show_bug.cgi?id=76008).
+static double sepiaFullConstants[3][3] = {
+ { 0.393, 0.769, 0.189 },
+ { 0.349, 0.686, 0.168 },
+ { 0.272, 0.534, 0.131 }
+};
+
+static double sepiaNoneConstants[3][3] = {
+ { 1, 0, 0 },
+ { 0, 1, 0 },
+ { 0, 0, 1 }
+};
+
+void PlatformCAFilters::setFiltersOnLayer(PlatformCALayer* platformCALayer, const FilterOperations& filters)
+{
+ CALayer* layer = platformCALayer->platformLayer();
+
+ if (!filters.size()) {
+ BEGIN_BLOCK_OBJC_EXCEPTIONS
+ [layer setFilters:nil];
+ // FIXME: this adds shadow properties to the layer even when it had none.
+ [layer setShadowOffset:CGSizeZero];
+ [layer setShadowColor:nil];
+ [layer setShadowRadius:0];
+ [layer setShadowOpacity:0];
+ END_BLOCK_OBJC_EXCEPTIONS
+ return;
+ }
+
+ // Assume filtersCanBeComposited was called and it returned true.
+ ASSERT(platformCALayer->filtersCanBeComposited(filters));
+
+ BEGIN_BLOCK_OBJC_EXCEPTIONS
+
+ RetainPtr<NSMutableArray> array = adoptNS([[NSMutableArray alloc] init]);
+
+ for (unsigned i = 0; i < filters.size(); ++i) {
+ String filterName = String::format("filter_%d", i);
+ const FilterOperation* filterOperation = filters.at(i);
+ switch (filterOperation->getOperationType()) {
+ case FilterOperation::DROP_SHADOW: {
+ // FIXME: For now assume drop shadow is the last filter, put it on the layer.
+ // <rdar://problem/10959969> Handle case where drop-shadow is not the last filter.
+ const DropShadowFilterOperation* op = static_cast<const DropShadowFilterOperation*>(filterOperation);
+ [layer setShadowOffset:CGSizeMake(op->x(), op->y())];
+
+ CGFloat components[4];
+ op->color().getRGBA(components[0], components[1], components[2], components[3]);
+ RetainPtr<CGColorSpaceRef> colorSpace = adoptCF(CGColorSpaceCreateDeviceRGB());
+ RetainPtr<CGColorRef> color = adoptCF(CGColorCreate(colorSpace.get(), components));
+ [layer setShadowColor:color.get()];
+ [layer setShadowRadius:op->stdDeviation()];
+ [layer setShadowOpacity:1];
+ break;
+ }
+#if USE_CA_FILTERS
+ case FilterOperation::GRAYSCALE: {
+ const BasicColorMatrixFilterOperation* op = static_cast<const BasicColorMatrixFilterOperation*>(filterOperation);
+ CAFilter *filter = [CAFilter filterWithType:kCAFilterColorMonochrome];
+ [filter setValue:[NSNumber numberWithFloat:op->amount()] forKey:@"inputAmount"];
+ [filter setName:filterName];
+ [array.get() addObject:filter];
+ break;
+ }
+ case FilterOperation::SEPIA: {
+ const BasicColorMatrixFilterOperation* op = static_cast<const BasicColorMatrixFilterOperation*>(filterOperation);
+ RetainPtr<NSValue> colorMatrixValue = PlatformCAFilters::colorMatrixValueForFilter(*op);
+ CAFilter *filter = [CAFilter filterWithType:kCAFilterColorMatrix];
+ [filter setValue:colorMatrixValue.get() forKey:@"inputColorMatrix"];
+ [filter setName:filterName];
+ [array.get() addObject:filter];
+ break;
+ }
+ case FilterOperation::SATURATE: {
+ const BasicColorMatrixFilterOperation* op = static_cast<const BasicColorMatrixFilterOperation*>(filterOperation);
+ CAFilter *filter = [CAFilter filterWithType:kCAFilterColorSaturate];
+ [filter setValue:[NSNumber numberWithFloat:op->amount()] forKey:@"inputAmount"];
+ [filter setName:filterName];
+ [array.get() addObject:filter];
+ break;
+ }
+ case FilterOperation::HUE_ROTATE: {
+ const BasicColorMatrixFilterOperation* op = static_cast<const BasicColorMatrixFilterOperation*>(filterOperation);
+ CAFilter *filter = [CAFilter filterWithType:kCAFilterColorHueRotate];
+ [filter setValue:[NSNumber numberWithFloat:deg2rad(op->amount())] forKey:@"inputAngle"];
+ [filter setName:@"hueRotate"];
+ [filter setName:filterName];
+ [array.get() addObject:filter];
+ break;
+ }
+ case FilterOperation::INVERT: {
+ const BasicComponentTransferFilterOperation* op = static_cast<const BasicComponentTransferFilterOperation*>(filterOperation);
+ RetainPtr<NSValue> colorMatrixValue = PlatformCAFilters::colorMatrixValueForFilter(*op);
+ CAFilter *filter = [CAFilter filterWithType:kCAFilterColorMatrix];
+ [filter setValue:colorMatrixValue.get() forKey:@"inputColorMatrix"];
+ [filter setName:filterName];
+ [array.get() addObject:filter];
+ break;
+ }
+ case FilterOperation::OPACITY: {
+ const BasicComponentTransferFilterOperation* op = static_cast<const BasicComponentTransferFilterOperation*>(filterOperation);
+ RetainPtr<NSValue> colorMatrixValue = PlatformCAFilters::colorMatrixValueForFilter(*op);
+ CAFilter *filter = [CAFilter filterWithType:kCAFilterColorMatrix];
+ [filter setValue:colorMatrixValue.get() forKey:@"inputColorMatrix"];
+ [filter setName:filterName];
+ [array.get() addObject:filter];
+ break;
+ }
+ case FilterOperation::BRIGHTNESS: {
+ const BasicComponentTransferFilterOperation* op = static_cast<const BasicComponentTransferFilterOperation*>(filterOperation);
+ RetainPtr<NSValue> colorMatrixValue = PlatformCAFilters::colorMatrixValueForFilter(*op);
+ CAFilter *filter = [CAFilter filterWithType:kCAFilterColorMatrix];
+ [filter setValue:colorMatrixValue.get() forKey:@"inputColorMatrix"];
+ [filter setName:filterName];
+ [array.get() addObject:filter];
+ break;
+ }
+ case FilterOperation::CONTRAST: {
+ const BasicComponentTransferFilterOperation* op = static_cast<const BasicComponentTransferFilterOperation*>(filterOperation);
+ RetainPtr<NSValue> colorMatrixValue = PlatformCAFilters::colorMatrixValueForFilter(*op);
+ CAFilter *filter = [CAFilter filterWithType:kCAFilterColorMatrix];
+ [filter setValue:colorMatrixValue.get() forKey:@"inputColorMatrix"];
+ [filter setName:filterName];
+ [array.get() addObject:filter];
+ break;
+ }
+ case FilterOperation::BLUR: {
+ const BlurFilterOperation* op = static_cast<const BlurFilterOperation*>(filterOperation);
+ CAFilter *filter = [CAFilter filterWithType:kCAFilterGaussianBlur];
+ [filter setValue:[NSNumber numberWithFloat:floatValueForLength(op->stdDeviation(), 0)] forKey:@"inputRadius"];
+ [filter setName:filterName];
+ [array.get() addObject:filter];
+ break;
+ }
+#else
+ case FilterOperation::GRAYSCALE: {
+ const BasicColorMatrixFilterOperation* op = static_cast<const BasicColorMatrixFilterOperation*>(filterOperation);
+ CIFilter* filter = [CIFilter filterWithName:@"CIColorMonochrome"];
+ [filter setDefaults];
+ [filter setValue:[NSNumber numberWithFloat:op->amount()] forKey:@"inputIntensity"];
+ [filter setValue:[CIColor colorWithRed:0.67 green:0.67 blue:0.67] forKey:@"inputColor"]; // Color derived empirically to match zero saturation levels.
+ [filter setName:filterName];
+ [array.get() addObject:filter];
+ break;
+ }
+ case FilterOperation::SEPIA: {
+ const BasicColorMatrixFilterOperation* op = static_cast<const BasicColorMatrixFilterOperation*>(filterOperation);
+ CIFilter* filter = [CIFilter filterWithName:@"CIColorMatrix"];
+ [filter setDefaults];
+
+ double t = op->amount();
+ t = std::min(std::max(0.0, t), 1.0);
+ // FIXME: results don't match the software filter.
+ [filter setValue:[CIVector vectorWithX:WebCore::blend(sepiaNoneConstants[0][0], sepiaFullConstants[0][0], t)
+ Y:WebCore::blend(sepiaNoneConstants[0][1], sepiaFullConstants[0][1], t)
+ Z:WebCore::blend(sepiaNoneConstants[0][2], sepiaFullConstants[0][2], t) W:0] forKey:@"inputRVector"];
+ [filter setValue:[CIVector vectorWithX:WebCore::blend(sepiaNoneConstants[1][0], sepiaFullConstants[1][0], t)
+ Y:WebCore::blend(sepiaNoneConstants[1][1], sepiaFullConstants[1][1], t)
+ Z:WebCore::blend(sepiaNoneConstants[1][2], sepiaFullConstants[1][2], t) W:0] forKey:@"inputGVector"];
+ [filter setValue:[CIVector vectorWithX:WebCore::blend(sepiaNoneConstants[2][0], sepiaFullConstants[2][0], t)
+ Y:WebCore::blend(sepiaNoneConstants[2][1], sepiaFullConstants[2][1], t)
+ Z:WebCore::blend(sepiaNoneConstants[2][2], sepiaFullConstants[2][2], t) W:0] forKey:@"inputBVector"];
+ [filter setName:filterName];
+ [array.get() addObject:filter];
+ break;
+ }
+ case FilterOperation::SATURATE: {
+ const BasicColorMatrixFilterOperation* op = static_cast<const BasicColorMatrixFilterOperation*>(filterOperation);
+ CIFilter* filter = [CIFilter filterWithName:@"CIColorControls"];
+ [filter setDefaults];
+ [filter setValue:[NSNumber numberWithFloat:op->amount()] forKey:@"inputSaturation"];
+ [filter setName:filterName];
+ [array.get() addObject:filter];
+ break;
+ }
+ case FilterOperation::HUE_ROTATE: {
+ const BasicColorMatrixFilterOperation* op = static_cast<const BasicColorMatrixFilterOperation*>(filterOperation);
+ CIFilter* filter = [CIFilter filterWithName:@"CIHueAdjust"];
+ [filter setDefaults];
+
+ [filter setValue:[NSNumber numberWithFloat:deg2rad(op->amount())] forKey:@"inputAngle"];
+ [filter setName:filterName];
+ [array.get() addObject:filter];
+ break;
+ }
+ case FilterOperation::INVERT: {
+ const BasicComponentTransferFilterOperation* op = static_cast<const BasicComponentTransferFilterOperation*>(filterOperation);
+ CIFilter* filter = [CIFilter filterWithName:@"CIColorMatrix"];
+ [filter setDefaults];
+
+ double multiplier = 1 - op->amount() * 2;
+
+ // FIXME: the results of this filter look wrong.
+ [filter setValue:[CIVector vectorWithX:multiplier Y:0 Z:0 W:0] forKey:@"inputRVector"];
+ [filter setValue:[CIVector vectorWithX:0 Y:multiplier Z:0 W:0] forKey:@"inputGVector"];
+ [filter setValue:[CIVector vectorWithX:0 Y:0 Z:multiplier W:0] forKey:@"inputBVector"];
+ [filter setValue:[CIVector vectorWithX:0 Y:0 Z:0 W:1] forKey:@"inputAVector"];
+ [filter setValue:[CIVector vectorWithX:op->amount() Y:op->amount() Z:op->amount() W:0] forKey:@"inputBiasVector"];
+ [filter setName:filterName];
+ [array.get() addObject:filter];
+ break;
+ }
+ case FilterOperation::OPACITY: {
+ const BasicComponentTransferFilterOperation* op = static_cast<const BasicComponentTransferFilterOperation*>(filterOperation);
+ CIFilter* filter = [CIFilter filterWithName:@"CIColorMatrix"];
+ [filter setDefaults];
+
+ [filter setValue:[CIVector vectorWithX:1 Y:0 Z:0 W:0] forKey:@"inputRVector"];
+ [filter setValue:[CIVector vectorWithX:0 Y:1 Z:0 W:0] forKey:@"inputGVector"];
+ [filter setValue:[CIVector vectorWithX:0 Y:0 Z:1 W:0] forKey:@"inputBVector"];
+ [filter setValue:[CIVector vectorWithX:0 Y:0 Z:0 W:op->amount()] forKey:@"inputAVector"];
+ [filter setValue:[CIVector vectorWithX:0 Y:0 Z:0 W:0] forKey:@"inputBiasVector"];
+ [filter setName:filterName];
+ [array.get() addObject:filter];
+ break;
+ }
+ case FilterOperation::BRIGHTNESS: {
+ const BasicComponentTransferFilterOperation* op = static_cast<const BasicComponentTransferFilterOperation*>(filterOperation);
+ CIFilter* filter = [CIFilter filterWithName:@"CIColorMatrix"];
+ [filter setDefaults];
+ double amount = op->amount();
+
+ [filter setValue:[CIVector vectorWithX:amount Y:0 Z:0 W:0] forKey:@"inputRVector"];
+ [filter setValue:[CIVector vectorWithX:0 Y:amount Z:0 W:0] forKey:@"inputGVector"];
+ [filter setValue:[CIVector vectorWithX:0 Y:0 Z:amount W:0] forKey:@"inputBVector"];
+ [filter setName:filterName];
+ [array.get() addObject:filter];
+ break;
+ }
+ case FilterOperation::CONTRAST: {
+ const BasicComponentTransferFilterOperation* op = static_cast<const BasicComponentTransferFilterOperation*>(filterOperation);
+ CIFilter* filter = [CIFilter filterWithName:@"CIColorControls"];
+ [filter setDefaults];
+ [filter setValue:[NSNumber numberWithFloat:op->amount()] forKey:@"inputContrast"];
+ [filter setName:filterName];
+ [array.get() addObject:filter];
+ break;
+ }
+ case FilterOperation::BLUR: {
+ // FIXME: For now we ignore stdDeviationY.
+ const BlurFilterOperation* op = static_cast<const BlurFilterOperation*>(filterOperation);
+ CIFilter* filter = [CIFilter filterWithName:@"CIGaussianBlur"];
+ [filter setDefaults];
+ [filter setValue:[NSNumber numberWithFloat:floatValueForLength(op->stdDeviation(), 0)] forKey:@"inputRadius"];
+ [filter setName:filterName];
+ [array.get() addObject:filter];
+ break;
+ }
+#endif
+ case FilterOperation::PASSTHROUGH:
+ break;
+ default:
+ ASSERT(0);
+ break;
+ }
+ }
+
+ if ([array.get() count] > 0)
+ [layer setFilters:array.get()];
+
+ END_BLOCK_OBJC_EXCEPTIONS
+}
+
+RetainPtr<NSValue> PlatformCAFilters::filterValueForOperation(const FilterOperation* operation, int internalFilterPropertyIndex)
+{
+#if USE_CA_FILTERS
+ UNUSED_PARAM(internalFilterPropertyIndex);
+#endif
+ FilterOperation::OperationType type = operation->getOperationType();
+ RetainPtr<id> value;
+
+ switch (type) {
+ case FilterOperation::GRAYSCALE: {
+ // CIFilter: inputIntensity
+ // CAFilter: inputAmount
+ double amount = 0;
+ if (!operation->isDefault()) {
+ const BasicColorMatrixFilterOperation* op = static_cast<const BasicColorMatrixFilterOperation*>(operation);
+ amount = op->amount();
+ }
+ value = [NSNumber numberWithDouble:amount];
+ break;
+ }
+ case FilterOperation::SEPIA: {
+#if USE_CA_FILTERS
+ // CAFilter: inputColorMatrix
+ const BasicColorMatrixFilterOperation* op = static_cast<const BasicColorMatrixFilterOperation*>(operation);
+ value = PlatformCAFilters::colorMatrixValueForFilter(*op);
+#else
+ // CIFilter: inputRVector, inputGVector, inputBVector
+ double amount = 0;
+ if (!operation->isDefault()) {
+ const BasicColorMatrixFilterOperation* op = static_cast<const BasicColorMatrixFilterOperation*>(operation);
+ amount = op->amount();
+ }
+
+ CIVector* rowVector = 0;
+ switch (internalFilterPropertyIndex) {
+ case 0: rowVector = [[CIVector alloc] initWithX:WebCore::blend(sepiaNoneConstants[0][0], sepiaFullConstants[0][0], amount)
+ Y:WebCore::blend(sepiaNoneConstants[0][1], sepiaFullConstants[0][1], amount)
+ Z:WebCore::blend(sepiaNoneConstants[0][2], sepiaFullConstants[0][2], amount) W:0]; break; // inputRVector
+ case 1: rowVector = [[CIVector alloc] initWithX:WebCore::blend(sepiaNoneConstants[1][0], sepiaFullConstants[1][0], amount)
+ Y:WebCore::blend(sepiaNoneConstants[1][1], sepiaFullConstants[1][1], amount)
+ Z:WebCore::blend(sepiaNoneConstants[1][2], sepiaFullConstants[1][2], amount) W:0]; break; // inputGVector
+ case 2: rowVector = [[CIVector alloc] initWithX:WebCore::blend(sepiaNoneConstants[2][0], sepiaFullConstants[2][0], amount)
+ Y:WebCore::blend(sepiaNoneConstants[2][1], sepiaFullConstants[2][1], amount)
+ Z:WebCore::blend(sepiaNoneConstants[2][2], sepiaFullConstants[2][2], amount) W:0]; break; // inputBVector
+ }
+ value = adoptNS(rowVector);
+#endif
+ break;
+ }
+ case FilterOperation::SATURATE: {
+ // CIFilter: inputSaturation
+ // CAFilter: inputAmount
+ double amount = 1;
+ if (!operation->isDefault()) {
+ const BasicColorMatrixFilterOperation* op = static_cast<const BasicColorMatrixFilterOperation*>(operation);
+ amount = op->amount();
+ }
+
+ value = [NSNumber numberWithDouble:amount];
+ break;
+ }
+ case FilterOperation::HUE_ROTATE: {
+ // Hue rotate CIFilter: inputAngle
+ // Hue rotate CAFilter: inputAngle
+ double amount = 0;
+ if (!operation->isDefault()) {
+ const BasicColorMatrixFilterOperation* op = static_cast<const BasicColorMatrixFilterOperation*>(operation);
+ amount = op->amount();
+ }
+ amount = deg2rad(amount);
+ value = [NSNumber numberWithDouble:amount];
+ break;
+ }
+ case FilterOperation::INVERT: {
+#if USE_CA_FILTERS
+ // CAFilter: inputColorMatrix
+ const BasicColorMatrixFilterOperation* op = static_cast<const BasicColorMatrixFilterOperation*>(operation);
+ value = PlatformCAFilters::colorMatrixValueForFilter(*op);
+#else
+ // CIFilter: inputRVector, inputGVector, inputBVector, inputBiasVector
+ double amount = 0;
+ if (!operation->isDefault()) {
+ const BasicComponentTransferFilterOperation* op = static_cast<const BasicComponentTransferFilterOperation*>(operation);
+ amount = op->amount();
+ }
+
+ double multiplier = 1 - amount * 2;
+
+ // The color matrix animation for invert does a scale of each color component by a value that goes from
+ // 1 (when amount is 0) to -1 (when amount is 1). Then the color values are offset by amount. This has the
+ // effect of performing the operation: c' = c * -1 + 1, which inverts the color.
+ CIVector* rowVector = 0;
+ switch (internalFilterPropertyIndex) {
+ case 0: rowVector = [[CIVector alloc] initWithX:multiplier Y:0 Z:0 W:0]; break; // inputRVector
+ case 1: rowVector = [[CIVector alloc] initWithX:0 Y:multiplier Z:0 W:0]; break; // inputGVector
+ case 2: rowVector = [[CIVector alloc] initWithX:0 Y:0 Z:multiplier W:0]; break; // inputBVector
+ case 3: rowVector = [[CIVector alloc] initWithX:amount Y:amount Z:amount W:0]; break; // inputBiasVector
+ }
+ value = adoptNS(rowVector);
+#endif
+ break;
+ }
+ case FilterOperation::OPACITY: {
+#if USE_CA_FILTERS
+ // Opacity CAFilter: inputColorMatrix
+ const BasicColorMatrixFilterOperation* op = static_cast<const BasicColorMatrixFilterOperation*>(operation);
+ value = PlatformCAFilters::colorMatrixValueForFilter(*op);
+#else
+ // Opacity CIFilter: inputAVector
+ double amount = 1;
+ if (!operation->isDefault()) {
+ const BasicComponentTransferFilterOperation* op = static_cast<const BasicComponentTransferFilterOperation*>(operation);
+ amount = op->amount();
+ }
+
+ value = adoptNS([[CIVector alloc] initWithX:0 Y:0 Z:0 W:amount]);
+#endif
+ break;
+ }
+
+ case FilterOperation::BRIGHTNESS: {
+#if USE_CA_FILTERS
+ // Brightness CAFilter: inputColorMatrix
+ const BasicColorMatrixFilterOperation* op = static_cast<const BasicColorMatrixFilterOperation*>(operation);
+ value = PlatformCAFilters::colorMatrixValueForFilter(*op);
+#else
+ // Brightness CIFilter: inputColorMatrix
+ double amount = 1;
+ if (!operation->isDefault()) {
+ const BasicComponentTransferFilterOperation* op = static_cast<const BasicComponentTransferFilterOperation*>(operation);
+ amount = op->amount();
+ }
+
+ CIVector* rowVector = 0;
+ switch (internalFilterPropertyIndex) {
+ case 0: rowVector = [[CIVector alloc] initWithX:amount Y:0 Z:0 W:0]; break; // inputRVector
+ case 1: rowVector = [[CIVector alloc] initWithX:0 Y:amount Z:0 W:0]; break; // inputGVector
+ case 2: rowVector = [[CIVector alloc] initWithX:0 Y:0 Z:amount W:0]; break; // inputBVector
+ }
+ value = adoptNS(rowVector);
+#endif
+ break;
+ }
+
+ case FilterOperation::CONTRAST: {
+#if USE_CA_FILTERS
+ // Contrast CAFilter: inputColorMatrix
+ const BasicColorMatrixFilterOperation* op = static_cast<const BasicColorMatrixFilterOperation*>(operation);
+ value = PlatformCAFilters::colorMatrixValueForFilter(*op);
+#else
+ // Contrast CIFilter: inputContrast
+ double amount = 1;
+ if (!operation->isDefault()) {
+ const BasicComponentTransferFilterOperation* op = static_cast<const BasicComponentTransferFilterOperation*>(operation);
+ amount = op->amount();
+ }
+
+ value = [NSNumber numberWithDouble:amount];
+#endif
+ break;
+ }
+ case FilterOperation::BLUR: {
+ // CIFilter: inputRadius
+ // CAFilter: inputRadius
+ double amount = 0;
+
+ if (!operation->isDefault()) {
+ const BlurFilterOperation* op = static_cast<const BlurFilterOperation*>(operation);
+ amount = floatValueForLength(op->stdDeviation(), 0);
+ }
+
+ value = [NSNumber numberWithDouble:amount];
+ break;
+ }
+ default:
+ break;
+ }
+
+ return value;
+}
+
+#if USE_CA_FILTERS
+RetainPtr<NSValue> PlatformCAFilters::colorMatrixValueForFilter(const FilterOperation& filterOperation)
+{
+ switch (filterOperation.getOperationType()) {
+ case FilterOperation::SEPIA: {
+ const BasicColorMatrixFilterOperation& op = static_cast<const BasicColorMatrixFilterOperation&>(filterOperation);
+ double t = op.amount();
+ t = std::min(std::max(0.0, t), 1.0);
+ CAColorMatrix colorMatrix = {
+ static_cast<float>(WebCore::blend(sepiaNoneConstants[0][0], sepiaFullConstants[0][0], t)),
+ static_cast<float>(WebCore::blend(sepiaNoneConstants[0][1], sepiaFullConstants[0][1], t)),
+ static_cast<float>(WebCore::blend(sepiaNoneConstants[0][2], sepiaFullConstants[0][2], t)), 0, 0,
+
+ static_cast<float>(WebCore::blend(sepiaNoneConstants[1][0], sepiaFullConstants[1][0], t)),
+ static_cast<float>(WebCore::blend(sepiaNoneConstants[1][1], sepiaFullConstants[1][1], t)),
+ static_cast<float>(WebCore::blend(sepiaNoneConstants[1][2], sepiaFullConstants[1][2], t)), 0, 0,
+
+ static_cast<float>(WebCore::blend(sepiaNoneConstants[2][0], sepiaFullConstants[2][0], t)),
+ static_cast<float>(WebCore::blend(sepiaNoneConstants[2][1], sepiaFullConstants[2][1], t)),
+ static_cast<float>(WebCore::blend(sepiaNoneConstants[2][2], sepiaFullConstants[2][2], t)), 0, 0,
+ 0, 0, 0, 1, 0
+ };
+ return [NSValue valueWithCAColorMatrix:colorMatrix];
+ }
+ case FilterOperation::INVERT: {
+ const BasicComponentTransferFilterOperation& op = static_cast<const BasicComponentTransferFilterOperation&>(filterOperation);
+ float amount = op.amount();
+ if (op.isDefault())
+ amount = 0;
+
+ float multiplier = 1 - amount * 2;
+ CAColorMatrix colorMatrix = {
+ multiplier, 0, 0, 0, amount,
+ 0, multiplier, 0, 0, amount,
+ 0, 0, multiplier, 0, amount,
+ 0, 0, 0, 1, 0
+ };
+ return [NSValue valueWithCAColorMatrix:colorMatrix];
+ }
+ case FilterOperation::OPACITY: {
+ const BasicComponentTransferFilterOperation& op = static_cast<const BasicComponentTransferFilterOperation&>(filterOperation);
+ float amount = op.amount();
+ if (op.isDefault())
+ amount = 1;
+
+ CAColorMatrix colorMatrix = {
+ 1, 0, 0, 0, 0,
+ 0, 1, 0, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 0, amount, 0
+ };
+ return [NSValue valueWithCAColorMatrix:colorMatrix];
+ }
+ case FilterOperation::CONTRAST: {
+ const BasicComponentTransferFilterOperation& op = static_cast<const BasicComponentTransferFilterOperation&>(filterOperation);
+ float amount = op.amount();
+ if (op.isDefault())
+ amount = 1;
+
+ float intercept = -0.5 * amount + 0.5;
+ CAColorMatrix colorMatrix = {
+ amount, 0, 0, 0, intercept,
+ 0, amount, 0, 0, intercept,
+ 0, 0, amount, 0, intercept,
+ 0, 0, 0, 1, 0
+ };
+ return [NSValue valueWithCAColorMatrix:colorMatrix];
+ }
+ case FilterOperation::BRIGHTNESS: {
+ const BasicComponentTransferFilterOperation& op = static_cast<const BasicComponentTransferFilterOperation&>(filterOperation);
+ float amount = op.amount();
+ if (op.isDefault())
+ amount = 1;
+
+ CAColorMatrix colorMatrix = {
+ amount, 0, 0, 0, 0,
+ 0, amount, 0, 0, 0,
+ 0, 0, amount, 0, 0,
+ 0, 0, 0, 1, 0
+ };
+ return [NSValue valueWithCAColorMatrix:colorMatrix];
+ }
+ default:
+ ASSERT_NOT_REACHED();
+ return 0;
+ }
+}
+#endif
+
+int PlatformCAFilters::numAnimatedFilterProperties(FilterOperation::OperationType type)
+{
+#if USE_CA_FILTERS
+ switch (type) {
+ case FilterOperation::GRAYSCALE: return 1;
+ case FilterOperation::SEPIA: return 1;
+ case FilterOperation::SATURATE: return 1;
+ case FilterOperation::HUE_ROTATE: return 1;
+ case FilterOperation::INVERT: return 1;
+ case FilterOperation::OPACITY: return 1;
+ case FilterOperation::BRIGHTNESS: return 1;
+ case FilterOperation::CONTRAST: return 1;
+ case FilterOperation::BLUR: return 1;
+ default: return 0;
+ }
+#else
+ switch (type) {
+ case FilterOperation::GRAYSCALE: return 1;
+ case FilterOperation::SEPIA: return 3;
+ case FilterOperation::SATURATE: return 1;
+ case FilterOperation::HUE_ROTATE: return 1;
+ case FilterOperation::INVERT: return 4;
+ case FilterOperation::OPACITY: return 1;
+ case FilterOperation::BRIGHTNESS: return 3;
+ case FilterOperation::CONTRAST: return 1;
+ case FilterOperation::BLUR: return 1;
+ default: return 0;
+ }
+#endif
+}
+
+const char* PlatformCAFilters::animatedFilterPropertyName(FilterOperation::OperationType type, int internalFilterPropertyIndex)
+{
+#if USE_CA_FILTERS
+ UNUSED_PARAM(internalFilterPropertyIndex);
+ switch (type) {
+ case FilterOperation::GRAYSCALE: return "inputAmount";
+ case FilterOperation::SEPIA:return "inputColorMatrix";
+ case FilterOperation::SATURATE: return "inputAmount";
+ case FilterOperation::HUE_ROTATE: return "inputAngle";
+ case FilterOperation::INVERT: return "inputColorMatrix";
+ case FilterOperation::OPACITY: return "inputColorMatrix";
+ case FilterOperation::BRIGHTNESS: return "inputColorMatrix";
+ case FilterOperation::CONTRAST: return "inputColorMatrix";
+ case FilterOperation::BLUR: return "inputRadius";
+ default: return "";
+ }
+#else
+ switch (type) {
+ case FilterOperation::GRAYSCALE: return "inputIntensity";
+ case FilterOperation::SEPIA:
+ case FilterOperation::BRIGHTNESS:
+ switch (internalFilterPropertyIndex) {
+ case 0: return "inputRVector";
+ case 1: return "inputGVector";
+ case 2: return "inputBVector";
+ default: return "";
+ }
+ case FilterOperation::SATURATE: return "inputSaturation";
+ case FilterOperation::HUE_ROTATE: return "inputAngle";
+ case FilterOperation::INVERT:
+ switch (internalFilterPropertyIndex) {
+ case 0: return "inputRVector";
+ case 1: return "inputGVector";
+ case 2: return "inputBVector";
+ case 3: return "inputBiasVector";
+ default: return "";
+ }
+ case FilterOperation::OPACITY: return "inputAVector";
+ case FilterOperation::CONTRAST: return "inputContrast";
+ case FilterOperation::BLUR: return "inputRadius";
+ default: return "";
+ }
+#endif
+}
+
+#endif // ENABLE(CSS_FILTERS)
+#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm b/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm
index 0f4eceb79..b5812f1fb 100644
--- a/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm
+++ b/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm
@@ -31,20 +31,25 @@
#import "AnimationUtilities.h"
#import "BlockExceptions.h"
-#import "FloatConversion.h"
#import "GraphicsContext.h"
#import "GraphicsLayerCA.h"
#import "LengthFunctions.h"
+#import "PlatformCAFilters.h"
+#import "SoftLinking.h"
#import "TiledBacking.h"
#import "WebLayer.h"
#import "WebTiledLayer.h"
-#import "WebTileCacheLayer.h"
+#import "WebTiledBackingLayer.h"
#import <objc/objc-auto.h>
#import <objc/runtime.h>
+#import <AVFoundation/AVFoundation.h>
#import <QuartzCore/QuartzCore.h>
#import <wtf/CurrentTime.h>
#import <wtf/MathExtras.h>
-#import <wtf/UnusedParam.h>
+#import <wtf/RetainPtr.h>
+
+SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)
+SOFT_LINK_CLASS(AVFoundation, AVPlayerLayer)
using std::min;
using std::max;
@@ -76,7 +81,7 @@ static double mediaTimeToCurrentTime(CFTimeInterval t)
// hasNonZeroBeginTime is stored in a key in the animation
bool hasNonZeroBeginTime = [[animation valueForKey:WKNonZeroBeginTimeFlag] boolValue];
CFTimeInterval startTime;
-
+
if (hasNonZeroBeginTime) {
// We don't know what time CA used to commit the animation, so just use the current time
// (even though this will be slightly off).
@@ -173,13 +178,16 @@ PlatformCALayer::PlatformCALayer(LayerType layerType, PlatformLayer* layer, Plat
{
BEGIN_BLOCK_OBJC_EXCEPTIONS
if (layer) {
- m_layerType = LayerTypeCustom;
+ if ([layer isKindOfClass:getAVPlayerLayerClass()])
+ m_layerType = LayerTypeAVPlayerLayer;
+ else
+ m_layerType = LayerTypeCustom;
m_layer = layer;
} else {
m_layerType = layerType;
Class layerClass = Nil;
- switch(layerType) {
+ switch (layerType) {
case LayerTypeLayer:
case LayerTypeRootLayer:
layerClass = [CALayer class];
@@ -193,16 +201,19 @@ PlatformCALayer::PlatformCALayer(LayerType layerType, PlatformLayer* layer, Plat
case LayerTypeWebTiledLayer:
layerClass = [WebTiledLayer class];
break;
- case LayerTypeTileCacheLayer:
- case LayerTypePageTileCacheLayer:
- layerClass = [WebTileCacheLayer class];
+ case LayerTypeTiledBackingLayer:
+ case LayerTypePageTiledBackingLayer:
+ layerClass = [WebTiledBackingLayer class];
+ break;
+ case LayerTypeAVPlayerLayer:
+ layerClass = getAVPlayerLayerClass();
break;
case LayerTypeCustom:
break;
}
if (layerClass)
- m_layer.adoptNS([[layerClass alloc] init]);
+ m_layer = adoptNS([[layerClass alloc] init]);
}
// Save a pointer to 'this' in the CALayer
@@ -220,15 +231,58 @@ PlatformCALayer::PlatformCALayer(LayerType layerType, PlatformLayer* layer, Plat
[tiledLayer setContentsGravity:@"bottomLeft"];
}
- if (usesTileCacheLayer()) {
+ if (usesTiledBackingLayer()) {
m_customSublayers = adoptPtr(new PlatformCALayerList(1));
- CALayer* tileCacheTileContainerLayer = [static_cast<WebTileCacheLayer *>(m_layer.get()) tileContainerLayer];
+ CALayer* tileCacheTileContainerLayer = [static_cast<WebTiledBackingLayer *>(m_layer.get()) tileContainerLayer];
(*m_customSublayers)[0] = PlatformCALayer::create(tileCacheTileContainerLayer, 0);
}
END_BLOCK_OBJC_EXCEPTIONS
}
+PassRefPtr<PlatformCALayer> PlatformCALayer::clone(PlatformCALayerClient* owner) const
+{
+ LayerType type;
+ switch (layerType()) {
+ case LayerTypeTransformLayer:
+ type = LayerTypeTransformLayer;
+ break;
+ case LayerTypeAVPlayerLayer:
+ type = LayerTypeAVPlayerLayer;
+ break;
+ case LayerTypeLayer:
+ default:
+ type = LayerTypeLayer;
+ break;
+ };
+ RefPtr<PlatformCALayer> newLayer = PlatformCALayer::create(type, owner);
+
+ newLayer->setPosition(position());
+ newLayer->setBounds(bounds());
+ newLayer->setAnchorPoint(anchorPoint());
+ newLayer->setTransform(transform());
+ newLayer->setSublayerTransform(sublayerTransform());
+ newLayer->setContents(contents());
+ newLayer->setMasksToBounds(masksToBounds());
+ newLayer->setDoubleSided(isDoubleSided());
+ newLayer->setOpaque(isOpaque());
+ newLayer->setBackgroundColor(backgroundColor());
+ newLayer->setContentsScale(contentsScale());
+#if ENABLE(CSS_FILTERS)
+ newLayer->copyFiltersFrom(this);
+#endif
+
+ if (type == LayerTypeAVPlayerLayer) {
+ AVPlayerLayer* destinationPlayerLayer = newLayer->playerLayer();
+ AVPlayerLayer* sourcePlayerLayer = playerLayer();
+ dispatch_async(dispatch_get_main_queue(), ^{
+ [destinationPlayerLayer setPlayer:[sourcePlayerLayer player]];
+ });
+ }
+
+ return newLayer;
+}
+
PlatformCALayer::~PlatformCALayer()
{
[m_layer.get() setValue:nil forKey:platformCALayerPointer];
@@ -240,8 +294,8 @@ PlatformCALayer::~PlatformCALayer()
// Remove the owner pointer from the delegate in case there is a pending animationStarted event.
[static_cast<WebAnimationDelegate*>(m_delegate.get()) setOwner:nil];
- if (usesTileCacheLayer())
- [static_cast<WebTileCacheLayer *>(m_layer.get()) invalidate];
+ if (usesTiledBackingLayer())
+ [static_cast<WebTiledBackingLayer *>(m_layer.get()) invalidate];
}
PlatformCALayer* PlatformCALayer::platformCALayer(void* platformLayer)
@@ -379,12 +433,11 @@ void PlatformCALayer::addAnimationForKey(const String& key, PlatformCAAnimation*
// Add the delegate
if (!m_delegate) {
WebAnimationDelegate* webAnimationDelegate = [[WebAnimationDelegate alloc] init];
- m_delegate.adoptNS(webAnimationDelegate);
+ m_delegate = adoptNS(webAnimationDelegate);
[webAnimationDelegate setOwner:this];
}
CAPropertyAnimation* propertyAnimation = static_cast<CAPropertyAnimation*>(animation->platformAnimation());
-
if (![propertyAnimation delegate])
[propertyAnimation setDelegate:static_cast<id>(m_delegate.get())];
@@ -626,8 +679,8 @@ void PlatformCALayer::setBackgroundColor(const Color& value)
CGFloat components[4];
value.getRGBA(components[0], components[1], components[2], components[3]);
- RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB());
- RetainPtr<CGColorRef> color(AdoptCF, CGColorCreate(colorSpace.get(), components));
+ RetainPtr<CGColorSpaceRef> colorSpace = adoptCF(CGColorSpaceCreateDeviceRGB());
+ RetainPtr<CGColorRef> color = adoptCF(CGColorCreate(colorSpace.get(), components));
BEGIN_BLOCK_OBJC_EXCEPTIONS
[m_layer.get() setBackgroundColor:color.get()];
@@ -656,8 +709,8 @@ void PlatformCALayer::setBorderColor(const Color& value)
CGFloat components[4];
value.getRGBA(components[0], components[1], components[2], components[3]);
- RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB());
- RetainPtr<CGColorRef> color(AdoptCF, CGColorCreate(colorSpace.get(), components));
+ RetainPtr<CGColorSpaceRef> colorSpace = adoptCF(CGColorSpaceCreateDeviceRGB());
+ RetainPtr<CGColorRef> color = adoptCF(CGColorCreate(colorSpace.get(), components));
BEGIN_BLOCK_OBJC_EXCEPTIONS
[m_layer.get() setBorderColor:color.get()];
@@ -679,162 +732,7 @@ void PlatformCALayer::setOpacity(float value)
#if ENABLE(CSS_FILTERS)
void PlatformCALayer::setFilters(const FilterOperations& filters)
{
- if (!filters.size()) {
- BEGIN_BLOCK_OBJC_EXCEPTIONS
- [m_layer.get() setFilters:nil];
- [m_layer.get() setShadowOffset:CGSizeZero];
- [m_layer.get() setShadowColor:nil];
- [m_layer.get() setShadowRadius:0];
- [m_layer.get() setShadowOpacity:0];
- END_BLOCK_OBJC_EXCEPTIONS
- return;
- }
-
- // Assume filtersCanBeComposited was called and it returned true
- ASSERT(filtersCanBeComposited(filters));
-
- BEGIN_BLOCK_OBJC_EXCEPTIONS
-
- RetainPtr<NSMutableArray> array(AdoptNS, [[NSMutableArray alloc] init]);
-
- for (unsigned i = 0; i < filters.size(); ++i) {
- String filterName = String::format("filter_%d", i);
-
- const FilterOperation* filterOperation = filters.at(i);
- switch(filterOperation->getOperationType()) {
- case FilterOperation::DROP_SHADOW: {
- // FIXME: For now assume drop shadow is the last filter, put it on the layer
- const DropShadowFilterOperation* op = static_cast<const DropShadowFilterOperation*>(filterOperation);
- [m_layer.get() setShadowOffset:CGSizeMake(op->x(), op->y())];
-
- CGFloat components[4];
- op->color().getRGBA(components[0], components[1], components[2], components[3]);
- RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB());
- RetainPtr<CGColorRef> color(AdoptCF, CGColorCreate(colorSpace.get(), components));
- [m_layer.get() setShadowColor:color.get()];
-
- [m_layer.get() setShadowRadius:op->stdDeviation()];
- [m_layer.get() setShadowOpacity:1];
- break;
- }
- case FilterOperation::GRAYSCALE: {
- const BasicColorMatrixFilterOperation* op = static_cast<const BasicColorMatrixFilterOperation*>(filterOperation);
- CIFilter* caFilter = [CIFilter filterWithName:@"CIColorMonochrome"];
- [caFilter setDefaults];
- [caFilter setValue:[NSNumber numberWithFloat:op->amount()] forKey:@"inputIntensity"];
- [caFilter setValue:[CIColor colorWithRed:1 green:1 blue:1] forKey:@"inputColor"];
- [caFilter setName:filterName];
- [array.get() addObject:caFilter];
- break;
- }
- case FilterOperation::SEPIA: {
- const BasicColorMatrixFilterOperation* op = static_cast<const BasicColorMatrixFilterOperation*>(filterOperation);
- CIFilter* caFilter = [CIFilter filterWithName:@"CIColorMatrix"];
- [caFilter setDefaults];
-
- double t = op->amount();
- t = min(max(0.0, t), 1.0);
-
- // FIXME: Should put these values into constants (https://bugs.webkit.org/show_bug.cgi?id=76008)
- [caFilter setValue:[CIVector vectorWithX:WebCore::blend(1.0, 0.393, t) Y:WebCore::blend(0.0, 0.769, t) Z:WebCore::blend(0.0, 0.189, t) W:0] forKey:@"inputRVector"];
- [caFilter setValue:[CIVector vectorWithX:WebCore::blend(0.0, 0.349, t) Y:WebCore::blend(1.0, 0.686, t) Z:WebCore::blend(0.0, 0.168, t) W:0] forKey:@"inputGVector"];
- [caFilter setValue:[CIVector vectorWithX:WebCore::blend(0.0, 0.272, t) Y:WebCore::blend(0.0, 0.534, t) Z:WebCore::blend(1.0, 0.131, t) W:0] forKey:@"inputBVector"];
- [caFilter setValue:[CIVector vectorWithX:0 Y:0 Z:0 W:1] forKey:@"inputAVector"];
- [caFilter setValue:[CIVector vectorWithX:0 Y:0 Z:0 W:0] forKey:@"inputBiasVector"];
- [caFilter setName:filterName];
- [array.get() addObject:caFilter];
- break;
- }
- case FilterOperation::SATURATE: {
- const BasicColorMatrixFilterOperation* op = static_cast<const BasicColorMatrixFilterOperation*>(filterOperation);
- CIFilter* caFilter = [CIFilter filterWithName:@"CIColorControls"];
- [caFilter setDefaults];
- [caFilter setValue:[NSNumber numberWithFloat:op->amount()] forKey:@"inputSaturation"];
- [caFilter setName:filterName];
- [array.get() addObject:caFilter];
- break;
- }
- case FilterOperation::HUE_ROTATE: {
- const BasicColorMatrixFilterOperation* op = static_cast<const BasicColorMatrixFilterOperation*>(filterOperation);
- CIFilter* caFilter = [CIFilter filterWithName:@"CIHueAdjust"];
- [caFilter setDefaults];
-
- // The CIHueAdjust value is in radians
- [caFilter setValue:[NSNumber numberWithFloat:deg2rad(op->amount())] forKey:@"inputAngle"];
- [caFilter setName:filterName];
- [array.get() addObject:caFilter];
- break;
- }
- case FilterOperation::INVERT: {
- const BasicComponentTransferFilterOperation* op = static_cast<const BasicComponentTransferFilterOperation*>(filterOperation);
- CIFilter* caFilter = [CIFilter filterWithName:@"CIColorMatrix"];
- [caFilter setDefaults];
-
- double multiplier = 1 - op->amount() * 2;
-
- [caFilter setValue:[CIVector vectorWithX:multiplier Y:0 Z:0 W:0] forKey:@"inputRVector"];
- [caFilter setValue:[CIVector vectorWithX:0 Y:multiplier Z:0 W:0] forKey:@"inputGVector"];
- [caFilter setValue:[CIVector vectorWithX:0 Y:0 Z:multiplier W:0] forKey:@"inputBVector"];
- [caFilter setValue:[CIVector vectorWithX:0 Y:0 Z:0 W:1] forKey:@"inputAVector"];
- [caFilter setValue:[CIVector vectorWithX:op->amount() Y:op->amount() Z:op->amount() W:0] forKey:@"inputBiasVector"];
- [caFilter setName:filterName];
- [array.get() addObject:caFilter];
- break;
- }
- case FilterOperation::OPACITY: {
- const BasicComponentTransferFilterOperation* op = static_cast<const BasicComponentTransferFilterOperation*>(filterOperation);
- CIFilter* caFilter = [CIFilter filterWithName:@"CIColorMatrix"];
- [caFilter setDefaults];
-
- [caFilter setValue:[CIVector vectorWithX:1 Y:0 Z:0 W:0] forKey:@"inputRVector"];
- [caFilter setValue:[CIVector vectorWithX:0 Y:1 Z:0 W:0] forKey:@"inputGVector"];
- [caFilter setValue:[CIVector vectorWithX:0 Y:0 Z:1 W:0] forKey:@"inputBVector"];
- [caFilter setValue:[CIVector vectorWithX:0 Y:0 Z:0 W:op->amount()] forKey:@"inputAVector"];
- [caFilter setValue:[CIVector vectorWithX:0 Y:0 Z:0 W:0] forKey:@"inputBiasVector"];
- [caFilter setName:filterName];
- [array.get() addObject:caFilter];
- break;
- }
- case FilterOperation::BLUR: {
- // FIXME: For now we ignore stdDeviationY
- const BlurFilterOperation* op = static_cast<const BlurFilterOperation*>(filterOperation);
- CIFilter* caFilter = [CIFilter filterWithName:@"CIGaussianBlur"];
- [caFilter setDefaults];
- [caFilter setValue:[NSNumber numberWithFloat:floatValueForLength(op->stdDeviation(), 0)] forKey:@"inputRadius"];
- [caFilter setName:filterName];
- [array.get() addObject:caFilter];
- break;
- }
- case FilterOperation::CONTRAST: {
- const BasicComponentTransferFilterOperation* op = static_cast<const BasicComponentTransferFilterOperation*>(filterOperation);
- CIFilter* caFilter = [CIFilter filterWithName:@"CIColorControls"];
- [caFilter setDefaults];
- [caFilter setValue:[NSNumber numberWithFloat:op->amount()] forKey:@"inputContrast"];
- [caFilter setName:filterName];
- [array.get() addObject:caFilter];
- break;
- }
- case FilterOperation::BRIGHTNESS: {
- const BasicComponentTransferFilterOperation* op = static_cast<const BasicComponentTransferFilterOperation*>(filterOperation);
- CIFilter* caFilter = [CIFilter filterWithName:@"CIColorControls"];
- [caFilter setDefaults];
- [caFilter setValue:[NSNumber numberWithFloat:op->amount()] forKey:@"inputBrightness"];
- [caFilter setName:filterName];
- [array.get() addObject:caFilter];
- break;
- }
- case FilterOperation::PASSTHROUGH:
- break;
- default:
- ASSERT(0);
- break;
- }
- }
-
- if ([array.get() count] > 0)
- [m_layer.get() setFilters:array.get()];
-
- END_BLOCK_OBJC_EXCEPTIONS
+ PlatformCAFilters::setFiltersOnLayer(this, filters);
}
void PlatformCALayer::copyFiltersFrom(const PlatformCALayer* sourceLayer)
@@ -852,7 +750,7 @@ bool PlatformCALayer::filtersCanBeComposited(const FilterOperations& filters)
for (unsigned i = 0; i < filters.size(); ++i) {
const FilterOperation* filterOperation = filters.at(i);
- switch(filterOperation->getOperationType()) {
+ switch (filterOperation->getOperationType()) {
case FilterOperation::REFERENCE:
#if ENABLE(CSS_SHADERS)
case FilterOperation::CUSTOM:
@@ -943,11 +841,11 @@ void PlatformCALayer::setContentsScale(float value)
TiledBacking* PlatformCALayer::tiledBacking()
{
- if (!usesTileCacheLayer())
+ if (!usesTiledBackingLayer())
return 0;
- WebTileCacheLayer *tileCacheLayer = static_cast<WebTileCacheLayer *>(m_layer.get());
- return [tileCacheLayer tiledBacking];
+ WebTiledBackingLayer *tiledBackingLayer = static_cast<WebTiledBackingLayer *>(m_layer.get());
+ return [tiledBackingLayer tiledBacking];
}
#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
@@ -967,4 +865,10 @@ void PlatformCALayer::synchronouslyDisplayTilesInRect(const FloatRect& rect)
}
#endif
+AVPlayerLayer* PlatformCALayer::playerLayer() const
+{
+ ASSERT([m_layer.get() isKindOfClass:getAVPlayerLayerClass()]);
+ return (AVPlayerLayer*)m_layer.get();
+}
+
#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebCore/platform/graphics/ca/mac/TileCache.h b/Source/WebCore/platform/graphics/ca/mac/TileCache.h
deleted file mode 100644
index 1259747eb..000000000
--- a/Source/WebCore/platform/graphics/ca/mac/TileCache.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef TileCache_h
-#define TileCache_h
-
-#include "IntPointHash.h"
-#include "IntRect.h"
-#include "TiledBacking.h"
-#include "Timer.h"
-#include <wtf/HashMap.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/RetainPtr.h>
-
-OBJC_CLASS CALayer;
-OBJC_CLASS WebTileCacheLayer;
-OBJC_CLASS WebTileLayer;
-
-namespace WebCore {
-
-class FloatRect;
-class IntPoint;
-class IntRect;
-
-typedef Vector<RetainPtr<WebTileLayer> > WebTileLayerList;
-
-class TileCache : public TiledBacking {
- WTF_MAKE_NONCOPYABLE(TileCache);
-
-public:
- static PassOwnPtr<TileCache> create(WebTileCacheLayer*);
- ~TileCache();
-
- void tileCacheLayerBoundsChanged();
-
- void setNeedsDisplay();
- void setNeedsDisplayInRect(const IntRect&);
- void drawLayer(WebTileLayer *, CGContextRef);
-
- void setScale(CGFloat);
-
- bool acceleratesDrawing() const { return m_acceleratesDrawing; }
- void setAcceleratesDrawing(bool);
-
- void setTilesOpaque(bool);
- bool tilesAreOpaque() const { return m_tilesAreOpaque; }
-
- CALayer *tileContainerLayer() const { return m_tileContainerLayer.get(); }
-
- void setTileDebugBorderWidth(float);
- void setTileDebugBorderColor(CGColorRef);
-
- virtual IntRect visibleRect() const OVERRIDE { return m_visibleRect; }
-
- unsigned blankPixelCount() const;
- static unsigned blankPixelCountForTiles(const WebTileLayerList&, IntRect, IntPoint);
-
-private:
- TileCache(WebTileCacheLayer*);
-
- // TiledBacking member functions.
- virtual void setVisibleRect(const IntRect&) OVERRIDE;
- virtual void setIsInWindow(bool) OVERRIDE;
- virtual void setTileCoverage(TileCoverage) OVERRIDE;
- virtual TileCoverage tileCoverage() const OVERRIDE { return m_tileCoverage; }
- virtual void forceRepaint() OVERRIDE;
- virtual IntSize tileSize() const OVERRIDE { return m_tileSize; }
- virtual IntRect tileGridExtent() const OVERRIDE;
- virtual void setScrollingPerformanceLoggingEnabled(bool flag) OVERRIDE { m_scrollingPerformanceLoggingEnabled = flag; }
- virtual bool scrollingPerformanceLoggingEnabled() const OVERRIDE { return m_scrollingPerformanceLoggingEnabled; }
- virtual IntRect tileCoverageRect() const OVERRIDE;
-
- IntRect bounds() const;
-
- typedef IntPoint TileIndex;
- IntRect rectForTileIndex(const TileIndex&) const;
- void getTileIndexRangeForRect(const IntRect&, TileIndex& topLeft, TileIndex& bottomRight) const;
-
- IntRect computeTileCoverageRect() const;
- IntSize tileSizeForCoverageRect(const IntRect&) const;
-
- void scheduleTileRevalidation(double interval);
- void tileRevalidationTimerFired(Timer<TileCache>*);
- void revalidateTiles();
-
- WebTileLayer* tileLayerAtIndex(const TileIndex&) const;
- RetainPtr<WebTileLayer> createTileLayer(const IntRect&);
-
- bool shouldShowRepaintCounters() const;
- void drawRepaintCounter(WebTileLayer *, CGContextRef);
-
- WebTileCacheLayer* m_tileCacheLayer;
- RetainPtr<CALayer> m_tileContainerLayer;
- IntSize m_tileSize;
- IntRect m_visibleRect;
-
- typedef HashMap<TileIndex, RetainPtr<WebTileLayer> > TileMap;
- TileMap m_tiles;
- Timer<TileCache> m_tileRevalidationTimer;
- IntRect m_tileCoverageRect;
-
- CGFloat m_scale;
- CGFloat m_deviceScaleFactor;
-
- TileCoverage m_tileCoverage;
- bool m_isInWindow;
- bool m_scrollingPerformanceLoggingEnabled;
- bool m_acceleratesDrawing;
- bool m_tilesAreOpaque;
-
- RetainPtr<CGColorRef> m_tileDebugBorderColor;
- float m_tileDebugBorderWidth;
-};
-
-} // namespace WebCore
-
-#endif // TileCache_h
diff --git a/Source/WebCore/platform/graphics/ca/mac/TileCache.mm b/Source/WebCore/platform/graphics/ca/mac/TileCache.mm
deleted file mode 100644
index 233352d57..000000000
--- a/Source/WebCore/platform/graphics/ca/mac/TileCache.mm
+++ /dev/null
@@ -1,570 +0,0 @@
-/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "TileCache.h"
-
-#import "IntRect.h"
-#import "PlatformCALayer.h"
-#import "Region.h"
-#import "LayerPool.h"
-#import "WebLayer.h"
-#import "WebTileCacheLayer.h"
-#import "WebTileLayer.h"
-#import <wtf/MainThread.h>
-#import <utility>
-
-using namespace std;
-
-#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
-@interface CALayer (WebCALayerDetails)
-- (void)setAcceleratesDrawing:(BOOL)flag;
-@end
-#endif
-
-namespace WebCore {
-
-static const int defaultTileCacheWidth = 512;
-static const int defaultTileCacheHeight = 512;
-
-PassOwnPtr<TileCache> TileCache::create(WebTileCacheLayer* tileCacheLayer)
-{
- return adoptPtr(new TileCache(tileCacheLayer));
-}
-
-TileCache::TileCache(WebTileCacheLayer* tileCacheLayer)
- : m_tileCacheLayer(tileCacheLayer)
- , m_tileContainerLayer(adoptCF([[CALayer alloc] init]))
- , m_tileSize(defaultTileCacheWidth, defaultTileCacheHeight)
- , m_tileRevalidationTimer(this, &TileCache::tileRevalidationTimerFired)
- , m_scale(1)
- , m_deviceScaleFactor(1)
- , m_tileCoverage(CoverageForVisibleArea)
- , m_isInWindow(false)
- , m_scrollingPerformanceLoggingEnabled(false)
- , m_acceleratesDrawing(false)
- , m_tilesAreOpaque(false)
- , m_tileDebugBorderWidth(0)
-{
- [CATransaction begin];
- [CATransaction setDisableActions:YES];
- [m_tileCacheLayer addSublayer:m_tileContainerLayer.get()];
-#ifndef NDEBUG
- [m_tileContainerLayer.get() setName:@"TileCache Container Layer"];
-#endif
- [CATransaction commit];
-}
-
-TileCache::~TileCache()
-{
- ASSERT(isMainThread());
-
- for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
- WebTileLayer* tileLayer = it->value.get();
- [tileLayer setTileCache:0];
- }
-}
-
-void TileCache::tileCacheLayerBoundsChanged()
-{
- if (m_tiles.isEmpty()) {
- // We must revalidate immediately instead of using a timer when there are
- // no tiles to avoid a flash when transitioning from one page to another.
- revalidateTiles();
- return;
- }
-
- scheduleTileRevalidation(0);
-}
-
-void TileCache::setNeedsDisplay()
-{
- for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it)
- [it->value.get() setNeedsDisplay];
-}
-
-void TileCache::setNeedsDisplayInRect(const IntRect& rect)
-{
- if (m_tiles.isEmpty())
- return;
-
- FloatRect scaledRect(rect);
- scaledRect.scale(m_scale);
-
- // Find the tiles that need to be invalidated.
- IntRect coveredRect = intersection(enclosingIntRect(scaledRect), m_tileCoverageRect);
- if (coveredRect.isEmpty())
- return;
-
- TileIndex topLeft;
- TileIndex bottomRight;
- getTileIndexRangeForRect(coveredRect, topLeft, bottomRight);
-
- for (int y = topLeft.y(); y <= bottomRight.y(); ++y) {
- for (int x = topLeft.x(); x <= bottomRight.x(); ++x) {
- WebTileLayer* tileLayer = tileLayerAtIndex(TileIndex(x, y));
- if (!tileLayer)
- continue;
-
- CGRect tileRect = [m_tileCacheLayer convertRect:rect toLayer:tileLayer];
- if (CGRectIsEmpty(tileRect))
- continue;
-
- [tileLayer setNeedsDisplayInRect:tileRect];
-
- if (shouldShowRepaintCounters()) {
- CGRect bounds = [tileLayer bounds];
- CGRect indicatorRect = CGRectMake(bounds.origin.x, bounds.origin.y, 52, 27);
- [tileLayer setNeedsDisplayInRect:indicatorRect];
- }
- }
- }
-}
-
-void TileCache::drawLayer(WebTileLayer *layer, CGContextRef context)
-{
- PlatformCALayer* platformLayer = PlatformCALayer::platformCALayer(m_tileCacheLayer);
- if (!platformLayer)
- return;
-
- CGContextSaveGState(context);
-
- CGPoint layerOrigin = [layer frame].origin;
- CGContextTranslateCTM(context, -layerOrigin.x, -layerOrigin.y);
- CGContextScaleCTM(context, m_scale, m_scale);
- drawLayerContents(context, layer, platformLayer);
-
- CGContextRestoreGState(context);
-
- drawRepaintCounter(layer, context);
-}
-
-void TileCache::setScale(CGFloat scale)
-{
- PlatformCALayer* platformLayer = PlatformCALayer::platformCALayer(m_tileCacheLayer);
- float deviceScaleFactor = platformLayer->owner()->platformCALayerDeviceScaleFactor();
-
- // The scale we get is the produce of the page scale factor and device scale factor.
- // Divide by the device scale factor so we'll get the page scale factor.
- scale /= deviceScaleFactor;
-
- if (m_scale == scale && m_deviceScaleFactor == deviceScaleFactor)
- return;
-
-#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
- Vector<FloatRect> dirtyRects;
-
- m_deviceScaleFactor = deviceScaleFactor;
- m_scale = scale;
- [m_tileContainerLayer.get() setTransform:CATransform3DMakeScale(1 / m_scale, 1 / m_scale, 1)];
-
- revalidateTiles();
-
- for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
- [it->value.get() setContentsScale:deviceScaleFactor];
-
- IntRect tileRect = rectForTileIndex(it->key);
- FloatRect scaledTileRect = tileRect;
-
- scaledTileRect.scale(1 / m_scale);
- dirtyRects.append(scaledTileRect);
- }
-
- platformLayer->owner()->platformCALayerDidCreateTiles(dirtyRects);
-#endif
-}
-
-void TileCache::setAcceleratesDrawing(bool acceleratesDrawing)
-{
-#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
- if (m_acceleratesDrawing == acceleratesDrawing)
- return;
-
- m_acceleratesDrawing = acceleratesDrawing;
-
- for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it)
- [it->value.get() setAcceleratesDrawing:m_acceleratesDrawing];
-#else
- UNUSED_PARAM(acceleratesDrawing);
-#endif
-}
-
-void TileCache::setTilesOpaque(bool opaque)
-{
- if (opaque == m_tilesAreOpaque)
- return;
-
- m_tilesAreOpaque = opaque;
-
- for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
- WebTileLayer* tileLayer = it->value.get();
- [tileLayer setOpaque:opaque];
- }
-}
-
-void TileCache::setVisibleRect(const IntRect& visibleRect)
-{
- if (m_visibleRect == visibleRect)
- return;
-
- m_visibleRect = visibleRect;
- revalidateTiles();
-}
-
-void TileCache::setIsInWindow(bool isInWindow)
-{
- if (m_isInWindow == isInWindow)
- return;
-
- m_isInWindow = isInWindow;
-
- if (!m_isInWindow) {
- const double tileRevalidationTimeout = 4;
- scheduleTileRevalidation(tileRevalidationTimeout);
- }
-}
-
-void TileCache::setTileCoverage(TileCoverage coverage)
-{
- if (coverage == m_tileCoverage)
- return;
-
- m_tileCoverage = coverage;
- scheduleTileRevalidation(0);
-}
-
-void TileCache::forceRepaint()
-{
- setNeedsDisplay();
-}
-
-void TileCache::setTileDebugBorderWidth(float borderWidth)
-{
- if (m_tileDebugBorderWidth == borderWidth)
- return;
-
- m_tileDebugBorderWidth = borderWidth;
- for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it)
- [it->value.get() setBorderWidth:m_tileDebugBorderWidth];
-}
-
-void TileCache::setTileDebugBorderColor(CGColorRef borderColor)
-{
- if (m_tileDebugBorderColor == borderColor)
- return;
-
- m_tileDebugBorderColor = borderColor;
- for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it)
- [it->value.get() setBorderColor:m_tileDebugBorderColor.get()];
-}
-
-IntRect TileCache::bounds() const
-{
- return IntRect(IntPoint(), IntSize([m_tileCacheLayer bounds].size));
-}
-
-IntRect TileCache::rectForTileIndex(const TileIndex& tileIndex) const
-{
- IntRect rect(tileIndex.x() * m_tileSize.width(), tileIndex.y() * m_tileSize.height(), m_tileSize.width(), m_tileSize.height());
- IntRect scaledBounds(bounds());
- scaledBounds.scale(m_scale);
-
- rect.intersect(scaledBounds);
-
- return rect;
-}
-
-void TileCache::getTileIndexRangeForRect(const IntRect& rect, TileIndex& topLeft, TileIndex& bottomRight) const
-{
- IntRect clampedRect = bounds();
- clampedRect.scale(m_scale);
- clampedRect.intersect(rect);
-
- topLeft.setX(max(clampedRect.x() / m_tileSize.width(), 0));
- topLeft.setY(max(clampedRect.y() / m_tileSize.height(), 0));
-
- int bottomXRatio = ceil((float)clampedRect.maxX() / m_tileSize.width());
- bottomRight.setX(max(bottomXRatio - 1, 0));
-
- int bottomYRatio = ceil((float)clampedRect.maxY() / m_tileSize.height());
- bottomRight.setY(max(bottomYRatio - 1, 0));
-}
-
-IntRect TileCache::computeTileCoverageRect() const
-{
- IntRect tileCoverageRect = m_visibleRect;
-
- // If the page is not in a window (for example if it's in a background tab), we limit the tile coverage rect to the visible rect.
- // Furthermore, if the page can't have scrollbars (for example if its body element has overflow:hidden) it's very unlikely that the
- // page will ever be scrolled so we limit the tile coverage rect as well.
- if (m_isInWindow && !(m_tileCoverage & CoverageForSlowScrolling)) {
- // Inflate the coverage rect so that it covers 2x of the visible width and 3x of the visible height.
- // These values were chosen because it's more common to have tall pages and to scroll vertically,
- // so we keep more tiles above and below the current area.
- if (m_tileCoverage & CoverageForHorizontalScrolling)
- tileCoverageRect.inflateX(tileCoverageRect.width() / 2);
-
- if (m_tileCoverage & CoverageForVerticalScrolling)
- tileCoverageRect.inflateY(tileCoverageRect.height());
- }
-
- return tileCoverageRect;
-}
-
-IntSize TileCache::tileSizeForCoverageRect(const IntRect& coverageRect) const
-{
- if (m_tileCoverage & CoverageForSlowScrolling)
- return coverageRect.size();
- return IntSize(defaultTileCacheWidth, defaultTileCacheHeight);
-}
-
-void TileCache::scheduleTileRevalidation(double interval)
-{
- if (m_tileRevalidationTimer.isActive() && m_tileRevalidationTimer.nextFireInterval() < interval)
- return;
-
- m_tileRevalidationTimer.startOneShot(interval);
-}
-
-void TileCache::tileRevalidationTimerFired(Timer<TileCache>*)
-{
- revalidateTiles();
-}
-
-unsigned TileCache::blankPixelCount() const
-{
- WebTileLayerList tiles(m_tiles.size());
- tiles.appendRange(m_tiles.begin().values(), m_tiles.end().values());
-
- return blankPixelCountForTiles(tiles, m_visibleRect, IntPoint(0,0));
-}
-
-unsigned TileCache::blankPixelCountForTiles(const WebTileLayerList& tiles, IntRect visibleRect, IntPoint tileTranslation)
-{
- Region paintedVisibleTiles;
-
- for (WebTileLayerList::const_iterator it = tiles.begin(), end = tiles.end(); it != end; ++it) {
- const WebTileLayer* tileLayer = it->get();
-
- IntRect visiblePart(CGRectOffset([tileLayer frame], tileTranslation.x(), tileTranslation.y()));
- visiblePart.intersect(visibleRect);
-
- if (!visiblePart.isEmpty() && [tileLayer repaintCount])
- paintedVisibleTiles.unite(visiblePart);
- }
-
- Region uncoveredRegion(visibleRect);
- uncoveredRegion.subtract(paintedVisibleTiles);
-
- return uncoveredRegion.totalArea();
-}
-
-void TileCache::revalidateTiles()
-{
- // If the underlying PlatformLayer has been destroyed, but the WebTileCacheLayer hasn't
- // platformLayer will be null here.
- PlatformCALayer* platformLayer = PlatformCALayer::platformCALayer(m_tileCacheLayer);
- if (!platformLayer)
- return;
-
- if (m_visibleRect.isEmpty() || bounds().isEmpty())
- return;
-
- IntRect tileCoverageRect = computeTileCoverageRect();
- IntRect coverageRectInTileCoords(tileCoverageRect);
- coverageRectInTileCoords.scale(m_scale);
-
- IntSize oldTileSize = m_tileSize;
- m_tileSize = tileSizeForCoverageRect(tileCoverageRect);
- bool tileSizeChanged = m_tileSize != oldTileSize;
-
- Vector<TileIndex> tilesToRemove;
-
- for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
- const TileIndex& tileIndex = it->key;
-
- WebTileLayer* tileLayer = it->value.get();
-
- if (!rectForTileIndex(tileIndex).intersects(coverageRectInTileCoords) || tileSizeChanged) {
- // Remove this layer.
- [tileLayer removeFromSuperlayer];
- [tileLayer setTileCache:0];
-
- tilesToRemove.append(tileIndex);
- }
- }
-
- // FIXME: Be more clever about which tiles to remove. We might not want to remove all
- // the tiles that are outside the coverage rect. When we know that we're going to be scrolling up,
- // we might want to remove the ones below the coverage rect but keep the ones above.
- for (size_t i = 0; i < tilesToRemove.size(); ++i)
- LayerPool::sharedPool()->addLayer(m_tiles.take(tilesToRemove[i]));
-
- TileIndex topLeft;
- TileIndex bottomRight;
- getTileIndexRangeForRect(coverageRectInTileCoords, topLeft, bottomRight);
-
- Vector<FloatRect> dirtyRects;
-
- for (int y = topLeft.y(); y <= bottomRight.y(); ++y) {
- for (int x = topLeft.x(); x <= bottomRight.x(); ++x) {
- TileIndex tileIndex(x, y);
-
- IntRect tileRect = rectForTileIndex(tileIndex);
- RetainPtr<WebTileLayer>& tileLayer = m_tiles.add(tileIndex, 0).iterator->value;
- if (!tileLayer) {
- tileLayer = createTileLayer(tileRect);
- [m_tileContainerLayer.get() addSublayer:tileLayer.get()];
- } else {
- // We already have a layer for this tile. Ensure that its size is correct.
- CGSize tileLayerSize = [tileLayer.get() frame].size;
- if (tileLayerSize.width >= tileRect.width() && tileLayerSize.height >= tileRect.height())
- continue;
- [tileLayer.get() setFrame:tileRect];
- }
-
- FloatRect scaledTileRect = tileRect;
- scaledTileRect.scale(1 / m_scale);
- dirtyRects.append(scaledTileRect);
- }
- }
-
- m_tileCoverageRect = IntRect();
- for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
- const TileIndex& tileIndex = it->key;
-
- m_tileCoverageRect.unite(rectForTileIndex(tileIndex));
- }
-
- if (dirtyRects.isEmpty())
- return;
- platformLayer->owner()->platformCALayerDidCreateTiles(dirtyRects);
-}
-
-IntRect TileCache::tileGridExtent() const
-{
- TileIndex topLeft;
- TileIndex bottomRight;
- getTileIndexRangeForRect(m_tileCoverageRect, topLeft, bottomRight);
-
- // Return index of top, left tile and the number of tiles across and down.
- return IntRect(topLeft.x(), topLeft.y(), bottomRight.x() - topLeft.x() + 1, bottomRight.y() - topLeft.y() + 1);
-}
-
-// Return the rect in layer coords, not tile coords.
-IntRect TileCache::tileCoverageRect() const
-{
- IntRect coverageRectInLayerCoords(m_tileCoverageRect);
- coverageRectInLayerCoords.scale(1 / m_scale);
- return coverageRectInLayerCoords;
-}
-
-WebTileLayer* TileCache::tileLayerAtIndex(const TileIndex& index) const
-{
- return m_tiles.get(index).get();
-}
-
-RetainPtr<WebTileLayer> TileCache::createTileLayer(const IntRect& tileRect)
-{
- RetainPtr<WebTileLayer> layer = LayerPool::sharedPool()->takeLayerWithSize(tileRect.size());
- if (layer) {
- // If we were able to restore a layer from the LayerPool, we should call setNeedsDisplay to
- // ensure we avoid stale content.
- [layer setNeedsDisplay];
- } else
- layer = adoptNS([[WebTileLayer alloc] init]);
- [layer.get() setAnchorPoint:CGPointZero];
- [layer.get() setFrame:tileRect];
- [layer.get() setTileCache:this];
- [layer.get() setBorderColor:m_tileDebugBorderColor.get()];
- [layer.get() setBorderWidth:m_tileDebugBorderWidth];
- [layer.get() setEdgeAntialiasingMask:0];
- [layer.get() setOpaque:m_tilesAreOpaque];
-#ifndef NDEBUG
- [layer.get() setName:@"Tile"];
-#endif
-
-#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
- [layer.get() setContentsScale:m_deviceScaleFactor];
- [layer.get() setAcceleratesDrawing:m_acceleratesDrawing];
-#endif
-
- return layer;
-}
-
-bool TileCache::shouldShowRepaintCounters() const
-{
- PlatformCALayer* platformLayer = PlatformCALayer::platformCALayer(m_tileCacheLayer);
- if (!platformLayer)
- return false;
-
- WebCore::PlatformCALayerClient* layerContents = platformLayer->owner();
- ASSERT(layerContents);
- if (!layerContents)
- return false;
-
- return layerContents->platformCALayerShowRepaintCounter(0);
-}
-
-void TileCache::drawRepaintCounter(WebTileLayer *layer, CGContextRef context)
-{
- unsigned repaintCount = [layer incrementRepaintCount];
- if (!shouldShowRepaintCounters())
- return;
-
- // FIXME: Some of this code could be shared with WebLayer.
- char text[16]; // that's a lot of repaints
- snprintf(text, sizeof(text), "%d", repaintCount);
-
- CGRect indicatorBox = [layer bounds];
- indicatorBox.size.width = 12 + 10 * strlen(text);
- indicatorBox.size.height = 27;
- CGContextSaveGState(context);
-
- CGContextSetAlpha(context, 0.5f);
- CGContextBeginTransparencyLayerWithRect(context, indicatorBox, 0);
-
- CGContextSetFillColorWithColor(context, m_tileDebugBorderColor.get());
- CGContextFillRect(context, indicatorBox);
-
- PlatformCALayer* platformLayer = PlatformCALayer::platformCALayer(m_tileCacheLayer);
-
- if (platformLayer->acceleratesDrawing())
- CGContextSetRGBFillColor(context, 1, 0, 0, 1);
- else
- CGContextSetRGBFillColor(context, 1, 1, 1, 1);
-
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- CGContextSetTextMatrix(context, CGAffineTransformMakeScale(1, -1));
- CGContextSelectFont(context, "Helvetica", 22, kCGEncodingMacRoman);
- CGContextShowTextAtPoint(context, indicatorBox.origin.x + 5, indicatorBox.origin.y + 22, text, strlen(text));
-#pragma clang diagnostic pop
-
- CGContextEndTransparencyLayer(context);
- CGContextRestoreGState(context);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/ca/mac/TileController.h b/Source/WebCore/platform/graphics/ca/mac/TileController.h
new file mode 100644
index 000000000..546fa81da
--- /dev/null
+++ b/Source/WebCore/platform/graphics/ca/mac/TileController.h
@@ -0,0 +1,217 @@
+/*
+ * Copyright (C) 2011, 2012, 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef TileController_h
+#define TileController_h
+
+#include "FloatRect.h"
+#include "IntPointHash.h"
+#include "IntRect.h"
+#include "TiledBacking.h"
+#include "Timer.h"
+#include <wtf/Deque.h>
+#include <wtf/HashMap.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/RetainPtr.h>
+
+OBJC_CLASS CALayer;
+OBJC_CLASS WebTiledBackingLayer;
+OBJC_CLASS WebTileLayer;
+OBJC_CLASS WebTiledScrollingIndicatorLayer;
+
+namespace WebCore {
+
+class FloatRect;
+class IntPoint;
+class IntRect;
+
+typedef Vector<RetainPtr<WebTileLayer> > WebTileLayerList;
+
+class TileController : public TiledBacking {
+ WTF_MAKE_NONCOPYABLE(TileController);
+
+public:
+ static PassOwnPtr<TileController> create(WebTiledBackingLayer*);
+ ~TileController();
+
+ void tileCacheLayerBoundsChanged();
+
+ void setNeedsDisplay();
+ void setNeedsDisplayInRect(const IntRect&);
+ void drawLayer(WebTileLayer *, CGContextRef);
+
+ void setScale(CGFloat);
+ CGFloat scale() const { return m_scale; }
+
+ bool acceleratesDrawing() const { return m_acceleratesDrawing; }
+ void setAcceleratesDrawing(bool);
+
+ void setTilesOpaque(bool);
+ bool tilesAreOpaque() const { return m_tilesAreOpaque; }
+
+ CALayer *tileContainerLayer() const { return m_tileContainerLayer.get(); }
+
+ void setTileDebugBorderWidth(float);
+ void setTileDebugBorderColor(CGColorRef);
+
+ virtual FloatRect visibleRect() const OVERRIDE { return m_visibleRect; }
+
+ unsigned blankPixelCount() const;
+ static unsigned blankPixelCountForTiles(const WebTileLayerList&, const FloatRect&, const IntPoint&);
+
+ // Only public for the WebTileCacheMapLayer.
+ void drawTileMapContents(CGContextRef, CGRect);
+
+public:
+ // Only public for inline methods in the implementation file.
+ typedef IntPoint TileIndex;
+ typedef unsigned TileCohort;
+ static const TileCohort VisibleTileCohort = UINT_MAX;
+
+ struct TileInfo {
+ RetainPtr<WebTileLayer> layer;
+ TileCohort cohort; // VisibleTileCohort is visible.
+ bool hasStaleContent;
+
+ TileInfo()
+ : cohort(VisibleTileCohort)
+ , hasStaleContent(false)
+ { }
+ };
+
+private:
+ TileController(WebTiledBackingLayer*);
+
+ // TiledBacking member functions.
+ virtual void setVisibleRect(const FloatRect&) OVERRIDE;
+ virtual bool tilesWouldChangeForVisibleRect(const FloatRect&) const OVERRIDE;
+ virtual void setExposedRect(const FloatRect&) OVERRIDE;
+ virtual bool clipsToExposedRect() OVERRIDE { return m_clipsToExposedRect; }
+ virtual void setClipsToExposedRect(bool) OVERRIDE;
+ virtual void prepopulateRect(const FloatRect&) OVERRIDE;
+ virtual void setIsInWindow(bool) OVERRIDE;
+ virtual void setTileCoverage(TileCoverage) OVERRIDE;
+ virtual TileCoverage tileCoverage() const OVERRIDE { return m_tileCoverage; }
+ virtual void forceRepaint() OVERRIDE;
+ virtual IntSize tileSize() const OVERRIDE { return m_tileSize; }
+ virtual IntRect tileGridExtent() const OVERRIDE;
+ virtual void setScrollingPerformanceLoggingEnabled(bool flag) OVERRIDE { m_scrollingPerformanceLoggingEnabled = flag; }
+ virtual bool scrollingPerformanceLoggingEnabled() const OVERRIDE { return m_scrollingPerformanceLoggingEnabled; }
+ virtual void setAggressivelyRetainsTiles(bool flag) OVERRIDE { m_aggressivelyRetainsTiles = flag; }
+ virtual bool aggressivelyRetainsTiles() const OVERRIDE { return m_aggressivelyRetainsTiles; }
+ virtual void setUnparentsOffscreenTiles(bool flag) OVERRIDE { m_unparentsOffscreenTiles = flag; }
+ virtual bool unparentsOffscreenTiles() const OVERRIDE { return m_unparentsOffscreenTiles; }
+ virtual double retainedTileBackingStoreMemory() const OVERRIDE;
+ virtual IntRect tileCoverageRect() const OVERRIDE;
+ virtual CALayer *tiledScrollingIndicatorLayer() OVERRIDE;
+ virtual void setScrollingModeIndication(ScrollingModeIndication) OVERRIDE;
+
+ IntRect bounds() const;
+
+ IntRect rectForTileIndex(const TileIndex&) const;
+ void getTileIndexRangeForRect(const IntRect&, TileIndex& topLeft, TileIndex& bottomRight) const;
+
+ FloatRect computeTileCoverageRect(const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect) const;
+ IntSize tileSizeForCoverageRect(const FloatRect&) const;
+
+ void scheduleTileRevalidation(double interval);
+ void tileRevalidationTimerFired(Timer<TileController>*);
+
+ void scheduleCohortRemoval();
+ void cohortRemovalTimerFired(Timer<TileController>*);
+
+ typedef unsigned TileValidationPolicyFlags;
+
+ void revalidateTiles(TileValidationPolicyFlags foregroundValidationPolicy = 0, TileValidationPolicyFlags backgroundValidationPolicy = 0);
+ void ensureTilesForRect(const FloatRect&);
+ void updateTileCoverageMap();
+
+ void removeAllTiles();
+ void removeAllSecondaryTiles();
+ void removeTilesInCohort(TileCohort);
+
+ TileCohort nextTileCohort() const;
+ void startedNewCohort(TileCohort);
+
+ TileCohort newestTileCohort() const;
+ TileCohort oldestTileCohort() const;
+
+ void setTileNeedsDisplayInRect(const TileIndex&, TileInfo&, const IntRect& repaintRectInTileCoords, const IntRect& coverageRectInTileCoords);
+
+ WebTileLayer* tileLayerAtIndex(const TileIndex&) const;
+ RetainPtr<WebTileLayer> createTileLayer(const IntRect&);
+
+ bool shouldShowRepaintCounters() const;
+ void drawRepaintCounter(WebTileLayer *, CGContextRef);
+
+ WebTiledBackingLayer* m_tileCacheLayer;
+ RetainPtr<CALayer> m_tileContainerLayer;
+ RetainPtr<WebTiledScrollingIndicatorLayer> m_tiledScrollingIndicatorLayer; // Used for coverage visualization.
+
+ IntSize m_tileSize;
+ FloatRect m_visibleRect;
+ FloatRect m_visibleRectAtLastRevalidate;
+ FloatRect m_exposedRect; // The exposed area of containing platform views.
+ IntRect m_boundsAtLastRevalidate;
+
+ typedef HashMap<TileIndex, TileInfo> TileMap;
+ TileMap m_tiles;
+ Timer<TileController> m_tileRevalidationTimer;
+ Timer<TileController> m_cohortRemovalTimer;
+
+ struct TileCohortInfo {
+ TileCohort cohort;
+ double creationTime; // in monotonicallyIncreasingTime().
+ TileCohortInfo(TileCohort inCohort, double inTime)
+ : cohort(inCohort)
+ , creationTime(inTime)
+ { }
+ };
+ typedef Deque<TileCohortInfo> TileCohortList;
+ TileCohortList m_cohortList;
+
+ IntRect m_primaryTileCoverageRect; // In tile coords.
+
+ CGFloat m_scale;
+ CGFloat m_deviceScaleFactor;
+
+ TileCoverage m_tileCoverage;
+ bool m_isInWindow;
+ bool m_scrollingPerformanceLoggingEnabled;
+ bool m_aggressivelyRetainsTiles;
+ bool m_unparentsOffscreenTiles;
+ bool m_acceleratesDrawing;
+ bool m_tilesAreOpaque;
+ bool m_clipsToExposedRect;
+
+ RetainPtr<CGColorRef> m_tileDebugBorderColor;
+ float m_tileDebugBorderWidth;
+ ScrollingModeIndication m_indicatorMode;
+};
+
+} // namespace WebCore
+
+#endif // TileController_h
diff --git a/Source/WebCore/platform/graphics/ca/mac/TileController.mm b/Source/WebCore/platform/graphics/ca/mac/TileController.mm
new file mode 100644
index 000000000..d7f7fa432
--- /dev/null
+++ b/Source/WebCore/platform/graphics/ca/mac/TileController.mm
@@ -0,0 +1,1135 @@
+/*
+ * Copyright (C) 2011, 2012, 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "TileController.h"
+
+#import "IntRect.h"
+#import "PlatformCALayer.h"
+#import "Region.h"
+#import "LayerPool.h"
+#import "WebLayer.h"
+#import "WebTiledBackingLayer.h"
+#import "WebTileLayer.h"
+#import <QuartzCore/QuartzCore.h>
+#import <wtf/MainThread.h>
+#import <WebCore/BlockExceptions.h>
+#import <utility>
+
+using namespace std;
+
+#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
+@interface CALayer (WebCALayerDetails)
+- (void)setAcceleratesDrawing:(BOOL)flag;
+@end
+#endif
+
+@interface WebTiledScrollingIndicatorLayer : CALayer {
+ WebCore::TileController* _tileController;
+ CALayer *_visibleRectFrameLayer; // Owned by being a sublayer.
+}
+@property (assign) WebCore::TileController* tileController;
+@property (assign) CALayer* visibleRectFrameLayer;
+@end
+
+@implementation WebTiledScrollingIndicatorLayer
+@synthesize tileController = _tileController;
+@synthesize visibleRectFrameLayer = _visibleRectFrameLayer;
+- (id)init
+{
+ if ((self = [super init])) {
+ [self setStyle:[NSDictionary dictionaryWithObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNull null], @"bounds", [NSNull null], @"position", [NSNull null], @"contents", nil] forKey:@"actions"]];
+
+ _visibleRectFrameLayer = [CALayer layer];
+ [_visibleRectFrameLayer setStyle:[NSDictionary dictionaryWithObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNull null], @"bounds", [NSNull null], @"position", [NSNull null], @"borderColor", nil] forKey:@"actions"]];
+ [self addSublayer:_visibleRectFrameLayer];
+ [_visibleRectFrameLayer setBorderColor:WebCore::cachedCGColor(WebCore::Color(255, 0, 0), WebCore::ColorSpaceDeviceRGB)];
+ [_visibleRectFrameLayer setBorderWidth:2];
+ return self;
+ }
+ return nil;
+}
+
+- (void)drawInContext:(CGContextRef)context
+{
+ if (_tileController)
+ _tileController->drawTileMapContents(context, [self bounds]);
+}
+@end
+
+namespace WebCore {
+
+enum TileValidationPolicyFlag {
+ PruneSecondaryTiles = 1 << 0,
+ UnparentAllTiles = 1 << 1
+};
+
+static const int defaultTileWidth = 512;
+static const int defaultTileHeight = 512;
+
+PassOwnPtr<TileController> TileController::create(WebTiledBackingLayer* tileCacheLayer)
+{
+ return adoptPtr(new TileController(tileCacheLayer));
+}
+
+TileController::TileController(WebTiledBackingLayer* tileCacheLayer)
+ : m_tileCacheLayer(tileCacheLayer)
+ , m_tileContainerLayer(adoptNS([[CALayer alloc] init]))
+ , m_tileSize(defaultTileWidth, defaultTileHeight)
+ , m_tileRevalidationTimer(this, &TileController::tileRevalidationTimerFired)
+ , m_cohortRemovalTimer(this, &TileController::cohortRemovalTimerFired)
+ , m_scale(1)
+ , m_deviceScaleFactor(1)
+ , m_tileCoverage(CoverageForVisibleArea)
+ , m_isInWindow(false)
+ , m_scrollingPerformanceLoggingEnabled(false)
+ , m_aggressivelyRetainsTiles(false)
+ , m_unparentsOffscreenTiles(false)
+ , m_acceleratesDrawing(false)
+ , m_tilesAreOpaque(false)
+ , m_clipsToExposedRect(false)
+ , m_tileDebugBorderWidth(0)
+ , m_indicatorMode(ThreadedScrollingIndication)
+{
+ [CATransaction begin];
+ [CATransaction setDisableActions:YES];
+ [m_tileCacheLayer addSublayer:m_tileContainerLayer.get()];
+#ifndef NDEBUG
+ [m_tileContainerLayer.get() setName:@"TileController Container Layer"];
+#endif
+ [CATransaction commit];
+}
+
+TileController::~TileController()
+{
+ ASSERT(isMainThread());
+
+ for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
+ const TileInfo& tileInfo = it->value;
+ [tileInfo.layer.get() setTileController:0];
+ }
+
+ if (m_tiledScrollingIndicatorLayer)
+ [m_tiledScrollingIndicatorLayer.get() setTileController:nil];
+}
+
+void TileController::tileCacheLayerBoundsChanged()
+{
+ if (m_tiles.isEmpty()) {
+ // We must revalidate immediately instead of using a timer when there are
+ // no tiles to avoid a flash when transitioning from one page to another.
+ revalidateTiles();
+ return;
+ }
+
+ scheduleTileRevalidation(0);
+}
+
+void TileController::setNeedsDisplay()
+{
+ for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
+ const TileInfo& tileInfo = it->value;
+ [tileInfo.layer.get() setNeedsDisplay];
+ }
+}
+
+void TileController::setNeedsDisplayInRect(const IntRect& rect)
+{
+ if (m_tiles.isEmpty())
+ return;
+
+ FloatRect scaledRect(rect);
+ scaledRect.scale(m_scale);
+ IntRect repaintRectInTileCoords(enclosingIntRect(scaledRect));
+
+ // For small invalidations, lookup the covered tiles.
+ if (repaintRectInTileCoords.height() < 2 * m_tileSize.height() && repaintRectInTileCoords.width() < 2 * m_tileSize.width()) {
+ TileIndex topLeft;
+ TileIndex bottomRight;
+ getTileIndexRangeForRect(repaintRectInTileCoords, topLeft, bottomRight);
+
+ for (int y = topLeft.y(); y <= bottomRight.y(); ++y) {
+ for (int x = topLeft.x(); x <= bottomRight.x(); ++x) {
+ TileIndex tileIndex(x, y);
+
+ TileMap::iterator it = m_tiles.find(tileIndex);
+ if (it != m_tiles.end())
+ setTileNeedsDisplayInRect(tileIndex, it->value, repaintRectInTileCoords, m_primaryTileCoverageRect);
+ }
+ }
+ return;
+ }
+
+ for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it)
+ setTileNeedsDisplayInRect(it->key, it->value, repaintRectInTileCoords, m_primaryTileCoverageRect);
+}
+
+void TileController::setTileNeedsDisplayInRect(const TileIndex& tileIndex, TileInfo& tileInfo, const IntRect& repaintRectInTileCoords, const IntRect& coverageRectInTileCoords)
+{
+ WebTileLayer* tileLayer = tileInfo.layer.get();
+
+ IntRect tileRect = rectForTileIndex(tileIndex);
+ IntRect tileRepaintRect = tileRect;
+ tileRepaintRect.intersect(repaintRectInTileCoords);
+ if (tileRepaintRect.isEmpty())
+ return;
+
+ tileRepaintRect.moveBy(-tileRect.location());
+
+ // We could test for intersection with the visible rect. This would reduce painting yet more,
+ // but may make scrolling stale tiles into view more frequent.
+ if (tileRect.intersects(coverageRectInTileCoords)) {
+ [tileLayer setNeedsDisplayInRect:tileRepaintRect];
+
+ if (shouldShowRepaintCounters()) {
+ CGRect bounds = [tileLayer bounds];
+ CGRect indicatorRect = CGRectMake(bounds.origin.x, bounds.origin.y, 52, 27);
+ [tileLayer setNeedsDisplayInRect:indicatorRect];
+ }
+ } else
+ tileInfo.hasStaleContent = true;
+}
+
+
+void TileController::drawLayer(WebTileLayer *layer, CGContextRef context)
+{
+ PlatformCALayer* platformLayer = PlatformCALayer::platformCALayer(m_tileCacheLayer);
+ if (!platformLayer)
+ return;
+
+ CGContextSaveGState(context);
+
+ CGPoint layerOrigin = [layer frame].origin;
+ CGContextTranslateCTM(context, -layerOrigin.x, -layerOrigin.y);
+ CGContextScaleCTM(context, m_scale, m_scale);
+ drawLayerContents(context, layer, platformLayer);
+
+ CGContextRestoreGState(context);
+
+ drawRepaintCounter(layer, context);
+}
+
+void TileController::setScale(CGFloat scale)
+{
+ PlatformCALayer* platformLayer = PlatformCALayer::platformCALayer(m_tileCacheLayer);
+ float deviceScaleFactor = platformLayer->owner()->platformCALayerDeviceScaleFactor();
+
+ // The scale we get is the produce of the page scale factor and device scale factor.
+ // Divide by the device scale factor so we'll get the page scale factor.
+ scale /= deviceScaleFactor;
+
+ if (m_scale == scale && m_deviceScaleFactor == deviceScaleFactor)
+ return;
+
+#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
+ Vector<FloatRect> dirtyRects;
+
+ m_deviceScaleFactor = deviceScaleFactor;
+ m_scale = scale;
+ [m_tileContainerLayer.get() setTransform:CATransform3DMakeScale(1 / m_scale, 1 / m_scale, 1)];
+
+ revalidateTiles(PruneSecondaryTiles, PruneSecondaryTiles);
+
+ for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
+ const TileInfo& tileInfo = it->value;
+ [tileInfo.layer.get() setContentsScale:deviceScaleFactor];
+
+ IntRect tileRect = rectForTileIndex(it->key);
+ FloatRect scaledTileRect = tileRect;
+
+ scaledTileRect.scale(1 / m_scale);
+ dirtyRects.append(scaledTileRect);
+ }
+
+ platformLayer->owner()->platformCALayerDidCreateTiles(dirtyRects);
+#endif
+}
+
+void TileController::setAcceleratesDrawing(bool acceleratesDrawing)
+{
+#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
+ if (m_acceleratesDrawing == acceleratesDrawing)
+ return;
+
+ m_acceleratesDrawing = acceleratesDrawing;
+
+ for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
+ const TileInfo& tileInfo = it->value;
+ [tileInfo.layer.get() setAcceleratesDrawing:m_acceleratesDrawing];
+ }
+#else
+ UNUSED_PARAM(acceleratesDrawing);
+#endif
+}
+
+void TileController::setTilesOpaque(bool opaque)
+{
+ if (opaque == m_tilesAreOpaque)
+ return;
+
+ m_tilesAreOpaque = opaque;
+
+ for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
+ const TileInfo& tileInfo = it->value;
+ [tileInfo.layer.get() setOpaque:opaque];
+ }
+}
+
+void TileController::setVisibleRect(const FloatRect& visibleRect)
+{
+ if (m_visibleRect == visibleRect)
+ return;
+
+ m_visibleRect = visibleRect;
+ revalidateTiles();
+}
+
+bool TileController::tilesWouldChangeForVisibleRect(const FloatRect& newVisibleRect) const
+{
+ FloatRect visibleRect = newVisibleRect;
+
+ if (m_clipsToExposedRect)
+ visibleRect.intersect(m_exposedRect);
+
+ if (visibleRect.isEmpty() || bounds().isEmpty())
+ return false;
+
+ FloatRect currentTileCoverageRect = computeTileCoverageRect(m_visibleRect, newVisibleRect);
+ FloatRect scaledRect(currentTileCoverageRect);
+ scaledRect.scale(m_scale);
+ IntRect currentCoverageRectInTileCoords(enclosingIntRect(scaledRect));
+
+ IntSize newTileSize = tileSizeForCoverageRect(currentTileCoverageRect);
+ bool tileSizeChanged = newTileSize != m_tileSize;
+ if (tileSizeChanged)
+ return true;
+
+ TileIndex topLeft;
+ TileIndex bottomRight;
+ getTileIndexRangeForRect(currentCoverageRectInTileCoords, topLeft, bottomRight);
+
+ IntRect coverageRect = rectForTileIndex(topLeft);
+ coverageRect.unite(rectForTileIndex(bottomRight));
+ return coverageRect != m_primaryTileCoverageRect;
+}
+
+void TileController::setExposedRect(const FloatRect& exposedRect)
+{
+ if (m_exposedRect == exposedRect)
+ return;
+
+ m_exposedRect = exposedRect;
+ revalidateTiles();
+}
+
+void TileController::setClipsToExposedRect(bool clipsToExposedRect)
+{
+ if (m_clipsToExposedRect == clipsToExposedRect)
+ return;
+
+ m_clipsToExposedRect = clipsToExposedRect;
+
+ // Going from not clipping to clipping, we don't need to revalidate right away.
+ if (clipsToExposedRect)
+ revalidateTiles();
+}
+
+void TileController::prepopulateRect(const FloatRect& rect)
+{
+ ensureTilesForRect(rect);
+}
+
+void TileController::setIsInWindow(bool isInWindow)
+{
+ if (m_isInWindow == isInWindow)
+ return;
+
+ m_isInWindow = isInWindow;
+
+ if (m_isInWindow)
+ revalidateTiles();
+ else {
+ const double tileRevalidationTimeout = 4;
+ scheduleTileRevalidation(tileRevalidationTimeout);
+ }
+}
+
+void TileController::setTileCoverage(TileCoverage coverage)
+{
+ if (coverage == m_tileCoverage)
+ return;
+
+ m_tileCoverage = coverage;
+ scheduleTileRevalidation(0);
+}
+
+void TileController::forceRepaint()
+{
+ setNeedsDisplay();
+}
+
+void TileController::setTileDebugBorderWidth(float borderWidth)
+{
+ if (m_tileDebugBorderWidth == borderWidth)
+ return;
+
+ m_tileDebugBorderWidth = borderWidth;
+ for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
+ const TileInfo& tileInfo = it->value;
+ [tileInfo.layer.get() setBorderWidth:m_tileDebugBorderWidth];
+ }
+}
+
+void TileController::setTileDebugBorderColor(CGColorRef borderColor)
+{
+ if (m_tileDebugBorderColor == borderColor)
+ return;
+
+ m_tileDebugBorderColor = borderColor;
+ for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
+ const TileInfo& tileInfo = it->value;
+ [tileInfo.layer.get() setBorderColor:m_tileDebugBorderColor.get()];
+ }
+}
+
+IntRect TileController::bounds() const
+{
+ return IntRect(IntPoint(), IntSize([m_tileCacheLayer bounds].size));
+}
+
+IntRect TileController::rectForTileIndex(const TileIndex& tileIndex) const
+{
+ IntRect rect(tileIndex.x() * m_tileSize.width(), tileIndex.y() * m_tileSize.height(), m_tileSize.width(), m_tileSize.height());
+ IntRect scaledBounds(bounds());
+ scaledBounds.scale(m_scale);
+
+ rect.intersect(scaledBounds);
+
+ return rect;
+}
+
+void TileController::getTileIndexRangeForRect(const IntRect& rect, TileIndex& topLeft, TileIndex& bottomRight) const
+{
+ IntRect clampedRect = bounds();
+ clampedRect.scale(m_scale);
+ clampedRect.intersect(rect);
+
+ topLeft.setX(max(clampedRect.x() / m_tileSize.width(), 0));
+ topLeft.setY(max(clampedRect.y() / m_tileSize.height(), 0));
+
+ int bottomXRatio = ceil((float)clampedRect.maxX() / m_tileSize.width());
+ bottomRight.setX(max(bottomXRatio - 1, 0));
+
+ int bottomYRatio = ceil((float)clampedRect.maxY() / m_tileSize.height());
+ bottomRight.setY(max(bottomYRatio - 1, 0));
+}
+
+FloatRect TileController::computeTileCoverageRect(const FloatRect& previousVisibleRect, const FloatRect& currentVisibleRect) const
+{
+ FloatRect visibleRect = currentVisibleRect;
+
+ if (m_clipsToExposedRect)
+ visibleRect.intersect(m_exposedRect);
+
+ // If the page is not in a window (for example if it's in a background tab), we limit the tile coverage rect to the visible rect.
+ // Furthermore, if the page can't have scrollbars (for example if its body element has overflow:hidden) it's very unlikely that the
+ // page will ever be scrolled so we limit the tile coverage rect as well.
+ if (!m_isInWindow || m_tileCoverage & CoverageForSlowScrolling)
+ return visibleRect;
+
+ bool largeVisibleRectChange = !previousVisibleRect.isEmpty() && !visibleRect.intersects(previousVisibleRect);
+
+ // FIXME: look at how far the document can scroll in each dimension.
+ float coverageHorizontalSize = visibleRect.width();
+ float coverageVerticalSize = visibleRect.height();
+
+ // Inflate the coverage rect so that it covers 2x of the visible width and 3x of the visible height.
+ // These values were chosen because it's more common to have tall pages and to scroll vertically,
+ // so we keep more tiles above and below the current area.
+ if (m_tileCoverage & CoverageForHorizontalScrolling && !largeVisibleRectChange)
+ coverageHorizontalSize *= 2;
+
+ if (m_tileCoverage & CoverageForVerticalScrolling && !largeVisibleRectChange)
+ coverageVerticalSize *= 3;
+
+ // Don't extend coverage before 0 or after the end.
+ FloatRect coverageBounds = bounds();
+ float coverageLeft = visibleRect.x() - (coverageHorizontalSize - visibleRect.width()) / 2;
+ coverageLeft = min(coverageLeft, coverageBounds.maxX() - coverageHorizontalSize);
+ coverageLeft = max(coverageLeft, coverageBounds.x());
+
+ float coverageTop = visibleRect.y() - (coverageVerticalSize - visibleRect.height()) / 2;
+ coverageTop = min(coverageTop, coverageBounds.maxY() - coverageVerticalSize);
+ coverageTop = max(coverageTop, coverageBounds.y());
+
+ return FloatRect(coverageLeft, coverageTop, coverageHorizontalSize, coverageVerticalSize);
+}
+
+IntSize TileController::tileSizeForCoverageRect(const FloatRect& coverageRect) const
+{
+ if (m_tileCoverage & CoverageForSlowScrolling) {
+ FloatSize tileSize = coverageRect.size();
+ tileSize.scale(m_scale);
+ return expandedIntSize(tileSize);
+ }
+
+ return IntSize(defaultTileWidth, defaultTileHeight);
+}
+
+void TileController::scheduleTileRevalidation(double interval)
+{
+ if (m_tileRevalidationTimer.isActive() && m_tileRevalidationTimer.nextFireInterval() < interval)
+ return;
+
+ m_tileRevalidationTimer.startOneShot(interval);
+}
+
+void TileController::tileRevalidationTimerFired(Timer<TileController>*)
+{
+ TileValidationPolicyFlags foregroundValidationPolicy = m_aggressivelyRetainsTiles ? 0 : PruneSecondaryTiles;
+ TileValidationPolicyFlags backgroundValidationPolicy = foregroundValidationPolicy | UnparentAllTiles;
+
+ revalidateTiles(foregroundValidationPolicy, backgroundValidationPolicy);
+}
+
+unsigned TileController::blankPixelCount() const
+{
+ WebTileLayerList tiles(m_tiles.size());
+
+ for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it)
+ tiles.append(it->value.layer);
+
+ return blankPixelCountForTiles(tiles, m_visibleRect, IntPoint(0,0));
+}
+
+unsigned TileController::blankPixelCountForTiles(const WebTileLayerList& tiles, const FloatRect& visibleRect, const IntPoint& tileTranslation)
+{
+ Region paintedVisibleTiles;
+
+ for (WebTileLayerList::const_iterator it = tiles.begin(), end = tiles.end(); it != end; ++it) {
+ const WebTileLayer* tileLayer = it->get();
+
+ FloatRect visiblePart(CGRectOffset([tileLayer frame], tileTranslation.x(), tileTranslation.y()));
+ visiblePart.intersect(visibleRect);
+
+ if (!visiblePart.isEmpty())
+ paintedVisibleTiles.unite(enclosingIntRect(visiblePart));
+ }
+
+ Region uncoveredRegion(enclosingIntRect(visibleRect));
+ uncoveredRegion.subtract(paintedVisibleTiles);
+
+ return uncoveredRegion.totalArea();
+}
+
+static inline void queueTileForRemoval(const TileController::TileIndex& tileIndex, const TileController::TileInfo& tileInfo, Vector<TileController::TileIndex>& tilesToRemove)
+{
+ WebTileLayer* tileLayer = tileInfo.layer.get();
+ [tileLayer removeFromSuperlayer];
+ [tileLayer setTileController:0];
+ tilesToRemove.append(tileIndex);
+}
+
+void TileController::removeAllTiles()
+{
+ Vector<TileIndex> tilesToRemove;
+
+ for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it)
+ queueTileForRemoval(it->key, it->value, tilesToRemove);
+
+ for (size_t i = 0; i < tilesToRemove.size(); ++i) {
+ TileInfo tileInfo = m_tiles.take(tilesToRemove[i]);
+ LayerPool::sharedPool()->addLayer(tileInfo.layer);
+ }
+}
+
+void TileController::removeAllSecondaryTiles()
+{
+ Vector<TileIndex> tilesToRemove;
+
+ for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
+ const TileInfo& tileInfo = it->value;
+ if (tileInfo.cohort == VisibleTileCohort)
+ continue;
+
+ queueTileForRemoval(it->key, it->value, tilesToRemove);
+ }
+
+ for (size_t i = 0; i < tilesToRemove.size(); ++i) {
+ TileInfo tileInfo = m_tiles.take(tilesToRemove[i]);
+ LayerPool::sharedPool()->addLayer(tileInfo.layer);
+ }
+}
+
+void TileController::removeTilesInCohort(TileCohort cohort)
+{
+ ASSERT(cohort != VisibleTileCohort);
+ Vector<TileIndex> tilesToRemove;
+
+ for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
+ const TileInfo& tileInfo = it->value;
+ if (tileInfo.cohort != cohort)
+ continue;
+
+ queueTileForRemoval(it->key, it->value, tilesToRemove);
+ }
+
+ for (size_t i = 0; i < tilesToRemove.size(); ++i) {
+ TileInfo tileInfo = m_tiles.take(tilesToRemove[i]);
+ LayerPool::sharedPool()->addLayer(tileInfo.layer);
+ }
+}
+
+void TileController::revalidateTiles(TileValidationPolicyFlags foregroundValidationPolicy, TileValidationPolicyFlags backgroundValidationPolicy)
+{
+ // If the underlying PlatformLayer has been destroyed, but the WebTiledBackingLayer hasn't
+ // platformLayer will be null here.
+ PlatformCALayer* platformLayer = PlatformCALayer::platformCALayer(m_tileCacheLayer);
+ if (!platformLayer)
+ return;
+
+ FloatRect visibleRect = m_visibleRect;
+ IntRect bounds = this->bounds();
+
+ if (m_clipsToExposedRect)
+ visibleRect.intersect(m_exposedRect);
+
+ if (visibleRect.isEmpty() || bounds.isEmpty())
+ return;
+
+ TileValidationPolicyFlags validationPolicy = m_isInWindow ? foregroundValidationPolicy : backgroundValidationPolicy;
+
+ FloatRect tileCoverageRect = computeTileCoverageRect(m_visibleRectAtLastRevalidate, m_visibleRect);
+ FloatRect scaledRect(tileCoverageRect);
+ scaledRect.scale(m_scale);
+ IntRect coverageRectInTileCoords(enclosingIntRect(scaledRect));
+
+ IntSize oldTileSize = m_tileSize;
+ m_tileSize = tileSizeForCoverageRect(tileCoverageRect);
+ bool tileSizeChanged = m_tileSize != oldTileSize;
+
+ if (tileSizeChanged) {
+ removeAllTiles();
+ m_cohortList.clear();
+ } else {
+ TileCohort currCohort = nextTileCohort();
+ unsigned tilesInCohort = 0;
+
+ // Move tiles newly outside the coverage rect into the cohort map.
+ for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
+ TileInfo& tileInfo = it->value;
+ TileIndex tileIndex = it->key;
+
+ WebTileLayer* tileLayer = tileInfo.layer.get();
+ IntRect tileRect = rectForTileIndex(tileIndex);
+ if (tileRect.intersects(coverageRectInTileCoords)) {
+ tileInfo.cohort = VisibleTileCohort;
+ if (tileInfo.hasStaleContent) {
+ // FIXME: store a dirty region per layer?
+ [tileLayer setNeedsDisplay];
+ tileInfo.hasStaleContent = false;
+ }
+ } else {
+ // Add to the currentCohort if not already in one.
+ if (tileInfo.cohort == VisibleTileCohort) {
+ tileInfo.cohort = currCohort;
+ ++tilesInCohort;
+
+ if (m_unparentsOffscreenTiles)
+ [tileInfo.layer.get() removeFromSuperlayer];
+ }
+ }
+ }
+
+ if (tilesInCohort)
+ startedNewCohort(currCohort);
+
+ if (!m_aggressivelyRetainsTiles)
+ scheduleCohortRemoval();
+ }
+
+ TileIndex topLeft;
+ TileIndex bottomRight;
+ getTileIndexRangeForRect(coverageRectInTileCoords, topLeft, bottomRight);
+
+ Vector<FloatRect> dirtyRects;
+
+ // Ensure primary tile coverage tiles.
+ m_primaryTileCoverageRect = IntRect();
+
+ for (int y = topLeft.y(); y <= bottomRight.y(); ++y) {
+ for (int x = topLeft.x(); x <= bottomRight.x(); ++x) {
+ TileIndex tileIndex(x, y);
+
+ IntRect tileRect = rectForTileIndex(tileIndex);
+ m_primaryTileCoverageRect.unite(tileRect);
+
+ bool shouldChangeTileLayerFrame = false;
+
+ TileInfo& tileInfo = m_tiles.add(tileIndex, TileInfo()).iterator->value;
+ if (!tileInfo.layer)
+ tileInfo.layer = createTileLayer(tileRect);
+ else {
+ // We already have a layer for this tile. Ensure that its size is correct.
+ FloatSize tileLayerSize([tileInfo.layer.get() frame].size);
+ shouldChangeTileLayerFrame = tileLayerSize != FloatSize(tileRect.size());
+
+ if (shouldChangeTileLayerFrame)
+ [tileInfo.layer.get() setFrame:tileRect];
+ }
+
+ bool shouldParentTileLayer = (!m_unparentsOffscreenTiles || m_isInWindow) && ![tileInfo.layer.get() superlayer];
+
+ if (shouldParentTileLayer)
+ [m_tileContainerLayer.get() addSublayer:tileInfo.layer.get()];
+
+ if ((shouldParentTileLayer && [tileInfo.layer.get() needsDisplay]) || shouldChangeTileLayerFrame) {
+ FloatRect scaledTileRect = tileRect;
+ scaledTileRect.scale(1 / m_scale);
+ dirtyRects.append(scaledTileRect);
+ }
+ }
+ }
+
+ if (validationPolicy & PruneSecondaryTiles) {
+ removeAllSecondaryTiles();
+ m_cohortList.clear();
+ }
+
+ if (m_unparentsOffscreenTiles && (validationPolicy & UnparentAllTiles)) {
+ for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it)
+ [it->value.layer.get() removeFromSuperlayer];
+ }
+
+ if (m_boundsAtLastRevalidate != bounds) {
+ FloatRect scaledBounds(bounds);
+ scaledBounds.scale(m_scale);
+ IntRect boundsInTileCoords(enclosingIntRect(scaledBounds));
+
+ TileIndex topLeftForBounds;
+ TileIndex bottomRightForBounds;
+ getTileIndexRangeForRect(boundsInTileCoords, topLeftForBounds, bottomRightForBounds);
+
+ Vector<TileIndex> tilesToRemove;
+ for (TileMap::iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
+ const TileIndex& index = it->key;
+ if (index.y() < topLeftForBounds.y()
+ || index.y() > bottomRightForBounds.y()
+ || index.x() < topLeftForBounds.x()
+ || index.x() > bottomRightForBounds.x())
+ queueTileForRemoval(index, it->value, tilesToRemove);
+ }
+
+ for (size_t i = 0, size = tilesToRemove.size(); i < size; ++i) {
+ TileInfo tileInfo = m_tiles.take(tilesToRemove[i]);
+ LayerPool::sharedPool()->addLayer(tileInfo.layer);
+ }
+ }
+
+ if (m_tiledScrollingIndicatorLayer)
+ updateTileCoverageMap();
+
+ m_visibleRectAtLastRevalidate = visibleRect;
+ m_boundsAtLastRevalidate = bounds;
+
+ if (dirtyRects.isEmpty())
+ return;
+
+ // This will ensure we flush compositing state and do layout in this run loop iteration.
+ platformLayer->owner()->platformCALayerDidCreateTiles(dirtyRects);
+}
+
+TileController::TileCohort TileController::nextTileCohort() const
+{
+ if (!m_cohortList.isEmpty())
+ return m_cohortList.last().cohort + 1;
+
+ return 1;
+}
+
+void TileController::startedNewCohort(TileCohort cohort)
+{
+ m_cohortList.append(TileCohortInfo(cohort, monotonicallyIncreasingTime()));
+}
+
+TileController::TileCohort TileController::newestTileCohort() const
+{
+ return m_cohortList.isEmpty() ? 0 : m_cohortList.last().cohort;
+}
+
+TileController::TileCohort TileController::oldestTileCohort() const
+{
+ return m_cohortList.isEmpty() ? 0 : m_cohortList.first().cohort;
+}
+
+void TileController::scheduleCohortRemoval()
+{
+ const double cohortRemovalTimerSeconds = 1;
+
+ // Start the timer, or reschedule the timer from now if it's already active.
+ if (!m_cohortRemovalTimer.isActive())
+ m_cohortRemovalTimer.startRepeating(cohortRemovalTimerSeconds);
+}
+
+void TileController::cohortRemovalTimerFired(Timer<TileController>*)
+{
+ if (m_cohortList.isEmpty()) {
+ m_cohortRemovalTimer.stop();
+ return;
+ }
+
+ double cohortLifeTimeSeconds = 2;
+ double timeThreshold = monotonicallyIncreasingTime() - cohortLifeTimeSeconds;
+
+ while (!m_cohortList.isEmpty() && m_cohortList.first().creationTime < timeThreshold) {
+ TileCohortInfo firstCohort = m_cohortList.takeFirst();
+ removeTilesInCohort(firstCohort.cohort);
+ }
+
+ if (m_tiledScrollingIndicatorLayer)
+ updateTileCoverageMap();
+}
+
+void TileController::ensureTilesForRect(const FloatRect& rect)
+{
+ if (m_unparentsOffscreenTiles && !m_isInWindow)
+ return;
+
+ PlatformCALayer* platformLayer = PlatformCALayer::platformCALayer(m_tileCacheLayer);
+ if (!platformLayer)
+ return;
+
+ FloatRect scaledRect(rect);
+ scaledRect.scale(m_scale);
+ IntRect rectInTileCoords(enclosingIntRect(scaledRect));
+
+ if (m_primaryTileCoverageRect.contains(rectInTileCoords))
+ return;
+
+ TileIndex topLeft;
+ TileIndex bottomRight;
+ getTileIndexRangeForRect(rectInTileCoords, topLeft, bottomRight);
+
+ Vector<FloatRect> dirtyRects;
+ TileCohort currCohort = nextTileCohort();
+ unsigned tilesInCohort = 0;
+
+ for (int y = topLeft.y(); y <= bottomRight.y(); ++y) {
+ for (int x = topLeft.x(); x <= bottomRight.x(); ++x) {
+ TileIndex tileIndex(x, y);
+
+ IntRect tileRect = rectForTileIndex(tileIndex);
+ TileInfo& tileInfo = m_tiles.add(tileIndex, TileInfo()).iterator->value;
+
+ bool shouldChangeTileLayerFrame = false;
+
+ if (!tileInfo.layer)
+ tileInfo.layer = createTileLayer(tileRect);
+ else {
+ // We already have a layer for this tile. Ensure that its size is correct.
+ CGSize tileLayerSize = [tileInfo.layer.get() frame].size;
+ shouldChangeTileLayerFrame = tileLayerSize.width < tileRect.width() || tileLayerSize.height < tileRect.height();
+
+ if (shouldChangeTileLayerFrame)
+ [tileInfo.layer.get() setFrame:tileRect];
+ }
+
+ if (!tileRect.intersects(m_primaryTileCoverageRect)) {
+ tileInfo.cohort = currCohort;
+ ++tilesInCohort;
+ }
+
+ bool shouldParentTileLayer = ![tileInfo.layer.get() superlayer];
+
+ if (shouldParentTileLayer)
+ [m_tileContainerLayer.get() addSublayer:tileInfo.layer.get()];
+
+ if ((shouldParentTileLayer && [tileInfo.layer.get() needsDisplay]) || shouldChangeTileLayerFrame) {
+ FloatRect scaledTileRect = tileRect;
+ scaledTileRect.scale(1 / m_scale);
+ dirtyRects.append(scaledTileRect);
+ }
+ }
+ }
+
+ if (tilesInCohort)
+ startedNewCohort(currCohort);
+
+ if (m_tiledScrollingIndicatorLayer)
+ updateTileCoverageMap();
+
+ // This will ensure we flush compositing state and do layout in this run loop iteration.
+ if (!dirtyRects.isEmpty())
+ platformLayer->owner()->platformCALayerDidCreateTiles(dirtyRects);
+}
+
+void TileController::updateTileCoverageMap()
+{
+ FloatRect containerBounds = bounds();
+ FloatRect visibleRect = this->visibleRect();
+
+ if (m_clipsToExposedRect)
+ visibleRect.intersect(m_exposedRect);
+
+ visibleRect.contract(4, 4); // Layer is positioned 2px from top and left edges.
+
+ float widthScale = 1;
+ float scale = 1;
+ if (!containerBounds.isEmpty()) {
+ widthScale = std::min<float>(visibleRect.width() / containerBounds.width(), 0.1);
+ scale = std::min(widthScale, visibleRect.height() / containerBounds.height());
+ }
+
+ float indicatorScale = scale * m_scale;
+ FloatRect mapBounds = containerBounds;
+ mapBounds.scale(indicatorScale, indicatorScale);
+
+ BEGIN_BLOCK_OBJC_EXCEPTIONS
+
+ if (m_clipsToExposedRect)
+ [m_tiledScrollingIndicatorLayer.get() setPosition:m_exposedRect.location() + FloatPoint(2, 2)];
+ else
+ [m_tiledScrollingIndicatorLayer.get() setPosition:CGPointMake(2, 2)];
+
+ [m_tiledScrollingIndicatorLayer.get() setBounds:mapBounds];
+ [m_tiledScrollingIndicatorLayer.get() setNeedsDisplay];
+
+ visibleRect.scale(indicatorScale, indicatorScale);
+ visibleRect.expand(2, 2);
+ [[m_tiledScrollingIndicatorLayer.get() visibleRectFrameLayer] setFrame:visibleRect];
+
+ Color backgroundColor;
+ switch (m_indicatorMode) {
+ case MainThreadScrollingBecauseOfStyleIndication:
+ backgroundColor = Color(255, 0, 0);
+ break;
+ case MainThreadScrollingBecauseOfEventHandlersIndication:
+ backgroundColor = Color(255, 255, 0);
+ break;
+ case ThreadedScrollingIndication:
+ backgroundColor = Color(0, 200, 0);
+ break;
+ }
+
+ [[m_tiledScrollingIndicatorLayer.get() visibleRectFrameLayer] setBorderColor:cachedCGColor(backgroundColor, ColorSpaceDeviceRGB)];
+
+ END_BLOCK_OBJC_EXCEPTIONS
+}
+
+IntRect TileController::tileGridExtent() const
+{
+ TileIndex topLeft;
+ TileIndex bottomRight;
+ getTileIndexRangeForRect(m_primaryTileCoverageRect, topLeft, bottomRight);
+
+ // Return index of top, left tile and the number of tiles across and down.
+ return IntRect(topLeft.x(), topLeft.y(), bottomRight.x() - topLeft.x() + 1, bottomRight.y() - topLeft.y() + 1);
+}
+
+double TileController::retainedTileBackingStoreMemory() const
+{
+ double totalBytes = 0;
+
+ for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
+ const TileInfo& tileInfo = it->value;
+ if ([tileInfo.layer.get() superlayer]) {
+ CGRect bounds = [tileInfo.layer.get() bounds];
+ double contentsScale = [tileInfo.layer.get() contentsScale];
+ totalBytes += 4 * bounds.size.width * contentsScale * bounds.size.height * contentsScale;
+ }
+ }
+
+ return totalBytes;
+}
+
+// Return the rect in layer coords, not tile coords.
+IntRect TileController::tileCoverageRect() const
+{
+ IntRect coverageRectInLayerCoords(m_primaryTileCoverageRect);
+ coverageRectInLayerCoords.scale(1 / m_scale);
+ return coverageRectInLayerCoords;
+}
+
+CALayer *TileController::tiledScrollingIndicatorLayer()
+{
+ if (!m_tiledScrollingIndicatorLayer) {
+ m_tiledScrollingIndicatorLayer = [WebTiledScrollingIndicatorLayer layer];
+ [m_tiledScrollingIndicatorLayer.get() setTileController:this];
+ [m_tiledScrollingIndicatorLayer.get() setOpacity:0.75];
+ [m_tiledScrollingIndicatorLayer.get() setAnchorPoint:CGPointZero];
+ [m_tiledScrollingIndicatorLayer.get() setBorderColor:cachedCGColor(Color::black, ColorSpaceDeviceRGB)];
+ [m_tiledScrollingIndicatorLayer.get() setBorderWidth:1];
+ [m_tiledScrollingIndicatorLayer.get() setPosition:CGPointMake(2, 2)];
+ updateTileCoverageMap();
+ }
+
+ return m_tiledScrollingIndicatorLayer.get();
+}
+
+void TileController::setScrollingModeIndication(ScrollingModeIndication scrollingMode)
+{
+ if (scrollingMode == m_indicatorMode)
+ return;
+
+ m_indicatorMode = scrollingMode;
+
+ if (m_tiledScrollingIndicatorLayer)
+ updateTileCoverageMap();
+}
+
+WebTileLayer* TileController::tileLayerAtIndex(const TileIndex& index) const
+{
+ return m_tiles.get(index).layer.get();
+}
+
+RetainPtr<WebTileLayer> TileController::createTileLayer(const IntRect& tileRect)
+{
+ RetainPtr<WebTileLayer> layer = LayerPool::sharedPool()->takeLayerWithSize(tileRect.size());
+ if (layer)
+ [layer resetPaintCount];
+ else
+ layer = adoptNS([[WebTileLayer alloc] init]);
+ [layer.get() setAnchorPoint:CGPointZero];
+ [layer.get() setFrame:tileRect];
+ [layer.get() setTileController:this];
+ [layer.get() setBorderColor:m_tileDebugBorderColor.get()];
+ [layer.get() setBorderWidth:m_tileDebugBorderWidth];
+ [layer.get() setEdgeAntialiasingMask:0];
+ [layer.get() setOpaque:m_tilesAreOpaque];
+#ifndef NDEBUG
+ [layer.get() setName:@"Tile"];
+#endif
+
+#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
+ [layer.get() setContentsScale:m_deviceScaleFactor];
+ [layer.get() setAcceleratesDrawing:m_acceleratesDrawing];
+#endif
+
+ [layer setNeedsDisplay];
+
+ return layer;
+}
+
+bool TileController::shouldShowRepaintCounters() const
+{
+ PlatformCALayer* platformLayer = PlatformCALayer::platformCALayer(m_tileCacheLayer);
+ if (!platformLayer)
+ return false;
+
+ WebCore::PlatformCALayerClient* layerContents = platformLayer->owner();
+ ASSERT(layerContents);
+ if (!layerContents)
+ return false;
+
+ return layerContents->platformCALayerShowRepaintCounter(0);
+}
+
+void TileController::drawRepaintCounter(WebTileLayer *layer, CGContextRef context)
+{
+ unsigned paintCount = [layer incrementPaintCount];
+ if (!shouldShowRepaintCounters())
+ return;
+
+ // FIXME: Some of this code could be shared with WebLayer.
+ char text[16]; // that's a lot of repaints
+ snprintf(text, sizeof(text), "%d", paintCount);
+
+ CGRect indicatorBox = [layer bounds];
+ indicatorBox.size.width = 12 + 10 * strlen(text);
+ indicatorBox.size.height = 27;
+ CGContextSaveGState(context);
+
+ CGContextSetAlpha(context, 0.5f);
+ CGContextBeginTransparencyLayerWithRect(context, indicatorBox, 0);
+
+ CGContextSetFillColorWithColor(context, m_tileDebugBorderColor.get());
+ CGContextFillRect(context, indicatorBox);
+
+ PlatformCALayer* platformLayer = PlatformCALayer::platformCALayer(m_tileCacheLayer);
+
+ if (platformLayer->acceleratesDrawing())
+ CGContextSetRGBFillColor(context, 1, 0, 0, 1);
+ else
+ CGContextSetRGBFillColor(context, 1, 1, 1, 1);
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ CGContextSetTextMatrix(context, CGAffineTransformMakeScale(1, -1));
+ CGContextSelectFont(context, "Helvetica", 22, kCGEncodingMacRoman);
+ CGContextShowTextAtPoint(context, indicatorBox.origin.x + 5, indicatorBox.origin.y + 22, text, strlen(text));
+#pragma clang diagnostic pop
+
+ CGContextEndTransparencyLayer(context);
+ CGContextRestoreGState(context);
+}
+
+void TileController::drawTileMapContents(CGContextRef context, CGRect layerBounds)
+{
+ CGContextSetRGBFillColor(context, 0.3, 0.3, 0.3, 1);
+ CGContextFillRect(context, layerBounds);
+
+ CGFloat scaleFactor = layerBounds.size.width / bounds().width();
+
+ CGFloat contextScale = scaleFactor / scale();
+ CGContextScaleCTM(context, contextScale, contextScale);
+
+ for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
+ const TileInfo& tileInfo = it->value;
+ WebTileLayer* tileLayer = tileInfo.layer.get();
+
+ CGFloat red = 1;
+ CGFloat green = 1;
+ CGFloat blue = 1;
+ if (tileInfo.hasStaleContent) {
+ red = 0.25;
+ green = 0.125;
+ blue = 0;
+ }
+
+ TileCohort newestCohort = newestTileCohort();
+ TileCohort oldestCohort = oldestTileCohort();
+
+ if (!m_aggressivelyRetainsTiles && tileInfo.cohort != VisibleTileCohort && newestCohort > oldestCohort) {
+ float cohortProportion = static_cast<float>((newestCohort - tileInfo.cohort)) / (newestCohort - oldestCohort);
+ CGContextSetRGBFillColor(context, red, green, blue, 1 - cohortProportion);
+ } else
+ CGContextSetRGBFillColor(context, red, green, blue, 1);
+
+ if ([tileLayer superlayer]) {
+ CGContextSetLineWidth(context, 0.5 / contextScale);
+ CGContextSetRGBStrokeColor(context, 0, 0, 0, 1);
+ } else {
+ CGContextSetLineWidth(context, 1 / contextScale);
+ CGContextSetRGBStrokeColor(context, 0.2, 0.1, 0.9, 1);
+ }
+
+ CGRect frame = [tileLayer frame];
+ CGContextFillRect(context, frame);
+ CGContextStrokeRect(context, frame);
+ }
+}
+
+
+} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/ca/mac/WebTileLayer.h b/Source/WebCore/platform/graphics/ca/mac/WebTileLayer.h
index 4a2d5c102..e3a28bbe7 100644
--- a/Source/WebCore/platform/graphics/ca/mac/WebTileLayer.h
+++ b/Source/WebCore/platform/graphics/ca/mac/WebTileLayer.h
@@ -27,17 +27,18 @@
#define WebTileLayer_h
namespace WebCore {
- class TileCache;
+class TileController;
}
@interface WebTileLayer : CALayer {
- WebCore::TileCache* _tileCache;
- unsigned _repaintCount;
+ WebCore::TileController* _tileController;
+ unsigned _paintCount;
}
-- (void)setTileCache:(WebCore::TileCache*)tileCache;
-- (unsigned)incrementRepaintCount;
-- (unsigned)repaintCount;
+- (void)setTileController:(WebCore::TileController*)tileController;
+- (void)resetPaintCount;
+- (unsigned)incrementPaintCount;
+- (unsigned)paintCount;
@end
diff --git a/Source/WebCore/platform/graphics/ca/mac/WebTileLayer.mm b/Source/WebCore/platform/graphics/ca/mac/WebTileLayer.mm
index f81cd68c8..7bfa78e1b 100644
--- a/Source/WebCore/platform/graphics/ca/mac/WebTileLayer.mm
+++ b/Source/WebCore/platform/graphics/ca/mac/WebTileLayer.mm
@@ -26,9 +26,8 @@
#import "config.h"
#import "WebTileLayer.h"
-#import "TileCache.h"
+#import "TileController.h"
#import <wtf/CurrentTime.h>
-#import <wtf/UnusedParam.h>
using namespace WebCore;
@@ -48,36 +47,41 @@ using namespace WebCore;
- (void)drawInContext:(CGContextRef)context
{
- if (_tileCache) {
- _tileCache->drawLayer(self, context);
+ if (_tileController) {
+ _tileController->drawLayer(self, context);
- if (static_cast<TiledBacking*>(_tileCache)->scrollingPerformanceLoggingEnabled())
+ if (static_cast<TiledBacking*>(_tileController)->scrollingPerformanceLoggingEnabled())
[self logFilledFreshTile];
}
}
-- (void)setTileCache:(WebCore::TileCache*)tileCache
+- (void)setTileController:(WebCore::TileController*)tileController
{
- _tileCache = tileCache;
+ _tileController = tileController;
}
-- (unsigned)incrementRepaintCount
+- (void)resetPaintCount
{
- return ++_repaintCount;
+ _paintCount = 0;
}
-- (unsigned)repaintCount
+- (unsigned)incrementPaintCount
{
- return _repaintCount;
+ return ++_paintCount;
+}
+
+- (unsigned)paintCount
+{
+ return _paintCount;
}
- (void)logFilledFreshTile
{
- IntRect visiblePart(enclosingIntRect([self frame]));
- visiblePart.intersect(_tileCache->visibleRect());
+ FloatRect visiblePart([self frame]);
+ visiblePart.intersect(_tileController->visibleRect());
- if ([self repaintCount] == 1 && !visiblePart.isEmpty())
- WTFLogAlways("SCROLLING: Filled visible fresh tile. Time: %f Unfilled Pixels: %u\n", WTF::monotonicallyIncreasingTime(), _tileCache->blankPixelCount());
+ if ([self paintCount] == 1 && !visiblePart.isEmpty())
+ WTFLogAlways("SCROLLING: Filled visible fresh tile. Time: %f Unfilled Pixels: %u\n", WTF::monotonicallyIncreasingTime(), _tileController->blankPixelCount());
}
@end
diff --git a/Source/WebCore/platform/graphics/ca/mac/WebTileCacheLayer.h b/Source/WebCore/platform/graphics/ca/mac/WebTiledBackingLayer.h
index 1e63a501e..4a6d08c95 100644
--- a/Source/WebCore/platform/graphics/ca/mac/WebTileCacheLayer.h
+++ b/Source/WebCore/platform/graphics/ca/mac/WebTiledBackingLayer.h
@@ -22,21 +22,21 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
-#ifndef WebTileCacheLayer_h
-#define WebTileCacheLayer_h
+
+#ifndef WebTiledBackingLayer_h
+#define WebTiledBackingLayer_h
#import <QuartzCore/QuartzCore.h>
#import <wtf/OwnPtr.h>
namespace WebCore {
- class IntRect;
- class TileCache;
- class TiledBacking;
+class IntRect;
+class TileController;
+class TiledBacking;
}
-@interface WebTileCacheLayer : CALayer {
- OwnPtr<WebCore::TileCache> _tileCache;
+@interface WebTiledBackingLayer : CALayer {
+ OwnPtr<WebCore::TileController> _tileController;
}
- (CALayer *)tileContainerLayer;
@@ -45,4 +45,4 @@ namespace WebCore {
@end
-#endif // WebTileCacheLayer_h
+#endif // WebTiledBackingLayer_h
diff --git a/Source/WebCore/platform/graphics/ca/mac/WebTileCacheLayer.mm b/Source/WebCore/platform/graphics/ca/mac/WebTiledBackingLayer.mm
index d119f5bd2..95e42b08d 100644
--- a/Source/WebCore/platform/graphics/ca/mac/WebTileCacheLayer.mm
+++ b/Source/WebCore/platform/graphics/ca/mac/WebTiledBackingLayer.mm
@@ -24,15 +24,15 @@
*/
#import "config.h"
-#import "WebTileCacheLayer.h"
+#import "WebTiledBackingLayer.h"
#import "IntRect.h"
-#import "TileCache.h"
+#import "TileController.h"
#import <wtf/MainThread.h>
using namespace WebCore;
-@implementation WebTileCacheLayer
+@implementation WebTiledBackingLayer
- (id)init
{
@@ -40,16 +40,16 @@ using namespace WebCore;
if (!self)
return nil;
- _tileCache = TileCache::create(self);
+ _tileController = TileController::create(self);
#ifndef NDEBUG
- [self setName:@"WebTileCacheLayer"];
+ [self setName:@"WebTiledBackingLayer"];
#endif
return self;
}
- (void)dealloc
{
- ASSERT(!_tileCache);
+ ASSERT(!_tileController);
[super dealloc];
}
@@ -74,70 +74,70 @@ using namespace WebCore;
{
[super setBounds:bounds];
- _tileCache->tileCacheLayerBoundsChanged();
+ _tileController->tileCacheLayerBoundsChanged();
}
- (void)setOpaque:(BOOL)opaque
{
- _tileCache->setTilesOpaque(opaque);
+ _tileController->setTilesOpaque(opaque);
}
- (BOOL)isOpaque
{
- return _tileCache->tilesAreOpaque();
+ return _tileController->tilesAreOpaque();
}
- (void)setNeedsDisplay
{
- _tileCache->setNeedsDisplay();
+ _tileController->setNeedsDisplay();
}
- (void)setNeedsDisplayInRect:(CGRect)rect
{
- _tileCache->setNeedsDisplayInRect(enclosingIntRect(rect));
+ _tileController->setNeedsDisplayInRect(enclosingIntRect(rect));
}
- (void)setAcceleratesDrawing:(BOOL)acceleratesDrawing
{
- _tileCache->setAcceleratesDrawing(acceleratesDrawing);
+ _tileController->setAcceleratesDrawing(acceleratesDrawing);
}
- (BOOL)acceleratesDrawing
{
- return _tileCache->acceleratesDrawing();
+ return _tileController->acceleratesDrawing();
}
- (void)setContentsScale:(CGFloat)contentsScale
{
- _tileCache->setScale(contentsScale);
+ _tileController->setScale(contentsScale);
}
- (CALayer *)tileContainerLayer
{
- return _tileCache->tileContainerLayer();
+ return _tileController->tileContainerLayer();
}
- (WebCore::TiledBacking*)tiledBacking
{
- return _tileCache.get();
+ return _tileController.get();
}
- (void)invalidate
{
ASSERT(isMainThread());
- ASSERT(_tileCache);
- _tileCache = nullptr;
+ ASSERT(_tileController);
+ _tileController = nullptr;
}
- (void)setBorderColor:(CGColorRef)borderColor
{
- _tileCache->setTileDebugBorderColor(borderColor);
+ _tileController->setTileDebugBorderColor(borderColor);
}
- (void)setBorderWidth:(CGFloat)borderWidth
{
// Tiles adjoin, so halve the border width.
- _tileCache->setTileDebugBorderWidth(borderWidth / 2);
+ _tileController->setTileDebugBorderWidth(borderWidth / 2);
}
@end
diff --git a/Source/WebCore/platform/graphics/ca/win/PlatformCAAnimationWin.cpp b/Source/WebCore/platform/graphics/ca/win/PlatformCAAnimationWin.cpp
index 856a4fcad..749e19b98 100644
--- a/Source/WebCore/platform/graphics/ca/win/PlatformCAAnimationWin.cpp
+++ b/Source/WebCore/platform/graphics/ca/win/PlatformCAAnimationWin.cpp
@@ -36,7 +36,6 @@
#include <QuartzCore/CACFTimingFunction.h>
#include <QuartzCore/CACFValueFunction.h>
#include <QuartzCore/CACFVector.h>
-#include <wtf/UnusedParam.h>
#include <wtf/text/WTFString.h>
using namespace WebCore;
@@ -127,7 +126,7 @@ static RetainPtr<CACFTimingFunctionRef> toCACFTimingFunction(const TimingFunctio
ASSERT(timingFunction);
if (timingFunction->isCubicBezierTimingFunction()) {
const CubicBezierTimingFunction* ctf = static_cast<const CubicBezierTimingFunction*>(timingFunction);
- return RetainPtr<CACFTimingFunctionRef>(AdoptCF, CACFTimingFunctionCreate(static_cast<float>(ctf->x1()), static_cast<float>(ctf->y1()), static_cast<float>(ctf->x2()), static_cast<float>(ctf->y2())));
+ return adoptCF(CACFTimingFunctionCreate(static_cast<float>(ctf->x1()), static_cast<float>(ctf->y1()), static_cast<float>(ctf->x2()), static_cast<float>(ctf->y2())));
}
return CACFTimingFunctionGetFunctionWithName(kCACFTimingFunctionLinear);
@@ -147,9 +146,9 @@ PlatformCAAnimation::PlatformCAAnimation(AnimationType type, const String& keyPa
: m_type(type)
{
if (type == Basic)
- m_animation.adoptCF(CACFAnimationCreate(kCACFBasicAnimation));
+ m_animation = adoptCF(CACFAnimationCreate(kCACFBasicAnimation));
else
- m_animation.adoptCF(CACFAnimationCreate(kCACFKeyframeAnimation));
+ m_animation = adoptCF(CACFAnimationCreate(kCACFKeyframeAnimation));
CACFAnimationSetKeyPath(m_animation.get(), keyPath.createCFString().get());
}
@@ -337,7 +336,7 @@ void PlatformCAAnimation::setFromValue(float value)
if (animationType() != Basic)
return;
- RetainPtr<CFNumberRef> v(AdoptCF, CFNumberCreate(0, kCFNumberFloatType, &value));
+ RetainPtr<CFNumberRef> v = adoptCF(CFNumberCreate(0, kCFNumberFloatType, &value));
CACFAnimationSetFromValue(m_animation.get(), v.get());
}
@@ -346,7 +345,7 @@ void PlatformCAAnimation::setFromValue(const WebCore::TransformationMatrix& valu
if (animationType() != Basic)
return;
- RetainPtr<CACFVectorRef> v(AdoptCF, CACFVectorCreateTransform(value));
+ RetainPtr<CACFVectorRef> v = adoptCF(CACFVectorCreateTransform(value));
CACFAnimationSetFromValue(m_animation.get(), v.get());
}
@@ -356,7 +355,7 @@ void PlatformCAAnimation::setFromValue(const FloatPoint3D& value)
return;
float a[3] = { value.x(), value.y(), value.z() };
- RetainPtr<CACFVectorRef> v(AdoptCF, CACFVectorCreate(3, a));
+ RetainPtr<CACFVectorRef> v = adoptCF(CACFVectorCreate(3, a));
CACFAnimationSetFromValue(m_animation.get(), v.get());
}
@@ -366,7 +365,7 @@ void PlatformCAAnimation::setFromValue(const WebCore::Color& value)
return;
float a[4] = { value.red(), value.green(), value.blue(), value.alpha() };
- RetainPtr<CACFVectorRef> v(AdoptCF, CACFVectorCreate(4, a));
+ RetainPtr<CACFVectorRef> v = adoptCF(CACFVectorCreate(4, a));
CACFAnimationSetFromValue(m_animation.get(), v.get());
}
@@ -390,7 +389,7 @@ void PlatformCAAnimation::setToValue(float value)
if (animationType() != Basic)
return;
- RetainPtr<CFNumberRef> v(AdoptCF, CFNumberCreate(0, kCFNumberFloatType, &value));
+ RetainPtr<CFNumberRef> v = adoptCF(CFNumberCreate(0, kCFNumberFloatType, &value));
CACFAnimationSetToValue(m_animation.get(), v.get());
}
@@ -399,7 +398,7 @@ void PlatformCAAnimation::setToValue(const WebCore::TransformationMatrix& value)
if (animationType() != Basic)
return;
- RetainPtr<CACFVectorRef> v(AdoptCF, CACFVectorCreateTransform(value));
+ RetainPtr<CACFVectorRef> v = adoptCF(CACFVectorCreateTransform(value));
CACFAnimationSetToValue(m_animation.get(), v.get());
}
@@ -409,7 +408,7 @@ void PlatformCAAnimation::setToValue(const FloatPoint3D& value)
return;
float a[3] = { value.x(), value.y(), value.z() };
- RetainPtr<CACFVectorRef> v(AdoptCF, CACFVectorCreate(3, a));
+ RetainPtr<CACFVectorRef> v = adoptCF(CACFVectorCreate(3, a));
CACFAnimationSetToValue(m_animation.get(), v.get());
}
@@ -419,7 +418,7 @@ void PlatformCAAnimation::setToValue(const WebCore::Color& value)
return;
float a[4] = { value.red(), value.green(), value.blue(), value.alpha() };
- RetainPtr<CACFVectorRef> v(AdoptCF, CACFVectorCreate(4, a));
+ RetainPtr<CACFVectorRef> v = adoptCF(CACFVectorCreate(4, a));
CACFAnimationSetToValue(m_animation.get(), v.get());
}
@@ -445,9 +444,9 @@ void PlatformCAAnimation::setValues(const Vector<float>& value)
if (animationType() != Keyframe)
return;
- RetainPtr<CFMutableArrayRef> array(AdoptCF, CFArrayCreateMutable(0, value.size(), &kCFTypeArrayCallBacks));
+ RetainPtr<CFMutableArrayRef> array = adoptCF(CFArrayCreateMutable(0, value.size(), &kCFTypeArrayCallBacks));
for (size_t i = 0; i < value.size(); ++i) {
- RetainPtr<CFNumberRef> v(AdoptCF, CFNumberCreate(0, kCFNumberFloatType, &value[i]));
+ RetainPtr<CFNumberRef> v = adoptCF(CFNumberCreate(0, kCFNumberFloatType, &value[i]));
CFArrayAppendValue(array.get(), v.get());
}
@@ -459,9 +458,9 @@ void PlatformCAAnimation::setValues(const Vector<WebCore::TransformationMatrix>&
if (animationType() != Keyframe)
return;
- RetainPtr<CFMutableArrayRef> array(AdoptCF, CFArrayCreateMutable(0, value.size(), &kCFTypeArrayCallBacks));
+ RetainPtr<CFMutableArrayRef> array = adoptCF(CFArrayCreateMutable(0, value.size(), &kCFTypeArrayCallBacks));
for (size_t i = 0; i < value.size(); ++i) {
- RetainPtr<CACFVectorRef> v(AdoptCF, CACFVectorCreateTransform(value[i]));
+ RetainPtr<CACFVectorRef> v = adoptCF(CACFVectorCreateTransform(value[i]));
CFArrayAppendValue(array.get(), v.get());
}
@@ -473,10 +472,10 @@ void PlatformCAAnimation::setValues(const Vector<FloatPoint3D>& value)
if (animationType() != Keyframe)
return;
- RetainPtr<CFMutableArrayRef> array(AdoptCF, CFArrayCreateMutable(0, value.size(), &kCFTypeArrayCallBacks));
+ RetainPtr<CFMutableArrayRef> array = adoptCF(CFArrayCreateMutable(0, value.size(), &kCFTypeArrayCallBacks));
for (size_t i = 0; i < value.size(); ++i) {
float a[3] = { value[i].x(), value[i].y(), value[i].z() };
- RetainPtr<CACFVectorRef> v(AdoptCF, CACFVectorCreate(3, a));
+ RetainPtr<CACFVectorRef> v = adoptCF(CACFVectorCreate(3, a));
CFArrayAppendValue(array.get(), v.get());
}
@@ -488,10 +487,10 @@ void PlatformCAAnimation::setValues(const Vector<WebCore::Color>& value)
if (animationType() != Keyframe)
return;
- RetainPtr<CFMutableArrayRef> array(AdoptCF, CFArrayCreateMutable(0, value.size(), &kCFTypeArrayCallBacks));
+ RetainPtr<CFMutableArrayRef> array = adoptCF(CFArrayCreateMutable(0, value.size(), &kCFTypeArrayCallBacks));
for (size_t i = 0; i < value.size(); ++i) {
float a[4] = { value[i].red(), value[i].green(), value[i].blue(), value[i].alpha() };
- RetainPtr<CACFVectorRef> v(AdoptCF, CACFVectorCreate(4, a));
+ RetainPtr<CACFVectorRef> v = adoptCF(CACFVectorCreate(4, a));
CFArrayAppendValue(array.get(), v.get());
}
@@ -518,9 +517,9 @@ void PlatformCAAnimation::setKeyTimes(const Vector<float>& value)
if (animationType() != Keyframe)
return;
- RetainPtr<CFMutableArrayRef> array(AdoptCF, CFArrayCreateMutable(0, value.size(), &kCFTypeArrayCallBacks));
+ RetainPtr<CFMutableArrayRef> array = adoptCF(CFArrayCreateMutable(0, value.size(), &kCFTypeArrayCallBacks));
for (size_t i = 0; i < value.size(); ++i) {
- RetainPtr<CFNumberRef> v(AdoptCF, CFNumberCreate(0, kCFNumberFloatType, &value[i]));
+ RetainPtr<CFNumberRef> v = adoptCF(CFNumberCreate(0, kCFNumberFloatType, &value[i]));
CFArrayAppendValue(array.get(), v.get());
}
@@ -541,9 +540,9 @@ void PlatformCAAnimation::setTimingFunctions(const Vector<const TimingFunction*>
if (animationType() != Keyframe)
return;
- RetainPtr<CFMutableArrayRef> array(AdoptCF, CFArrayCreateMutable(0, value.size(), &kCFTypeArrayCallBacks));
+ RetainPtr<CFMutableArrayRef> array = adoptCF(CFArrayCreateMutable(0, value.size(), &kCFTypeArrayCallBacks));
for (size_t i = 0; i < value.size(); ++i) {
- RetainPtr<CFNumberRef> v(AdoptCF, CFNumberCreate(0, kCFNumberFloatType, &value[i]));
+ RetainPtr<CFNumberRef> v = adoptCF(CFNumberCreate(0, kCFNumberFloatType, &value[i]));
CFArrayAppendValue(array.get(), toCACFTimingFunction(value[i]).get());
}
@@ -555,18 +554,4 @@ void PlatformCAAnimation::copyTimingFunctionsFrom(const PlatformCAAnimation* val
CACFAnimationSetTimingFunctions(m_animation.get(), CACFAnimationGetTimingFunctions(value->platformAnimation()));
}
-#if ENABLE(CSS_FILTERS)
-int PlatformCAAnimation::numAnimatedFilterProperties(FilterOperation::OperationType)
-{
- // FIXME: Hardware filter animation not implemented on Windows
- return 0;
-}
-
-const char* PlatformCAAnimation::animatedFilterPropertyName(FilterOperation::OperationType, int)
-{
- // FIXME: Hardware filter animation not implemented on Windows
- return "";
-}
-#endif
-
#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebCore/platform/graphics/clutter/GraphicsLayerClutter.h b/Source/WebCore/platform/graphics/ca/win/PlatformCAFiltersWin.cpp
index 3e142e487..3eb3954f4 100644
--- a/Source/WebCore/platform/graphics/clutter/GraphicsLayerClutter.h
+++ b/Source/WebCore/platform/graphics/ca/win/PlatformCAFiltersWin.cpp
@@ -1,6 +1,5 @@
/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
- * Copyright (C) 2011 Collabora Ltd.
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -24,33 +23,31 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef GraphicsLayerClutter_h
-#define GraphicsLayerClutter_h
+#include "config.h"
#if USE(ACCELERATED_COMPOSITING)
+#if ENABLE(CSS_FILTERS)
-#include "GraphicsLayer.h"
+#include "PlatformCAFilters.h"
-#include <clutter/clutter.h>
-#include <wtf/gobject/GRefPtr.h>
+using namespace WebCore;
-namespace WebCore {
+void PlatformCAFilters::setFiltersOnLayer(PlatformCALayer* platformCALayer, const FilterOperations& filters)
+{
+ // Hardware filter animation not implemented on Windows.
+}
-class GraphicsLayerClutter : public GraphicsLayer {
-public:
- GraphicsLayerClutter(GraphicsLayerClient*);
- virtual ~GraphicsLayerClutter();
+int PlatformCAFilters::numAnimatedFilterProperties(FilterOperation::OperationType type)
+{
+ // Hardware filter animation not implemented on Windows.
+ return 0;
+}
- virtual ClutterActor* platformLayer() const;
- virtual void setNeedsDisplay();
- virtual void setNeedsDisplayInRect(const FloatRect&);
-
-private:
- GRefPtr<ClutterActor> m_layer;
-};
-
-} // namespace WebCore
+const char* PlatformCAFilters::animatedFilterPropertyName(FilterOperation::OperationType type, int internalFilterPropertyIndex)
+{
+ // Hardware filter animation not implemented on Windows.
+ return "";
+}
+#endif // ENABLE(CSS_FILTERS)
#endif // USE(ACCELERATED_COMPOSITING)
-
-#endif // GraphicsLayerClutter_h
diff --git a/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp b/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp
index bba8f2c5c..688649e1e 100644
--- a/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp
+++ b/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp
@@ -116,7 +116,7 @@ PlatformCALayer::PlatformCALayer(LayerType layerType, PlatformLayer* layer, Plat
m_layer = layer;
} else {
m_layerType = layerType;
- m_layer.adoptCF(CACFLayerCreate(toCACFLayerType(layerType)));
+ m_layer = adoptCF(CACFLayerCreate(toCACFLayerType(layerType)));
// Create the PlatformCALayerWinInternal object and point to it in the userdata.
PlatformCALayerWinInternal* intern = new PlatformCALayerWinInternal(this);
@@ -149,6 +149,30 @@ PlatformCALayer* PlatformCALayer::platformCALayer(void* platformLayer)
return layerIntern ? layerIntern->owner() : 0;
}
+PassRefPtr<PlatformCALayer> PlatformCALayer::clone(PlatformCALayerClient* owner) const
+{
+ PlatformCALayer::LayerType type = (layerType() == PlatformCALayer::LayerTypeTransformLayer) ?
+ PlatformCALayer::LayerTypeTransformLayer : PlatformCALayer::LayerTypeLayer;
+ RefPtr<PlatformCALayer> newLayer = PlatformCALayer::create(type, owner);
+
+ newLayer->setPosition(position());
+ newLayer->setBounds(bounds());
+ newLayer->setAnchorPoint(anchorPoint());
+ newLayer->setTransform(transform());
+ newLayer->setSublayerTransform(sublayerTransform());
+ newLayer->setContents(contents());
+ newLayer->setMasksToBounds(masksToBounds());
+ newLayer->setDoubleSided(isDoubleSided());
+ newLayer->setOpaque(isOpaque());
+ newLayer->setBackgroundColor(backgroundColor());
+ newLayer->setContentsScale(contentsScale());
+#if ENABLE(CSS_FILTERS)
+ newLayer->copyFiltersFrom(this);
+#endif
+
+ return newLayer;
+}
+
PlatformLayer* PlatformCALayer::platformLayer() const
{
return m_layer.get();
@@ -516,8 +540,8 @@ void PlatformCALayer::setBackgroundColor(const Color& value)
CGFloat components[4];
value.getRGBA(components[0], components[1], components[2], components[3]);
- RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB());
- RetainPtr<CGColorRef> color(AdoptCF, CGColorCreate(colorSpace.get(), components));
+ RetainPtr<CGColorSpaceRef> colorSpace = adoptCF(CGColorSpaceCreateDeviceRGB());
+ RetainPtr<CGColorRef> color = adoptCF(CGColorCreate(colorSpace.get(), components));
CACFLayerSetBackgroundColor(m_layer.get(), color.get());
setNeedsCommit();
@@ -544,8 +568,8 @@ void PlatformCALayer::setBorderColor(const Color& value)
CGFloat components[4];
value.getRGBA(components[0], components[1], components[2], components[3]);
- RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB());
- RetainPtr<CGColorRef> color(AdoptCF, CGColorCreate(colorSpace.get(), components));
+ RetainPtr<CGColorSpaceRef> colorSpace = adoptCF(CGColorSpaceCreateDeviceRGB());
+ RetainPtr<CGColorRef> color = adoptCF(CGColorCreate(colorSpace.get(), components));
CACFLayerSetBorderColor(m_layer.get(), color.get());
setNeedsCommit();
diff --git a/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp b/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp
index 15275b3ae..7f2bc82a8 100644
--- a/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp
+++ b/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp
@@ -51,7 +51,7 @@ PlatformCALayerWinInternal::PlatformCALayerWinInternal(PlatformCALayer* owner)
{
if (m_owner->layerType() == PlatformCALayer::LayerTypeWebTiledLayer) {
// Tiled layers are placed in a child layer that is always the first child of the TiledLayer
- m_tileParent.adoptCF(CACFLayerCreate(kCACFLayer));
+ m_tileParent = adoptCF(CACFLayerCreate(kCACFLayer));
CACFLayerInsertSublayer(m_owner->platformLayer(), m_tileParent.get(), 0);
updateTiles();
}
@@ -124,9 +124,7 @@ void PlatformCALayerWinInternal::displayCallback(CACFLayerRef caLayer, CGContext
NONCLIENTMETRICS metrics;
metrics.cbSize = sizeof(metrics);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, metrics.cbSize, &metrics, 0);
- FontFamily family;
- family.setFamily(metrics.lfSmCaptionFont.lfFaceName);
- desc.setFamily(family);
+ desc.setOneFamily(metrics.lfSmCaptionFont.lfFaceName);
desc.setComputedSize(18);
@@ -384,7 +382,7 @@ void PlatformCALayerWinInternal::tileDisplayCallback(CACFLayerRef layer, CGConte
void PlatformCALayerWinInternal::addTile()
{
- RetainPtr<CACFLayerRef> newLayer(AdoptCF, CACFLayerCreate(kCACFLayer));
+ RetainPtr<CACFLayerRef> newLayer = adoptCF(CACFLayerCreate(kCACFLayer));
CACFLayerSetAnchorPoint(newLayer.get(), CGPointMake(0, 1));
CACFLayerSetUserData(newLayer.get(), this);
CACFLayerSetDisplayCallback(newLayer.get(), tileDisplayCallback);
diff --git a/Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp b/Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp
index d945c3e2e..2f64ab160 100644
--- a/Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp
+++ b/Source/WebCore/platform/graphics/ca/win/WKCACFViewLayerTreeHost.cpp
@@ -72,7 +72,7 @@ PassRefPtr<WKCACFViewLayerTreeHost> WKCACFViewLayerTreeHost::create()
}
WKCACFViewLayerTreeHost::WKCACFViewLayerTreeHost()
- : m_view(AdoptCF, WKCACFViewCreate(kWKCACFViewDrawingDestinationWindow))
+ : m_view(adoptCF(WKCACFViewCreate(kWKCACFViewDrawingDestinationWindow)))
, m_viewNeedsUpdate(true)
{
}
diff --git a/Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp b/Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp
index 225dfb2f6..56077318b 100644
--- a/Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp
+++ b/Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp
@@ -29,18 +29,12 @@
#include "BitmapImage.h"
#include "ImageObserver.h"
-#include "NativeImageCairo.h"
#include "PlatformContextCairo.h"
#include <cairo.h>
namespace WebCore {
-PassRefPtr<BitmapImage> BitmapImage::create(cairo_surface_t* surface)
-{
- return BitmapImage::create(new NativeImageCairo(surface));
-}
-
-BitmapImage::BitmapImage(NativeImageCairo* nativeImage, ImageObserver* observer)
+BitmapImage::BitmapImage(PassRefPtr<cairo_surface_t> nativeImage, ImageObserver* observer)
: Image(observer)
, m_currentFrame(0)
, m_frames(0)
@@ -58,33 +52,33 @@ BitmapImage::BitmapImage(NativeImageCairo* nativeImage, ImageObserver* observer)
, m_sizeAvailable(true)
, m_haveFrameCount(true)
{
- cairo_surface_t* surface = nativeImage->surface();
- int width = cairo_image_surface_get_width(surface);
- int height = cairo_image_surface_get_height(surface);
+ int width = cairo_image_surface_get_width(nativeImage.get());
+ int height = cairo_image_surface_get_height(nativeImage.get());
m_decodedSize = width * height * 4;
m_size = IntSize(width, height);
m_frames.grow(1);
+ m_frames[0].m_hasAlpha = cairo_surface_get_content(nativeImage.get()) != CAIRO_CONTENT_COLOR;
m_frames[0].m_frame = nativeImage;
- m_frames[0].m_hasAlpha = cairo_surface_get_content(surface) != CAIRO_CONTENT_COLOR;
m_frames[0].m_haveMetadata = true;
checkForSolidColor();
}
-void BitmapImage::draw(GraphicsContext* context, const FloatRect& dst, const FloatRect& src, ColorSpace styleColorSpace, CompositeOperator op)
+void BitmapImage::draw(GraphicsContext* context, const FloatRect& dst, const FloatRect& src, ColorSpace styleColorSpace, CompositeOperator op, BlendMode blendMode)
{
- draw(context, dst, src, styleColorSpace, op, DoNotRespectImageOrientation);
+ draw(context, dst, src, styleColorSpace, op, blendMode, DoNotRespectImageOrientation);
}
-void BitmapImage::draw(GraphicsContext* context, const FloatRect& dst, const FloatRect& src, ColorSpace styleColorSpace, CompositeOperator op, RespectImageOrientationEnum shouldRespectImageOrientation)
+void BitmapImage::draw(GraphicsContext* context, const FloatRect& dst, const FloatRect& src, ColorSpace styleColorSpace, CompositeOperator op,
+ BlendMode blendMode, RespectImageOrientationEnum shouldRespectImageOrientation)
{
if (!dst.width() || !dst.height() || !src.width() || !src.height())
return;
startAnimation();
- NativeImageCairo* nativeImage = frameAtIndex(m_currentFrame);
- if (!nativeImage) // If it's too early we won't have an image yet.
+ RefPtr<cairo_surface_t> surface = frameAtIndex(m_currentFrame);
+ if (!surface) // If it's too early we won't have an image yet.
return;
if (mayFillWithSolidColor()) {
@@ -95,14 +89,13 @@ void BitmapImage::draw(GraphicsContext* context, const FloatRect& dst, const Flo
context->save();
// Set the compositing operation.
- if (op == CompositeSourceOver && !frameHasAlphaAtIndex(m_currentFrame))
+ if (op == CompositeSourceOver && blendMode == BlendModeNormal && !frameHasAlphaAtIndex(m_currentFrame))
context->setCompositeOperation(CompositeCopy);
else
- context->setCompositeOperation(op);
+ context->setCompositeOperation(op, blendMode);
#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
- cairo_surface_t* surface = nativeImage->surface();
- IntSize scaledSize(cairo_image_surface_get_width(surface), cairo_image_surface_get_height(surface));
+ IntSize scaledSize(cairo_image_surface_get_width(surface.get()), cairo_image_surface_get_height(surface.get()));
FloatRect adjustedSrcRect = adjustSourceRectForDownSampling(src, scaledSize);
#else
FloatRect adjustedSrcRect(src);
@@ -126,7 +119,7 @@ void BitmapImage::draw(GraphicsContext* context, const FloatRect& dst, const Flo
}
}
- context->platformContext()->drawSurfaceToContext(nativeImage->surface(), dstRect, adjustedSrcRect, context);
+ context->platformContext()->drawSurfaceToContext(surface.get(), dstRect, adjustedSrcRect, context);
context->restore();
@@ -142,20 +135,19 @@ void BitmapImage::checkForSolidColor()
if (frameCount() > 1)
return;
- NativeImageCairo* nativeImage = frameAtIndex(m_currentFrame);
- if (!nativeImage) // If it's too early we won't have an image yet.
+ RefPtr<cairo_surface_t> surface = frameAtIndex(m_currentFrame);
+ if (!surface) // If it's too early we won't have an image yet.
return;
- cairo_surface_t* surface = nativeImage->surface();
- ASSERT(cairo_surface_get_type(surface) == CAIRO_SURFACE_TYPE_IMAGE);
+ ASSERT(cairo_surface_get_type(surface.get()) == CAIRO_SURFACE_TYPE_IMAGE);
- int width = cairo_image_surface_get_width(surface);
- int height = cairo_image_surface_get_height(surface);
+ int width = cairo_image_surface_get_width(surface.get());
+ int height = cairo_image_surface_get_height(surface.get());
if (width != 1 || height != 1)
return;
- unsigned* pixelColor = reinterpret_cast<unsigned*>(cairo_image_surface_get_data(surface));
+ unsigned* pixelColor = reinterpret_cast_ptr<unsigned*>(cairo_image_surface_get_data(surface.get()));
m_solidColor = colorFromPremultipliedARGB(*pixelColor);
m_isSolidColor = true;
@@ -167,8 +159,7 @@ bool FrameData::clear(bool clearMetadata)
m_haveMetadata = false;
if (m_frame) {
- delete m_frame;
- m_frame = 0;
+ m_frame.clear();
return true;
}
return false;
diff --git a/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp b/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp
index 94bf970bd..a67371d63 100644
--- a/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp
+++ b/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp
@@ -131,12 +131,51 @@ cairo_operator_t toCairoOperator(CompositeOperator op)
return CAIRO_OPERATOR_SOURCE;
}
}
+cairo_operator_t toCairoOperator(BlendMode blendOp)
+{
+ switch (blendOp) {
+ case BlendModeNormal:
+ return CAIRO_OPERATOR_OVER;
+ case BlendModeMultiply:
+ return CAIRO_OPERATOR_MULTIPLY;
+ case BlendModeScreen:
+ return CAIRO_OPERATOR_SCREEN;
+ case BlendModeOverlay:
+ return CAIRO_OPERATOR_OVERLAY;
+ case BlendModeDarken:
+ return CAIRO_OPERATOR_DARKEN;
+ case BlendModeLighten:
+ return CAIRO_OPERATOR_LIGHTEN;
+ case BlendModeColorDodge:
+ return CAIRO_OPERATOR_COLOR_DODGE;
+ case BlendModeColorBurn:
+ return CAIRO_OPERATOR_COLOR_BURN;
+ case BlendModeHardLight:
+ return CAIRO_OPERATOR_HARD_LIGHT;
+ case BlendModeSoftLight:
+ return CAIRO_OPERATOR_SOFT_LIGHT;
+ case BlendModeDifference:
+ return CAIRO_OPERATOR_DIFFERENCE;
+ case BlendModeExclusion:
+ return CAIRO_OPERATOR_EXCLUSION;
+ case BlendModeHue:
+ return CAIRO_OPERATOR_HSL_HUE;
+ case BlendModeSaturation:
+ return CAIRO_OPERATOR_HSL_SATURATION;
+ case BlendModeColor:
+ return CAIRO_OPERATOR_HSL_COLOR;
+ case BlendModeLuminosity:
+ return CAIRO_OPERATOR_HSL_LUMINOSITY;
+ default:
+ return CAIRO_OPERATOR_OVER;
+ }
+}
void drawPatternToCairoContext(cairo_t* cr, cairo_surface_t* image, const IntSize& imageSize, const FloatRect& tileRect,
const AffineTransform& patternTransform, const FloatPoint& phase, cairo_operator_t op, const FloatRect& destRect)
{
// Avoid NaN
- if (!isfinite(phase.x()) || !isfinite(phase.y()))
+ if (!std::isfinite(phase.x()) || !std::isfinite(phase.y()))
return;
cairo_save(cr);
diff --git a/Source/WebCore/platform/graphics/cairo/CairoUtilities.h b/Source/WebCore/platform/graphics/cairo/CairoUtilities.h
index 344bc49a1..011f972a0 100644
--- a/Source/WebCore/platform/graphics/cairo/CairoUtilities.h
+++ b/Source/WebCore/platform/graphics/cairo/CairoUtilities.h
@@ -46,6 +46,7 @@ void setPathOnCairoContext(cairo_t* to, cairo_t* from);
void appendWebCorePathToCairoContext(cairo_t* context, const Path& path);
void appendRegionToCairoContext(cairo_t*, const cairo_region_t*);
cairo_operator_t toCairoOperator(CompositeOperator op);
+cairo_operator_t toCairoOperator(BlendMode blendOp);
void drawPatternToCairoContext(cairo_t* cr, cairo_surface_t* image, const IntSize& imageSize, const FloatRect& tileRect,
const AffineTransform& patternTransform, const FloatPoint& phase, cairo_operator_t op, const FloatRect& destRect);
PassRefPtr<cairo_surface_t> copyCairoImageSurface(cairo_surface_t*);
diff --git a/Source/WebCore/platform/graphics/cairo/DrawErrorUnderline.h b/Source/WebCore/platform/graphics/cairo/DrawErrorUnderline.h
index 3a49d5c5c..4eca4e4c5 100644
--- a/Source/WebCore/platform/graphics/cairo/DrawErrorUnderline.h
+++ b/Source/WebCore/platform/graphics/cairo/DrawErrorUnderline.h
@@ -97,6 +97,8 @@ static inline void drawErrorUnderline(cairo_t* cr, double x, double y, double wi
cairo_line_to(cr, left, top); // H
}
+
+ cairo_fill(cr);
}
#endif // DrawErrorUnderline_h
diff --git a/Source/WebCore/platform/graphics/cairo/DrawingBufferCairo.cpp b/Source/WebCore/platform/graphics/cairo/DrawingBufferCairo.cpp
index a4eabe8ab..738e49381 100644
--- a/Source/WebCore/platform/graphics/cairo/DrawingBufferCairo.cpp
+++ b/Source/WebCore/platform/graphics/cairo/DrawingBufferCairo.cpp
@@ -33,65 +33,7 @@
namespace WebCore {
-DrawingBuffer::DrawingBuffer(GraphicsContext3D* context,
- const IntSize& size,
- bool multisampleExtensionSupported,
- bool packedDepthStencilExtensionSupported,
- PreserveDrawingBuffer preserveDrawingBuffer,
- AlphaRequirement alpha)
- : m_preserveDrawingBuffer(preserveDrawingBuffer)
- , m_alpha(alpha)
- , m_scissorEnabled(false)
- , m_texture2DBinding(0)
- , m_framebufferBinding(0)
- , m_activeTextureUnit(GraphicsContext3D::TEXTURE0)
- , m_context(context)
- , m_size(-1, -1)
- , m_multisampleExtensionSupported(multisampleExtensionSupported)
- , m_packedDepthStencilExtensionSupported(packedDepthStencilExtensionSupported)
- , m_fbo(context->createFramebuffer())
- , m_colorBuffer(0)
- , m_frontColorBuffer(0)
- , m_separateFrontTexture(false)
- , m_depthStencilBuffer(0)
- , m_depthBuffer(0)
- , m_stencilBuffer(0)
- , m_multisampleFBO(0)
- , m_multisampleColorBuffer(0)
-{
- ASSERT(m_fbo);
- if (!m_fbo) {
- clear();
- return;
- }
-
- // create a texture to render into
- m_colorBuffer = context->createTexture();
- context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_colorBuffer);
- context->texParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR);
- context->texParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR);
- context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE);
- context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE);
- context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0);
-
- createSecondaryBuffers();
- reset(size);
-}
-
-DrawingBuffer::~DrawingBuffer()
-{
- clear();
-}
-
#if USE(ACCELERATED_COMPOSITING)
-void DrawingBuffer::prepareBackBuffer()
-{
-}
-
-bool DrawingBuffer::requiresCopyFromBackToFrontBuffer() const
-{
- return false;
-}
unsigned DrawingBuffer::frontColorBuffer() const
{
diff --git a/Source/WebCore/platform/graphics/cairo/FontCairo.cpp b/Source/WebCore/platform/graphics/cairo/FontCairo.cpp
index 9a0fd305a..a09e555d2 100644
--- a/Source/WebCore/platform/graphics/cairo/FontCairo.cpp
+++ b/Source/WebCore/platform/graphics/cairo/FontCairo.cpp
@@ -69,7 +69,7 @@ static void drawGlyphsShadow(GraphicsContext* graphicsContext, const FloatPoint&
if (!(graphicsContext->textDrawingMode() & TextModeFill) || shadow.type() == ShadowBlur::NoShadow)
return;
- if (!shadow.mustUseShadowBlur(graphicsContext)) {
+ if (!graphicsContext->mustUseShadowBlur()) {
// Optimize non-blurry shadows, by just drawing text without the ShadowBlur.
cairo_t* context = graphicsContext->platformContext()->cr();
cairo_save(context);
@@ -105,7 +105,7 @@ void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, cons
for (int i = 0; i < numGlyphs; i++) {
glyphs[i].x = offset;
glyphs[i].y = point.y();
- offset += glyphBuffer.advanceAt(from + i);
+ offset += glyphBuffer.advanceAt(from + i).width();
}
PlatformContextCairo* platformContext = context->platformContext();
diff --git a/Source/WebCore/platform/graphics/cairo/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/cairo/FontCustomPlatformData.h
index f8f3c998e..580710268 100644
--- a/Source/WebCore/platform/graphics/cairo/FontCustomPlatformData.h
+++ b/Source/WebCore/platform/graphics/cairo/FontCustomPlatformData.h
@@ -25,7 +25,6 @@
#include "FontOrientation.h"
#include "FontRenderingMode.h"
#include "FontWidthVariant.h"
-#include "TextOrientation.h"
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
@@ -42,7 +41,7 @@ struct FontCustomPlatformData {
public:
FontCustomPlatformData(FT_Face, SharedBuffer*);
~FontCustomPlatformData();
- FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation = Horizontal, TextOrientation = TextOrientationVerticalRight, FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode);
+ FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation = Horizontal, FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode);
static bool supportsFormat(const String&);
private:
diff --git a/Source/WebCore/platform/graphics/cairo/GLContext.cpp b/Source/WebCore/platform/graphics/cairo/GLContext.cpp
index 2cb0ab3cc..687c5ea12 100644
--- a/Source/WebCore/platform/graphics/cairo/GLContext.cpp
+++ b/Source/WebCore/platform/graphics/cairo/GLContext.cpp
@@ -21,19 +21,55 @@
#if USE(OPENGL)
+#if USE(EGL)
#include "GLContextEGL.h"
+#endif
+
+#if USE(GLX)
#include "GLContextGLX.h"
-#include <wtf/MainThread.h>
+#endif
+
+#include <wtf/ThreadSpecific.h>
#if PLATFORM(X11)
#include <X11/Xlib.h>
#endif
+#if PLATFORM(GTK)
+#include <gdk/gdk.h>
+#ifndef GTK_API_VERSION_2
+#ifdef GDK_WINDOWING_WAYLAND
+#include <gdk/gdkwayland.h>
+#endif
+#endif
+#endif
+
+using WTF::ThreadSpecific;
+
namespace WebCore {
+class ThreadGlobalGLContext {
+public:
+ static ThreadSpecific<ThreadGlobalGLContext>* staticGLContext;
+
+ void setContext(GLContext* context) { m_context = context; }
+ GLContext* context() { return m_context; }
+
+private:
+ GLContext* m_context;
+};
+
+ThreadSpecific<ThreadGlobalGLContext>* ThreadGlobalGLContext::staticGLContext;
+
+inline ThreadGlobalGLContext* currentContext()
+{
+ if (!ThreadGlobalGLContext::staticGLContext)
+ ThreadGlobalGLContext::staticGLContext = new ThreadSpecific<ThreadGlobalGLContext>;
+ return *ThreadGlobalGLContext::staticGLContext;
+}
+
GLContext* GLContext::sharingContext()
{
- ASSERT(isMainThread());
DEFINE_STATIC_LOCAL(OwnPtr<GLContext>, sharing, (createOffscreenContext()));
return sharing.get();
}
@@ -113,6 +149,16 @@ void GLContext::cleanupActiveContextsAtExit()
PassOwnPtr<GLContext> GLContext::createContextForWindow(uint64_t windowHandle, GLContext* sharingContext)
{
+#if PLATFORM(GTK) && defined(GDK_WINDOWING_WAYLAND) && USE(EGL)
+ GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get());
+
+ if (GDK_IS_WAYLAND_DISPLAY(display)) {
+ if (OwnPtr<GLContext> eglContext = GLContextEGL::createContext(windowHandle, sharingContext))
+ return eglContext.release();
+ return nullptr;
+ }
+#endif
+
#if USE(GLX)
if (OwnPtr<GLContext> glxContext = GLContextGLX::createContext(windowHandle, sharingContext))
return glxContext.release();
@@ -131,39 +177,25 @@ GLContext::GLContext()
PassOwnPtr<GLContext> GLContext::createOffscreenContext(GLContext* sharingContext)
{
-#if USE(GLX)
- if (OwnPtr<GLContext> glxContext = GLContextGLX::createContext(0, sharingContext))
- return glxContext.release();
-#endif
-#if USE(EGL)
- if (OwnPtr<GLContext> eglContext = GLContextEGL::createContext(0, sharingContext))
- return eglContext.release();
-#endif
- return nullptr;
+ return createContextForWindow(0, sharingContext);
}
-// FIXME: This should be a thread local eventually if we
-// want to support using GLContexts from multiple threads.
-static GLContext* gCurrentContext = 0;
-
GLContext::~GLContext()
{
- if (this == gCurrentContext)
- gCurrentContext = 0;
+ if (this == currentContext()->context())
+ currentContext()->setContext(0);
removeActiveContext(this);
}
bool GLContext::makeContextCurrent()
{
- ASSERT(isMainThread());
- gCurrentContext = this;
+ currentContext()->setContext(this);
return true;
}
GLContext* GLContext::getCurrent()
{
- ASSERT(isMainThread());
- return gCurrentContext;
+ return currentContext()->context();
}
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/cairo/GLContext.h b/Source/WebCore/platform/graphics/cairo/GLContext.h
index 1a8807222..38df7a669 100644
--- a/Source/WebCore/platform/graphics/cairo/GLContext.h
+++ b/Source/WebCore/platform/graphics/cairo/GLContext.h
@@ -25,6 +25,8 @@
#include <wtf/Noncopyable.h>
#include <wtf/PassOwnPtr.h>
+typedef struct _cairo_device cairo_device_t;
+
#if PLATFORM(X11)
typedef struct _XDisplay Display;
#endif
@@ -46,6 +48,7 @@ public:
virtual void waitNative() = 0;
virtual bool canRenderToDefaultFramebuffer() = 0;
virtual IntSize defaultFrameBufferSize() = 0;
+ virtual cairo_device_t* cairoDevice() = 0;
#if PLATFORM(X11)
static Display* sharedX11Display();
diff --git a/Source/WebCore/platform/graphics/cairo/GradientCairo.cpp b/Source/WebCore/platform/graphics/cairo/GradientCairo.cpp
index f76bb6db9..e0cfe3e65 100644
--- a/Source/WebCore/platform/graphics/cairo/GradientCairo.cpp
+++ b/Source/WebCore/platform/graphics/cairo/GradientCairo.cpp
@@ -27,7 +27,6 @@
#include "config.h"
#include "Gradient.h"
-#include "CSSParser.h"
#include "GraphicsContext.h"
#include "PlatformContextCairo.h"
#include <cairo.h>
diff --git a/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp b/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp
index 8ba049b17..d31adf326 100644
--- a/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp
+++ b/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp
@@ -36,12 +36,17 @@
#include "NotImplemented.h"
#include "PlatformContextCairo.h"
#include "RefPtrCairo.h"
-#include "ShaderLang.h"
#include <cairo.h>
#include <wtf/NotFound.h>
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
+#if PLATFORM(WIN)
+#include "GLSLANG/ShaderLang.h"
+#else
+#include "ShaderLang.h"
+#endif
+
#if USE(OPENGL_ES_2)
#include "Extensions3DOpenGLES.h"
#else
@@ -75,13 +80,11 @@ PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attri
GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attributes, HostWindow*, GraphicsContext3D::RenderStyle renderStyle)
: m_currentWidth(0)
, m_currentHeight(0)
+ , m_compiler(isGLES2Compliant() ? SH_ESSL_OUTPUT : SH_GLSL_OUTPUT)
, m_attrs(attributes)
, m_texture(0)
, m_fbo(0)
, m_depthStencilBuffer(0)
- , m_boundFBO(0)
- , m_activeTexture(GL_TEXTURE0)
- , m_boundTexture0(0)
, m_multisampleFBO(0)
, m_multisampleDepthStencilBuffer(0)
, m_multisampleColorBuffer(0)
@@ -105,7 +108,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attributes, H
::glGenFramebuffers(1, &m_fbo);
::glBindFramebuffer(GL_FRAMEBUFFER, m_fbo);
- m_boundFBO = m_fbo;
+ m_state.boundFBO = m_fbo;
if (!m_attrs.antialias && (m_attrs.stencil || m_attrs.depth))
::glGenRenderbuffers(1, &m_depthStencilBuffer);
@@ -113,7 +116,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attributes, H
if (m_attrs.antialias) {
::glGenFramebuffers(1, &m_multisampleFBO);
::glBindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO);
- m_boundFBO = m_multisampleFBO;
+ m_state.boundFBO = m_multisampleFBO;
::glGenRenderbuffers(1, &m_multisampleColorBuffer);
if (m_attrs.stencil || m_attrs.depth)
::glGenRenderbuffers(1, &m_multisampleDepthStencilBuffer);
@@ -134,6 +137,11 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attributes, H
// Always set to 1 for OpenGL ES.
ANGLEResources.MaxDrawBuffers = 1;
+
+ GC3Dint range[2], precision;
+ getShaderPrecisionFormat(GraphicsContext3D::FRAGMENT_SHADER, GraphicsContext3D::HIGH_FLOAT, range, &precision);
+ ANGLEResources.FragmentPrecisionHigh = (range[0] || range[1] || precision);
+
m_compiler.setResources(ANGLEResources);
#if !USE(OPENGL_ES_2)
@@ -163,57 +171,66 @@ GraphicsContext3D::~GraphicsContext3D()
::glDeleteFramebuffers(1, &m_fbo);
}
-bool GraphicsContext3D::getImageData(Image* image, unsigned int format, unsigned int type, bool premultiplyAlpha, bool ignoreGammaAndColorProfile, Vector<uint8_t>& outputVector)
+GraphicsContext3D::ImageExtractor::~ImageExtractor()
{
- if (!image)
+ if (m_decoder)
+ delete m_decoder;
+}
+
+bool GraphicsContext3D::ImageExtractor::extractImage(bool premultiplyAlpha, bool ignoreGammaAndColorProfile)
+{
+ if (!m_image)
return false;
// We need this to stay in scope because the native image is just a shallow copy of the data.
- ImageSource decoder(premultiplyAlpha ? ImageSource::AlphaPremultiplied : ImageSource::AlphaNotPremultiplied,
- ignoreGammaAndColorProfile ? ImageSource::GammaAndColorProfileIgnored : ImageSource::GammaAndColorProfileApplied);
- AlphaOp alphaOp = AlphaDoNothing;
- RefPtr<cairo_surface_t> imageSurface;
- if (image->data()) {
- decoder.setData(image->data(), true);
- if (!decoder.frameCount() || !decoder.frameIsCompleteAtIndex(0))
+ m_decoder = new ImageSource(premultiplyAlpha ? ImageSource::AlphaPremultiplied : ImageSource::AlphaNotPremultiplied, ignoreGammaAndColorProfile ? ImageSource::GammaAndColorProfileIgnored : ImageSource::GammaAndColorProfileApplied);
+ if (!m_decoder)
+ return false;
+ ImageSource& decoder = *m_decoder;
+
+ m_alphaOp = AlphaDoNothing;
+ if (m_image->data()) {
+ decoder.setData(m_image->data(), true);
+ if (!decoder.frameCount())
+ return false;
+
+ m_imageSurface = decoder.createFrameAtIndex(0);
+ if (!m_imageSurface || !decoder.frameIsCompleteAtIndex(0))
return false;
- OwnPtr<NativeImageCairo> nativeImage = adoptPtr(decoder.createFrameAtIndex(0));
- imageSurface = nativeImage->surface();
} else {
- NativeImageCairo* nativeImage = image->nativeImageForCurrentFrame();
- imageSurface = (nativeImage) ? nativeImage->surface() : 0;
- if (!premultiplyAlpha)
- alphaOp = AlphaDoUnmultiply;
+ m_imageSurface = m_image->nativeImageForCurrentFrame();
+ // 1. For texImage2D with HTMLVideoElment input, assume no PremultiplyAlpha had been applied and the alpha value is 0xFF for each pixel,
+ // which is true at present and may be changed in the future and needs adjustment accordingly.
+ // 2. For texImage2D with HTMLCanvasElement input in which Alpha is already Premultiplied in this port,
+ // do AlphaDoUnmultiply if UNPACK_PREMULTIPLY_ALPHA_WEBGL is set to false.
+ if (!premultiplyAlpha && m_imageHtmlDomSource != HtmlDomVideo)
+ m_alphaOp = AlphaDoUnmultiply;
}
- if (!imageSurface)
+ if (!m_imageSurface)
return false;
- int width = cairo_image_surface_get_width(imageSurface.get());
- int height = cairo_image_surface_get_height(imageSurface.get());
- if (!width || !height)
+ m_imageWidth = cairo_image_surface_get_width(m_imageSurface.get());
+ m_imageHeight = cairo_image_surface_get_height(m_imageSurface.get());
+ if (!m_imageWidth || !m_imageHeight)
return false;
- if (cairo_image_surface_get_format(imageSurface.get()) != CAIRO_FORMAT_ARGB32)
+ if (cairo_image_surface_get_format(m_imageSurface.get()) != CAIRO_FORMAT_ARGB32)
return false;
unsigned int srcUnpackAlignment = 1;
- size_t bytesPerRow = cairo_image_surface_get_stride(imageSurface.get());
+ size_t bytesPerRow = cairo_image_surface_get_stride(m_imageSurface.get());
size_t bitsPerPixel = 32;
- unsigned int padding = bytesPerRow - bitsPerPixel / 8 * width;
+ unsigned padding = bytesPerRow - bitsPerPixel / 8 * m_imageWidth;
if (padding) {
srcUnpackAlignment = padding + 1;
while (bytesPerRow % srcUnpackAlignment)
++srcUnpackAlignment;
}
- unsigned int packedSize;
- // Output data is tightly packed (alignment == 1).
- if (computeImageSizeInBytes(format, type, width, height, 1, &packedSize, 0) != GraphicsContext3D::NO_ERROR)
- return false;
- outputVector.resize(packedSize);
-
- return packPixels(cairo_image_surface_get_data(imageSurface.get()), SourceFormatBGRA8,
- width, height, srcUnpackAlignment, format, type, alphaOp, outputVector.data());
+ m_imagePixelData = cairo_image_surface_get_data(m_imageSurface.get());
+ m_imageSourceFormat = DataFormatBGRA8;
+ m_imageSourceUnpackAlignment = srcUnpackAlignment;
+ return true;
}
void GraphicsContext3D::paintToCanvas(const unsigned char* imagePixels, int imageWidth, int imageHeight, int canvasWidth, int canvasHeight, PlatformContextCairo* context)
@@ -257,11 +274,17 @@ bool GraphicsContext3D::makeContextCurrent()
return false;
return m_private->makeContextCurrent();
}
+
PlatformGraphicsContext3D GraphicsContext3D::platformGraphicsContext3D()
{
return m_private->platformContext();
}
+Platform3DObject GraphicsContext3D::platformTexture() const
+{
+ return m_texture;
+}
+
bool GraphicsContext3D::isGLES2Compliant() const
{
#if USE(OPENGL_ES_2)
diff --git a/Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.cpp b/Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.cpp
index 294169e0e..aa7fec179 100644
--- a/Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.cpp
+++ b/Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.cpp
@@ -78,13 +78,15 @@ PlatformGraphicsContext3D GraphicsContext3DPrivate::platformContext()
}
#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
-void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity, BitmapTexture* mask)
+void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity)
{
if (!m_glContext)
return;
ASSERT(m_renderStyle == GraphicsContext3D::RenderOffscreen);
+ m_context->markLayerComposited();
+
// FIXME: We do not support mask for the moment with TextureMapperImageBuffer.
if (textureMapper->accelerationMode() != TextureMapper::OpenGLMode) {
GraphicsContext* context = textureMapper->graphicsContext();
@@ -125,22 +127,22 @@ void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper* textureMapper
}
#if USE(TEXTURE_MAPPER_GL)
- if (m_context->m_attrs.antialias && m_context->m_boundFBO == m_context->m_multisampleFBO) {
+ if (m_context->m_attrs.antialias && m_context->m_state.boundFBO == m_context->m_multisampleFBO) {
GLContext* previousActiveContext = GLContext::getCurrent();
if (previousActiveContext != m_glContext)
m_context->makeContextCurrent();
m_context->resolveMultisamplingIfNecessary();
- ::glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_boundFBO);
+ ::glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_state.boundFBO);
if (previousActiveContext && previousActiveContext != m_glContext)
previousActiveContext->makeContextCurrent();
}
TextureMapperGL* texmapGL = static_cast<TextureMapperGL*>(textureMapper);
- TextureMapperGL::Flags flags = TextureMapperGL::ShouldFlipTexture | (m_context->m_attrs.alpha ? TextureMapperGL::SupportsBlending : 0);
+ TextureMapperGL::Flags flags = TextureMapperGL::ShouldFlipTexture | (m_context->m_attrs.alpha ? TextureMapperGL::ShouldBlend : 0);
IntSize textureSize(m_context->m_currentWidth, m_context->m_currentHeight);
- texmapGL->drawTexture(m_context->m_texture, flags, textureSize, targetRect, matrix, opacity, mask);
+ texmapGL->drawTexture(m_context->m_texture, flags, textureSize, targetRect, matrix, opacity);
#endif // USE(ACCELERATED_COMPOSITING_GL)
}
#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.h b/Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.h
index 69dad6754..42eb6c2e7 100644
--- a/Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.h
+++ b/Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.h
@@ -25,7 +25,7 @@
#include <wtf/PassOwnPtr.h>
#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
-#include "TextureMapper.h"
+#include "TextureMapperPlatformLayer.h"
#endif
namespace WebCore {
@@ -44,7 +44,7 @@ public:
GraphicsContext3D::RenderStyle renderStyle() { return m_renderStyle; }
#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
- virtual void paintToTextureMapper(TextureMapper*, const FloatRect& target, const TransformationMatrix&, float opacity, BitmapTexture* mask);
+ virtual void paintToTextureMapper(TextureMapper*, const FloatRect& target, const TransformationMatrix&, float opacity);
#endif
private:
diff --git a/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp b/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
index b87af4ac6..f22eacad8 100644
--- a/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
+++ b/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
@@ -37,6 +37,7 @@
#include "AffineTransform.h"
#include "CairoUtilities.h"
+#include "DrawErrorUnderline.h"
#include "FloatConversion.h"
#include "FloatRect.h"
#include "Font.h"
@@ -51,6 +52,7 @@
#include "RefPtrCairo.h"
#include "ShadowBlur.h"
#include "SimpleFontData.h"
+#include "TransformationMatrix.h"
#include <cairo.h>
#include <math.h>
#include <stdio.h>
@@ -58,7 +60,6 @@
#if PLATFORM(GTK)
#include <gdk/gdk.h>
-#include <pango/pango.h>
#elif PLATFORM(WIN)
#include <cairo-win32.h>
#endif
@@ -140,10 +141,12 @@ static inline void drawPathShadow(GraphicsContext* context, PathDrawingStyle dra
cairo_stroke(cairoShadowContext);
}
- shadow.endShadowLayer(context);
-
- // ShadowBlur::endShadowLayer destroys the current path on the Cairo context. We restore it here.
+ // The original path may still be hanging around on the context and endShadowLayer
+ // will take care of properly creating a path to draw the result shadow. We remove the path
+ // temporarily and then restore it.
+ // See: https://bugs.webkit.org/show_bug.cgi?id=108897
cairo_new_path(cairoContext);
+ shadow.endShadowLayer(context);
cairo_append_path(cairoContext, path.get());
}
@@ -296,7 +299,6 @@ static void drawLineOnCairoContext(GraphicsContext* graphicsContext, cairo_t* co
FloatPoint point2OnPixelBoundaries = point2;
GraphicsContext::adjustLineToPixelBoundaries(point1OnPixelBoundaries, point2OnPixelBoundaries, strokeThickness, style);
- cairo_set_antialias(context, CAIRO_ANTIALIAS_NONE);
if (patternWidth) {
// Do a rect fill of our endpoints. This ensures we always have the
// appearance of being a border. We then draw the actual dotted/dashed line.
@@ -365,63 +367,6 @@ void GraphicsContext::drawEllipse(const IntRect& rect)
cairo_new_path(cr);
}
-void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan)
-{
- if (paintingDisabled() || strokeStyle() == NoStroke)
- return;
-
- int x = rect.x();
- int y = rect.y();
- float w = rect.width();
- float h = rect.height();
- float scaleFactor = h / w;
- float reverseScaleFactor = w / h;
-
- float hRadius = w / 2;
- float vRadius = h / 2;
- float fa = startAngle;
- float falen = fa + angleSpan;
-
- cairo_t* cr = platformContext()->cr();
- cairo_save(cr);
-
- if (w != h)
- cairo_scale(cr, 1., scaleFactor);
-
- cairo_arc_negative(cr, x + hRadius, (y + vRadius) * reverseScaleFactor, hRadius, deg2rad(-fa), deg2rad(-falen));
-
- if (w != h)
- cairo_scale(cr, 1., reverseScaleFactor);
-
- int patternWidth = 0;
- switch (strokeStyle()) {
- case DottedStroke:
- patternWidth = floorf(strokeThickness() / 2.f);
- break;
- case DashedStroke:
- patternWidth = 3 * floorf(strokeThickness() / 2.f);
- break;
- default:
- break;
- }
-
- setSourceRGBAFromColor(cr, strokeColor());
-
- if (patternWidth) {
- float distance = 0;
- if (hRadius == vRadius)
- distance = (piFloat * hRadius) / 2.f;
- else // We are elliptical and will have to estimate the distance
- distance = (piFloat * sqrtf((hRadius * hRadius + vRadius * vRadius) / 2.f)) / 2.f;
- double patternOffset = calculateStrokePatternOffset(floorf(distance), patternWidth);
- double patternWidthAsDouble = patternWidth;
- cairo_set_dash(cr, &patternWidthAsDouble, 1, patternOffset);
- }
-
- cairo_stroke(cr);
- cairo_restore(cr);
-}
-
void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points, bool shouldAntialias)
{
if (paintingDisabled())
@@ -687,10 +632,6 @@ void GraphicsContext::drawLineForText(const FloatPoint& origin, float width, boo
cairo_restore(cairoContext);
}
-#if !PLATFORM(GTK)
-#include "DrawErrorUnderline.h"
-#endif
-
void GraphicsContext::drawLineForDocumentMarker(const FloatPoint& origin, float width, DocumentMarkerLineStyle style)
{
if (paintingDisabled())
@@ -711,12 +652,7 @@ void GraphicsContext::drawLineForDocumentMarker(const FloatPoint& origin, float
return;
}
-#if PLATFORM(GTK)
- // We ignore most of the provided constants in favour of the platform style
- pango_cairo_show_error_underline(cr, origin.x(), origin.y(), width, cMisspellingLineThickness);
-#else
drawErrorUnderline(cr, origin.x(), origin.y(), width, cMisspellingLineThickness);
-#endif
cairo_restore(cr);
}
@@ -844,29 +780,6 @@ void GraphicsContext::setCTM(const AffineTransform& transform)
m_data->setCTM(transform);
}
-void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness)
-{
- if (paintingDisabled())
- return;
-
- cairo_t* cr = platformContext()->cr();
- clip(rect);
-
- Path p;
- FloatRect r(rect);
- // Add outer ellipse
- p.addEllipse(r);
- // Add inner ellipse
- r.inflate(-thickness);
- p.addEllipse(r);
- appendWebCorePathToCairoContext(cr, p);
-
- cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
- cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD);
- cairo_clip(cr);
- cairo_set_fill_rule(cr, savedFillRule);
-}
-
void GraphicsContext::setPlatformShadow(FloatSize const& size, float, Color const&, ColorSpace)
{
if (paintingDisabled())
@@ -1006,15 +919,21 @@ void GraphicsContext::setAlpha(float alpha)
platformContext()->setGlobalAlpha(alpha);
}
-void GraphicsContext::setPlatformCompositeOperation(CompositeOperator op)
+void GraphicsContext::setPlatformCompositeOperation(CompositeOperator op, BlendMode blendOp)
{
if (paintingDisabled())
return;
- cairo_set_operator(platformContext()->cr(), toCairoOperator(op));
+ cairo_operator_t cairo_op;
+ if (blendOp == BlendModeNormal)
+ cairo_op = toCairoOperator(op);
+ else
+ cairo_op = toCairoOperator(blendOp);
+
+ cairo_set_operator(platformContext()->cr(), cairo_op);
}
-void GraphicsContext::clip(const Path& path)
+void GraphicsContext::clip(const Path& path, WindRule windRule)
{
if (paintingDisabled())
return;
@@ -1026,15 +945,18 @@ void GraphicsContext::clip(const Path& path)
cairo_append_path(cr, pathCopy.get());
}
cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
- cairo_set_fill_rule(cr, CAIRO_FILL_RULE_WINDING);
+ if (windRule == RULE_NONZERO)
+ cairo_set_fill_rule(cr, CAIRO_FILL_RULE_WINDING);
+ else
+ cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD);
cairo_clip(cr);
cairo_set_fill_rule(cr, savedFillRule);
m_data->clip(path);
}
-void GraphicsContext::canvasClip(const Path& path)
+void GraphicsContext::canvasClip(const Path& path, WindRule windRule)
{
- clip(path);
+ clip(path, windRule);
}
void GraphicsContext::clipOut(const Path& path)
@@ -1155,6 +1077,11 @@ InterpolationQuality GraphicsContext::imageInterpolationQuality() const
return platformContext()->imageInterpolationQuality();
}
+bool GraphicsContext::isAcceleratedContext() const
+{
+ return cairo_surface_get_type(cairo_get_target(platformContext()->cr())) == CAIRO_SURFACE_TYPE_GL;
+}
+
#if ENABLE(3D_RENDERING) && USE(TEXTURE_MAPPER)
TransformationMatrix GraphicsContext::get3DTransform() const
{
diff --git a/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp b/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
index 026f4491d..3cfc2f4d1 100644
--- a/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
+++ b/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
@@ -33,7 +33,6 @@
#include "CairoUtilities.h"
#include "Color.h"
#include "GraphicsContext.h"
-#include "ImageData.h"
#include "MIMETypeRegistry.h"
#include "NotImplemented.h"
#include "Pattern.h"
@@ -44,29 +43,72 @@
#include <wtf/text/Base64.h>
#include <wtf/text/WTFString.h>
+#if ENABLE(ACCELERATED_2D_CANVAS)
+#include "GLContext.h"
+#include "OpenGLShims.h"
+#include "TextureMapperGL.h"
+#include <cairo-gl.h>
+#endif
+
using namespace std;
namespace WebCore {
-ImageBufferData::ImageBufferData(const IntSize&)
- : m_surface(0)
- , m_platformContext(0)
+ImageBufferData::ImageBufferData(const IntSize& size)
+ : m_platformContext(0)
+ , m_size(size)
+#if ENABLE(ACCELERATED_2D_CANVAS)
+ , m_texture(0)
+#endif
+{
+}
+
+#if ENABLE(ACCELERATED_2D_CANVAS)
+PassRefPtr<cairo_surface_t> createCairoGLSurface(const IntSize& size, uint32_t& texture)
{
+ GLContext::sharingContext()->makeContextCurrent();
+
+ // We must generate the texture ourselves, because there is no Cairo API for extracting it
+ // from a pre-existing surface.
+ glGenTextures(1, &texture);
+ glBindTexture(GL_TEXTURE_2D, texture);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+ glTexImage2D(GL_TEXTURE_2D, 0 /* level */, GL_RGBA8, size.width(), size.height(), 0 /* border */, GL_RGBA, GL_UNSIGNED_BYTE, 0);
+
+ GLContext* context = GLContext::sharingContext();
+ cairo_device_t* device = context->cairoDevice();
+
+ // Thread-awareness is a huge performance hit on non-Intel drivers.
+ cairo_gl_device_set_thread_aware(device, FALSE);
+
+ return adoptRef(cairo_gl_surface_create_for_texture(device, CAIRO_CONTENT_COLOR_ALPHA, texture, size.width(), size.height()));
}
+#endif
-ImageBuffer::ImageBuffer(const IntSize& size, float /* resolutionScale */, ColorSpace, RenderingMode, DeferralMode, bool& success)
+ImageBuffer::ImageBuffer(const IntSize& size, float /* resolutionScale */, ColorSpace, RenderingMode renderingMode, bool& success)
: m_data(size)
, m_size(size)
, m_logicalSize(size)
{
success = false; // Make early return mean error.
- m_data.m_surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
- size.width(),
- size.height());
- if (cairo_surface_status(m_data.m_surface) != CAIRO_STATUS_SUCCESS)
+
+#if ENABLE(ACCELERATED_2D_CANVAS)
+ if (renderingMode == Accelerated)
+ m_data.m_surface = createCairoGLSurface(size, m_data.m_texture);
+ else
+#endif
+ m_data.m_surface = adoptRef(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, size.width(), size.height()));
+
+ if (cairo_surface_status(m_data.m_surface.get()) != CAIRO_STATUS_SUCCESS)
return; // create will notice we didn't set m_initialized and fail.
- RefPtr<cairo_t> cr = adoptRef(cairo_create(m_data.m_surface));
+ RefPtr<cairo_t> cr = adoptRef(cairo_create(m_data.m_surface.get()));
m_data.m_platformContext.setCr(cr.get());
m_context = adoptPtr(new GraphicsContext(&m_data.m_platformContext));
success = true;
@@ -74,7 +116,6 @@ ImageBuffer::ImageBuffer(const IntSize& size, float /* resolutionScale */, Color
ImageBuffer::~ImageBuffer()
{
- cairo_surface_destroy(m_data.m_surface);
}
GraphicsContext* ImageBuffer::context() const
@@ -85,23 +126,28 @@ GraphicsContext* ImageBuffer::context() const
PassRefPtr<Image> ImageBuffer::copyImage(BackingStoreCopy copyBehavior, ScaleBehavior) const
{
if (copyBehavior == CopyBackingStore)
- return BitmapImage::create(copyCairoImageSurface(m_data.m_surface).leakRef());
+ return BitmapImage::create(copyCairoImageSurface(m_data.m_surface.get()));
// BitmapImage will release the passed in surface on destruction
- return BitmapImage::create(cairo_surface_reference(m_data.m_surface));
+ return BitmapImage::create(m_data.m_surface);
+}
+
+BackingStoreCopy ImageBuffer::fastCopyImageMode()
+{
+ return DontCopyBackingStore;
}
void ImageBuffer::clip(GraphicsContext* context, const FloatRect& maskRect) const
{
- context->platformContext()->pushImageMask(m_data.m_surface, maskRect);
+ context->platformContext()->pushImageMask(m_data.m_surface.get(), maskRect);
}
void ImageBuffer::draw(GraphicsContext* destinationContext, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect,
- CompositeOperator op , bool useLowQualityScale)
+ CompositeOperator op, BlendMode blendMode, bool useLowQualityScale)
{
BackingStoreCopy copyMode = destinationContext == context() ? CopyBackingStore : DontCopyBackingStore;
RefPtr<Image> image = copyImage(copyMode);
- destinationContext->drawImage(image.get(), styleColorSpace, destRect, srcRect, op, DoNotRespectImageOrientation, useLowQualityScale);
+ destinationContext->drawImage(image.get(), styleColorSpace, destRect, srcRect, op, blendMode, DoNotRespectImageOrientation, useLowQualityScale);
}
void ImageBuffer::drawPattern(GraphicsContext* context, const FloatRect& srcRect, const AffineTransform& patternTransform,
@@ -113,12 +159,14 @@ void ImageBuffer::drawPattern(GraphicsContext* context, const FloatRect& srcRect
void ImageBuffer::platformTransformColorSpace(const Vector<int>& lookUpTable)
{
- ASSERT(cairo_surface_get_type(m_data.m_surface) == CAIRO_SURFACE_TYPE_IMAGE);
+ // FIXME: Enable color space conversions on accelerated canvases.
+ if (cairo_surface_get_type(m_data.m_surface.get()) != CAIRO_SURFACE_TYPE_IMAGE)
+ return;
- unsigned char* dataSrc = cairo_image_surface_get_data(m_data.m_surface);
- int stride = cairo_image_surface_get_stride(m_data.m_surface);
+ unsigned char* dataSrc = cairo_image_surface_get_data(m_data.m_surface.get());
+ int stride = cairo_image_surface_get_stride(m_data.m_surface.get());
for (int y = 0; y < m_size.height(); ++y) {
- unsigned* row = reinterpret_cast<unsigned*>(dataSrc + stride * y);
+ unsigned* row = reinterpret_cast_ptr<unsigned*>(dataSrc + stride * y);
for (int x = 0; x < m_size.width(); x++) {
unsigned* pixel = row + x;
Color pixelColor = colorFromPremultipliedARGB(*pixel);
@@ -129,16 +177,49 @@ void ImageBuffer::platformTransformColorSpace(const Vector<int>& lookUpTable)
*pixel = premultipliedARGBFromColor(pixelColor);
}
}
- cairo_surface_mark_dirty_rectangle (m_data.m_surface, 0, 0, m_size.width(), m_size.height());
+ cairo_surface_mark_dirty_rectangle(m_data.m_surface.get(), 0, 0, m_size.width(), m_size.height());
+}
+
+static cairo_surface_t* mapSurfaceToImage(cairo_surface_t* surface, const IntSize& size)
+{
+ if (cairo_surface_get_type(surface) == CAIRO_SURFACE_TYPE_IMAGE)
+ return surface;
+
+ cairo_surface_t* imageSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, size.width(), size.height());
+ RefPtr<cairo_t> cr = adoptRef(cairo_create(imageSurface));
+ cairo_set_source_surface(cr.get(), surface, 0, 0);
+ cairo_paint(cr.get());
+ return imageSurface;
+}
+
+static void unmapSurfaceFromImage(cairo_surface_t* surface, cairo_surface_t* imageSurface, const IntRect& dirtyRectangle = IntRect())
+{
+ if (surface == imageSurface && dirtyRectangle.isEmpty())
+ return;
+
+ if (dirtyRectangle.isEmpty()) {
+ cairo_surface_destroy(imageSurface);
+ return;
+ }
+
+ if (surface == imageSurface) {
+ cairo_surface_mark_dirty_rectangle(surface, dirtyRectangle.x(), dirtyRectangle.y(), dirtyRectangle.width(), dirtyRectangle.height());
+ return;
+ }
+
+ RefPtr<cairo_t> cr = adoptRef(cairo_create(surface));
+ cairo_set_source_surface(cr.get(), imageSurface, 0, 0);
+ cairo_rectangle(cr.get(), dirtyRectangle.x(), dirtyRectangle.y(), dirtyRectangle.width(), dirtyRectangle.height());
+ cairo_fill(cr.get());
+ cairo_surface_destroy(imageSurface);
}
template <Multiply multiplied>
PassRefPtr<Uint8ClampedArray> getImageData(const IntRect& rect, const ImageBufferData& data, const IntSize& size)
{
- ASSERT(cairo_surface_get_type(data.m_surface) == CAIRO_SURFACE_TYPE_IMAGE);
-
RefPtr<Uint8ClampedArray> result = Uint8ClampedArray::createUninitialized(rect.width() * rect.height() * 4);
- unsigned char* dataSrc = cairo_image_surface_get_data(data.m_surface);
+ cairo_surface_t* imageSurface = mapSurfaceToImage(data.m_surface.get(), size);
+ unsigned char* dataSrc = cairo_image_surface_get_data(imageSurface);
unsigned char* dataDst = result->data();
if (rect.x() < 0 || rect.y() < 0 || (rect.x() + rect.width()) > size.width() || (rect.y() + rect.height()) > size.height())
@@ -166,12 +247,12 @@ PassRefPtr<Uint8ClampedArray> getImageData(const IntRect& rect, const ImageBuffe
endy = size.height();
int numRows = endy - originy;
- int stride = cairo_image_surface_get_stride(data.m_surface);
+ int stride = cairo_image_surface_get_stride(imageSurface);
unsigned destBytesPerRow = 4 * rect.width();
unsigned char* destRows = dataDst + desty * destBytesPerRow + destx * 4;
for (int y = 0; y < numRows; ++y) {
- unsigned* row = reinterpret_cast<unsigned*>(dataSrc + stride * (y + originy));
+ unsigned* row = reinterpret_cast_ptr<unsigned*>(dataSrc + stride * (y + originy));
for (int x = 0; x < numColumns; x++) {
int basex = x * 4;
unsigned* pixel = row + x + originx;
@@ -199,6 +280,7 @@ PassRefPtr<Uint8ClampedArray> getImageData(const IntRect& rect, const ImageBuffe
destRows += destBytesPerRow;
}
+ unmapSurfaceFromImage(data.m_surface.get(), imageSurface);
return result.release();
}
@@ -214,9 +296,8 @@ PassRefPtr<Uint8ClampedArray> ImageBuffer::getPremultipliedImageData(const IntRe
void ImageBuffer::putByteArray(Multiply multiplied, Uint8ClampedArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, CoordinateSystem)
{
- ASSERT(cairo_surface_get_type(m_data.m_surface) == CAIRO_SURFACE_TYPE_IMAGE);
-
- unsigned char* dataDst = cairo_image_surface_get_data(m_data.m_surface);
+ cairo_surface_t* imageSurface = mapSurfaceToImage(m_data.m_surface.get(), sourceSize);
+ unsigned char* dataDst = cairo_image_surface_get_data(imageSurface);
ASSERT(sourceRect.width() > 0);
ASSERT(sourceRect.height() > 0);
@@ -245,11 +326,11 @@ void ImageBuffer::putByteArray(Multiply multiplied, Uint8ClampedArray* source, c
int numRows = endy - desty;
unsigned srcBytesPerRow = 4 * sourceSize.width();
- int stride = cairo_image_surface_get_stride(m_data.m_surface);
+ int stride = cairo_image_surface_get_stride(imageSurface);
unsigned char* srcRows = source->data() + originy * srcBytesPerRow + originx * 4;
for (int y = 0; y < numRows; ++y) {
- unsigned* row = reinterpret_cast<unsigned*>(dataDst + stride * (y + desty));
+ unsigned* row = reinterpret_cast_ptr<unsigned*>(dataDst + stride * (y + desty));
for (int x = 0; x < numColumns; x++) {
int basex = x * 4;
unsigned* pixel = row + x + destx;
@@ -273,9 +354,8 @@ void ImageBuffer::putByteArray(Multiply multiplied, Uint8ClampedArray* source, c
}
srcRows += srcBytesPerRow;
}
- cairo_surface_mark_dirty_rectangle(m_data.m_surface,
- destx, desty,
- numColumns, numRows);
+
+ unmapSurfaceFromImage(m_data.m_surface.get(), imageSurface, IntRect(destx, desty, numColumns, numRows));
}
#if !PLATFORM(GTK)
@@ -310,4 +390,34 @@ String ImageBuffer::toDataURL(const String& mimeType, const double*, CoordinateS
}
#endif
+#if ENABLE(ACCELERATED_2D_CANVAS)
+void ImageBufferData::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity)
+{
+ if (textureMapper->accelerationMode() != TextureMapper::OpenGLMode) {
+ notImplemented();
+ return;
+ }
+
+ ASSERT(m_texture);
+
+ // Cairo may change the active context, so we make sure to change it back after flushing.
+ GLContext* previousActiveContext = GLContext::getCurrent();
+ cairo_surface_flush(m_surface.get());
+ previousActiveContext->makeContextCurrent();
+
+ static_cast<TextureMapperGL*>(textureMapper)->drawTexture(m_texture, TextureMapperGL::ShouldBlend, m_size, targetRect, matrix, opacity);
+}
+#endif
+
+#if USE(ACCELERATED_COMPOSITING)
+PlatformLayer* ImageBuffer::platformLayer() const
+{
+#if ENABLE(ACCELERATED_2D_CANVAS)
+ if (m_data.m_texture)
+ return const_cast<ImageBufferData*>(&m_data);
+#endif
+ return 0;
+}
+#endif
+
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/cairo/ImageBufferDataCairo.h b/Source/WebCore/platform/graphics/cairo/ImageBufferDataCairo.h
index 5ca7262f9..72ea4c34f 100644
--- a/Source/WebCore/platform/graphics/cairo/ImageBufferDataCairo.h
+++ b/Source/WebCore/platform/graphics/cairo/ImageBufferDataCairo.h
@@ -24,19 +24,33 @@
*/
#include "PlatformContextCairo.h"
+#include "RefPtrCairo.h"
-typedef struct _cairo_surface cairo_surface_t;
+#if ENABLE(ACCELERATED_2D_CANVAS)
+#include "TextureMapper.h"
+#include "TextureMapperPlatformLayer.h"
+#endif
namespace WebCore {
class IntSize;
-class ImageBufferData {
+class ImageBufferData
+#if ENABLE(ACCELERATED_2D_CANVAS)
+ : public TextureMapperPlatformLayer
+#endif
+{
public:
ImageBufferData(const IntSize&);
- cairo_surface_t* m_surface;
+ RefPtr<cairo_surface_t> m_surface;
PlatformContextCairo m_platformContext;
+ IntSize m_size;
+
+#if ENABLE(ACCELERATED_2D_CANVAS)
+ virtual void paintToTextureMapper(TextureMapper*, const FloatRect& target, const TransformationMatrix&, float opacity);
+ uint32_t m_texture;
+#endif
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/cairo/ImageCairo.cpp b/Source/WebCore/platform/graphics/cairo/ImageCairo.cpp
index f1af13c51..46a39b45b 100644
--- a/Source/WebCore/platform/graphics/cairo/ImageCairo.cpp
+++ b/Source/WebCore/platform/graphics/cairo/ImageCairo.cpp
@@ -35,7 +35,6 @@
#include "Color.h"
#include "GraphicsContext.h"
#include "ImageObserver.h"
-#include "NativeImageCairo.h"
#include "PlatformContextCairo.h"
#include <cairo.h>
#include <math.h>
@@ -43,14 +42,14 @@
namespace WebCore {
void Image::drawPattern(GraphicsContext* context, const FloatRect& tileRect, const AffineTransform& patternTransform,
- const FloatPoint& phase, ColorSpace, CompositeOperator op, const FloatRect& destRect)
+ const FloatPoint& phase, ColorSpace, CompositeOperator op, const FloatRect& destRect, BlendMode)
{
- NativeImageCairo* image = nativeImageForCurrentFrame();
- if (!image) // If it's too early we won't have an image yet.
+ RefPtr<cairo_surface_t> surface = nativeImageForCurrentFrame();
+ if (!surface) // If it's too early we won't have an image yet.
return;
cairo_t* cr = context->platformContext()->cr();
- drawPatternToCairoContext(cr, image->surface(), size(), tileRect, patternTransform, phase, toCairoOperator(op), destRect);
+ drawPatternToCairoContext(cr, surface.get(), size(), tileRect, patternTransform, phase, toCairoOperator(op), destRect);
if (imageObserver())
imageObserver()->didDraw(this);
diff --git a/Source/WebCore/platform/graphics/cairo/NativeImageCairo.cpp b/Source/WebCore/platform/graphics/cairo/NativeImageCairo.cpp
deleted file mode 100644
index af674d471..000000000
--- a/Source/WebCore/platform/graphics/cairo/NativeImageCairo.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2008, Google Inc. All rights reserved.
- * Copyright (c) 2012, Igalia S.L.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "NativeImageCairo.h"
-
-namespace WebCore {
-
-NativeImageCairo::NativeImageCairo()
-{
-}
-
-NativeImageCairo::NativeImageCairo(cairo_surface_t* surface)
- : m_surface(adoptRef(surface))
-{
-}
-
-NativeImageCairo::~NativeImageCairo()
-{
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/cairo/PathCairo.cpp b/Source/WebCore/platform/graphics/cairo/PathCairo.cpp
index 5e946531a..5fac5f0b9 100644
--- a/Source/WebCore/platform/graphics/cairo/PathCairo.cpp
+++ b/Source/WebCore/platform/graphics/cairo/PathCairo.cpp
@@ -173,7 +173,7 @@ void Path::addArc(const FloatPoint& p, float r, float startAngle, float endAngle
{
// http://bugs.webkit.org/show_bug.cgi?id=16449
// cairo_arc() functions hang or crash when passed inf as radius or start/end angle
- if (!isfinite(r) || !isfinite(startAngle) || !isfinite(endAngle))
+ if (!std::isfinite(r) || !std::isfinite(startAngle) || !std::isfinite(endAngle))
return;
cairo_t* cr = ensurePlatformPath()->context();
@@ -330,7 +330,7 @@ FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier) const
bool Path::contains(const FloatPoint& point, WindRule rule) const
{
- if (isNull() || !isfinite(point.x()) || !isfinite(point.y()))
+ if (isNull() || !std::isfinite(point.x()) || !std::isfinite(point.y()))
return false;
cairo_t* cr = platformPath()->context();
cairo_fill_rule_t cur = cairo_get_fill_rule(cr);
diff --git a/Source/WebCore/platform/graphics/cairo/PatternCairo.cpp b/Source/WebCore/platform/graphics/cairo/PatternCairo.cpp
index 22368b8c0..8870d3e03 100644
--- a/Source/WebCore/platform/graphics/cairo/PatternCairo.cpp
+++ b/Source/WebCore/platform/graphics/cairo/PatternCairo.cpp
@@ -34,11 +34,11 @@ namespace WebCore {
cairo_pattern_t* Pattern::createPlatformPattern(const AffineTransform&) const
{
- NativeImageCairo* image = tileImage()->nativeImageForCurrentFrame();
- if (!image)
+ RefPtr<cairo_surface_t> surface = tileImage()->nativeImageForCurrentFrame();
+ if (!surface)
return 0;
- cairo_pattern_t* pattern = cairo_pattern_create_for_surface(image->surface());
+ cairo_pattern_t* pattern = cairo_pattern_create_for_surface(surface.get());
// cairo merges patter space and user space itself
cairo_matrix_t matrix = m_patternSpaceTransformation;
diff --git a/Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp b/Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp
index 865d15294..147dc15ad 100644
--- a/Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp
+++ b/Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp
@@ -154,12 +154,28 @@ static void drawPatternToCairoContext(cairo_t* cr, cairo_pattern_t* pattern, con
cairo_fill(cr);
}
-void PlatformContextCairo::drawSurfaceToContext(cairo_surface_t* surface, const FloatRect& destRect, const FloatRect& srcRect, GraphicsContext* context)
+void PlatformContextCairo::drawSurfaceToContext(cairo_surface_t* surface, const FloatRect& destRect, const FloatRect& originalSrcRect, GraphicsContext* context)
{
- // If we're drawing a sub portion of the image or scaling then create
- // a pattern transformation on the image and draw the transformed pattern.
- // Test using example site at http://www.meyerweb.com/eric/css/edge/complexspiral/demo.html
- RefPtr<cairo_pattern_t> pattern = adoptRef(cairo_pattern_create_for_surface(surface));
+ FloatRect srcRect = originalSrcRect;
+
+ // We need to account for negative source dimensions by flipping the rectangle.
+ if (originalSrcRect.width() < 0) {
+ srcRect.setX(originalSrcRect.x() + originalSrcRect.width());
+ srcRect.setWidth(std::fabs(originalSrcRect.width()));
+ }
+ if (originalSrcRect.height() < 0) {
+ srcRect.setY(originalSrcRect.y() + originalSrcRect.height());
+ srcRect.setHeight(std::fabs(originalSrcRect.height()));
+ }
+
+ // Cairo subsurfaces don't support floating point boundaries well, so we expand the rectangle.
+ IntRect expandedSrcRect(enclosingIntRect(srcRect));
+
+ // We use a subsurface here so that we don't end up sampling outside the originalSrcRect rectangle.
+ // See https://bugs.webkit.org/show_bug.cgi?id=58309
+ RefPtr<cairo_surface_t> subsurface = adoptRef(cairo_surface_create_for_rectangle(
+ surface, expandedSrcRect.x(), expandedSrcRect.y(), expandedSrcRect.width(), expandedSrcRect.height()));
+ RefPtr<cairo_pattern_t> pattern = adoptRef(cairo_pattern_create_for_surface(subsurface.get()));
ASSERT(m_state);
switch (m_state->m_imageInterpolationQuality) {
@@ -177,9 +193,15 @@ void PlatformContextCairo::drawSurfaceToContext(cairo_surface_t* surface, const
}
cairo_pattern_set_extend(pattern.get(), CAIRO_EXTEND_PAD);
- float scaleX = srcRect.width() / destRect.width();
- float scaleY = srcRect.height() / destRect.height();
- cairo_matrix_t matrix = { scaleX, 0, 0, scaleY, srcRect.x(), srcRect.y() };
+ // The pattern transformation properly scales the pattern for when the source rectangle is a
+ // different size than the destination rectangle. We also account for any offset we introduced
+ // by expanding floating point source rectangle sizes. It's important to take the absolute value
+ // of the scale since the original width and height might be negative.
+ float scaleX = std::fabs(srcRect.width() / destRect.width());
+ float scaleY = std::fabs(srcRect.height() / destRect.height());
+ float leftPadding = static_cast<float>(expandedSrcRect.x()) - floorf(srcRect.x());
+ float topPadding = static_cast<float>(expandedSrcRect.y()) - floorf(srcRect.y());
+ cairo_matrix_t matrix = { scaleX, 0, 0, scaleY, leftPadding, topPadding };
cairo_pattern_set_matrix(pattern.get(), &matrix);
ShadowBlur& shadow = context->platformContext()->shadowBlur();
diff --git a/Source/WebCore/platform/graphics/cg/BitmapImageCG.cpp b/Source/WebCore/platform/graphics/cg/BitmapImageCG.cpp
index 1f2d0355e..cd037a98a 100644
--- a/Source/WebCore/platform/graphics/cg/BitmapImageCG.cpp
+++ b/Source/WebCore/platform/graphics/cg/BitmapImageCG.cpp
@@ -31,10 +31,11 @@
#include "FloatConversion.h"
#include "GraphicsContextCG.h"
#include "ImageObserver.h"
+#include "SubimageCacheWithTimer.h"
#include <ApplicationServices/ApplicationServices.h>
#include <wtf/RetainPtr.h>
-#if PLATFORM(MAC) || PLATFORM(CHROMIUM)
+#if PLATFORM(MAC)
#include "WebCoreSystemInterface.h"
#endif
@@ -52,6 +53,9 @@ bool FrameData::clear(bool clearMetadata)
m_orientation = DefaultImageOrientation;
if (m_frame) {
+#if CACHE_SUBIMAGES
+ subimageCache().clearImage(m_frame);
+#endif
CGImageRelease(m_frame);
m_frame = 0;
return true;
@@ -110,7 +114,7 @@ void BitmapImage::checkForSolidColor()
// Currently we only check for solid color in the important special case of a 1x1 image.
if (image && CGImageGetWidth(image) == 1 && CGImageGetHeight(image) == 1) {
unsigned char pixel[4]; // RGBA
- RetainPtr<CGContextRef> bmap(AdoptCF, CGBitmapContextCreate(pixel, 1, 1, 8, sizeof(pixel), deviceRGBColorSpaceRef(),
+ RetainPtr<CGContextRef> bmap = adoptCF(CGBitmapContextCreate(pixel, 1, 1, 8, sizeof(pixel), deviceRGBColorSpaceRef(),
kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big));
if (!bmap)
return;
@@ -154,15 +158,15 @@ RetainPtr<CFArrayRef> BitmapImage::getCGImageArray()
if (CGImageRef currFrame = frameAtIndex(i))
CFArrayAppendValue(array, currFrame);
}
- return RetainPtr<CFArrayRef>(AdoptCF, array);
+ return adoptCF(array);
}
-void BitmapImage::draw(GraphicsContext* ctx, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator op)
+void BitmapImage::draw(GraphicsContext* ctx, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator op, BlendMode blendMode)
{
- draw(ctx, dstRect, srcRect, styleColorSpace, op, DoNotRespectImageOrientation);
+ draw(ctx, dstRect, srcRect, styleColorSpace, op, blendMode, DoNotRespectImageOrientation);
}
-void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& destRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator compositeOp, RespectImageOrientationEnum shouldRespectImageOrientation)
+void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& destRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator compositeOp, BlendMode blendMode, RespectImageOrientationEnum shouldRespectImageOrientation)
{
startAnimation();
@@ -181,7 +185,7 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& destRect, const F
if (shouldRespectImageOrientation == RespectImageOrientation)
orientation = frameOrientationAtIndex(m_currentFrame);
- ctxt->drawNativeImage(image, selfSize, styleColorSpace, destRect, srcRect, compositeOp, orientation);
+ ctxt->drawNativeImage(image, selfSize, styleColorSpace, destRect, srcRect, compositeOp, blendMode, orientation);
if (imageObserver())
imageObserver()->didDraw(this);
diff --git a/Source/WebCore/platform/graphics/cg/ColorCG.cpp b/Source/WebCore/platform/graphics/cg/ColorCG.cpp
index 55a301717..d74b4b470 100644
--- a/Source/WebCore/platform/graphics/cg/ColorCG.cpp
+++ b/Source/WebCore/platform/graphics/cg/ColorCG.cpp
@@ -123,7 +123,7 @@ template<ColorSpace colorSpace> static CGColorRef cachedCGColor(const Color& col
static size_t cursor;
cachedRGBAValues[cursor] = color.rgb();
- cachedCGColors[cursor].adoptCF(newCGColor);
+ cachedCGColors[cursor] = adoptCF(newCGColor);
if (++cursor == cacheSize)
cursor = 0;
diff --git a/Source/WebCore/platform/graphics/cg/FloatPointCG.cpp b/Source/WebCore/platform/graphics/cg/FloatPointCG.cpp
index 006983e3f..f37e07f31 100644
--- a/Source/WebCore/platform/graphics/cg/FloatPointCG.cpp
+++ b/Source/WebCore/platform/graphics/cg/FloatPointCG.cpp
@@ -27,7 +27,7 @@
#include "config.h"
#include "FloatPoint.h"
-#if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM)
+#if USE(CG)
#include <ApplicationServices/ApplicationServices.h>
diff --git a/Source/WebCore/platform/graphics/cg/FloatRectCG.cpp b/Source/WebCore/platform/graphics/cg/FloatRectCG.cpp
index fe6f880cc..4ea083aea 100644
--- a/Source/WebCore/platform/graphics/cg/FloatRectCG.cpp
+++ b/Source/WebCore/platform/graphics/cg/FloatRectCG.cpp
@@ -27,7 +27,7 @@
#include "config.h"
#include "FloatRect.h"
-#if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM)
+#if USE(CG)
#include <ApplicationServices/ApplicationServices.h>
diff --git a/Source/WebCore/platform/graphics/cg/FloatSizeCG.cpp b/Source/WebCore/platform/graphics/cg/FloatSizeCG.cpp
index a3dcbdd00..14e14fc2a 100644
--- a/Source/WebCore/platform/graphics/cg/FloatSizeCG.cpp
+++ b/Source/WebCore/platform/graphics/cg/FloatSizeCG.cpp
@@ -27,7 +27,7 @@
#include "config.h"
#include "FloatSize.h"
-#if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM) || (PLATFORM(QT) && USE(QTKIT))
+#if USE(CG)
#include <ApplicationServices/ApplicationServices.h>
diff --git a/Source/WebCore/platform/graphics/cg/GradientCG.cpp b/Source/WebCore/platform/graphics/cg/GradientCG.cpp
index 9308e6f1c..47d9c7f60 100644
--- a/Source/WebCore/platform/graphics/cg/GradientCG.cpp
+++ b/Source/WebCore/platform/graphics/cg/GradientCG.cpp
@@ -48,10 +48,10 @@ CGGradientRef Gradient::platformGradient()
const int cReservedStops = 3;
Vector<CGFloat, 4 * cReservedStops> colorComponents;
- colorComponents.reserveCapacity(m_stops.size() * 4); // RGBA components per stop
+ colorComponents.reserveInitialCapacity(m_stops.size() * 4); // RGBA components per stop
Vector<CGFloat, cReservedStops> locations;
- locations.reserveCapacity(m_stops.size());
+ locations.reserveInitialCapacity(m_stops.size());
for (size_t i = 0; i < m_stops.size(); ++i) {
colorComponents.uncheckedAppend(m_stops[i].red);
diff --git a/Source/WebCore/platform/graphics/cg/GraphicsContext3DCG.cpp b/Source/WebCore/platform/graphics/cg/GraphicsContext3DCG.cpp
index ac00c43de..b9eddb672 100644
--- a/Source/WebCore/platform/graphics/cg/GraphicsContext3DCG.cpp
+++ b/Source/WebCore/platform/graphics/cg/GraphicsContext3DCG.cpp
@@ -34,6 +34,10 @@
#include "GraphicsContextCG.h"
#include "Image.h"
+#if HAVE(ARM_NEON_INTRINSICS)
+#include "GraphicsContext3DNEON.h"
+#endif
+
#include <CoreGraphics/CGBitmapContext.h>
#include <CoreGraphics/CGContext.h>
#include <CoreGraphics/CGDataProvider.h>
@@ -62,7 +66,7 @@ enum AlphaFormat {
};
// This returns SourceFormatNumFormats if the combination of input parameters is unsupported.
-static GraphicsContext3D::SourceDataFormat getSourceDataFormat(unsigned int componentsPerPixel, AlphaFormat alphaFormat, bool is16BitFormat, bool bigEndian)
+static GraphicsContext3D::DataFormat getSourceDataFormat(unsigned componentsPerPixel, AlphaFormat alphaFormat, bool is16BitFormat, bool bigEndian)
{
const static SourceDataFormatBase formatTableBase[4][AlphaFormatNumFormats] = { // componentsPerPixel x AlphaFormat
// AlphaFormatNone AlphaFormatFirst AlphaFormatLast
@@ -71,59 +75,279 @@ static GraphicsContext3D::SourceDataFormat getSourceDataFormat(unsigned int comp
{ SourceFormatBaseRGB, SourceFormatBaseNumFormats, SourceFormatBaseNumFormats }, // 3 componentsPerPixel
{ SourceFormatBaseNumFormats, SourceFormatBaseARGB, SourceFormatBaseRGBA } // 4 componentsPerPixel
};
- const static GraphicsContext3D::SourceDataFormat formatTable[SourceFormatBaseNumFormats][4] = { // SourceDataFormatBase x bitsPerComponent x endian
+ const static GraphicsContext3D::DataFormat formatTable[SourceFormatBaseNumFormats][4] = { // SourceDataFormatBase x bitsPerComponent x endian
// 8bits, little endian 8bits, big endian 16bits, little endian 16bits, big endian
- { GraphicsContext3D::SourceFormatR8, GraphicsContext3D::SourceFormatR8, GraphicsContext3D::SourceFormatR16Little, GraphicsContext3D::SourceFormatR16Big },
- { GraphicsContext3D::SourceFormatA8, GraphicsContext3D::SourceFormatA8, GraphicsContext3D::SourceFormatA16Little, GraphicsContext3D::SourceFormatA16Big },
- { GraphicsContext3D::SourceFormatAR8, GraphicsContext3D::SourceFormatRA8, GraphicsContext3D::SourceFormatRA16Little, GraphicsContext3D::SourceFormatRA16Big },
- { GraphicsContext3D::SourceFormatRA8, GraphicsContext3D::SourceFormatAR8, GraphicsContext3D::SourceFormatAR16Little, GraphicsContext3D::SourceFormatAR16Big },
- { GraphicsContext3D::SourceFormatBGR8, GraphicsContext3D::SourceFormatRGB8, GraphicsContext3D::SourceFormatRGB16Little, GraphicsContext3D::SourceFormatRGB16Big },
- { GraphicsContext3D::SourceFormatABGR8, GraphicsContext3D::SourceFormatRGBA8, GraphicsContext3D::SourceFormatRGBA16Little, GraphicsContext3D::SourceFormatRGBA16Big },
- { GraphicsContext3D::SourceFormatBGRA8, GraphicsContext3D::SourceFormatARGB8, GraphicsContext3D::SourceFormatARGB16Little, GraphicsContext3D::SourceFormatARGB16Big }
+ { GraphicsContext3D::DataFormatR8, GraphicsContext3D::DataFormatR8, GraphicsContext3D::DataFormatR16Little, GraphicsContext3D::DataFormatR16Big },
+ { GraphicsContext3D::DataFormatA8, GraphicsContext3D::DataFormatA8, GraphicsContext3D::DataFormatA16Little, GraphicsContext3D::DataFormatA16Big },
+ { GraphicsContext3D::DataFormatAR8, GraphicsContext3D::DataFormatRA8, GraphicsContext3D::DataFormatRA16Little, GraphicsContext3D::DataFormatRA16Big },
+ { GraphicsContext3D::DataFormatRA8, GraphicsContext3D::DataFormatAR8, GraphicsContext3D::DataFormatAR16Little, GraphicsContext3D::DataFormatAR16Big },
+ { GraphicsContext3D::DataFormatBGR8, GraphicsContext3D::DataFormatRGB8, GraphicsContext3D::DataFormatRGB16Little, GraphicsContext3D::DataFormatRGB16Big },
+ { GraphicsContext3D::DataFormatABGR8, GraphicsContext3D::DataFormatRGBA8, GraphicsContext3D::DataFormatRGBA16Little, GraphicsContext3D::DataFormatRGBA16Big },
+ { GraphicsContext3D::DataFormatBGRA8, GraphicsContext3D::DataFormatARGB8, GraphicsContext3D::DataFormatARGB16Little, GraphicsContext3D::DataFormatARGB16Big }
};
ASSERT(componentsPerPixel <= 4 && componentsPerPixel > 0);
SourceDataFormatBase formatBase = formatTableBase[componentsPerPixel - 1][alphaFormat];
if (formatBase == SourceFormatBaseNumFormats)
- return GraphicsContext3D::SourceFormatNumFormats;
+ return GraphicsContext3D::DataFormatNumFormats;
return formatTable[formatBase][(is16BitFormat ? 2 : 0) + (bigEndian ? 1 : 0)];
}
-bool GraphicsContext3D::getImageData(Image* image,
- GC3Denum format,
- GC3Denum type,
- bool premultiplyAlpha,
- bool ignoreGammaAndColorProfile,
- Vector<uint8_t>& outputVector)
+namespace {
+uint8_t convertColor16LittleTo8(uint16_t value)
+{
+ return value >> 8;
+}
+
+uint8_t convertColor16BigTo8(uint16_t value)
+{
+ return static_cast<uint8_t>(value & 0x00FF);
+}
+
+template<int format, typename SourceType, typename DstType>
+ALWAYS_INLINE void convert16BitFormatToRGBA8(const SourceType*, DstType*, unsigned)
+{
+ ASSERT_NOT_REACHED();
+}
+
+template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormatRGBA16Little, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+#if HAVE(ARM_NEON_INTRINSICS)
+ SIMD::unpackOneRowOfRGBA16LittleToRGBA8(source, destination, pixelsPerRow);
+#endif
+ for (unsigned i = 0; i < pixelsPerRow; ++i) {
+ destination[0] = convertColor16LittleTo8(source[0]);
+ destination[1] = convertColor16LittleTo8(source[1]);
+ destination[2] = convertColor16LittleTo8(source[2]);
+ destination[3] = convertColor16LittleTo8(source[3]);
+ source += 4;
+ destination += 4;
+ }
+}
+
+template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormatRGBA16Big, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+ for (unsigned i = 0; i < pixelsPerRow; ++i) {
+ destination[0] = convertColor16BigTo8(source[0]);
+ destination[1] = convertColor16BigTo8(source[1]);
+ destination[2] = convertColor16BigTo8(source[2]);
+ destination[3] = convertColor16BigTo8(source[3]);
+ source += 4;
+ destination += 4;
+ }
+}
+
+template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormatRGB16Little, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
{
- if (!image)
+#if HAVE(ARM_NEON_INTRINSICS)
+ SIMD::unpackOneRowOfRGB16LittleToRGBA8(source, destination, pixelsPerRow);
+#endif
+ for (unsigned i = 0; i < pixelsPerRow; ++i) {
+ destination[0] = convertColor16LittleTo8(source[0]);
+ destination[1] = convertColor16LittleTo8(source[1]);
+ destination[2] = convertColor16LittleTo8(source[2]);
+ destination[3] = 0xFF;
+ source += 3;
+ destination += 4;
+ }
+}
+
+template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormatRGB16Big, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+ for (unsigned i = 0; i < pixelsPerRow; ++i) {
+ destination[0] = convertColor16BigTo8(source[0]);
+ destination[1] = convertColor16BigTo8(source[1]);
+ destination[2] = convertColor16BigTo8(source[2]);
+ destination[3] = 0xFF;
+ source += 3;
+ destination += 4;
+ }
+}
+
+template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormatARGB16Little, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+#if HAVE(ARM_NEON_INTRINSICS)
+ SIMD::unpackOneRowOfARGB16LittleToRGBA8(source, destination, pixelsPerRow);
+#endif
+ for (unsigned i = 0; i < pixelsPerRow; ++i) {
+ destination[0] = convertColor16LittleTo8(source[1]);
+ destination[1] = convertColor16LittleTo8(source[2]);
+ destination[2] = convertColor16LittleTo8(source[3]);
+ destination[3] = convertColor16LittleTo8(source[0]);
+ source += 4;
+ destination += 4;
+ }
+}
+
+template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormatARGB16Big, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+ for (unsigned i = 0; i < pixelsPerRow; ++i) {
+ destination[0] = convertColor16BigTo8(source[1]);
+ destination[1] = convertColor16BigTo8(source[2]);
+ destination[2] = convertColor16BigTo8(source[3]);
+ destination[3] = convertColor16BigTo8(source[0]);
+ source += 4;
+ destination += 4;
+ }
+}
+
+template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormatR16Little, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+ for (unsigned i = 0; i < pixelsPerRow; ++i) {
+ destination[0] = convertColor16LittleTo8(source[0]);
+ destination[1] = convertColor16LittleTo8(source[0]);
+ destination[2] = convertColor16LittleTo8(source[0]);
+ destination[3] = 0xFF;
+ source += 1;
+ destination += 4;
+ }
+}
+
+template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormatR16Big, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+ for (unsigned i = 0; i < pixelsPerRow; ++i) {
+ destination[0] = convertColor16BigTo8(source[0]);
+ destination[1] = convertColor16BigTo8(source[0]);
+ destination[2] = convertColor16BigTo8(source[0]);
+ destination[3] = 0xFF;
+ source += 1;
+ destination += 4;
+ }
+}
+
+template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormatRA16Little, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+ for (unsigned i = 0; i < pixelsPerRow; ++i) {
+ destination[0] = convertColor16LittleTo8(source[0]);
+ destination[1] = convertColor16LittleTo8(source[0]);
+ destination[2] = convertColor16LittleTo8(source[0]);
+ destination[3] = convertColor16LittleTo8(source[1]);
+ source += 2;
+ destination += 4;
+ }
+}
+
+template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormatRA16Big, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+ for (unsigned i = 0; i < pixelsPerRow; ++i) {
+ destination[0] = convertColor16BigTo8(source[0]);
+ destination[1] = convertColor16BigTo8(source[0]);
+ destination[2] = convertColor16BigTo8(source[0]);
+ destination[3] = convertColor16BigTo8(source[1]);
+ source += 2;
+ destination += 4;
+ }
+}
+
+template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormatAR16Little, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+ for (unsigned i = 0; i < pixelsPerRow; ++i) {
+ destination[0] = convertColor16LittleTo8(source[1]);
+ destination[1] = convertColor16LittleTo8(source[1]);
+ destination[2] = convertColor16LittleTo8(source[1]);
+ destination[3] = convertColor16LittleTo8(source[0]);
+ source += 2;
+ destination += 4;
+ }
+}
+
+template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormatAR16Big, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+ for (unsigned i = 0; i < pixelsPerRow; ++i) {
+ destination[0] = convertColor16BigTo8(source[1]);
+ destination[1] = convertColor16BigTo8(source[1]);
+ destination[2] = convertColor16BigTo8(source[1]);
+ destination[3] = convertColor16BigTo8(source[0]);
+ source += 2;
+ destination += 4;
+ }
+}
+
+template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormatA16Little, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+ for (unsigned i = 0; i < pixelsPerRow; ++i) {
+ destination[0] = 0x0;
+ destination[1] = 0x0;
+ destination[2] = 0x0;
+ destination[3] = convertColor16LittleTo8(source[0]);
+ source += 1;
+ destination += 4;
+ }
+}
+
+template<> ALWAYS_INLINE void convert16BitFormatToRGBA8<GraphicsContext3D::DataFormatA16Big, uint16_t, uint8_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+ for (unsigned i = 0; i < pixelsPerRow; ++i) {
+ destination[0] = 0x0;
+ destination[1] = 0x0;
+ destination[2] = 0x0;
+ destination[3] = convertColor16BigTo8(source[0]);
+ source += 1;
+ destination += 4;
+ }
+}
+
+void convert16BitFormatToRGBA8(GraphicsContext3D::DataFormat srcFormat, const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow)
+{
+#define CONVERT16BITFORMATTORGBA8(SrcFormat) \
+ case SrcFormat: \
+ return convert16BitFormatToRGBA8<SrcFormat>(source, destination, pixelsPerRow);
+
+ switch (srcFormat) {
+ CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormatR16Little)
+ CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormatR16Big)
+ CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormatA16Little)
+ CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormatA16Big)
+ CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormatRA16Little)
+ CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormatRA16Big)
+ CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormatAR16Little)
+ CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormatAR16Big)
+ CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormatRGB16Little)
+ CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormatRGB16Big)
+ CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormatRGBA16Little)
+ CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormatRGBA16Big)
+ CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormatARGB16Little)
+ CONVERT16BITFORMATTORGBA8(GraphicsContext3D::DataFormatARGB16Big)
+ default:
+ ASSERT_NOT_REACHED();
+ }
+#undef CONVERT16BITFORMATTORGBA8
+}
+
+}
+
+GraphicsContext3D::ImageExtractor::~ImageExtractor()
+{
+}
+
+bool GraphicsContext3D::ImageExtractor::extractImage(bool premultiplyAlpha, bool ignoreGammaAndColorProfile)
+{
+ if (!m_image)
return false;
- CGImageRef cgImage;
- RetainPtr<CGImageRef> decodedImage;
- bool hasAlpha = image->isBitmapImage() ? image->currentFrameHasAlpha() : true;
- if ((ignoreGammaAndColorProfile || (hasAlpha && !premultiplyAlpha)) && image->data()) {
+ bool hasAlpha = !m_image->currentFrameKnownToBeOpaque();
+ if ((ignoreGammaAndColorProfile || (hasAlpha && !premultiplyAlpha)) && m_image->data()) {
ImageSource decoder(ImageSource::AlphaNotPremultiplied,
ignoreGammaAndColorProfile ? ImageSource::GammaAndColorProfileIgnored : ImageSource::GammaAndColorProfileApplied);
- decoder.setData(image->data(), true);
+ decoder.setData(m_image->data(), true);
if (!decoder.frameCount())
return false;
- decodedImage.adoptCF(decoder.createFrameAtIndex(0));
- cgImage = decodedImage.get();
+ m_decodedImage = adoptCF(decoder.createFrameAtIndex(0));
+ m_cgImage = m_decodedImage.get();
} else
- cgImage = image->nativeImageForCurrentFrame();
- if (!cgImage)
+ m_cgImage = m_image->nativeImageForCurrentFrame();
+ if (!m_cgImage)
return false;
- size_t width = CGImageGetWidth(cgImage);
- size_t height = CGImageGetHeight(cgImage);
- if (!width || !height)
+ m_imageWidth = CGImageGetWidth(m_cgImage);
+ m_imageHeight = CGImageGetHeight(m_cgImage);
+ if (!m_imageWidth || !m_imageHeight)
return false;
// See whether the image is using an indexed color space, and if
// so, re-render it into an RGB color space. The image re-packing
// code requires color data, not color table indices, for the
// image data.
- CGColorSpaceRef colorSpace = CGImageGetColorSpace(cgImage);
+ CGColorSpaceRef colorSpace = CGImageGetColorSpace(m_cgImage);
CGColorSpaceModel model = CGColorSpaceGetModel(colorSpace);
if (model == kCGColorSpaceModelIndexed) {
RetainPtr<CGContextRef> bitmapContext;
@@ -131,30 +355,29 @@ bool GraphicsContext3D::getImageData(Image* image,
// the color table, which would allow us to avoid premultiplying the
// alpha channel. Creation of a bitmap context with an alpha channel
// doesn't seem to work unless it's premultiplied.
- bitmapContext.adoptCF(CGBitmapContextCreate(0, width, height, 8, width * 4,
- deviceRGBColorSpaceRef(),
- kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host));
+ bitmapContext = adoptCF(CGBitmapContextCreate(0, m_imageWidth, m_imageHeight, 8, m_imageWidth * 4,
+ deviceRGBColorSpaceRef(), kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host));
if (!bitmapContext)
return false;
CGContextSetBlendMode(bitmapContext.get(), kCGBlendModeCopy);
CGContextSetInterpolationQuality(bitmapContext.get(), kCGInterpolationNone);
- CGContextDrawImage(bitmapContext.get(), CGRectMake(0, 0, width, height), cgImage);
+ CGContextDrawImage(bitmapContext.get(), CGRectMake(0, 0, m_imageWidth, m_imageHeight), m_cgImage);
// Now discard the original CG image and replace it with a copy from the bitmap context.
- decodedImage.adoptCF(CGBitmapContextCreateImage(bitmapContext.get()));
- cgImage = decodedImage.get();
+ m_decodedImage = adoptCF(CGBitmapContextCreateImage(bitmapContext.get()));
+ m_cgImage = m_decodedImage.get();
}
- size_t bitsPerComponent = CGImageGetBitsPerComponent(cgImage);
- size_t bitsPerPixel = CGImageGetBitsPerPixel(cgImage);
+ size_t bitsPerComponent = CGImageGetBitsPerComponent(m_cgImage);
+ size_t bitsPerPixel = CGImageGetBitsPerPixel(m_cgImage);
if (bitsPerComponent != 8 && bitsPerComponent != 16)
return false;
if (bitsPerPixel % bitsPerComponent)
return false;
size_t componentsPerPixel = bitsPerPixel / bitsPerComponent;
- CGBitmapInfo bitInfo = CGImageGetBitmapInfo(cgImage);
+ CGBitmapInfo bitInfo = CGImageGetBitmapInfo(m_cgImage);
bool bigEndianSource = false;
// These could technically be combined into one large switch
// statement, but we prefer not to so that we fail fast if we
@@ -194,18 +417,18 @@ bool GraphicsContext3D::getImageData(Image* image,
}
}
- AlphaOp neededAlphaOp = AlphaDoNothing;
+ m_alphaOp = AlphaDoNothing;
AlphaFormat alphaFormat = AlphaFormatNone;
- switch (CGImageGetAlphaInfo(cgImage)) {
+ switch (CGImageGetAlphaInfo(m_cgImage)) {
case kCGImageAlphaPremultipliedFirst:
if (!premultiplyAlpha)
- neededAlphaOp = AlphaDoUnmultiply;
+ m_alphaOp = AlphaDoUnmultiply;
alphaFormat = AlphaFormatFirst;
break;
case kCGImageAlphaFirst:
// This path is only accessible for MacOS earlier than 10.6.4.
if (premultiplyAlpha)
- neededAlphaOp = AlphaDoPremultiply;
+ m_alphaOp = AlphaDoPremultiply;
alphaFormat = AlphaFormatFirst;
break;
case kCGImageAlphaNoneSkipFirst:
@@ -214,12 +437,12 @@ bool GraphicsContext3D::getImageData(Image* image,
break;
case kCGImageAlphaPremultipliedLast:
if (!premultiplyAlpha)
- neededAlphaOp = AlphaDoUnmultiply;
+ m_alphaOp = AlphaDoUnmultiply;
alphaFormat = AlphaFormatLast;
break;
case kCGImageAlphaLast:
if (premultiplyAlpha)
- neededAlphaOp = AlphaDoPremultiply;
+ m_alphaOp = AlphaDoPremultiply;
alphaFormat = AlphaFormatLast;
break;
case kCGImageAlphaNoneSkipLast:
@@ -231,54 +454,87 @@ bool GraphicsContext3D::getImageData(Image* image,
default:
return false;
}
- SourceDataFormat srcDataFormat = getSourceDataFormat(componentsPerPixel, alphaFormat, bitsPerComponent == 16, bigEndianSource);
- if (srcDataFormat == SourceFormatNumFormats)
- return false;
- RetainPtr<CFDataRef> pixelData;
- pixelData.adoptCF(CGDataProviderCopyData(CGImageGetDataProvider(cgImage)));
- if (!pixelData)
+ m_imageSourceFormat = getSourceDataFormat(componentsPerPixel, alphaFormat, bitsPerComponent == 16, bigEndianSource);
+ if (m_imageSourceFormat == DataFormatNumFormats)
return false;
- const UInt8* rgba = CFDataGetBytePtr(pixelData.get());
- unsigned int packedSize;
- // Output data is tightly packed (alignment == 1).
- if (computeImageSizeInBytes(format, type, width, height, 1, &packedSize, 0) != GraphicsContext3D::NO_ERROR)
+ m_pixelData = adoptCF(CGDataProviderCopyData(CGImageGetDataProvider(m_cgImage)));
+ if (!m_pixelData)
return false;
- outputVector.resize(packedSize);
+
+ m_imagePixelData = reinterpret_cast<const void*>(CFDataGetBytePtr(m_pixelData.get()));
unsigned int srcUnpackAlignment = 0;
- size_t bytesPerRow = CGImageGetBytesPerRow(cgImage);
- unsigned int padding = bytesPerRow - bitsPerPixel / 8 * width;
+ size_t bytesPerRow = CGImageGetBytesPerRow(m_cgImage);
+ unsigned padding = bytesPerRow - bitsPerPixel / 8 * m_imageWidth;
if (padding) {
srcUnpackAlignment = padding + 1;
while (bytesPerRow % srcUnpackAlignment)
++srcUnpackAlignment;
}
- bool rt = packPixels(rgba, srcDataFormat, width, height, srcUnpackAlignment,
- format, type, neededAlphaOp, outputVector.data());
- return rt;
+
+ m_imageSourceUnpackAlignment = srcUnpackAlignment;
+ // Using a bitmap context created according to destination format and drawing the CGImage to the bitmap context can also do the format conversion,
+ // but it would premultiply the alpha channel as a side effect.
+ // Prefer to mannually Convert 16bit per-component formats to RGBA8 formats instead.
+ if (bitsPerComponent == 16) {
+ m_formalizedRGBA8Data = adoptArrayPtr(new uint8_t[m_imageWidth * m_imageHeight * 4]);
+ const uint16_t* source = reinterpret_cast<const uint16_t*>(m_imagePixelData);
+ uint8_t* destination = m_formalizedRGBA8Data.get();
+ const ptrdiff_t srcStrideInElements = bytesPerRow / sizeof(uint16_t);
+ const ptrdiff_t dstStrideInElements = 4 * m_imageWidth;
+ for (unsigned i =0; i < m_imageHeight; i++) {
+ convert16BitFormatToRGBA8(m_imageSourceFormat, source, destination, m_imageWidth);
+ source += srcStrideInElements;
+ destination += dstStrideInElements;
+ }
+ m_imagePixelData = reinterpret_cast<const void*>(m_formalizedRGBA8Data.get());
+ m_imageSourceFormat = DataFormatRGBA8;
+ m_imageSourceUnpackAlignment = 1;
+ }
+ return true;
+}
+
+static void releaseImageData(void*, const void* data, size_t)
+{
+ fastFree(const_cast<void*>(data));
}
-void GraphicsContext3D::paintToCanvas(const unsigned char* imagePixels, int imageWidth, int imageHeight, int canvasWidth, int canvasHeight, CGContextRef context)
+void GraphicsContext3D::paintToCanvas(const unsigned char* imagePixels, int imageWidth, int imageHeight, int canvasWidth, int canvasHeight, GraphicsContext* context)
{
if (!imagePixels || imageWidth <= 0 || imageHeight <= 0 || canvasWidth <= 0 || canvasHeight <= 0 || !context)
return;
int rowBytes = imageWidth * 4;
- RetainPtr<CGDataProviderRef> dataProvider(AdoptCF, CGDataProviderCreateWithData(0, imagePixels, rowBytes * imageHeight, 0));
- RetainPtr<CGImageRef> cgImage(AdoptCF, CGImageCreate(imageWidth, imageHeight, 8, 32, rowBytes, deviceRGBColorSpaceRef(), kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host,
+ RetainPtr<CGDataProviderRef> dataProvider;
+
+ if (context->isAcceleratedContext()) {
+ unsigned char* copiedPixels;
+
+ if (!tryFastCalloc(imageHeight, rowBytes).getValue(copiedPixels))
+ return;
+
+ memcpy(copiedPixels, imagePixels, rowBytes * imageHeight);
+ dataProvider = adoptCF(CGDataProviderCreateWithData(0, copiedPixels, rowBytes * imageHeight, releaseImageData));
+ } else
+ dataProvider = adoptCF(CGDataProviderCreateWithData(0, imagePixels, rowBytes * imageHeight, 0));
+
+ RetainPtr<CGImageRef> cgImage = adoptCF(CGImageCreate(imageWidth, imageHeight, 8, 32, rowBytes, deviceRGBColorSpaceRef(), kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host,
dataProvider.get(), 0, false, kCGRenderingIntentDefault));
+
// CSS styling may cause the canvas's content to be resized on
// the page. Go back to the Canvas to figure out the correct
// width and height to draw.
- CGRect rect = CGRectMake(0, 0, canvasWidth, canvasHeight);
+ FloatRect canvasRect(0, 0, canvasWidth, canvasHeight);
+ FloatSize imageSize(imageWidth, imageHeight);
// We want to completely overwrite the previous frame's
// rendering results.
- CGContextSaveGState(context);
- CGContextSetBlendMode(context, kCGBlendModeCopy);
- CGContextSetInterpolationQuality(context, kCGInterpolationNone);
- CGContextDrawImage(context, rect, cgImage.get());
- CGContextRestoreGState(context);
+
+ GraphicsContextStateSaver stateSaver(*context);
+ context->scale(FloatSize(1, -1));
+ context->translate(0, -imageHeight);
+ context->setImageInterpolationQuality(InterpolationNone);
+ context->drawNativeImage(cgImage.get(), imageSize, ColorSpaceDeviceRGB, canvasRect, FloatRect(FloatPoint(), imageSize), CompositeCopy);
}
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp b/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
index 1edab0c33..bc9d9836b 100644
--- a/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
+++ b/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
@@ -37,14 +37,14 @@
#include "Path.h"
#include "Pattern.h"
#include "ShadowBlur.h"
+#include "SubimageCacheWithTimer.h"
#include "Timer.h"
#include <CoreGraphics/CoreGraphics.h>
#include <wtf/MathExtras.h>
#include <wtf/OwnArrayPtr.h>
#include <wtf/RetainPtr.h>
-#include <wtf/UnusedParam.h>
-#if PLATFORM(MAC) || PLATFORM(CHROMIUM)
+#if PLATFORM(MAC)
#include "WebCoreSystemInterface.h"
#endif
@@ -52,20 +52,6 @@
#include <WebKitSystemInterface/WebKitSystemInterface.h>
#endif
-#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))
-
-#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
-// Building on 10.6 or later: kCGInterpolationMedium is defined in the CGInterpolationQuality enum.
-#define HAVE_CG_INTERPOLATION_MEDIUM 1
-#endif
-
-#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
-// Targeting 10.6 or later: use kCGInterpolationMedium.
-#define WTF_USE_CG_INTERPOLATION_MEDIUM 1
-#endif
-
-#endif
-
extern "C" {
CG_EXTERN void CGContextSetCTM(CGContextRef, CGAffineTransform);
CG_EXTERN CGAffineTransform CGContextGetBaseCTM(CGContextRef);
@@ -79,117 +65,8 @@ using WTF::pairIntHash;
// FIXME: The following using declaration should be in <wtf/HashTraits.h>.
using WTF::GenericHashTraits;
-#define CACHE_SUBIMAGES 1
-
namespace WebCore {
-#if !CACHE_SUBIMAGES
-
-static inline RetainPtr<CGImageRef> subimage(CGImageRef image, const FloatRect& rect)
-{
- return adoptCF(CGImageCreateWithImageInRect(image, rect));
-}
-
-#else // CACHE_SUBIMAGES
-
-static const double subimageCacheClearDelay = 1;
-static const int maxSubimageCacheSize = 300;
-
-struct SubimageCacheEntry {
- RetainPtr<CGImageRef> image;
- FloatRect rect;
- RetainPtr<CGImageRef> subimage;
-};
-
-struct SubimageCacheEntryTraits : GenericHashTraits<SubimageCacheEntry> {
- typedef HashTraits<RetainPtr<CGImageRef> > ImageTraits;
-
- static const bool emptyValueIsZero = true;
-
- static const bool hasIsEmptyValueFunction = true;
- static bool isEmptyValue(const SubimageCacheEntry& value) { return !value.image; }
-
- static void constructDeletedValue(SubimageCacheEntry& slot) { ImageTraits::constructDeletedValue(slot.image); }
- static bool isDeletedValue(const SubimageCacheEntry& value) { return ImageTraits::isDeletedValue(value.image); }
-};
-
-struct SubimageCacheHash {
- static unsigned hash(CGImageRef image, const FloatRect& rect)
- {
- return pairIntHash(PtrHash<CGImageRef>::hash(image),
- (static_cast<unsigned>(rect.x()) << 16) | static_cast<unsigned>(rect.y()));
- }
- static unsigned hash(const SubimageCacheEntry& key)
- {
- return hash(key.image.get(), key.rect);
- }
- static bool equal(const SubimageCacheEntry& a, const SubimageCacheEntry& b)
- {
- return a.image == b.image && a.rect == b.rect;
- }
- static const bool safeToCompareToEmptyOrDeleted = true;
-};
-
-typedef HashSet<SubimageCacheEntry, SubimageCacheHash, SubimageCacheEntryTraits> SubimageCache;
-
-struct SubimageCacheWithTimer {
- SubimageCache cache;
- DeferrableOneShotTimer<SubimageCacheWithTimer> timer;
-
- SubimageCacheWithTimer()
- : timer(this, &SubimageCacheWithTimer::invalidateCacheTimerFired, subimageCacheClearDelay)
- {
- }
-
- void invalidateCacheTimerFired(DeferrableOneShotTimer<SubimageCacheWithTimer>*);
-};
-
-static SubimageCacheWithTimer& subimageCache()
-{
- static SubimageCacheWithTimer& cache = *new SubimageCacheWithTimer;
- return cache;
-}
-
-void SubimageCacheWithTimer::invalidateCacheTimerFired(DeferrableOneShotTimer<SubimageCacheWithTimer>*)
-{
- subimageCache().cache.clear();
-}
-
-struct SubimageRequest {
- CGImageRef image;
- const FloatRect& rect;
- SubimageRequest(CGImageRef image, const FloatRect& rect) : image(image), rect(rect) { }
-};
-
-struct SubimageCacheAdder {
- static unsigned hash(const SubimageRequest& value)
- {
- return SubimageCacheHash::hash(value.image, value.rect);
- }
- static bool equal(const SubimageCacheEntry& a, const SubimageRequest& b)
- {
- return a.image == b.image && a.rect == b.rect;
- }
- static void translate(SubimageCacheEntry& entry, const SubimageRequest& request, unsigned /*hashCode*/)
- {
- entry.image = request.image;
- entry.rect = request.rect;
- entry.subimage = adoptCF(CGImageCreateWithImageInRect(request.image, request.rect));
- }
-};
-
-static RetainPtr<CGImageRef> subimage(CGImageRef image, const FloatRect& rect)
-{
- SubimageCacheWithTimer& cache = subimageCache();
- cache.timer.restart();
- if (cache.cache.size() == maxSubimageCacheSize)
- cache.cache.remove(cache.cache.begin());
- ASSERT(cache.cache.size() < maxSubimageCacheSize);
- return cache.cache.add<SubimageRequest, SubimageCacheAdder>(SubimageRequest(image, rect)).iterator->subimage;
-}
-
-#endif // CACHE_SUBIMAGES
-
static void setCGFillColor(CGContextRef context, const Color& color, ColorSpace colorSpace)
{
CGContextSetFillColorWithColor(context, cachedCGColor(color, colorSpace));
@@ -265,7 +142,7 @@ void GraphicsContext::restorePlatformState()
m_data->m_userToDeviceTransformKnownToBeIdentity = false;
}
-void GraphicsContext::drawNativeImage(NativeImagePtr imagePtr, const FloatSize& imageSize, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator op, ImageOrientation orientation)
+void GraphicsContext::drawNativeImage(PassNativeImagePtr imagePtr, const FloatSize& imageSize, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator op, BlendMode blendMode, ImageOrientation orientation)
{
RetainPtr<CGImageRef> image(imagePtr);
@@ -306,7 +183,11 @@ void GraphicsContext::drawNativeImage(NativeImagePtr imagePtr, const FloatSize&
subimageRect.setHeight(ceilf(subimageRect.height() + topPadding));
adjustedDestRect.setHeight(subimageRect.height() / yScale);
- image = subimage(image.get(), subimageRect);
+#if CACHE_SUBIMAGES
+ image = subimageCache().getSubimage(image.get(), subimageRect);
+#else
+ image = adoptCF(CGImageCreateWithImageInRect(image, subimageRect));
+#endif
if (currHeight < srcRect.maxY()) {
ASSERT(CGImageGetHeight(image.get()) == currHeight - CGRectIntegral(srcRect).origin.y);
adjustedDestRect.setHeight(CGImageGetHeight(image.get()) / yScale);
@@ -324,7 +205,7 @@ void GraphicsContext::drawNativeImage(NativeImagePtr imagePtr, const FloatSize&
if (!shouldUseSubimage && currHeight < imageSize.height())
adjustedDestRect.setHeight(adjustedDestRect.height() * currHeight / imageSize.height());
- setPlatformCompositeOperation(op);
+ setPlatformCompositeOperation(op, blendMode);
// ImageOrientation expects the origin to be at (0, 0)
CGContextTranslateCTM(context, adjustedDestRect.x(), adjustedDestRect.y());
@@ -516,95 +397,6 @@ void GraphicsContext::drawEllipse(const IntRect& rect)
drawPath(path);
}
-
-void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan)
-{
- if (paintingDisabled() || strokeStyle() == NoStroke || strokeThickness() <= 0.0f)
- return;
-
- CGContextRef context = platformContext();
- CGContextSaveGState(context);
- CGContextBeginPath(context);
- CGContextSetShouldAntialias(context, false);
-
- int x = rect.x();
- int y = rect.y();
- float w = (float)rect.width();
- float h = (float)rect.height();
- float scaleFactor = h / w;
- float reverseScaleFactor = w / h;
-
- if (w != h)
- scale(FloatSize(1, scaleFactor));
-
- float hRadius = w / 2;
- float vRadius = h / 2;
- float fa = startAngle;
- float falen = fa + angleSpan;
- float start = -fa * piFloat / 180.0f;
- float end = -falen * piFloat / 180.0f;
- CGContextAddArc(context, x + hRadius, (y + vRadius) * reverseScaleFactor, hRadius, start, end, true);
-
- if (w != h)
- scale(FloatSize(1, reverseScaleFactor));
-
- float width = strokeThickness();
- int patWidth = 0;
-
- switch (strokeStyle()) {
- case DottedStroke:
- patWidth = (int)(width / 2);
- break;
- case DashedStroke:
- patWidth = 3 * (int)(width / 2);
- break;
- default:
- break;
- }
-
- if (patWidth) {
- // Example: 80 pixels with a width of 30 pixels.
- // Remainder is 20. The maximum pixels of line we could paint
- // will be 50 pixels.
- int distance;
- if (hRadius == vRadius)
- distance = static_cast<int>((piFloat * hRadius) / 2.0f);
- else // We are elliptical and will have to estimate the distance
- distance = static_cast<int>((piFloat * sqrtf((hRadius * hRadius + vRadius * vRadius) / 2.0f)) / 2.0f);
-
- int remainder = distance % patWidth;
- int coverage = distance - remainder;
- int numSegments = coverage / patWidth;
-
- float patternOffset = 0.0f;
- // Special case 1px dotted borders for speed.
- if (patWidth == 1)
- patternOffset = 1.0f;
- else {
- bool evenNumberOfSegments = !(numSegments % 2);
- if (remainder)
- evenNumberOfSegments = !evenNumberOfSegments;
- if (evenNumberOfSegments) {
- if (remainder) {
- patternOffset += patWidth - remainder;
- patternOffset += remainder / 2.0f;
- } else
- patternOffset = patWidth / 2.0f;
- } else {
- if (remainder)
- patternOffset = (patWidth - remainder) / 2.0f;
- }
- }
-
- const CGFloat dottedLine[2] = { static_cast<CGFloat>(patWidth), static_cast<CGFloat>(patWidth) };
- CGContextSetLineDash(context, patternOffset, dottedLine, 2);
- }
-
- CGContextStrokePath(context);
-
- CGContextRestoreGState(context);
-}
-
static void addConvexPolygonToPath(Path& path, size_t numberOfPoints, const FloatPoint* points)
{
ASSERT(numberOfPoints > 0);
@@ -662,11 +454,11 @@ void GraphicsContext::applyStrokePattern()
CGContextRef cgContext = platformContext();
AffineTransform userToBaseCTM = AffineTransform(wkGetUserToBaseCTM(cgContext));
- RetainPtr<CGPatternRef> platformPattern(AdoptCF, m_state.strokePattern->createPlatformPattern(userToBaseCTM));
+ RetainPtr<CGPatternRef> platformPattern = adoptCF(m_state.strokePattern->createPlatformPattern(userToBaseCTM));
if (!platformPattern)
return;
- RetainPtr<CGColorSpaceRef> patternSpace(AdoptCF, CGColorSpaceCreatePattern(0));
+ RetainPtr<CGColorSpaceRef> patternSpace = adoptCF(CGColorSpaceCreatePattern(0));
CGContextSetStrokeColorSpace(cgContext, patternSpace.get());
const CGFloat patternAlpha = 1;
@@ -678,11 +470,11 @@ void GraphicsContext::applyFillPattern()
CGContextRef cgContext = platformContext();
AffineTransform userToBaseCTM = AffineTransform(wkGetUserToBaseCTM(cgContext));
- RetainPtr<CGPatternRef> platformPattern(AdoptCF, m_state.fillPattern->createPlatformPattern(userToBaseCTM));
+ RetainPtr<CGPatternRef> platformPattern = adoptCF(m_state.fillPattern->createPlatformPattern(userToBaseCTM));
if (!platformPattern)
return;
- RetainPtr<CGColorSpaceRef> patternSpace(AdoptCF, CGColorSpaceCreatePattern(0));
+ RetainPtr<CGColorSpaceRef> patternSpace = adoptCF(CGColorSpaceCreatePattern(0));
CGContextSetFillColorSpace(cgContext, patternSpace.get());
const CGFloat patternAlpha = 1;
@@ -866,16 +658,6 @@ void GraphicsContext::strokePath(const Path& path)
CGContextStrokePath(context);
}
-static float radiusToLegacyRadius(float radius)
-{
- return radius > 8 ? 8 + 4 * sqrt((radius - 8) / 2) : radius;
-}
-
-static bool hasBlurredShadow(const GraphicsContextState& state)
-{
- return state.shadowColor.isValid() && state.shadowColor.alpha() && state.shadowBlur;
-}
-
void GraphicsContext::fillRect(const FloatRect& rect)
{
if (paintingDisabled())
@@ -912,14 +694,13 @@ void GraphicsContext::fillRect(const FloatRect& rect)
if (m_state.fillPattern)
applyFillPattern();
- bool drawOwnShadow = !isAcceleratedContext() && hasBlurredShadow(m_state) && !m_state.shadowsIgnoreTransforms; // Don't use ShadowBlur for canvas yet.
+ bool drawOwnShadow = !isAcceleratedContext() && hasBlurredShadow() && !m_state.shadowsIgnoreTransforms; // Don't use ShadowBlur for canvas yet.
if (drawOwnShadow) {
- float shadowBlur = m_state.shadowsUseLegacyRadius ? radiusToLegacyRadius(m_state.shadowBlur) : m_state.shadowBlur;
// Turn off CG shadows.
CGContextSaveGState(context);
CGContextSetShadowWithColor(platformContext(), CGSizeZero, 0, 0);
- ShadowBlur contextShadow(FloatSize(shadowBlur, shadowBlur), m_state.shadowOffset, m_state.shadowColor, m_state.shadowColorSpace);
+ ShadowBlur contextShadow(m_state);
contextShadow.drawRectShadow(this, rect, RoundedRect::Radii());
}
@@ -941,14 +722,13 @@ void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorS
if (oldFillColor != color || oldColorSpace != colorSpace)
setCGFillColor(context, color, colorSpace);
- bool drawOwnShadow = !isAcceleratedContext() && hasBlurredShadow(m_state) && !m_state.shadowsIgnoreTransforms; // Don't use ShadowBlur for canvas yet.
+ bool drawOwnShadow = !isAcceleratedContext() && hasBlurredShadow() && !m_state.shadowsIgnoreTransforms; // Don't use ShadowBlur for canvas yet.
if (drawOwnShadow) {
- float shadowBlur = m_state.shadowsUseLegacyRadius ? radiusToLegacyRadius(m_state.shadowBlur) : m_state.shadowBlur;
// Turn off CG shadows.
CGContextSaveGState(context);
CGContextSetShadowWithColor(platformContext(), CGSizeZero, 0, 0);
- ShadowBlur contextShadow(FloatSize(shadowBlur, shadowBlur), m_state.shadowOffset, m_state.shadowColor, m_state.shadowColorSpace);
+ ShadowBlur contextShadow(m_state);
contextShadow.drawRectShadow(this, rect, RoundedRect::Radii());
}
@@ -973,15 +753,13 @@ void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLef
if (oldFillColor != color || oldColorSpace != colorSpace)
setCGFillColor(context, color, colorSpace);
- bool drawOwnShadow = !isAcceleratedContext() && hasBlurredShadow(m_state) && !m_state.shadowsIgnoreTransforms; // Don't use ShadowBlur for canvas yet.
+ bool drawOwnShadow = !isAcceleratedContext() && hasBlurredShadow() && !m_state.shadowsIgnoreTransforms; // Don't use ShadowBlur for canvas yet.
if (drawOwnShadow) {
- float shadowBlur = m_state.shadowsUseLegacyRadius ? radiusToLegacyRadius(m_state.shadowBlur) : m_state.shadowBlur;
-
// Turn off CG shadows.
CGContextSaveGState(context);
CGContextSetShadowWithColor(platformContext(), CGSizeZero, 0, 0);
- ShadowBlur contextShadow(FloatSize(shadowBlur, shadowBlur), m_state.shadowOffset, m_state.shadowColor, m_state.shadowColorSpace);
+ ShadowBlur contextShadow(m_state);
contextShadow.drawRectShadow(this, rect, RoundedRect::Radii(topLeft, topRight, bottomLeft, bottomRight));
}
@@ -1026,15 +804,13 @@ void GraphicsContext::fillRectWithRoundedHole(const IntRect& rect, const Rounded
setFillColor(color, colorSpace);
// fillRectWithRoundedHole() assumes that the edges of rect are clipped out, so we only care about shadows cast around inside the hole.
- bool drawOwnShadow = !isAcceleratedContext() && hasBlurredShadow(m_state) && !m_state.shadowsIgnoreTransforms;
+ bool drawOwnShadow = !isAcceleratedContext() && hasBlurredShadow() && !m_state.shadowsIgnoreTransforms;
if (drawOwnShadow) {
- float shadowBlur = m_state.shadowsUseLegacyRadius ? radiusToLegacyRadius(m_state.shadowBlur) : m_state.shadowBlur;
-
// Turn off CG shadows.
CGContextSaveGState(context);
CGContextSetShadowWithColor(platformContext(), CGSizeZero, 0, 0);
- ShadowBlur contextShadow(FloatSize(shadowBlur, shadowBlur), m_state.shadowOffset, m_state.shadowColor, m_state.shadowColorSpace);
+ ShadowBlur contextShadow(m_state);
contextShadow.drawInsetShadow(this, rect, roundedHoleRect.rect(), roundedHoleRect.radii());
}
@@ -1097,23 +873,6 @@ IntRect GraphicsContext::clipBounds() const
return enclosingIntRect(CGContextGetClipBoundingBox(platformContext()));
}
-void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness)
-{
- if (paintingDisabled())
- return;
-
- clip(rect);
- CGContextRef context = platformContext();
-
- // Add outer ellipse
- CGContextAddEllipseInRect(context, CGRectMake(rect.x(), rect.y(), rect.width(), rect.height()));
- // Add inner ellipse.
- CGContextAddEllipseInRect(context, CGRectMake(rect.x() + thickness, rect.y() + thickness,
- rect.width() - (thickness * 2), rect.height() - (thickness * 2)));
-
- CGContextEOClip(context);
-}
-
void GraphicsContext::beginPlatformTransparencyLayer(float opacity)
{
if (paintingDisabled())
@@ -1334,7 +1093,7 @@ void GraphicsContext::setLineJoin(LineJoin join)
}
}
-void GraphicsContext::clip(const Path& path)
+void GraphicsContext::clip(const Path& path, WindRule fillRule)
{
if (paintingDisabled())
return;
@@ -1348,14 +1107,17 @@ void GraphicsContext::clip(const Path& path)
else {
CGContextBeginPath(context);
CGContextAddPath(context, path.platformPath());
- CGContextClip(context);
+ if (fillRule == RULE_NONZERO)
+ CGContextClip(context);
+ else
+ CGContextEOClip(context);
}
m_data->clip(path);
}
-void GraphicsContext::canvasClip(const Path& path)
+void GraphicsContext::canvasClip(const Path& path, WindRule fillRule)
{
- clip(path);
+ clip(path, fillRule);
}
void GraphicsContext::clipOut(const Path& path)
@@ -1431,9 +1193,6 @@ AffineTransform GraphicsContext::getCTM(IncludeDeviceScale includeScale) const
FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect, RoundingMode roundingMode)
{
-#if PLATFORM(CHROMIUM)
- return rect;
-#else
// It is not enough just to round to pixels in device space. The rotation part of the
// affine transform matrix to device space can mess with this conversion if we have a
// rotating image like the hands of the world clock widget. We just need the scale, so
@@ -1474,7 +1233,6 @@ FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect, RoundingMo
FloatPoint roundedOrigin = FloatPoint(deviceOrigin.x / deviceScaleX, deviceOrigin.y / deviceScaleY);
FloatPoint roundedLowerRight = FloatPoint(deviceLowerRight.x / deviceScaleX, deviceLowerRight.y / deviceScaleY);
return FloatRect(roundedOrigin, roundedLowerRight - roundedOrigin);
-#endif
}
void GraphicsContext::drawLineForText(const FloatPoint& point, float width, bool printing)
@@ -1531,7 +1289,7 @@ void GraphicsContext::setURLForRect(const KURL& link, const IntRect& destRect)
if (paintingDisabled())
return;
- RetainPtr<CFURLRef> urlRef(AdoptCF, link.createCFURL());
+ RetainPtr<CFURLRef> urlRef = link.createCFURL();
if (!urlRef)
return;
@@ -1564,13 +1322,9 @@ void GraphicsContext::setImageInterpolationQuality(InterpolationQuality mode)
case InterpolationLow:
quality = kCGInterpolationLow;
break;
-
- // Fall through to InterpolationHigh if kCGInterpolationMedium is not usable.
case InterpolationMedium:
-#if USE(CG_INTERPOLATION_MEDIUM)
quality = kCGInterpolationMedium;
break;
-#endif
case InterpolationHigh:
quality = kCGInterpolationHigh;
break;
@@ -1591,16 +1345,8 @@ InterpolationQuality GraphicsContext::imageInterpolationQuality() const
return InterpolationNone;
case kCGInterpolationLow:
return InterpolationLow;
-#if HAVE(CG_INTERPOLATION_MEDIUM)
- // kCGInterpolationMedium is known to be present in the CGInterpolationQuality enum.
case kCGInterpolationMedium:
-#if USE(CG_INTERPOLATION_MEDIUM)
- // Only map to InterpolationMedium if targeting a system that understands it.
return InterpolationMedium;
-#else
- return InterpolationDefault;
-#endif // USE(CG_INTERPOLATION_MEDIUM)
-#endif // HAVE(CG_INTERPOLATION_MEDIUM)
case kCGInterpolationHigh:
return InterpolationHigh;
}
@@ -1610,7 +1356,7 @@ InterpolationQuality GraphicsContext::imageInterpolationQuality() const
void GraphicsContext::setAllowsFontSmoothing(bool allowsFontSmoothing)
{
UNUSED_PARAM(allowsFontSmoothing);
-#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
+#if PLATFORM(MAC)
CGContextRef context = platformContext();
CGContextSetAllowsFontSmoothing(context, allowsFontSmoothing);
#endif
@@ -1698,55 +1444,106 @@ void GraphicsContext::setPlatformShouldSmoothFonts(bool enable)
CGContextSetShouldSmoothFonts(platformContext(), enable);
}
-void GraphicsContext::setPlatformCompositeOperation(CompositeOperator mode)
+void GraphicsContext::setPlatformCompositeOperation(CompositeOperator mode, BlendMode blendMode)
{
if (paintingDisabled())
return;
CGBlendMode target = kCGBlendModeNormal;
- switch (mode) {
- case CompositeClear:
- target = kCGBlendModeClear;
- break;
- case CompositeCopy:
- target = kCGBlendModeCopy;
- break;
- case CompositeSourceOver:
- //kCGBlendModeNormal
- break;
- case CompositeSourceIn:
- target = kCGBlendModeSourceIn;
- break;
- case CompositeSourceOut:
- target = kCGBlendModeSourceOut;
- break;
- case CompositeSourceAtop:
- target = kCGBlendModeSourceAtop;
- break;
- case CompositeDestinationOver:
- target = kCGBlendModeDestinationOver;
- break;
- case CompositeDestinationIn:
- target = kCGBlendModeDestinationIn;
- break;
- case CompositeDestinationOut:
- target = kCGBlendModeDestinationOut;
- break;
- case CompositeDestinationAtop:
- target = kCGBlendModeDestinationAtop;
- break;
- case CompositeXOR:
- target = kCGBlendModeXOR;
- break;
- case CompositePlusDarker:
- target = kCGBlendModePlusDarker;
- break;
- case CompositePlusLighter:
- target = kCGBlendModePlusLighter;
- break;
- case CompositeDifference:
- target = kCGBlendModeDifference;
- break;
+ if (blendMode != BlendModeNormal) {
+ switch (blendMode) {
+ case BlendModeMultiply:
+ target = kCGBlendModeMultiply;
+ break;
+ case BlendModeScreen:
+ target = kCGBlendModeScreen;
+ break;
+ case BlendModeOverlay:
+ target = kCGBlendModeOverlay;
+ break;
+ case BlendModeDarken:
+ target = kCGBlendModeDarken;
+ break;
+ case BlendModeLighten:
+ target = kCGBlendModeLighten;
+ break;
+ case BlendModeColorDodge:
+ target = kCGBlendModeColorDodge;
+ break;
+ case BlendModeColorBurn:
+ target = kCGBlendModeColorBurn;
+ break;
+ case BlendModeHardLight:
+ target = kCGBlendModeHardLight;
+ break;
+ case BlendModeSoftLight:
+ target = kCGBlendModeSoftLight;
+ break;
+ case BlendModeDifference:
+ target = kCGBlendModeDifference;
+ break;
+ case BlendModeExclusion:
+ target = kCGBlendModeExclusion;
+ break;
+ case BlendModeHue:
+ target = kCGBlendModeHue;
+ break;
+ case BlendModeSaturation:
+ target = kCGBlendModeSaturation;
+ break;
+ case BlendModeColor:
+ target = kCGBlendModeColor;
+ break;
+ case BlendModeLuminosity:
+ target = kCGBlendModeLuminosity;
+ default:
+ break;
+ }
+ } else {
+ switch (mode) {
+ case CompositeClear:
+ target = kCGBlendModeClear;
+ break;
+ case CompositeCopy:
+ target = kCGBlendModeCopy;
+ break;
+ case CompositeSourceOver:
+ // kCGBlendModeNormal
+ break;
+ case CompositeSourceIn:
+ target = kCGBlendModeSourceIn;
+ break;
+ case CompositeSourceOut:
+ target = kCGBlendModeSourceOut;
+ break;
+ case CompositeSourceAtop:
+ target = kCGBlendModeSourceAtop;
+ break;
+ case CompositeDestinationOver:
+ target = kCGBlendModeDestinationOver;
+ break;
+ case CompositeDestinationIn:
+ target = kCGBlendModeDestinationIn;
+ break;
+ case CompositeDestinationOut:
+ target = kCGBlendModeDestinationOut;
+ break;
+ case CompositeDestinationAtop:
+ target = kCGBlendModeDestinationAtop;
+ break;
+ case CompositeXOR:
+ target = kCGBlendModeXOR;
+ break;
+ case CompositePlusDarker:
+ target = kCGBlendModePlusDarker;
+ break;
+ case CompositePlusLighter:
+ target = kCGBlendModePlusLighter;
+ break;
+ case CompositeDifference:
+ target = kCGBlendModeDifference;
+ break;
+ }
}
CGContextSetBlendMode(platformContext(), target);
}
diff --git a/Source/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h b/Source/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h
index 5c0030836..fcc9d0152 100644
--- a/Source/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h
+++ b/Source/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h
@@ -51,7 +51,7 @@ public:
{
}
-#if PLATFORM(MAC) || PLATFORM(CHROMIUM)
+#if PLATFORM(MAC)
// These methods do nothing on Mac.
void save() {}
void restore() {}
diff --git a/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp b/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp
index b5871dc99..7c7cca86a 100644
--- a/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp
+++ b/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp
@@ -40,11 +40,10 @@
#include <wtf/MainThread.h>
#include <wtf/OwnArrayPtr.h>
#include <wtf/RetainPtr.h>
-#include <wtf/UnusedParam.h>
#include <wtf/text/Base64.h>
#include <wtf/text/WTFString.h>
-#if PLATFORM(MAC) || PLATFORM(CHROMIUM)
+#if PLATFORM(MAC)
#include "WebCoreSystemInterface.h"
#endif
@@ -62,7 +61,6 @@ namespace WebCore {
#if USE(IOSURFACE_CANVAS_BACKING_STORE)
static const int maxIOSurfaceDimension = 4096;
-static const int minIOSurfaceArea = 50 * 100;
static RetainPtr<IOSurfaceRef> createIOSurface(const IntSize& size)
{
@@ -94,11 +92,11 @@ static RetainPtr<IOSurfaceRef> createIOSurface(const IntSize& size)
keys[5] = kIOSurfaceAllocSize;
values[5] = CFNumberCreate(0, kCFNumberLongType, &allocSize);
- RetainPtr<CFDictionaryRef> dict(AdoptCF, CFDictionaryCreate(0, keys, values, 6, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+ RetainPtr<CFDictionaryRef> dict = adoptCF(CFDictionaryCreate(0, keys, values, 6, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
for (unsigned i = 0; i < 6; i++)
CFRelease(values[i]);
- return RetainPtr<IOSurfaceRef>(AdoptCF, IOSurfaceCreate(dict.get()));
+ return adoptCF(IOSurfaceCreate(dict.get()));
}
#endif
@@ -107,7 +105,7 @@ static void releaseImageData(void*, const void* data, size_t)
fastFree(const_cast<void*>(data));
}
-ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace imageColorSpace, RenderingMode renderingMode, DeferralMode, bool& success)
+ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace imageColorSpace, RenderingMode renderingMode, bool& success)
: m_data(size) // NOTE: The input here isn't important as ImageBufferDataCG's constructor just ignores it.
, m_logicalSize(size)
, m_resolutionScale(resolutionScale)
@@ -136,7 +134,7 @@ ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace
return;
#if USE(IOSURFACE_CANVAS_BACKING_STORE)
- if (width.unsafeGet() >= maxIOSurfaceDimension || height.unsafeGet() >= maxIOSurfaceDimension || (width * height).unsafeGet() < minIOSurfaceArea)
+ if (width.unsafeGet() >= maxIOSurfaceDimension || height.unsafeGet() >= maxIOSurfaceDimension)
accelerateRendering = false;
#else
ASSERT(renderingMode == Unaccelerated);
@@ -158,7 +156,7 @@ ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace
if (accelerateRendering) {
#if USE(IOSURFACE_CANVAS_BACKING_STORE)
m_data.m_surface = createIOSurface(m_size);
- cgContext.adoptCF(wkIOSurfaceContextCreate(m_data.m_surface.get(), width.unsafeGet(), height.unsafeGet(), m_data.m_colorSpace));
+ cgContext = adoptCF(wkIOSurfaceContextCreate(m_data.m_surface.get(), width.unsafeGet(), height.unsafeGet(), m_data.m_colorSpace));
#endif
if (!cgContext)
accelerateRendering = false; // If allocation fails, fall back to non-accelerated path.
@@ -170,9 +168,9 @@ ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace
ASSERT(!(reinterpret_cast<size_t>(m_data.m_data) & 2));
m_data.m_bitmapInfo = kCGImageAlphaPremultipliedLast;
- cgContext.adoptCF(CGBitmapContextCreate(m_data.m_data, width.unsafeGet(), height.unsafeGet(), 8, m_data.m_bytesPerRow.unsafeGet(), m_data.m_colorSpace, m_data.m_bitmapInfo));
+ cgContext = adoptCF(CGBitmapContextCreate(m_data.m_data, width.unsafeGet(), height.unsafeGet(), 8, m_data.m_bytesPerRow.unsafeGet(), m_data.m_colorSpace, m_data.m_bitmapInfo));
// Create a live image that wraps the data.
- m_data.m_dataProvider.adoptCF(CGDataProviderCreateWithData(0, m_data.m_data, numBytes.unsafeGet(), releaseImageData));
+ m_data.m_dataProvider = adoptCF(CGDataProviderCreateWithData(0, m_data.m_data, numBytes.unsafeGet(), releaseImageData));
}
if (!cgContext)
@@ -196,20 +194,31 @@ ImageBuffer::~ImageBuffer()
GraphicsContext* ImageBuffer::context() const
{
#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1070
+ flushContextIfNecessary();
+#endif
+ return m_context.get();
+}
+
+void ImageBuffer::flushContextIfNecessary() const
+{
+#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1070
// Force a flush if last flush was more than 20ms ago
if (m_context->isAcceleratedContext()) {
double elapsedTime = currentTimeMS() - m_data.m_lastFlushTime;
double maxFlushInterval = 20; // in ms
- if (elapsedTime > maxFlushInterval) {
- CGContextRef context = m_context->platformContext();
- CGContextFlush(context);
- m_data.m_lastFlushTime = currentTimeMS();
- }
+ if (elapsedTime > maxFlushInterval)
+ flushContext();
}
#endif
+}
- return m_context.get();
+void ImageBuffer::flushContext() const
+{
+ CGContextFlush(m_context->platformContext());
+#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1070
+ m_data.m_lastFlushTime = currentTimeMS();
+#endif
}
PassRefPtr<Image> ImageBuffer::copyImage(BackingStoreCopy copyBehavior, ScaleBehavior scaleBehavior) const
@@ -218,8 +227,8 @@ PassRefPtr<Image> ImageBuffer::copyImage(BackingStoreCopy copyBehavior, ScaleBeh
if (m_resolutionScale == 1 || scaleBehavior == Unscaled)
image = copyNativeImage(copyBehavior);
else {
- image.adoptCF(copyNativeImage(DontCopyBackingStore));
- RetainPtr<CGContextRef> context(AdoptCF, CGBitmapContextCreate(0, logicalSize().width(), logicalSize().height(), 8, 4 * logicalSize().width(), deviceRGBColorSpaceRef(), kCGImageAlphaPremultipliedLast));
+ image = adoptCF(copyNativeImage(DontCopyBackingStore));
+ RetainPtr<CGContextRef> context = adoptCF(CGBitmapContextCreate(0, logicalSize().width(), logicalSize().height(), 8, 4 * logicalSize().width(), deviceRGBColorSpaceRef(), kCGImageAlphaPremultipliedLast));
CGContextSetBlendMode(context.get(), kCGBlendModeCopy);
CGContextDrawImage(context.get(), CGRectMake(0, 0, logicalSize().width(), logicalSize().height()), image.get());
image = CGBitmapContextCreateImage(context.get());
@@ -231,7 +240,12 @@ PassRefPtr<Image> ImageBuffer::copyImage(BackingStoreCopy copyBehavior, ScaleBeh
return BitmapImage::create(image.get());
}
-NativeImagePtr ImageBuffer::copyNativeImage(BackingStoreCopy copyBehavior) const
+BackingStoreCopy ImageBuffer::fastCopyImageMode()
+{
+ return DontCopyBackingStore;
+}
+
+PassNativeImagePtr ImageBuffer::copyNativeImage(BackingStoreCopy copyBehavior) const
{
CGImageRef image = 0;
if (!m_context->isAcceleratedContext()) {
@@ -259,20 +273,20 @@ NativeImagePtr ImageBuffer::copyNativeImage(BackingStoreCopy copyBehavior) const
return image;
}
-void ImageBuffer::draw(GraphicsContext* destContext, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator op, bool useLowQualityScale)
+void ImageBuffer::draw(GraphicsContext* destContext, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator op, BlendMode blendMode, bool useLowQualityScale)
{
UNUSED_PARAM(useLowQualityScale);
ColorSpace colorSpace = (destContext == m_context) ? ColorSpaceDeviceRGB : styleColorSpace;
RetainPtr<CGImageRef> image;
if (destContext == m_context || destContext->isAcceleratedContext())
- image.adoptCF(copyNativeImage(CopyBackingStore)); // Drawing into our own buffer, need to deep copy.
+ image = adoptCF(copyNativeImage(CopyBackingStore)); // Drawing into our own buffer, need to deep copy.
else
- image.adoptCF(copyNativeImage(DontCopyBackingStore));
+ image = adoptCF(copyNativeImage(DontCopyBackingStore));
FloatRect adjustedSrcRect = srcRect;
adjustedSrcRect.scale(m_resolutionScale, m_resolutionScale);
- destContext->drawNativeImage(image.get(), internalSize(), colorSpace, destRect, adjustedSrcRect, op);
+ destContext->drawNativeImage(image.get(), internalSize(), colorSpace, destRect, adjustedSrcRect, op, blendMode);
}
void ImageBuffer::drawPattern(GraphicsContext* destContext, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect)
@@ -298,7 +312,7 @@ void ImageBuffer::clip(GraphicsContext* contextToClip, const FloatRect& rect) co
{
CGContextRef platformContextToClip = contextToClip->platformContext();
// FIXME: This image needs to be grayscale to be used as an alpha mask here.
- RetainPtr<CGImageRef> image(AdoptCF, copyNativeImage(DontCopyBackingStore));
+ RetainPtr<CGImageRef> image = adoptCF(copyNativeImage(DontCopyBackingStore));
CGContextTranslateCTM(platformContextToClip, rect.x(), rect.y() + rect.height());
CGContextScaleCTM(platformContextToClip, 1, -1);
CGContextClipToMask(platformContextToClip, FloatRect(FloatPoint(), rect.size()), image.get());
@@ -308,23 +322,17 @@ void ImageBuffer::clip(GraphicsContext* contextToClip, const FloatRect& rect) co
PassRefPtr<Uint8ClampedArray> ImageBuffer::getUnmultipliedImageData(const IntRect& rect, CoordinateSystem coordinateSystem) const
{
- if (m_context->isAcceleratedContext()) {
- CGContextFlush(context()->platformContext());
-#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1070
- m_data.m_lastFlushTime = currentTimeMS();
-#endif
- }
+ if (m_context->isAcceleratedContext())
+ flushContext();
+
return m_data.getData(rect, internalSize(), m_context->isAcceleratedContext(), true, coordinateSystem == LogicalCoordinateSystem ? m_resolutionScale : 1);
}
PassRefPtr<Uint8ClampedArray> ImageBuffer::getPremultipliedImageData(const IntRect& rect, CoordinateSystem coordinateSystem) const
{
- if (m_context->isAcceleratedContext()) {
- CGContextFlush(context()->platformContext());
-#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1070
- m_data.m_lastFlushTime = currentTimeMS();
-#endif
- }
+ if (m_context->isAcceleratedContext())
+ flushContext();
+
return m_data.getData(rect, internalSize(), m_context->isAcceleratedContext(), false, coordinateSystem == LogicalCoordinateSystem ? m_resolutionScale : 1);
}
@@ -360,7 +368,7 @@ void ImageBuffer::putByteArray(Multiply multiplied, Uint8ClampedArray* source, c
// Draw the image in CG coordinate space
IntPoint destPointInCGCoords(destPoint.x() + sourceRect.x(), (coordinateSystem == LogicalCoordinateSystem ? logicalSize() : internalSize()).height() - (destPoint.y() + sourceRect.y()) - sourceRect.height());
IntRect destRectInCGCoords(destPointInCGCoords, sourceCopySize);
- RetainPtr<CGImageRef> sourceCopyImage(AdoptCF, sourceCopy->copyNativeImage());
+ RetainPtr<CGImageRef> sourceCopyImage = adoptCF(sourceCopy->copyNativeImage());
CGContextDrawImage(destContext, destRectInCGCoords, sourceCopyImage.get());
CGContextRestoreGState(destContext);
#endif
@@ -403,17 +411,17 @@ static bool CGImageEncodeToData(CGImageRef image, CFStringRef uti, const double*
if (!image || !uti || !data)
return false;
- RetainPtr<CGImageDestinationRef> destination(AdoptCF, CGImageDestinationCreateWithData(data, uti, 1, 0));
+ RetainPtr<CGImageDestinationRef> destination = adoptCF(CGImageDestinationCreateWithData(data, uti, 1, 0));
if (!destination)
return false;
RetainPtr<CFDictionaryRef> imageProperties = 0;
if (CFEqual(uti, jpegUTI()) && quality && *quality >= 0.0 && *quality <= 1.0) {
// Apply the compression quality to the JPEG image destination.
- RetainPtr<CFNumberRef> compressionQuality(AdoptCF, CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, quality));
+ RetainPtr<CFNumberRef> compressionQuality = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, quality));
const void* key = kCGImageDestinationLossyCompressionQuality;
const void* value = compressionQuality.get();
- imageProperties.adoptCF(CFDictionaryCreate(0, &key, &value, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+ imageProperties = adoptCF(CFDictionaryCreate(0, &key, &value, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
}
// Setting kCGImageDestinationBackgroundColor to black for JPEG images in imageProperties would save some math
@@ -428,7 +436,7 @@ static String CGImageToDataURL(CGImageRef image, const String& mimeType, const d
RetainPtr<CFStringRef> uti = utiFromMIMEType(mimeType);
ASSERT(uti);
- RetainPtr<CFMutableDataRef> data(AdoptCF, CFDataCreateMutable(kCFAllocatorDefault, 0));
+ RetainPtr<CFMutableDataRef> data = adoptCF(CFDataCreateMutable(kCFAllocatorDefault, 0));
if (!CGImageEncodeToData(image, uti.get(), quality, data.get()))
return "data:,";
@@ -442,6 +450,9 @@ String ImageBuffer::toDataURL(const String& mimeType, const double* quality, Coo
{
ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType));
+ if (m_context->isAcceleratedContext())
+ flushContext();
+
RetainPtr<CFStringRef> uti = utiFromMIMEType(mimeType);
ASSERT(uti);
@@ -455,21 +466,21 @@ String ImageBuffer::toDataURL(const String& mimeType, const double* quality, Coo
return "data:,";
RetainPtr<CGDataProviderRef> dataProvider;
- dataProvider.adoptCF(CGDataProviderCreateWithData(0, premultipliedData->data(), 4 * logicalSize().width() * logicalSize().height(), 0));
+ dataProvider = adoptCF(CGDataProviderCreateWithData(0, premultipliedData->data(), 4 * logicalSize().width() * logicalSize().height(), 0));
if (!dataProvider)
return "data:,";
- image.adoptCF(CGImageCreate(logicalSize().width(), logicalSize().height(), 8, 32, 4 * logicalSize().width(),
+ image = adoptCF(CGImageCreate(logicalSize().width(), logicalSize().height(), 8, 32, 4 * logicalSize().width(),
deviceRGBColorSpaceRef(), kCGBitmapByteOrderDefault | kCGImageAlphaNoneSkipLast,
dataProvider.get(), 0, false, kCGRenderingIntentDefault));
} else if (m_resolutionScale == 1)
- image.adoptCF(copyNativeImage(CopyBackingStore));
+ image = adoptCF(copyNativeImage(CopyBackingStore));
else {
- image.adoptCF(copyNativeImage(DontCopyBackingStore));
- RetainPtr<CGContextRef> context(AdoptCF, CGBitmapContextCreate(0, logicalSize().width(), logicalSize().height(), 8, 4 * logicalSize().width(), deviceRGBColorSpaceRef(), kCGImageAlphaPremultipliedLast));
+ image = adoptCF(copyNativeImage(DontCopyBackingStore));
+ RetainPtr<CGContextRef> context = adoptCF(CGBitmapContextCreate(0, logicalSize().width(), logicalSize().height(), 8, 4 * logicalSize().width(), deviceRGBColorSpaceRef(), kCGImageAlphaPremultipliedLast));
CGContextSetBlendMode(context.get(), kCGBlendModeCopy);
CGContextDrawImage(context.get(), CGRectMake(0, 0, logicalSize().width(), logicalSize().height()), image.get());
- image.adoptCF(CGBitmapContextCreateImage(context.get()));
+ image = adoptCF(CGBitmapContextCreateImage(context.get()));
}
return CGImageToDataURL(image.get(), mimeType, quality);
@@ -511,12 +522,12 @@ String ImageDataToDataURL(const ImageData& source, const String& mimeType, const
}
RetainPtr<CGDataProviderRef> dataProvider;
- dataProvider.adoptCF(CGDataProviderCreateWithData(0, data, 4 * source.width() * source.height(), 0));
+ dataProvider = adoptCF(CGDataProviderCreateWithData(0, data, 4 * source.width() * source.height(), 0));
if (!dataProvider)
return "data:,";
RetainPtr<CGImageRef> image;
- image.adoptCF(CGImageCreate(source.width(), source.height(), 8, 32, 4 * source.width(),
+ image = adoptCF(CGImageCreate(source.width(), source.height(), 8, 32, 4 * source.width(),
deviceRGBColorSpaceRef(), kCGBitmapByteOrderDefault | dataAlphaInfo,
dataProvider.get(), 0, false, kCGRenderingIntentDefault));
diff --git a/Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp b/Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp
index 649d9b766..35dc2b82f 100644
--- a/Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp
+++ b/Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp
@@ -202,9 +202,9 @@ PassRefPtr<Uint8ClampedArray> ImageBufferData::getData(const IntRect& rect, cons
}
#endif
if (resolutionScale != 1) {
- RetainPtr<CGContextRef> sourceContext(AdoptCF, CGBitmapContextCreate(srcRows, width.unsafeGet(), height.unsafeGet(), 8, srcBytesPerRow, m_colorSpace, kCGImageAlphaPremultipliedLast));
- RetainPtr<CGImageRef> sourceImage(AdoptCF, CGBitmapContextCreateImage(sourceContext.get()));
- RetainPtr<CGContextRef> destinationContext(AdoptCF, CGBitmapContextCreate(destRows, destw, desth, 8, destBytesPerRow, m_colorSpace, kCGImageAlphaPremultipliedLast));
+ RetainPtr<CGContextRef> sourceContext = adoptCF(CGBitmapContextCreate(srcRows, width.unsafeGet(), height.unsafeGet(), 8, srcBytesPerRow, m_colorSpace, kCGImageAlphaPremultipliedLast));
+ RetainPtr<CGImageRef> sourceImage = adoptCF(CGBitmapContextCreateImage(sourceContext.get()));
+ RetainPtr<CGContextRef> destinationContext = adoptCF(CGBitmapContextCreate(destRows, destw, desth, 8, destBytesPerRow, m_colorSpace, kCGImageAlphaPremultipliedLast));
CGContextSetBlendMode(destinationContext.get(), kCGBlendModeCopy);
CGContextDrawImage(destinationContext.get(), CGRectMake(0, 0, width.unsafeGet() / resolutionScale, height.unsafeGet() / resolutionScale), sourceImage.get()); // FIXME: Add subpixel translation.
if (!unmultiplied)
@@ -291,9 +291,9 @@ PassRefPtr<Uint8ClampedArray> ImageBufferData::getData(const IntRect& rect, cons
}
#else
if (resolutionScale != 1) {
- RetainPtr<CGContextRef> sourceContext(AdoptCF, CGBitmapContextCreate(srcRows, width.unsafeGet(), height.unsafeGet(), 8, srcBytesPerRow, m_colorSpace, kCGImageAlphaPremultipliedLast));
- RetainPtr<CGImageRef> sourceImage(AdoptCF, CGBitmapContextCreateImage(sourceContext.get()));
- RetainPtr<CGContextRef> destinationContext(AdoptCF, CGBitmapContextCreate(destRows, destw, desth, 8, destBytesPerRow, m_colorSpace, kCGImageAlphaPremultipliedLast));
+ RetainPtr<CGContextRef> sourceContext = adoptCF(CGBitmapContextCreate(srcRows, width.unsafeGet(), height.unsafeGet(), 8, srcBytesPerRow, m_colorSpace, kCGImageAlphaPremultipliedLast));
+ RetainPtr<CGImageRef> sourceImage = adoptCF(CGBitmapContextCreateImage(sourceContext.get()));
+ RetainPtr<CGContextRef> destinationContext = adoptCF(CGBitmapContextCreate(destRows, destw, desth, 8, destBytesPerRow, m_colorSpace, kCGImageAlphaPremultipliedLast));
CGContextSetBlendMode(destinationContext.get(), kCGBlendModeCopy);
CGContextDrawImage(destinationContext.get(), CGRectMake(0, 0, width.unsafeGet() / resolutionScale, height.unsafeGet() / resolutionScale), sourceImage.get()); // FIXME: Add subpixel translation.
@@ -425,9 +425,9 @@ void ImageBufferData::putData(Uint8ClampedArray*& source, const IntSize& sourceS
}
#endif
if (resolutionScale != 1) {
- RetainPtr<CGContextRef> sourceContext(AdoptCF, CGBitmapContextCreate(srcRows, width.unsafeGet(), height.unsafeGet(), 8, srcBytesPerRow, m_colorSpace, kCGImageAlphaPremultipliedLast));
- RetainPtr<CGImageRef> sourceImage(AdoptCF, CGBitmapContextCreateImage(sourceContext.get()));
- RetainPtr<CGContextRef> destinationContext(AdoptCF, CGBitmapContextCreate(destRows, destw.unsafeGet(), desth.unsafeGet(), 8, destBytesPerRow, m_colorSpace, kCGImageAlphaPremultipliedLast));
+ RetainPtr<CGContextRef> sourceContext = adoptCF(CGBitmapContextCreate(srcRows, width.unsafeGet(), height.unsafeGet(), 8, srcBytesPerRow, m_colorSpace, kCGImageAlphaPremultipliedLast));
+ RetainPtr<CGImageRef> sourceImage = adoptCF(CGBitmapContextCreateImage(sourceContext.get()));
+ RetainPtr<CGContextRef> destinationContext = adoptCF(CGBitmapContextCreate(destRows, destw.unsafeGet(), desth.unsafeGet(), 8, destBytesPerRow, m_colorSpace, kCGImageAlphaPremultipliedLast));
CGContextSetBlendMode(destinationContext.get(), kCGBlendModeCopy);
CGContextDrawImage(destinationContext.get(), CGRectMake(0, 0, width.unsafeGet() / resolutionScale, height.unsafeGet() / resolutionScale), sourceImage.get()); // FIXME: Add subpixel translation.
if (!unmultiplied)
@@ -504,9 +504,9 @@ void ImageBufferData::putData(Uint8ClampedArray*& source, const IntSize& sourceS
}
#else
if (resolutionScale != 1) {
- RetainPtr<CGContextRef> sourceContext(AdoptCF, CGBitmapContextCreate(srcRows, width.unsafeGet(), height.unsafeGet(), 8, srcBytesPerRow, m_colorSpace, kCGImageAlphaPremultipliedLast));
- RetainPtr<CGImageRef> sourceImage(AdoptCF, CGBitmapContextCreateImage(sourceContext.get()));
- RetainPtr<CGContextRef> destinationContext(AdoptCF, CGBitmapContextCreate(destRows, destw.unsafeGet(), desth.unsafeGet(), 8, destBytesPerRow, m_colorSpace, kCGImageAlphaPremultipliedLast));
+ RetainPtr<CGContextRef> sourceContext = adoptCF(CGBitmapContextCreate(srcRows, width.unsafeGet(), height.unsafeGet(), 8, srcBytesPerRow, m_colorSpace, kCGImageAlphaPremultipliedLast));
+ RetainPtr<CGImageRef> sourceImage = adoptCF(CGBitmapContextCreateImage(sourceContext.get()));
+ RetainPtr<CGContextRef> destinationContext = adoptCF(CGBitmapContextCreate(destRows, destw.unsafeGet(), desth.unsafeGet(), 8, destBytesPerRow, m_colorSpace, kCGImageAlphaPremultipliedLast));
CGContextSetBlendMode(destinationContext.get(), kCGBlendModeCopy);
CGContextDrawImage(destinationContext.get(), CGRectMake(0, 0, width.unsafeGet() / resolutionScale, height.unsafeGet() / resolutionScale), sourceImage.get()); // FIXME: Add subpixel translation.
diff --git a/Source/WebCore/platform/graphics/cg/ImageCG.cpp b/Source/WebCore/platform/graphics/cg/ImageCG.cpp
index a54a867d6..a53573778 100644
--- a/Source/WebCore/platform/graphics/cg/ImageCG.cpp
+++ b/Source/WebCore/platform/graphics/cg/ImageCG.cpp
@@ -35,7 +35,7 @@
#include <ApplicationServices/ApplicationServices.h>
#include <wtf/RetainPtr.h>
-#if PLATFORM(MAC) || PLATFORM(CHROMIUM)
+#if PLATFORM(MAC)
#include "WebCoreSystemInterface.h"
#endif
@@ -58,9 +58,9 @@ RetainPtr<CGImageRef> Image::imageWithColorSpace(CGImageRef originalImage, Color
case ColorSpaceDeviceRGB:
return originalImage;
case ColorSpaceSRGB:
- return RetainPtr<CGImageRef>(AdoptCF, CGImageCreateCopyWithColorSpace(originalImage, sRGBColorSpaceRef()));
+ return adoptCF(CGImageCreateCopyWithColorSpace(originalImage, sRGBColorSpaceRef()));
case ColorSpaceLinearRGB:
- return RetainPtr<CGImageRef>(AdoptCF, CGImageCreateCopyWithColorSpace(originalImage, linearRGBColorSpaceRef()));
+ return adoptCF(CGImageCreateCopyWithColorSpace(originalImage, linearRGBColorSpaceRef()));
}
ASSERT_NOT_REACHED();
@@ -74,7 +74,7 @@ static void drawPatternCallback(void* info, CGContextRef context)
}
void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const AffineTransform& patternTransform,
- const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect)
+ const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect, BlendMode blendMode)
{
if (!nativeImageForCurrentFrame())
return;
@@ -85,7 +85,7 @@ void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const
CGContextRef context = ctxt->platformContext();
GraphicsContextStateSaver stateSaver(*ctxt);
CGContextClipToRect(context, destRect);
- ctxt->setCompositeOperation(op);
+ ctxt->setCompositeOperation(op, blendMode);
CGContextTranslateCTM(context, destRect.x(), destRect.y() + destRect.height());
CGContextScaleCTM(context, 1, -1);
@@ -107,7 +107,7 @@ void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const
// Copying a sub-image out of a partially-decoded image stops the decoding of the original image. It should never happen
// because sub-images are only used for border-image, which only renders when the image is fully decoded.
ASSERT(h == height());
- subImage.adoptCF(CGImageCreateWithImageInRect(tileImage, tileRect));
+ subImage = adoptCF(CGImageCreateWithImageInRect(tileImage, tileRect));
}
// Adjust the color space.
@@ -119,11 +119,7 @@ void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const
// FIXME: We cannot use CGContextDrawTiledImage with scaled tiles on Leopard, because it suffers from rounding errors. Snow Leopard is ok.
float scaledTileWidth = tileRect.width() * narrowPrecisionToFloat(patternTransform.a());
float w = CGImageGetWidth(tileImage);
-#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1050
- if (w == size().width() && h == size().height() && scaledTileWidth == tileRect.width() && scaledTileHeight == tileRect.height())
-#else
if (w == size().width() && h == size().height())
-#endif
CGContextDrawTiledImage(context, FloatRect(adjustedX, adjustedY, scaledTileWidth, scaledTileHeight), subImage.get());
else {
@@ -133,16 +129,16 @@ void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const
matrix = CGAffineTransformConcat(matrix, CGContextGetCTM(context));
// The top of a partially-decoded image is drawn at the bottom of the tile. Map it to the top.
matrix = CGAffineTransformTranslate(matrix, 0, size().height() - h);
- RetainPtr<CGPatternRef> pattern(AdoptCF, CGPatternCreate(subImage.get(), CGRectMake(0, 0, tileRect.width(), tileRect.height()),
+ RetainPtr<CGPatternRef> pattern = adoptCF(CGPatternCreate(subImage.get(), CGRectMake(0, 0, tileRect.width(), tileRect.height()),
matrix, tileRect.width(), tileRect.height(),
kCGPatternTilingConstantSpacing, true, &patternCallbacks));
if (!pattern)
return;
- RetainPtr<CGColorSpaceRef> patternSpace(AdoptCF, CGColorSpaceCreatePattern(0));
+ RetainPtr<CGColorSpaceRef> patternSpace = adoptCF(CGColorSpaceCreatePattern(0));
CGFloat alpha = 1;
- RetainPtr<CGColorRef> color(AdoptCF, CGColorCreateWithPattern(patternSpace.get(), pattern.get(), &alpha));
+ RetainPtr<CGColorRef> color = adoptCF(CGColorCreateWithPattern(patternSpace.get(), pattern.get(), &alpha));
CGContextSetFillColorSpace(context, patternSpace.get());
// FIXME: Really want a public API for this. It is just CGContextSetBaseCTM(context, CGAffineTransformIdentiy).
diff --git a/Source/WebCore/platform/graphics/cg/ImageSourceCG.cpp b/Source/WebCore/platform/graphics/cg/ImageSourceCG.cpp
index c133364dd..96e21c972 100644
--- a/Source/WebCore/platform/graphics/cg/ImageSourceCG.cpp
+++ b/Source/WebCore/platform/graphics/cg/ImageSourceCG.cpp
@@ -33,10 +33,8 @@
#include "IntPoint.h"
#include "IntSize.h"
#include "MIMETypeRegistry.h"
-#include "PlatformMemoryInstrumentation.h"
#include "SharedBuffer.h"
#include <ApplicationServices/ApplicationServices.h>
-#include <wtf/UnusedParam.h>
using namespace std;
@@ -84,21 +82,11 @@ ImageSource::~ImageSource()
void ImageSource::clear(bool destroyAllFrames, size_t, SharedBuffer* data, bool allDataReceived)
{
-#if !PLATFORM(MAC) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
// Recent versions of ImageIO discard previously decoded image frames if the client
// application no longer holds references to them, so there's no need to throw away
// the decoder unless we're explicitly asked to destroy all of the frames.
-
if (!destroyAllFrames)
return;
-#else
- // Older versions of ImageIO hold references to previously decoded image frames.
- // There is no API to selectively release some of the frames it is holding, and
- // if we don't release the frames we use too much memory on large images.
- // Destroying the decoder is the only way to release previous frames.
-
- UNUSED_PARAM(destroyAllFrames);
-#endif
if (m_decoder) {
CFRelease(m_decoder);
@@ -145,7 +133,7 @@ void ImageSource::setData(SharedBuffer* data, bool allDataReceived)
m_decoder = CGImageSourceCreateIncremental(0);
// On Mac the NSData inside the SharedBuffer can be secretly appended to without the SharedBuffer's knowledge. We use SharedBuffer's ability
// to wrap itself inside CFData to get around this, ensuring that ImageIO is really looking at the SharedBuffer.
- RetainPtr<CFDataRef> cfData(AdoptCF, data->createCFData());
+ RetainPtr<CFDataRef> cfData = adoptCF(data->createCFData());
CGImageSourceUpdateData(m_decoder, cfData.get(), allDataReceived);
#else
if (!m_decoder) {
@@ -164,7 +152,7 @@ void ImageSource::setData(SharedBuffer* data, bool allDataReceived)
// does not provide a way to lock down the byte pointer and guarantee that it won't move, which
// is a requirement for using the GetBytePointer callback.
CGDataProviderDirectCallbacks providerCallbacks = { 0, 0, 0, sharedBufferGetBytesAtPosition, sharedBufferRelease };
- RetainPtr<CGDataProviderRef> dataProvider(AdoptCF, CGDataProviderCreateDirect(data, data->size(), &providerCallbacks));
+ RetainPtr<CGDataProviderRef> dataProvider = adoptCF(CGDataProviderCreateDirect(data, data->size(), &providerCallbacks));
CGImageSourceUpdateDataProvider(m_decoder, dataProvider.get(), allDataReceived);
#endif
}
@@ -184,7 +172,7 @@ bool ImageSource::isSizeAvailable()
// Ragnaros yells: TOO SOON! You have awakened me TOO SOON, Executus!
if (imageSourceStatus >= kCGImageStatusIncomplete) {
- RetainPtr<CFDictionaryRef> image0Properties(AdoptCF, CGImageSourceCopyPropertiesAtIndex(m_decoder, 0, imageSourceOptions(SkipMetadata)));
+ RetainPtr<CFDictionaryRef> image0Properties = adoptCF(CGImageSourceCopyPropertiesAtIndex(m_decoder, 0, imageSourceOptions(SkipMetadata)));
if (image0Properties) {
CFNumberRef widthNumber = (CFNumberRef)CFDictionaryGetValue(image0Properties.get(), kCGImagePropertyPixelWidth);
CFNumberRef heightNumber = (CFNumberRef)CFDictionaryGetValue(image0Properties.get(), kCGImagePropertyPixelHeight);
@@ -209,7 +197,7 @@ static ImageOrientation orientationFromProperties(CFDictionaryRef imagePropertie
IntSize ImageSource::frameSizeAtIndex(size_t index, RespectImageOrientationEnum shouldRespectOrientation) const
{
- RetainPtr<CFDictionaryRef> properties(AdoptCF, CGImageSourceCopyPropertiesAtIndex(m_decoder, index, imageSourceOptions(SkipMetadata)));
+ RetainPtr<CFDictionaryRef> properties = adoptCF(CGImageSourceCopyPropertiesAtIndex(m_decoder, index, imageSourceOptions(SkipMetadata)));
if (!properties)
return IntSize();
@@ -230,7 +218,7 @@ IntSize ImageSource::frameSizeAtIndex(size_t index, RespectImageOrientationEnum
ImageOrientation ImageSource::orientationAtIndex(size_t index) const
{
- RetainPtr<CFDictionaryRef> properties(AdoptCF, CGImageSourceCopyPropertiesAtIndex(m_decoder, index, imageSourceOptions(SkipMetadata)));
+ RetainPtr<CFDictionaryRef> properties = adoptCF(CGImageSourceCopyPropertiesAtIndex(m_decoder, index, imageSourceOptions(SkipMetadata)));
if (!properties)
return DefaultImageOrientation;
@@ -244,7 +232,7 @@ IntSize ImageSource::size(RespectImageOrientationEnum shouldRespectOrientation)
bool ImageSource::getHotSpot(IntPoint& hotSpot) const
{
- RetainPtr<CFDictionaryRef> properties(AdoptCF, CGImageSourceCopyPropertiesAtIndex(m_decoder, 0, imageSourceOptions(SkipMetadata)));
+ RetainPtr<CFDictionaryRef> properties = adoptCF(CGImageSourceCopyPropertiesAtIndex(m_decoder, 0, imageSourceOptions(SkipMetadata)));
if (!properties)
return false;
@@ -281,7 +269,7 @@ int ImageSource::repetitionCount()
if (!initialized())
return result;
- RetainPtr<CFDictionaryRef> properties(AdoptCF, CGImageSourceCopyProperties(m_decoder, imageSourceOptions(SkipMetadata)));
+ RetainPtr<CFDictionaryRef> properties = adoptCF(CGImageSourceCopyProperties(m_decoder, imageSourceOptions(SkipMetadata)));
if (properties) {
CFDictionaryRef gifProperties = (CFDictionaryRef)CFDictionaryGetValue(properties.get(), kCGImagePropertyGIFDictionary);
if (gifProperties) {
@@ -309,7 +297,7 @@ CGImageRef ImageSource::createFrameAtIndex(size_t index)
if (!initialized())
return 0;
- RetainPtr<CGImageRef> image(AdoptCF, CGImageSourceCreateImageAtIndex(m_decoder, index, imageSourceOptions(SkipMetadata)));
+ RetainPtr<CGImageRef> image = adoptCF(CGImageSourceCreateImageAtIndex(m_decoder, index, imageSourceOptions(SkipMetadata)));
CFStringRef imageUTI = CGImageSourceGetType(m_decoder);
static const CFStringRef xbmUTI = CFSTR("public.xbitmap-image");
if (!imageUTI || !CFEqual(imageUTI, xbmUTI))
@@ -317,14 +305,14 @@ CGImageRef ImageSource::createFrameAtIndex(size_t index)
// If it is an xbm image, mask out all the white areas to render them transparent.
const CGFloat maskingColors[6] = {255, 255, 255, 255, 255, 255};
- RetainPtr<CGImageRef> maskedImage(AdoptCF, CGImageCreateWithMaskingColors(image.get(), maskingColors));
+ RetainPtr<CGImageRef> maskedImage = adoptCF(CGImageCreateWithMaskingColors(image.get(), maskingColors));
if (!maskedImage)
return image.leakRef();
return maskedImage.leakRef();
}
-bool ImageSource::frameIsCompleteAtIndex(size_t index)
+bool ImageSource::frameIsCompleteAtIndex(size_t index) const
{
ASSERT(frameCount());
@@ -344,13 +332,13 @@ bool ImageSource::frameIsCompleteAtIndex(size_t index)
return frameStatus == kCGImageStatusComplete;
}
-float ImageSource::frameDurationAtIndex(size_t index)
+float ImageSource::frameDurationAtIndex(size_t index) const
{
if (!initialized())
return 0;
float duration = 0;
- RetainPtr<CFDictionaryRef> properties(AdoptCF, CGImageSourceCopyPropertiesAtIndex(m_decoder, index, imageSourceOptions(SkipMetadata)));
+ RetainPtr<CFDictionaryRef> properties = adoptCF(CGImageSourceCopyPropertiesAtIndex(m_decoder, index, imageSourceOptions(SkipMetadata)));
if (properties) {
CFDictionaryRef typeProperties = (CFDictionaryRef)CFDictionaryGetValue(properties.get(), kCGImagePropertyGIFDictionary);
if (typeProperties) {
@@ -373,10 +361,13 @@ float ImageSource::frameDurationAtIndex(size_t index)
return duration;
}
-bool ImageSource::frameHasAlphaAtIndex(size_t)
+bool ImageSource::frameHasAlphaAtIndex(size_t index) const
{
if (!m_decoder)
- return false;
+ return false; // FIXME: why doesn't this return true?
+
+ if (!frameIsCompleteAtIndex(index))
+ return true;
CFStringRef imageType = CGImageSourceGetType(m_decoder);
@@ -397,12 +388,6 @@ unsigned ImageSource::frameBytesAtIndex(size_t index) const
return frameSize.width() * frameSize.height() * 4;
}
-void ImageSource::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
-{
- MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Image);
- // FIXME: addMember call required for m_decoder.
-}
-
}
#endif // USE(CG)
diff --git a/Source/WebCore/platform/graphics/cg/IntPointCG.cpp b/Source/WebCore/platform/graphics/cg/IntPointCG.cpp
index a76767f3f..708fcc2e1 100644
--- a/Source/WebCore/platform/graphics/cg/IntPointCG.cpp
+++ b/Source/WebCore/platform/graphics/cg/IntPointCG.cpp
@@ -26,7 +26,7 @@
#include "config.h"
#include "IntPoint.h"
-#if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM)
+#if USE(CG)
#include <ApplicationServices/ApplicationServices.h>
diff --git a/Source/WebCore/platform/graphics/cg/IntRectCG.cpp b/Source/WebCore/platform/graphics/cg/IntRectCG.cpp
index f757497a5..8d10207bf 100644
--- a/Source/WebCore/platform/graphics/cg/IntRectCG.cpp
+++ b/Source/WebCore/platform/graphics/cg/IntRectCG.cpp
@@ -26,7 +26,7 @@
#include "config.h"
#include "IntRect.h"
-#if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM) || (PLATFORM(QT) && USE(QTKIT))
+#if USE(CG)
#include <ApplicationServices/ApplicationServices.h>
diff --git a/Source/WebCore/platform/graphics/cg/IntSizeCG.cpp b/Source/WebCore/platform/graphics/cg/IntSizeCG.cpp
index 7993d4250..41fb399e3 100644
--- a/Source/WebCore/platform/graphics/cg/IntSizeCG.cpp
+++ b/Source/WebCore/platform/graphics/cg/IntSizeCG.cpp
@@ -26,7 +26,7 @@
#include "config.h"
#include "IntSize.h"
-#if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM)
+#if USE(CG)
#include <ApplicationServices/ApplicationServices.h>
diff --git a/Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp b/Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp
index 14fdfc11a..ecd73ef13 100644
--- a/Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp
+++ b/Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp
@@ -89,15 +89,15 @@ bool PDFDocumentImage::dataChanged(bool allDataReceived)
#if PLATFORM(MAC)
// On Mac the NSData inside the SharedBuffer can be secretly appended to without the SharedBuffer's knowledge. We use SharedBuffer's ability
// to wrap itself inside CFData to get around this, ensuring that ImageIO is really looking at the SharedBuffer.
- RetainPtr<CFDataRef> data(AdoptCF, this->data()->createCFData());
- RetainPtr<CGDataProviderRef> dataProvider(AdoptCF, CGDataProviderCreateWithCFData(data.get()));
+ RetainPtr<CFDataRef> data = adoptCF(this->data()->createCFData());
+ RetainPtr<CGDataProviderRef> dataProvider = adoptCF(CGDataProviderCreateWithCFData(data.get()));
#else
// Create a CGDataProvider to wrap the SharedBuffer.
// We use the GetBytesAtPosition callback rather than the GetBytePointer one because SharedBuffer
// does not provide a way to lock down the byte pointer and guarantee that it won't move, which
// is a requirement for using the GetBytePointer callback.
CGDataProviderDirectCallbacks providerCallbacks = { 0, 0, 0, sharedBufferGetBytesAtPosition, 0 };
- RetainPtr<CGDataProviderRef> dataProvider(AdoptCF, CGDataProviderCreateDirect(this->data(), this->data()->size(), &providerCallbacks));
+ RetainPtr<CGDataProviderRef> dataProvider = adoptCF(CGDataProviderCreateDirect(this->data(), this->data()->size(), &providerCallbacks));
#endif
m_document = CGPDFDocumentCreateWithProvider(dataProvider.get());
setCurrentPage(0);
@@ -163,7 +163,7 @@ int PDFDocumentImage::pageCount() const
return m_document ? CGPDFDocumentGetNumberOfPages(m_document) : 0;
}
-void PDFDocumentImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace, CompositeOperator op)
+void PDFDocumentImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace, CompositeOperator op, BlendMode)
{
if (!m_document || m_currentPage == -1)
return;
diff --git a/Source/WebCore/platform/graphics/cg/PDFDocumentImage.h b/Source/WebCore/platform/graphics/cg/PDFDocumentImage.h
index 4a28e376c..689a0310e 100644
--- a/Source/WebCore/platform/graphics/cg/PDFDocumentImage.h
+++ b/Source/WebCore/platform/graphics/cg/PDFDocumentImage.h
@@ -63,8 +63,11 @@ namespace WebCore {
virtual IntSize size() const;
PDFDocumentImage();
- virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator);
-
+ virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode);
+
+ // FIXME: Implement this to be less conservative.
+ virtual bool currentFrameKnownToBeOpaque() OVERRIDE { return false; }
+
void setCurrentPage(int);
int pageCount() const;
void adjustCTM(GraphicsContext*) const;
diff --git a/Source/WebCore/platform/graphics/cg/PathCG.cpp b/Source/WebCore/platform/graphics/cg/PathCG.cpp
index 61e681765..57304e9b6 100644
--- a/Source/WebCore/platform/graphics/cg/PathCG.cpp
+++ b/Source/WebCore/platform/graphics/cg/PathCG.cpp
@@ -39,7 +39,7 @@
#include <wtf/RetainPtr.h>
#include <wtf/text/WTFString.h>
-#if PLATFORM(MAC) || PLATFORM(CHROMIUM)
+#if PLATFORM(MAC)
#include "WebCoreSystemInterface.h"
#endif
@@ -57,7 +57,7 @@ static size_t putBytesNowhere(void*, const void*, size_t count)
static CGContextRef createScratchContext()
{
CGDataConsumerCallbacks callbacks = { putBytesNowhere, 0 };
- RetainPtr<CGDataConsumerRef> consumer(AdoptCF, CGDataConsumerCreate(0, &callbacks));
+ RetainPtr<CGDataConsumerRef> consumer = adoptCF(CGDataConsumerCreate(0, &callbacks));
CGContextRef context = CGPDFContextCreate(consumer.get(), 0, 0);
CGFloat black[4] = { 0, 0, 0, 1 };
@@ -148,7 +148,7 @@ bool Path::contains(const FloatPoint &point, WindRule rule) const
return false;
// CGPathContainsPoint returns false for non-closed paths, as a work-around, we copy and close the path first. Radar 4758998 asks for a better CG API to use
- RetainPtr<CGMutablePathRef> path(AdoptCF, copyCGPathClosingSubpaths(m_path));
+ RetainPtr<CGMutablePathRef> path = adoptCF(copyCGPathClosingSubpaths(m_path));
bool ret = CGPathContainsPoint(path.get(), 0, point, rule == RULE_EVENODD ? true : false);
return ret;
}
@@ -193,12 +193,7 @@ FloatRect Path::boundingRect() const
// CGPathGetBoundingBox includes the path's control points, CGPathGetPathBoundingBox
// does not, but only exists on 10.6 and above.
- CGRect bound = CGRectZero;
-#if !PLATFORM(MAC) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
- bound = CGPathGetPathBoundingBox(m_path);
-#else
- bound = CGPathGetBoundingBox(m_path);
-#endif
+ CGRect bound = CGPathGetPathBoundingBox(m_path);
return CGRectIsNull(bound) ? CGRectZero : bound;
}
@@ -285,7 +280,7 @@ void Path::closeSubpath()
void Path::addArc(const FloatPoint& p, float r, float sa, float ea, bool clockwise)
{
// Workaround for <rdar://problem/5189233> CGPathAddArc hangs or crashes when passed inf as start or end angle
- if (isfinite(sa) && isfinite(ea))
+ if (std::isfinite(sa) && std::isfinite(ea))
CGPathAddArc(ensurePlatformPath(), 0, p.x(), p.y(), r, sa, ea, clockwise);
}
diff --git a/Source/WebCore/platform/graphics/cg/PatternCG.cpp b/Source/WebCore/platform/graphics/cg/PatternCG.cpp
index ae9a01b36..0cd529eab 100644
--- a/Source/WebCore/platform/graphics/cg/PatternCG.cpp
+++ b/Source/WebCore/platform/graphics/cg/PatternCG.cpp
@@ -32,7 +32,7 @@
#include <ApplicationServices/ApplicationServices.h>
#include <wtf/MainThread.h>
-#if PLATFORM(MAC) || PLATFORM(CHROMIUM)
+#if PLATFORM(MAC)
#include "WebCoreSystemInterface.h"
#endif
diff --git a/Source/WebCore/platform/graphics/cg/SubimageCacheWithTimer.cpp b/Source/WebCore/platform/graphics/cg/SubimageCacheWithTimer.cpp
new file mode 100644
index 000000000..ee792057d
--- /dev/null
+++ b/Source/WebCore/platform/graphics/cg/SubimageCacheWithTimer.cpp
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2012, 2013 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "SubimageCacheWithTimer.h"
+
+#include <wtf/Vector.h>
+
+#if CACHE_SUBIMAGES
+
+namespace WebCore {
+
+static const double subimageCacheClearDelay = 1;
+static const int maxSubimageCacheSize = 300;
+
+struct SubimageRequest {
+ CGImageRef image;
+ const FloatRect& rect;
+ SubimageRequest(CGImageRef image, const FloatRect& rect) : image(image), rect(rect) { }
+};
+
+struct SubimageCacheAdder {
+ static unsigned hash(const SubimageRequest& value)
+ {
+ return SubimageCacheWithTimer::SubimageCacheHash::hash(value.image, value.rect);
+ }
+
+ static bool equal(const SubimageCacheWithTimer::SubimageCacheEntry& a, const SubimageRequest& b)
+ {
+ return a.image == b.image && a.rect == b.rect;
+ }
+
+ static void translate(SubimageCacheWithTimer::SubimageCacheEntry& entry, const SubimageRequest& request, unsigned /*hashCode*/)
+ {
+ entry.image = request.image;
+ entry.rect = request.rect;
+ entry.subimage = adoptCF(CGImageCreateWithImageInRect(request.image, request.rect));
+ }
+};
+
+SubimageCacheWithTimer::SubimageCacheWithTimer()
+ : m_timer(this, &SubimageCacheWithTimer::invalidateCacheTimerFired, subimageCacheClearDelay)
+{
+}
+
+void SubimageCacheWithTimer::invalidateCacheTimerFired(DeferrableOneShotTimer<SubimageCacheWithTimer>*)
+{
+ m_images.clear();
+ m_cache.clear();
+}
+
+RetainPtr<CGImageRef> SubimageCacheWithTimer::getSubimage(CGImageRef image, const FloatRect& rect)
+{
+ m_timer.restart();
+ if (m_cache.size() == maxSubimageCacheSize) {
+ SubimageCacheEntry entry = *m_cache.begin();
+ m_images.remove(entry.image.get());
+ m_cache.remove(entry);
+ }
+
+ ASSERT(m_cache.size() < maxSubimageCacheSize);
+ SubimageCache::AddResult result = m_cache.add<SubimageCacheAdder>(SubimageRequest(image, rect));
+ if (result.isNewEntry)
+ m_images.add(image);
+
+ return result.iterator->subimage;
+}
+
+void SubimageCacheWithTimer::clearImage(CGImageRef image)
+{
+ if (m_images.contains(image)) {
+ Vector<SubimageCacheEntry> toBeRemoved;
+ SubimageCache::const_iterator end = m_cache.end();
+ for (SubimageCache::const_iterator it = m_cache.begin(); it != end; ++it) {
+ if (it->image.get() == image)
+ toBeRemoved.append(*it);
+ }
+
+ for (Vector<SubimageCacheEntry>::iterator removeIt = toBeRemoved.begin(); removeIt != toBeRemoved.end(); ++removeIt)
+ m_cache.remove(*removeIt);
+
+ m_images.removeAll(image);
+ }
+}
+
+SubimageCacheWithTimer& subimageCache()
+{
+ static SubimageCacheWithTimer& cache = *new SubimageCacheWithTimer;
+ return cache;
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/platform/graphics/cg/SubimageCacheWithTimer.h b/Source/WebCore/platform/graphics/cg/SubimageCacheWithTimer.h
new file mode 100644
index 000000000..0f5ceda72
--- /dev/null
+++ b/Source/WebCore/platform/graphics/cg/SubimageCacheWithTimer.h
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2012, 2013 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SubimageCacheWithTimer_h
+#define SubimageCacheWithTimer_h
+
+#include "FloatRect.h"
+#include "Timer.h"
+
+#include <CoreGraphics/CoreGraphics.h>
+#include <wtf/HashCountedSet.h>
+#include <wtf/HashSet.h>
+#include <wtf/HashTraits.h>
+#include <wtf/RetainPtr.h>
+
+#define CACHE_SUBIMAGES 1
+
+namespace WebCore {
+
+#if CACHE_SUBIMAGES
+
+class SubimageCacheWithTimer {
+ WTF_MAKE_NONCOPYABLE(SubimageCacheWithTimer); WTF_MAKE_FAST_ALLOCATED;
+
+public:
+ struct SubimageCacheEntry {
+ RetainPtr<CGImageRef> image;
+ FloatRect rect;
+ RetainPtr<CGImageRef> subimage;
+ };
+
+ struct SubimageCacheEntryTraits : WTF::GenericHashTraits<SubimageCacheEntry> {
+ typedef HashTraits<RetainPtr<CGImageRef> > ImageTraits;
+
+ static const bool emptyValueIsZero = true;
+
+ static const bool hasIsEmptyValueFunction = true;
+ static bool isEmptyValue(const SubimageCacheEntry& value) { return !value.image; }
+
+ static void constructDeletedValue(SubimageCacheEntry& slot) { ImageTraits::constructDeletedValue(slot.image); }
+ static bool isDeletedValue(const SubimageCacheEntry& value) { return ImageTraits::isDeletedValue(value.image); }
+ };
+
+ struct SubimageCacheHash {
+ static unsigned hash(CGImageRef image, const FloatRect& rect)
+ {
+ return WTF::pairIntHash(PtrHash<CGImageRef>::hash(image),
+ (static_cast<unsigned>(rect.x()) << 16) | static_cast<unsigned>(rect.y()));
+ }
+ static unsigned hash(const SubimageCacheEntry& key)
+ {
+ return hash(key.image.get(), key.rect);
+ }
+ static bool equal(const SubimageCacheEntry& a, const SubimageCacheEntry& b)
+ {
+ return a.image == b.image && a.rect == b.rect;
+ }
+ static const bool safeToCompareToEmptyOrDeleted = true;
+ };
+
+ typedef HashSet<SubimageCacheEntry, SubimageCacheHash, SubimageCacheEntryTraits> SubimageCache;
+
+public:
+ SubimageCacheWithTimer();
+ RetainPtr<CGImageRef> getSubimage(CGImageRef, const FloatRect&);
+ void clearImage(CGImageRef);
+
+private:
+ void invalidateCacheTimerFired(DeferrableOneShotTimer<SubimageCacheWithTimer>*);
+
+ HashCountedSet<CGImageRef> m_images;
+ SubimageCache m_cache;
+ DeferrableOneShotTimer<SubimageCacheWithTimer> m_timer;
+};
+
+SubimageCacheWithTimer& subimageCache();
+
+#endif // CACHE_SUBIMAGES
+
+}
+
+#endif // SubimageCacheWithTimer_h
diff --git a/Source/WebCore/platform/graphics/chromium/AnimationTranslationUtil.cpp b/Source/WebCore/platform/graphics/chromium/AnimationTranslationUtil.cpp
deleted file mode 100644
index 1ee8ea053..000000000
--- a/Source/WebCore/platform/graphics/chromium/AnimationTranslationUtil.cpp
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "AnimationTranslationUtil.h"
-
-#include "FloatSize.h"
-#include "GraphicsLayer.h"
-#include "IdentityTransformOperation.h"
-#include "Length.h"
-#include "LengthFunctions.h"
-#include "Matrix3DTransformOperation.h"
-#include "MatrixTransformOperation.h"
-#include "PerspectiveTransformOperation.h"
-#include "RotateTransformOperation.h"
-#include "ScaleTransformOperation.h"
-#include "SkewTransformOperation.h"
-#include "TransformOperations.h"
-#include "TranslateTransformOperation.h"
-
-#include <public/Platform.h>
-#include <public/WebAnimation.h>
-#include <public/WebAnimationCurve.h>
-#include <public/WebCompositorSupport.h>
-#include <public/WebFloatAnimationCurve.h>
-#include <public/WebTransformAnimationCurve.h>
-#include <public/WebTransformOperations.h>
-#include <public/WebTransformationMatrix.h>
-
-#include <wtf/OwnPtr.h>
-#include <wtf/text/CString.h>
-
-using namespace std;
-using namespace WebKit;
-
-namespace WebCore {
-
-WebTransformOperations toWebTransformOperations(const TransformOperations& transformOperations, const FloatSize& boxSize)
-{
- // We need to do a deep copy the transformOperations may contain ref pointers to TransformOperation objects.
- WebTransformOperations webTransformOperations;
- for (size_t j = 0; j < transformOperations.size(); ++j) {
- TransformOperation::OperationType operationType = transformOperations.operations()[j]->getOperationType();
- switch (operationType) {
- case TransformOperation::SCALE_X:
- case TransformOperation::SCALE_Y:
- case TransformOperation::SCALE_Z:
- case TransformOperation::SCALE_3D:
- case TransformOperation::SCALE: {
- ScaleTransformOperation* transform = static_cast<ScaleTransformOperation*>(transformOperations.operations()[j].get());
- webTransformOperations.appendScale(transform->x(), transform->y(), transform->z());
- break;
- }
- case TransformOperation::TRANSLATE_X:
- case TransformOperation::TRANSLATE_Y:
- case TransformOperation::TRANSLATE_Z:
- case TransformOperation::TRANSLATE_3D:
- case TransformOperation::TRANSLATE: {
- TranslateTransformOperation* transform = static_cast<TranslateTransformOperation*>(transformOperations.operations()[j].get());
- webTransformOperations.appendTranslate(floatValueForLength(transform->x(), boxSize.width()), floatValueForLength(transform->y(), boxSize.height()), floatValueForLength(transform->z(), 1));
- break;
- }
- case TransformOperation::ROTATE_X:
- case TransformOperation::ROTATE_Y:
- case TransformOperation::ROTATE_3D:
- case TransformOperation::ROTATE: {
- RotateTransformOperation* transform = static_cast<RotateTransformOperation*>(transformOperations.operations()[j].get());
- webTransformOperations.appendRotate(transform->x(), transform->y(), transform->z(), transform->angle());
- break;
- }
- case TransformOperation::SKEW_X:
- case TransformOperation::SKEW_Y:
- case TransformOperation::SKEW: {
- SkewTransformOperation* transform = static_cast<SkewTransformOperation*>(transformOperations.operations()[j].get());
- webTransformOperations.appendSkew(transform->angleX(), transform->angleY());
- break;
- }
- case TransformOperation::MATRIX: {
- MatrixTransformOperation* transform = static_cast<MatrixTransformOperation*>(transformOperations.operations()[j].get());
- TransformationMatrix m = transform->matrix();
- webTransformOperations.appendMatrix(WebTransformationMatrix(m));
- break;
- }
- case TransformOperation::MATRIX_3D: {
- Matrix3DTransformOperation* transform = static_cast<Matrix3DTransformOperation*>(transformOperations.operations()[j].get());
- TransformationMatrix m = transform->matrix();
- webTransformOperations.appendMatrix(WebTransformationMatrix(m));
- break;
- }
- case TransformOperation::PERSPECTIVE: {
- PerspectiveTransformOperation* transform = static_cast<PerspectiveTransformOperation*>(transformOperations.operations()[j].get());
- webTransformOperations.appendPerspective(floatValueForLength(transform->perspective(), 0));
- break;
- }
- case TransformOperation::IDENTITY:
- webTransformOperations.appendIdentity();
- break;
- case TransformOperation::NONE:
- // Do nothing.
- break;
- } // switch
- } // for each operation
-
- return webTransformOperations;
-}
-
-template <class Value, class Keyframe, class Curve>
-bool appendKeyframeWithStandardTimingFunction(Curve* curve, double keyTime, const Value* value, const Value* lastValue, WebKit::WebAnimationCurve::TimingFunctionType timingFunctionType, const FloatSize&)
-{
- curve->add(Keyframe(keyTime, value->value()), timingFunctionType);
- return true;
-}
-
-template <class Value, class Keyframe, class Curve>
-bool appendKeyframeWithCustomBezierTimingFunction(Curve* curve, double keyTime, const Value* value, const Value* lastValue, double x1, double y1, double x2, double y2, const FloatSize&)
-{
- curve->add(Keyframe(keyTime, value->value()), x1, y1, x2, y2);
- return true;
-}
-
-bool isRotationType(TransformOperation::OperationType transformType)
-{
- return transformType == TransformOperation::ROTATE
- || transformType == TransformOperation::ROTATE_X
- || transformType == TransformOperation::ROTATE_Y
- || transformType == TransformOperation::ROTATE_Z
- || transformType == TransformOperation::ROTATE_3D;
-}
-
-template <>
-bool appendKeyframeWithStandardTimingFunction<TransformAnimationValue, WebTransformKeyframe, WebTransformAnimationCurve>(WebTransformAnimationCurve* curve, double keyTime, const TransformAnimationValue* value, const TransformAnimationValue* lastValue, WebKit::WebAnimationCurve::TimingFunctionType timingFunctionType, const FloatSize& boxSize)
-{
- bool canBlend = !lastValue;
- WebTransformOperations operations = toWebTransformOperations(*value->value(), boxSize);
- if (!canBlend) {
- WebTransformOperations lastOperations = toWebTransformOperations(*lastValue->value(), boxSize);
- canBlend = lastOperations.canBlendWith(operations);
- }
- if (canBlend) {
- curve->add(WebTransformKeyframe(keyTime, operations), timingFunctionType);
- return true;
- }
- return false;
-}
-
-template <>
-bool appendKeyframeWithCustomBezierTimingFunction<TransformAnimationValue, WebTransformKeyframe, WebTransformAnimationCurve>(WebTransformAnimationCurve* curve, double keyTime, const TransformAnimationValue* value, const TransformAnimationValue* lastValue, double x1, double y1, double x2, double y2, const FloatSize& boxSize)
-{
- bool canBlend = !lastValue;
- WebTransformOperations operations = toWebTransformOperations(*value->value(), boxSize);
- if (!canBlend) {
- WebTransformOperations lastOperations = toWebTransformOperations(*lastValue->value(), boxSize);
- canBlend = lastOperations.canBlendWith(operations);
- }
- if (canBlend) {
- curve->add(WebTransformKeyframe(keyTime, operations), x1, y1, x2, y2);
- return true;
- }
- return false;
-}
-
-template <class Value, class Keyframe, class Curve>
-PassOwnPtr<WebKit::WebAnimation> createWebAnimation(const KeyframeValueList& valueList, const Animation* animation, int animationId, double timeOffset, Curve* curve, WebKit::WebAnimation::TargetProperty targetProperty, const FloatSize& boxSize)
-{
- bool alternate = false;
- bool reverse = false;
- if (animation && animation->isDirectionSet()) {
- Animation::AnimationDirection direction = animation->direction();
- if (direction == Animation::AnimationDirectionAlternate || direction == Animation::AnimationDirectionAlternateReverse)
- alternate = true;
- if (direction == Animation::AnimationDirectionReverse || direction == Animation::AnimationDirectionAlternateReverse)
- reverse = true;
- }
-
- for (size_t i = 0; i < valueList.size(); i++) {
- size_t index = reverse ? valueList.size() - i - 1 : i;
- const Value* originalValue = static_cast<const Value*>(valueList.at(index));
- const Value* lastOriginalValue = 0;
- if (valueList.size() > 1 && ((reverse && index + 1 < valueList.size()) || (!reverse && index > 0)))
- lastOriginalValue = static_cast<const Value*>(valueList.at(reverse ? index + 1 : index - 1));
-
- const TimingFunction* originalTimingFunction = originalValue->timingFunction();
-
- // If there hasn't been a timing function associated with this keyframe, use the
- // animation's timing function, if we have one.
- if (!originalTimingFunction && animation->isTimingFunctionSet())
- originalTimingFunction = animation->timingFunction().get();
-
- // Ease is the default timing function.
- WebKit::WebAnimationCurve::TimingFunctionType timingFunctionType = WebKit::WebAnimationCurve::TimingFunctionTypeEase;
-
- bool isUsingCustomBezierTimingFunction = false;
- double x1 = 0;
- double y1 = 0;
- double x2 = 1;
- double y2 = 1;
-
- if (originalTimingFunction) {
- switch (originalTimingFunction->type()) {
- case TimingFunction::StepsFunction:
- // FIXME: add support for steps timing function.
- return nullptr;
- case TimingFunction::LinearFunction:
- timingFunctionType = WebKit::WebAnimationCurve::TimingFunctionTypeLinear;
- break;
- case TimingFunction::CubicBezierFunction:
- const CubicBezierTimingFunction* originalBezierTimingFunction = static_cast<const CubicBezierTimingFunction*>(originalTimingFunction);
- isUsingCustomBezierTimingFunction = true;
- x1 = originalBezierTimingFunction->x1();
- y1 = originalBezierTimingFunction->y1();
- x2 = originalBezierTimingFunction->x2();
- y2 = originalBezierTimingFunction->y2();
- break;
- } // switch
- }
-
- double duration = (animation && animation->isDurationSet()) ? animation->duration() : 1;
- double keyTime = originalValue->keyTime() * duration;
-
- if (reverse)
- keyTime = duration - keyTime;
-
- bool addedKeyframe = false;
- if (isUsingCustomBezierTimingFunction)
- addedKeyframe = appendKeyframeWithCustomBezierTimingFunction<Value, Keyframe, Curve>(curve, keyTime, originalValue, lastOriginalValue, x1, y1, x2, y2, boxSize);
- else
- addedKeyframe = appendKeyframeWithStandardTimingFunction<Value, Keyframe, Curve>(curve, keyTime, originalValue, lastOriginalValue, timingFunctionType, boxSize);
- if (!addedKeyframe)
- return nullptr;
- }
-
- OwnPtr<WebKit::WebAnimation> webAnimation = adoptPtr(Platform::current()->compositorSupport()->createAnimation(*curve, targetProperty, animationId));
-
- int iterations = (animation && animation->isIterationCountSet()) ? animation->iterationCount() : 1;
- webAnimation->setIterations(iterations);
- webAnimation->setAlternatesDirection(alternate);
-
- // If timeOffset > 0, then the animation has started in the past.
- webAnimation->setTimeOffset(timeOffset);
-
- return webAnimation.release();
-}
-
-PassOwnPtr<WebKit::WebAnimation> createWebAnimation(const KeyframeValueList& values, const Animation* animation, int animationId, double timeOffset, const FloatSize& boxSize)
-{
-
-
- if (values.property() == AnimatedPropertyWebkitTransform) {
- OwnPtr<WebTransformAnimationCurve> curve = adoptPtr(Platform::current()->compositorSupport()->createTransformAnimationCurve());
- return createWebAnimation<TransformAnimationValue, WebTransformKeyframe, WebTransformAnimationCurve>(values, animation, animationId, timeOffset, curve.get(), WebKit::WebAnimation::TargetPropertyTransform, FloatSize(boxSize));
- }
-
- if (values.property() == AnimatedPropertyOpacity) {
- OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(Platform::current()->compositorSupport()->createFloatAnimationCurve());
- return createWebAnimation<FloatAnimationValue, WebFloatKeyframe, WebFloatAnimationCurve>(values, animation, animationId, timeOffset, curve.get(), WebKit::WebAnimation::TargetPropertyOpacity, FloatSize());
- }
-
- return nullptr;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/chromium/AnimationTranslationUtil.h b/Source/WebCore/platform/graphics/chromium/AnimationTranslationUtil.h
deleted file mode 100644
index 8739ab76a..000000000
--- a/Source/WebCore/platform/graphics/chromium/AnimationTranslationUtil.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2010 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef AnimationTranslationUtil_h
-#define AnimationTranslationUtil_h
-
-#include <wtf/PassOwnPtr.h>
-
-namespace WebKit {
-class WebAnimation;
-}
-
-namespace WebCore {
-
-class KeyframeValueList;
-class Animation;
-class FloatSize;
-
-
-// Translates WebCore animation data into a WebAnimation. If we are unable
-// to perform this translation, we return nullptr. This can happen if
-// - a steps timing function is used,
-// - a property other than AnimatedPropertyWebkitTransform, or AnimatedPropertyOpacity is animated, or
-// - a transform animation involves a non-invertable transform.
-PassOwnPtr<WebKit::WebAnimation> createWebAnimation(const KeyframeValueList&, const Animation*, int animationId, double timeOffset, const FloatSize& boxSize);
-
-} // namespace WebCore
-
-#endif // AnimationTranslationUtil_h
diff --git a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.cpp b/Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.cpp
deleted file mode 100644
index b89d995f1..000000000
--- a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.cpp
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "Canvas2DLayerBridge.h"
-
-#include "Canvas2DLayerManager.h"
-#include "GrContext.h"
-#include "GraphicsContext3D.h"
-#include "GraphicsContext3DPrivate.h"
-#include "GraphicsLayerChromium.h"
-#include "TraceEvent.h"
-#include <public/Platform.h>
-#include <public/WebCompositorSupport.h>
-#include <public/WebGraphicsContext3D.h>
-
-using WebKit::WebExternalTextureLayer;
-using WebKit::WebGraphicsContext3D;
-using WebKit::WebTextureUpdater;
-
-namespace WebCore {
-
-Canvas2DLayerBridge::Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D> context, const IntSize& size, DeferralMode deferralMode, unsigned textureId)
- : m_deferralMode(deferralMode)
- , m_frontBufferTexture(0)
- , m_backBufferTexture(textureId)
- , m_size(size)
- , m_canvas(0)
- , m_context(context)
- , m_bytesAllocated(0)
- , m_didRecordDrawCommand(false)
- , m_framesPending(0)
- , m_next(0)
- , m_prev(0)
-{
- // Used by browser tests to detect the use of a Canvas2DLayerBridge.
- TRACE_EVENT_INSTANT0("test_gpu", "Canvas2DLayerBridgeCreation");
-
- bool compositorThreadingEnabled = WebKit::Platform::current()->compositorSupport()->isThreadingEnabled();
- // FIXME: We currently turn off double buffering when canvas rendering is
- // deferred. What we should be doing is to use a smarter heuristic based
- // on GPU resource monitoring and other factors to chose between single
- // and double buffering.
- m_useDoubleBuffering = compositorThreadingEnabled && deferralMode == NonDeferred;
-
- if (m_useDoubleBuffering) {
- m_context->makeContextCurrent();
- m_frontBufferTexture = m_context->createTexture();
- m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_frontBufferTexture);
- // Do basic linear filtering on resize.
- m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR);
- m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR);
- // NPOT textures in GL ES only work when the wrap mode is set to GraphicsContext3D::CLAMP_TO_EDGE.
- m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE);
- m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE);
- m_context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, size.width(), size.height(), 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE);
- if (GrContext* grContext = m_context->grContext())
- grContext->resetContext();
- }
-
- m_layer = adoptPtr(WebKit::Platform::current()->compositorSupport()->createExternalTextureLayer(this));
- m_layer->setTextureId(textureId);
- m_layer->setRateLimitContext(!compositorThreadingEnabled || m_useDoubleBuffering);
- GraphicsLayerChromium::registerContentsLayer(m_layer->layer());
-}
-
-Canvas2DLayerBridge::~Canvas2DLayerBridge()
-{
- GraphicsLayerChromium::unregisterContentsLayer(m_layer->layer());
- Canvas2DLayerManager::get().layerToBeDestroyed(this);
- if (SkDeferredCanvas* deferred = deferredCanvas())
- deferred->setNotificationClient(0);
- m_layer->setTextureId(0);
- if (m_useDoubleBuffering) {
- m_context->makeContextCurrent();
- m_context->deleteTexture(m_frontBufferTexture);
- m_context->flush();
- }
-}
-
-SkDeferredCanvas* Canvas2DLayerBridge::deferredCanvas()
-{
- if (m_deferralMode == Deferred)
- return static_cast<SkDeferredCanvas*>(m_canvas);
- return 0;
-}
-
-void Canvas2DLayerBridge::limitPendingFrames()
-{
- if (m_didRecordDrawCommand) {
- m_framesPending++;
- m_didRecordDrawCommand = false;
- if (m_framesPending > 1)
- flush();
- }
-}
-
-void Canvas2DLayerBridge::prepareForDraw()
-{
- ASSERT(deferredCanvas());
- if (!m_useDoubleBuffering)
- m_layer->willModifyTexture();
- m_context->makeContextCurrent();
-}
-
-void Canvas2DLayerBridge::storageAllocatedForRecordingChanged(size_t bytesAllocated)
-{
- ASSERT(m_deferralMode == Deferred);
- intptr_t delta = (intptr_t)bytesAllocated - (intptr_t)m_bytesAllocated;
- m_bytesAllocated = bytesAllocated;
- Canvas2DLayerManager::get().layerAllocatedStorageChanged(this, delta);
-}
-
-size_t Canvas2DLayerBridge::storageAllocatedForRecording()
-{
- return deferredCanvas()->storageAllocatedForRecording();
-}
-
-void Canvas2DLayerBridge::flushedDrawCommands()
-{
- storageAllocatedForRecordingChanged(storageAllocatedForRecording());
- m_framesPending = 0;
-}
-
-void Canvas2DLayerBridge::skippedPendingDrawCommands()
-{
- flushedDrawCommands();
-}
-
-size_t Canvas2DLayerBridge::freeMemoryIfPossible(size_t bytesToFree)
-{
- ASSERT(deferredCanvas());
- size_t bytesFreed = deferredCanvas()->freeMemoryIfPossible(bytesToFree);
- if (bytesFreed)
- Canvas2DLayerManager::get().layerAllocatedStorageChanged(this, -((intptr_t)bytesFreed));
- m_bytesAllocated -= bytesFreed;
- return bytesFreed;
-}
-
-void Canvas2DLayerBridge::flush()
-{
- ASSERT(deferredCanvas());
- if (deferredCanvas()->hasPendingCommands())
- m_canvas->flush();
-}
-
-SkCanvas* Canvas2DLayerBridge::skCanvas(SkDevice* device)
-{
- ASSERT(!m_canvas);
- if (m_deferralMode == Deferred) {
- SkDeferredCanvas* deferred = new SkDeferredCanvas(device);
- deferred->setNotificationClient(this);
- m_canvas = deferred;
- } else
- m_canvas = new SkCanvas(device);
-
- return m_canvas;
-}
-
-
-unsigned Canvas2DLayerBridge::prepareTexture(WebTextureUpdater& updater)
-{
- m_context->makeContextCurrent();
-
- if (m_canvas) {
- TRACE_EVENT0("cc", "Canvas2DLayerBridge::SkCanvas::flush");
- m_canvas->flush();
- }
-
- m_context->flush();
-
- if (m_useDoubleBuffering) {
- updater.appendCopy(m_backBufferTexture, m_frontBufferTexture, m_size);
- return m_frontBufferTexture;
- }
-
- if (m_canvas) {
- // Notify skia that the state of the backing store texture object will be touched by the compositor
- GrRenderTarget* renderTarget = reinterpret_cast<GrRenderTarget*>(m_canvas->getDevice()->accessRenderTarget());
- if (renderTarget)
- renderTarget->asTexture()->invalidateCachedState();
- }
- return m_backBufferTexture;
-}
-
-WebGraphicsContext3D* Canvas2DLayerBridge::context()
-{
- return GraphicsContext3DPrivate::extractWebGraphicsContext3D(m_context.get());
-}
-
-WebKit::WebLayer* Canvas2DLayerBridge::layer()
-{
- return m_layer->layer();
-}
-
-void Canvas2DLayerBridge::contextAcquired()
-{
- if (m_deferralMode == NonDeferred && !m_useDoubleBuffering)
- m_layer->willModifyTexture();
- else if (m_deferralMode == Deferred) {
- Canvas2DLayerManager::get().layerDidDraw(this);
- m_didRecordDrawCommand = true;
- }
-}
-
-unsigned Canvas2DLayerBridge::backBufferTexture()
-{
- contextAcquired();
- if (m_canvas)
- m_canvas->flush();
- m_context->flush();
- return m_backBufferTexture;
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.h b/Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.h
deleted file mode 100644
index 996917493..000000000
--- a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef Canvas2DLayerBridge_h
-#define Canvas2DLayerBridge_h
-
-#include "GraphicsContext3D.h"
-#include "ImageBuffer.h" // For DeferralMode enum.
-#include "IntSize.h"
-#include "SkDeferredCanvas.h"
-#include <public/WebExternalTextureLayer.h>
-#include <public/WebExternalTextureLayerClient.h>
-#include <wtf/DoublyLinkedList.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/RefPtr.h>
-
-namespace WebKit {
-class WebGraphicsContext3D;
-}
-
-namespace WebCore {
-
-class LayerChromium;
-
-class Canvas2DLayerBridge : public WebKit::WebExternalTextureLayerClient, public SkDeferredCanvas::NotificationClient, public DoublyLinkedListNode<Canvas2DLayerBridge> {
- WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge);
-public:
- static PassOwnPtr<Canvas2DLayerBridge> create(PassRefPtr<GraphicsContext3D> context, const IntSize& size, DeferralMode deferralMode, unsigned textureId)
- {
- return adoptPtr(new Canvas2DLayerBridge(context, size, deferralMode, textureId));
- }
-
- virtual ~Canvas2DLayerBridge();
-
- // WebKit::WebExternalTextureLayerClient implementation.
- virtual unsigned prepareTexture(WebKit::WebTextureUpdater&) OVERRIDE;
- virtual WebKit::WebGraphicsContext3D* context() OVERRIDE;
-
- // SkDeferredCanvas::NotificationClient implementation
- virtual void prepareForDraw() OVERRIDE;
- virtual void storageAllocatedForRecordingChanged(size_t) OVERRIDE;
- virtual void flushedDrawCommands() OVERRIDE;
- virtual void skippedPendingDrawCommands() OVERRIDE;
-
- // Methods used by Canvas2DLayerManager
- virtual size_t freeMemoryIfPossible(size_t); // virtual for mocking
- virtual void flush(); // virtual for mocking
- virtual size_t storageAllocatedForRecording(); // virtual for faking
- size_t bytesAllocated() const {return m_bytesAllocated;}
- void limitPendingFrames();
-
- SkCanvas* skCanvas(SkDevice*);
- WebKit::WebLayer* layer();
- void contextAcquired();
-
- unsigned backBufferTexture();
-
-protected:
- Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D>, const IntSize&, DeferralMode, unsigned textureId);
- SkDeferredCanvas* deferredCanvas();
-
- DeferralMode m_deferralMode;
- bool m_useDoubleBuffering;
- unsigned m_frontBufferTexture;
- unsigned m_backBufferTexture;
- IntSize m_size;
- SkCanvas* m_canvas;
- OwnPtr<WebKit::WebExternalTextureLayer> m_layer;
- RefPtr<GraphicsContext3D> m_context;
- size_t m_bytesAllocated;
- bool m_didRecordDrawCommand;
- int m_framesPending;
-
- friend class WTF::DoublyLinkedListNode<Canvas2DLayerBridge>;
- Canvas2DLayerBridge* m_next;
- Canvas2DLayerBridge* m_prev;
-};
-
-}
-
-#endif
diff --git a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerManager.cpp b/Source/WebCore/platform/graphics/chromium/Canvas2DLayerManager.cpp
deleted file mode 100644
index 7e7adb994..000000000
--- a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerManager.cpp
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
-Copyright (C) 2012 Google Inc. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
-EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
-DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-#include "config.h"
-
-#include "Canvas2DLayerManager.h"
-
-#include <public/Platform.h>
-#include <wtf/StdLibExtras.h>
-
-using WebKit::WebThread;
-
-namespace {
-enum {
- DefaultMaxBytesAllocated = 64*1024*1024,
- DefaultTargetBytesAllocated = 16*1024*1024,
-};
-}
-
-namespace WebCore {
-
-Canvas2DLayerManager::Canvas2DLayerManager()
- : m_bytesAllocated(0)
- , m_maxBytesAllocated(DefaultMaxBytesAllocated)
- , m_targetBytesAllocated(DefaultTargetBytesAllocated)
- , m_taskObserverActive(false)
-{
-}
-
-Canvas2DLayerManager::~Canvas2DLayerManager()
-{
- ASSERT(!m_bytesAllocated);
- ASSERT(!m_layerList.head());
- ASSERT(!m_taskObserverActive);
-}
-
-void Canvas2DLayerManager::init(size_t maxBytesAllocated, size_t targetBytesAllocated)
-{
- ASSERT(maxBytesAllocated >= targetBytesAllocated);
- m_maxBytesAllocated = maxBytesAllocated;
- m_targetBytesAllocated = targetBytesAllocated;
-}
-
-Canvas2DLayerManager& Canvas2DLayerManager::get()
-{
- DEFINE_STATIC_LOCAL(Canvas2DLayerManager, manager, ());
- return manager;
-}
-
-void Canvas2DLayerManager::willProcessTask()
-{
-}
-
-void Canvas2DLayerManager::didProcessTask()
-{
- // Called after the script action for the current frame has been processed.
- ASSERT(m_taskObserverActive);
- WebKit::Platform::current()->currentThread()->removeTaskObserver(this);
- m_taskObserverActive = false;
- for (Canvas2DLayerBridge* layer = m_layerList.head(); layer; layer = layer->next())
- layer->limitPendingFrames();
-}
-
-void Canvas2DLayerManager::layerDidDraw(Canvas2DLayerBridge* layer)
-{
- if (isInList(layer)) {
- if (layer != m_layerList.head()) {
- m_layerList.remove(layer);
- m_layerList.push(layer); // Set as MRU
- }
- } else
- addLayerToList(layer);
-
- if (!m_taskObserverActive) {
- m_taskObserverActive = true;
- // Schedule a call to didProcessTask() after completion of the current script task.
- WebKit::Platform::current()->currentThread()->addTaskObserver(this);
- }
-}
-
-void Canvas2DLayerManager::addLayerToList(Canvas2DLayerBridge* layer)
-{
- ASSERT(!isInList(layer));
- m_bytesAllocated += layer->bytesAllocated();
- m_layerList.push(layer); // Set as MRU
-}
-
-void Canvas2DLayerManager::layerAllocatedStorageChanged(Canvas2DLayerBridge* layer, intptr_t deltaBytes)
-{
- if (!isInList(layer))
- addLayerToList(layer);
- else {
- ASSERT((intptr_t)m_bytesAllocated + deltaBytes >= 0);
- m_bytesAllocated = (intptr_t)m_bytesAllocated + deltaBytes;
- }
- if (deltaBytes > 0)
- freeMemoryIfNecessary();
-}
-
-void Canvas2DLayerManager::layerToBeDestroyed(Canvas2DLayerBridge* layer)
-{
- if (isInList(layer))
- removeLayerFromList(layer);
-}
-
-void Canvas2DLayerManager::freeMemoryIfNecessary()
-{
- if (m_bytesAllocated > m_maxBytesAllocated) {
- // Pass 1: Free memory from caches
- Canvas2DLayerBridge* layer = m_layerList.tail(); // LRU
- while (m_bytesAllocated > m_targetBytesAllocated && layer) {
- layer->freeMemoryIfPossible(m_bytesAllocated - m_targetBytesAllocated);
- layer = layer->prev();
- }
-
- // Pass 2: Flush canvases
- Canvas2DLayerBridge* leastRecentlyUsedLayer = m_layerList.tail();
- while (m_bytesAllocated > m_targetBytesAllocated && leastRecentlyUsedLayer) {
- leastRecentlyUsedLayer->flush();
- leastRecentlyUsedLayer->freeMemoryIfPossible(~0);
- removeLayerFromList(leastRecentlyUsedLayer);
- leastRecentlyUsedLayer = m_layerList.tail();
- }
- }
-}
-
-void Canvas2DLayerManager::removeLayerFromList(Canvas2DLayerBridge* layer)
-{
- ASSERT(isInList(layer));
- m_bytesAllocated -= layer->bytesAllocated();
- m_layerList.remove(layer);
- layer->setNext(0);
- layer->setPrev(0);
-}
-
-bool Canvas2DLayerManager::isInList(Canvas2DLayerBridge* layer)
-{
- return layer->prev() || m_layerList.head() == layer;
-}
-
-}
-
diff --git a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerManager.h b/Source/WebCore/platform/graphics/chromium/Canvas2DLayerManager.h
deleted file mode 100644
index 55d7ce455..000000000
--- a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerManager.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
-Copyright (C) 2012 Google Inc. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
-EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
-DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifndef Canvas2DLayerManager_h
-#define Canvas2DLayerManager_h
-
-#include "Canvas2DLayerBridge.h"
-#include <public/WebThread.h>
-
-class Canvas2DLayerManagerTest;
-
-namespace WebCore {
-
-class Canvas2DLayerManager : public WebKit::WebThread::TaskObserver {
-public:
- static Canvas2DLayerManager& get();
- void init(size_t maxBytesAllocated, size_t targetBytesAllocated);
- virtual ~Canvas2DLayerManager();
-
- void layerAllocatedStorageChanged(Canvas2DLayerBridge*, intptr_t deltaBytes);
- void layerDidDraw(Canvas2DLayerBridge*);
- void layerToBeDestroyed(Canvas2DLayerBridge*);
-private:
- Canvas2DLayerManager();
-
- // internal methods
- void freeMemoryIfNecessary();
- bool isInList(Canvas2DLayerBridge*);
- void addLayerToList(Canvas2DLayerBridge*);
- void removeLayerFromList(Canvas2DLayerBridge*);
- virtual void willProcessTask() OVERRIDE;
- virtual void didProcessTask() OVERRIDE;
-
- size_t m_bytesAllocated;
- size_t m_maxBytesAllocated;
- size_t m_targetBytesAllocated;
- bool m_taskObserverActive;
- DoublyLinkedList<Canvas2DLayerBridge> m_layerList;
-
- friend class ::Canvas2DLayerManagerTest; // for unit testing
-};
-
-}
-
-#endif
-
diff --git a/Source/WebCore/platform/graphics/chromium/CompositorHUDFontAtlas.cpp b/Source/WebCore/platform/graphics/chromium/CompositorHUDFontAtlas.cpp
deleted file mode 100644
index 6edf3c5e0..000000000
--- a/Source/WebCore/platform/graphics/chromium/CompositorHUDFontAtlas.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "CompositorHUDFontAtlas.h"
-
-#include "Font.h"
-#include "FontCache.h"
-#include "FontDescription.h"
-#include "GraphicsContext.h"
-#include "PlatformContextSkia.h"
-#include "SkCanvas.h"
-#include "SkDevice.h"
-#include "TextRun.h"
-#include "skia/ext/platform_canvas.h"
-
-using WebKit::WebRect;
-
-namespace WebCore {
-
-#define ATLAS_SIZE 128
-
-static void wrapPositionIfNeeded(IntPoint& position, int textWidth, int textHeight)
-{
- if (position.x() + textWidth > ATLAS_SIZE)
- position = IntPoint(0, position.y() + textHeight);
-}
-
-// Paints the font into the atlas, from left-to-right, top-to-bottom, starting at
-// startingPosition. At the same time, it updates the ascii-to-WebRect mapping for
-// each character. By doing things this way, it is possible to support variable-width
-// fonts and multiple fonts on the same atlas.
-SkBitmap CompositorHUDFontAtlas::generateFontAtlas(WebRect asciiToRectTable[128], int& fontHeight)
-{
- fontHeight = 14;
-
- OwnPtr<SkCanvas> canvas = adoptPtr(skia::CreateBitmapCanvas(ATLAS_SIZE, ATLAS_SIZE, false /* opaque */));
-
- PlatformContextSkia platformContext(canvas.get());
- platformContext.setDrawingToImageBuffer(true);
- GraphicsContext atlasContext(&platformContext);
-
- // Clear the entire texture atlas to transparent before drawing fonts.
- atlasContext.setFillColor(Color(0, 0, 0, 0), ColorSpaceDeviceRGB);
- atlasContext.clearRect(FloatRect(0, 0, ATLAS_SIZE, ATLAS_SIZE));
-
- // FIXME: monospace font does not work as expected.
- FontDescription fontDescription;
- fontDescription.setGenericFamily(FontDescription::MonospaceFamily);
- fontDescription.setComputedSize(fontHeight);
-
- FontCachePurgePreventer fontCachePurgePreventer;
-
- int textHeight = fontDescription.computedPixelSize();
- IntPoint position(0, textHeight);
- // This is a dirty little trick to account for overhang letters like g, p, j.
- int inflation = textHeight / 3;
-
- Font font(fontDescription, 0, 0);
- font.update(0);
-
- Color fontColor(255, 0, 0);
- atlasContext.setStrokeColor(fontColor, ColorSpaceDeviceRGB);
- atlasContext.setFillColor(fontColor, ColorSpaceDeviceRGB);
-
- // First, draw a generic rect that will be used for special and unknown characters that have nothing else to render.
- {
- int textWidth = textHeight / 2;
- wrapPositionIfNeeded(position, textWidth, textHeight + inflation);
- atlasContext.strokeRect(FloatRect(FloatPoint(position.x() + 1, position.y() - textHeight + 1 + inflation), FloatSize(textWidth - 2, textHeight - 2 - inflation)), 1);
-
- // Initialize the rect that would be copied when drawing this glyph from the atlas.
- asciiToRectTable[0] = WebRect(position.x(), position.y() - textHeight, textWidth, textHeight + inflation);
-
- // Increment to the position where the next glyph will be placed.
- position.setX(position.x() + textWidth);
- }
-
- // Then, draw the ASCII characters.
- for (LChar i = 1; i < 128; ++i) {
- if (i < 32) {
- // Special characters will simply use the the default glyph.
- asciiToRectTable[i] = asciiToRectTable[0];
- continue;
- }
-
- String str;
- str.append(i);
- TextRun text(str);
-
- int textWidth = round(font.width(text));
- wrapPositionIfNeeded(position, textWidth, textHeight + inflation);
- atlasContext.drawText(font, text, position);
-
- // Initialize the rect that would be copied when drawing this glyph from the atlas.
- asciiToRectTable[i] = WebRect(position.x(), position.y() - textHeight, textWidth, textHeight + inflation);
-
- // Increment to the position where the next glyph will be placed.
- position.setX(position.x() + textWidth);
- }
-
- SkBitmap copy;
- const SkBitmap& source = canvas->getDevice()->accessBitmap(false);
- source.copyTo(&copy, source.config());
- return copy;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/chromium/CompositorHUDFontAtlas.h b/Source/WebCore/platform/graphics/chromium/CompositorHUDFontAtlas.h
deleted file mode 100644
index 91bab5d62..000000000
--- a/Source/WebCore/platform/graphics/chromium/CompositorHUDFontAtlas.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef CompositorHUDFontAtlas_h
-#define CompositorHUDFontAtlas_h
-
-#include "SkBitmap.h"
-#include <public/WebRect.h>
-
-namespace WebCore {
-
-class CompositorHUDFontAtlas {
-public:
- // This is a helper function that can generate a font atlas suitable for the compositor's heads up display.
- // Returns a bitmap containing glyphs and populates asciiToRectTable with the
- // location of each glyph.
- static SkBitmap generateFontAtlas(WebKit::WebRect asciiToRectTable[128], int& fontHeight);
-};
-
-} // namespace WebCore
-
-#endif // CompositorHUDFontAtlas_h
-
diff --git a/Source/WebCore/platform/graphics/chromium/CrossProcessFontLoading.h b/Source/WebCore/platform/graphics/chromium/CrossProcessFontLoading.h
deleted file mode 100644
index e8deeb15a..000000000
--- a/Source/WebCore/platform/graphics/chromium/CrossProcessFontLoading.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2010 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef CrossProcessFontLoading_h
-#define CrossProcessFontLoading_h
-
-#import <wtf/RefCounted.h>
-#import <wtf/RetainPtr.h>
-#import <wtf/text/WTFString.h>
-
-typedef struct CGFont* CGFontRef;
-
-namespace WebCore {
-
-// MemoryActivatedFont encapsulates a font loaded from another process and
-// activated from memory.
-//
-// Responsibilities:
-// * Holder for the CGFontRef & ATSFontRef belonging to the activated font.
-// * Responsible for unloading the font container when done.
-//
-// Memory Management:
-// The class is reference counted, with each instance of FontPlatformData that
-// uses this class holding a reference to it.
-// Entries are kept track of internally in a hash to allow quick lookup
-// of existing instances for reuse:
-// - fontCacheBySrcFontContainerRef() - key is the ATSFontContainerRef
-// corresponding to the *original in-process NSFont* whose loading was blocked
-// by the sandbox.
-// This is needed to allow lookup of a pre-existing MemoryActivatedFont when
-// creating a new FontPlatformData object.
-//
-// Assumptions:
-// This code assumes that an ATSFontRef is a unique identifier tied to an
-// activated font. i.e. After we activate a font, its ATSFontRef doesn't
-// change.
-// It also assumes that the ATSFoncontainerRef for two in-memory NSFonts that
-// correspond to the same on-disk font file are always the same and don't change
-// with time.
-//
-// Flushing caches:
-// When the system notifies us of a system font cache flush, all FontDataCache
-// objects are destroyed. This should in turn dereference all
-// MemoryActivatedFonts and thus unload all in-memory fonts.
-class MemoryActivatedFont : public RefCounted<MemoryActivatedFont> {
-public:
- // Use to create a new object, see docs on constructor below.
- static PassRefPtr<MemoryActivatedFont> create(uint32_t fontID, NSFont*, CGFontRef);
- ~MemoryActivatedFont();
-
- // Get cached CGFontRef corresponding to the in-memory font.
- CGFontRef cgFont() { return m_cgFont.get(); }
-
-private:
- // srcFontRef - ATSFontRef belonging to the NSFont object that failed to
- // load in-process.
- // container - a font container corresponding to an identical font that
- // we loaded cross-process.
- MemoryActivatedFont(uint32_t fontID, NSFont*, CGFontRef);
-
- WTF::RetainPtr<CGFontRef> m_cgFont;
- uint32_t m_fontID;
- WTF::String m_inSandboxHashKey;
-};
-
-} // namespace WebCore
-
-#endif // CrossProcessFontLoading_h
diff --git a/Source/WebCore/platform/graphics/chromium/CrossProcessFontLoading.mm b/Source/WebCore/platform/graphics/chromium/CrossProcessFontLoading.mm
deleted file mode 100644
index 15341ca43..000000000
--- a/Source/WebCore/platform/graphics/chromium/CrossProcessFontLoading.mm
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * This file is part of the internal font implementation.
- *
- * Copyright (c) 2010 Google Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-// This file provides additional functionality to the Mac FontPlatformData class
-// defined in WebCore/platform/cocoa/FontPlatformDataCocoa.mm .
-// Because we want to support loading fonts between processes in the face of
-// font loading being blocked by the sandbox, we need a mechnasim to both
-// do the loading of in-memory fonts and keep track of them.
-
-#import "config.h"
-#import "CrossProcessFontLoading.h"
-
-#import "../graphics/FontPlatformData.h"
-#include "LinkHash.h"
-#import <AppKit/NSFont.h>
-#import <public/Platform.h>
-#import <public/mac/WebSandboxSupport.h>
-#import <wtf/HashMap.h>
-
-namespace WebCore {
-
-namespace {
-
-typedef HashMap<uint32, MemoryActivatedFont*> FontContainerRefMemoryFontHash;
-typedef HashMap<WTF::String, MemoryActivatedFont*> FontNameMemoryFontHash;
-
-// Caching:
-//
-// Requesting a font from the browser process is expensive and so is
-// "activating" said font. Caching of loaded fonts is complicated by the fact
-// that it's impossible to get a unique identifier for the on-disk font file
-// from inside the sandboxed renderer process.
-// This means that when loading a font we need to round-trip through the browser
-// process in order to get the unique font file identifer which we might already
-// have activated and cached.
-//
-// In order to save as much work as we can, we maintain 2 levels of caching
-// for the font data:
-// 1. A dumb cache keyed by the font name/style (information we can determine
-// from inside the sandbox).
-// 2. A smarter cache keyed by the real "unique font id".
-//
-// In order to perform a lookup in #2 we need to consult with the browser to get
-// us the lookup key. While this doesn't save us the font load, it does save
-// us font activation.
-//
-// It's important to remember that existing FontPlatformData objects are already
-// cached, so a cache miss in the code in this file isn't necessarily so bad.
-
-FontContainerRefMemoryFontHash& fontCacheByFontID()
-{
- DEFINE_STATIC_LOCAL(FontContainerRefMemoryFontHash, srcFontIDCache, ());
- return srcFontIDCache;
-}
-
-
-FontNameMemoryFontHash& fontCacheByFontName()
-{
- DEFINE_STATIC_LOCAL(FontNameMemoryFontHash, srcFontNameCache, ());
- return srcFontNameCache;
-}
-
-// Given a font specified by |srcFont|, use the information we can query in
-// the sandbox to construct a key which we hope will be as unique as possible
-// to the containing font file.
-WTF::String hashKeyFromNSFont(NSFont* srcFont)
-{
- NSFontDescriptor* desc = [srcFont fontDescriptor];
- NSFontSymbolicTraits traits = [desc symbolicTraits];
- return WTF::String::format("%s %x", [[srcFont fontName] UTF8String], traits);
-}
-
-// The only way we can tell that an in-process font has failed to load
-// is if CTFontCopyGraphicsFont() returns the LastResort font.
-bool isLastResortFont(CGFontRef cgFont)
-{
- NSString* fontName = (NSString*)CGFontCopyPostScriptName(cgFont);
- return [fontName isEqualToString:@"LastResort"];
-}
-
-// Given an in-process font which has failed to load, return a
-// MemoryActivatedFont* corresponding to an in-memory representation of the
-// same font loaded from the browser process.
-// On failure this function returns a PassRefPtr pointing to 0.
-PassRefPtr<MemoryActivatedFont> loadFontFromBrowserProcess(NSFont* nsFont)
-{
- // First try to lookup in our cache with the limited information we have.
- WTF::String hashKey = hashKeyFromNSFont(nsFont);
- RefPtr<MemoryActivatedFont> font(fontCacheByFontName().get(hashKey));
- if (font)
- return font;
-
- CGFontRef tmpCGFont;
- uint32_t fontID;
- // Send cross-process request to load font.
- WebKit::WebSandboxSupport* sandboxSupport = WebKit::Platform::current()->sandboxSupport();
- if (!sandboxSupport) {
- // This function should only be called in response to an error loading a
- // font due to being blocked by the sandbox.
- // This by definition shouldn't happen if there is no sandbox support.
- ASSERT_NOT_REACHED();
- return 0;
- }
- if (!sandboxSupport->loadFont(nsFont, &tmpCGFont, &fontID))
- return 0;
-
- RetainPtr<CGFontRef> cgFont(tmpCGFont);
- // Now that we have the fontID from the browser process, we can consult
- // the ID cache.
- font = fontCacheByFontID().get(fontID);
- if (font)
- // FIXME: WebSandboxSupport::loadFont() should consult the id cache
- // before activating the font.
- return font;
-
- return MemoryActivatedFont::create(fontID, nsFont, cgFont.get());
-}
-
-} // namespace
-
-PassRefPtr<MemoryActivatedFont> MemoryActivatedFont::create(uint32_t fontID, NSFont* nsFont, CGFontRef cgFont)
-{
- return adoptRef(new MemoryActivatedFont(fontID, nsFont, cgFont));
-}
-
-MemoryActivatedFont::MemoryActivatedFont(uint32_t fontID, NSFont* nsFont, CGFontRef cgFont)
- : m_cgFont(cgFont)
- , m_fontID(fontID)
- , m_inSandboxHashKey(hashKeyFromNSFont(nsFont))
-{
- // Add ourselves to caches.
- fontCacheByFontID().add(fontID, this);
- fontCacheByFontName().add(m_inSandboxHashKey, this);
-}
-
-// Destructor - Unload font container from memory and remove ourselves
-// from cache.
-MemoryActivatedFont::~MemoryActivatedFont()
-{
- // First remove ourselves from the caches.
- ASSERT(fontCacheByFontID().contains(m_fontID));
- ASSERT(fontCacheByFontName().contains(m_inSandboxHashKey));
-
- fontCacheByFontID().remove(m_fontID);
- fontCacheByFontName().remove(m_inSandboxHashKey);
-}
-
-// Given an NSFont, try to load a representation of that font into the cgFont
-// parameter. If loading is blocked by the sandbox, the font may be loaded
-// cross-process.
-// If sandbox loading also fails, a fallback font is loaded.
-//
-// Considerations:
-// * cgFont must be CFRelease()ed by the caller when done.
-//
-// Parameters:
-// * nsFont - The font we wish to load.
-// * fontSize - point size of the font we wish to load.
-// * outNSFont - The font that was actually loaded or null if loading failed.
-// * cgFont - on output this contains the CGFontRef corresponding to the NSFont
-// that was picked in the end. The caller is responsible for calling
-// CFRelease() on this parameter when done with it.
-// * fontID - on output, the ID corresponding to nsFont.
-void FontPlatformData::loadFont(NSFont* nsFont, float fontSize, NSFont*& outNSFont, CGFontRef& cgFont)
-{
- outNSFont = nsFont;
- cgFont = CTFontCopyGraphicsFont(toCTFontRef(outNSFont), 0);
- if (outNSFont && cgFont && isLastResortFont(cgFont)) {
- // Release old CGFontRef since it points at the LastResort font which we don't want.
- CFRelease(cgFont);
- cgFont = 0;
-
- // Font loading was blocked by the Sandbox.
- m_inMemoryFont = loadFontFromBrowserProcess(outNSFont);
- if (m_inMemoryFont) {
- cgFont = m_inMemoryFont->cgFont();
-
- // Need to add an extra retain so output semantics of this function
- // are consistent.
- CFRetain(cgFont);
- } else {
- // If we still can't load the font, set |outNSFont| to null so that FontPlatformData won't be used.
- outNSFont = 0;
- }
- }
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/chromium/DeferredImageDecoder.cpp b/Source/WebCore/platform/graphics/chromium/DeferredImageDecoder.cpp
deleted file mode 100644
index ff8bf308b..000000000
--- a/Source/WebCore/platform/graphics/chromium/DeferredImageDecoder.cpp
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "DeferredImageDecoder.h"
-
-#include "ImageDecodingStore.h"
-#include "ImageFrameGenerator.h"
-#include "LazyDecodingPixelRef.h"
-#include <wtf/PassOwnPtr.h>
-
-namespace WebCore {
-
-namespace {
-
-// URI label for a lazily decoded SkPixelRef.
-const char labelLazyDecoded[] = "lazy";
-
-} // namespace
-
-bool DeferredImageDecoder::s_enabled = false;
-
-DeferredImageDecoder::DeferredImageDecoder(ImageDecoder* actualDecoder)
- : m_allDataReceived(false)
- , m_actualDecoder(adoptPtr(actualDecoder))
- , m_orientation(DefaultImageOrientation)
-{
-}
-
-DeferredImageDecoder::~DeferredImageDecoder()
-{
-}
-
-DeferredImageDecoder* DeferredImageDecoder::create(const SharedBuffer& data, ImageSource::AlphaOption alphaOption, ImageSource::GammaAndColorProfileOption gammaAndColorOption)
-{
- ImageDecoder* actualDecoder = ImageDecoder::create(data, alphaOption, gammaAndColorOption);
- return actualDecoder ? new DeferredImageDecoder(actualDecoder) : 0;
-}
-
-PassOwnPtr<DeferredImageDecoder> DeferredImageDecoder::createForTesting(PassOwnPtr<ImageDecoder> decoder)
-{
- return adoptPtr(new DeferredImageDecoder(decoder.leakPtr()));
-}
-
-bool DeferredImageDecoder::isLazyDecoded(const SkBitmap& bitmap)
-{
- return bitmap.pixelRef()
- && bitmap.pixelRef()->getURI()
- && !memcmp(bitmap.pixelRef()->getURI(), labelLazyDecoded, sizeof(labelLazyDecoded));
-}
-
-SkBitmap DeferredImageDecoder::createResizedLazyDecodingBitmap(const SkBitmap& bitmap, const SkISize& scaledSize, const SkIRect& scaledSubset)
-{
- LazyDecodingPixelRef* pixelRef = static_cast<LazyDecodingPixelRef*>(bitmap.pixelRef());
-
- int rowBytes = 0;
- rowBytes = SkBitmap::ComputeRowBytes(SkBitmap::kARGB_8888_Config, scaledSize.width());
-
- SkBitmap resizedBitmap;
- resizedBitmap.setConfig(SkBitmap::kARGB_8888_Config, scaledSubset.width(), scaledSubset.height(), rowBytes);
-
- // FIXME: This code has the potential problem that multiple
- // LazyDecodingPixelRefs are created even though they share the same
- // scaled size and ImageFrameGenerator.
- resizedBitmap.setPixelRef(new LazyDecodingPixelRef(pixelRef->frameGenerator(), scaledSize, scaledSubset))->unref();
-
- // See comments in createLazyDecodingBitmap().
- resizedBitmap.setImmutable();
- return resizedBitmap;
-}
-
-void DeferredImageDecoder::setEnabled(bool enabled)
-{
- s_enabled = enabled;
-}
-
-String DeferredImageDecoder::filenameExtension() const
-{
- return m_actualDecoder ? m_actualDecoder->filenameExtension() : m_filenameExtension;
-}
-
-ImageFrame* DeferredImageDecoder::frameBufferAtIndex(size_t index)
-{
- // Only defer image decoding if this is a single frame image. The reason is
- // because a multiframe is usually animated GIF. Animation is handled by
- // BitmapImage which uses some metadata functions that do synchronous image
- // decoding.
- if (s_enabled
- && m_actualDecoder
- && m_actualDecoder->repetitionCount() == cAnimationNone
- && m_actualDecoder->isSizeAvailable()) {
-
- m_size = m_actualDecoder->size();
- m_filenameExtension = m_actualDecoder->filenameExtension();
- m_orientation = m_actualDecoder->orientation();
-
- SkBitmap lazyDecodedSkBitmap = createLazyDecodingBitmap();
- m_lazyDecodedFrame.setSkBitmap(lazyDecodedSkBitmap);
-
- // Don't mark the frame as completely decoded until the underlying
- // decoder has really decoded it. Until then, our data and metadata may
- // be incorrect, so callers can't rely on them.
- m_lazyDecodedFrame.setStatus(ImageFrame::FramePartial);
- }
-
- return m_actualDecoder ? m_actualDecoder->frameBufferAtIndex(index) : &m_lazyDecodedFrame;
-}
-
-void DeferredImageDecoder::setData(SharedBuffer* data, bool allDataReceived)
-{
- if (m_actualDecoder) {
- // Keep a reference to data until image decoding is deferred.
- // When image decoding is deferred then ownership of m_data is
- // transferred to ImageDecodingStore.
- m_data = data;
- m_allDataReceived = allDataReceived;
- m_actualDecoder->setData(data, allDataReceived);
- } else {
- ASSERT(!m_data);
- m_frameGenerator->setData(data, allDataReceived);
- }
-}
-
-bool DeferredImageDecoder::isSizeAvailable()
-{
- // m_actualDecoder is 0 only if image decoding is deferred and that
- // means image header decoded successfully and size is available.
- return m_actualDecoder ? m_actualDecoder->isSizeAvailable() : true;
-}
-
-IntSize DeferredImageDecoder::size() const
-{
- return m_actualDecoder ? m_actualDecoder->size() : m_size;
-}
-
-IntSize DeferredImageDecoder::frameSizeAtIndex(size_t index) const
-{
- return m_actualDecoder ? m_actualDecoder->frameSizeAtIndex(index) : m_size;
-}
-
-size_t DeferredImageDecoder::frameCount()
-{
- return m_actualDecoder ? m_actualDecoder->frameCount() : 1;
-}
-
-int DeferredImageDecoder::repetitionCount() const
-{
- return m_actualDecoder ? m_actualDecoder->repetitionCount() : cAnimationNone;
-}
-
-void DeferredImageDecoder::clearFrameBufferCache(size_t clearBeforeFrame)
-{
- // If image decoding is deferred then frame buffer cache is managed by
- // the compositor and this call is ignored.
- if (m_actualDecoder)
- m_actualDecoder->clearFrameBufferCache(clearBeforeFrame);
-}
-
-bool DeferredImageDecoder::frameHasAlphaAtIndex(size_t index) const
-{
- // FIXME: Synchronize this state with ImageDecodingStore when image is
- // actually decoded. Return true here is correct in terms of rendering but
- // may not go through some optimized rendering code path.
- return m_actualDecoder ? m_actualDecoder->frameHasAlphaAtIndex(index) : true;
-}
-
-unsigned DeferredImageDecoder::frameBytesAtIndex(size_t index) const
-{
- // If frame decoding is deferred then it is not managed by MemoryCache
- // so return 0 here.
- return m_actualDecoder ? m_actualDecoder->frameBytesAtIndex(index) : 0;
-}
-
-ImageOrientation DeferredImageDecoder::orientation() const
-{
- return m_actualDecoder ? m_actualDecoder->orientation() : m_orientation;
-}
-
-SkBitmap DeferredImageDecoder::createLazyDecodingBitmap()
-{
- SkISize fullSize = SkISize::Make(m_actualDecoder->size().width(), m_actualDecoder->size().height());
- ASSERT(!fullSize.isEmpty());
-
- SkIRect fullRect = SkIRect::MakeSize(fullSize);
-
- // Creates a lazily decoded SkPixelRef that references the entire image without scaling.
- SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, fullSize.width(), fullSize.height());
-
- m_frameGenerator = ImageFrameGenerator::create(fullSize, m_data.release(), m_allDataReceived);
- m_actualDecoder.clear();
-
- bitmap.setPixelRef(new LazyDecodingPixelRef(m_frameGenerator, fullSize, fullRect))->unref();
-
- // Use the URI to identify this as a lazily decoded SkPixelRef of type LazyDecodingPixelRef.
- // FIXME: It would be more useful to give the actual image URI.
- bitmap.pixelRef()->setURI(labelLazyDecoded);
-
- // Inform the bitmap that we will never change the pixels. This is a performance hint
- // subsystems that may try to cache this bitmap (e.g. pictures, pipes, gpu, pdf, etc.)
- bitmap.setImmutable();
-
- // FIXME: Setting bitmap.setIsOpaque() is big performance gain if possible. We can
- // do so safely if the image is fully loaded and it is a JPEG image, or if the image was
- // decoded before.
-
- return bitmap;
-}
-
-bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const
-{
- return m_actualDecoder ? m_actualDecoder->hotSpot(hotSpot) : false;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/chromium/DeferredImageDecoder.h b/Source/WebCore/platform/graphics/chromium/DeferredImageDecoder.h
deleted file mode 100644
index 5df92354b..000000000
--- a/Source/WebCore/platform/graphics/chromium/DeferredImageDecoder.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef DeferredImageDecoder_h
-#define DeferredImageDecoder_h
-
-#include "ImageDecoder.h"
-#include "ImageSource.h"
-#include "IntSize.h"
-#include "SkBitmap.h"
-
-namespace WebCore {
-
-class ImageFrameGenerator;
-class SharedBuffer;
-
-class DeferredImageDecoder {
-public:
- ~DeferredImageDecoder();
- static DeferredImageDecoder* create(const SharedBuffer& data, ImageSource::AlphaOption, ImageSource::GammaAndColorProfileOption);
-
- static PassOwnPtr<DeferredImageDecoder> createForTesting(PassOwnPtr<ImageDecoder>);
-
- static bool isLazyDecoded(const SkBitmap&);
-
- static SkBitmap createResizedLazyDecodingBitmap(const SkBitmap&, const SkISize& scaledSize, const SkIRect& scaledSubset);
-
- static void setEnabled(bool);
-
- String filenameExtension() const;
-
- ImageFrame* frameBufferAtIndex(size_t index);
-
- void setData(SharedBuffer* data, bool allDataReceived);
-
- bool isSizeAvailable();
- IntSize size() const;
- IntSize frameSizeAtIndex(size_t index) const;
- size_t frameCount();
- int repetitionCount() const;
- void clearFrameBufferCache(size_t);
- bool frameHasAlphaAtIndex(size_t index) const;
- unsigned frameBytesAtIndex(size_t index) const;
- ImageOrientation orientation() const;
- bool hotSpot(IntPoint&) const;
-
-private:
- explicit DeferredImageDecoder(ImageDecoder* actualDecoder);
- SkBitmap createLazyDecodingBitmap();
- void setData(PassRefPtr<SharedBuffer>, bool allDataReceived);
-
- RefPtr<SharedBuffer> m_data;
- bool m_allDataReceived;
- OwnPtr<ImageDecoder> m_actualDecoder;
-
- String m_filenameExtension;
- IntSize m_size;
- ImageOrientation m_orientation;
-
- ImageFrame m_lazyDecodedFrame;
- RefPtr<ImageFrameGenerator> m_frameGenerator;
-
- static bool s_enabled;
-};
-
-} // namespace WebCore
-
-#endif
diff --git a/Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp b/Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp
deleted file mode 100644
index aeee45188..000000000
--- a/Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Copyright (c) 2010, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "DrawingBuffer.h"
-
-#include "CanvasRenderingContext.h"
-#include "Extensions3DChromium.h"
-#include "GraphicsContext3D.h"
-#include "GraphicsContext3DPrivate.h"
-#include "GraphicsLayerChromium.h"
-#include "TraceEvent.h"
-#include <algorithm>
-#include <public/Platform.h>
-#include <public/WebCompositorSupport.h>
-#include <public/WebExternalTextureLayer.h>
-#include <public/WebExternalTextureLayerClient.h>
-#include <public/WebGraphicsContext3D.h>
-
-using namespace std;
-
-namespace WebCore {
-
-static unsigned generateColorTexture(GraphicsContext3D* context, const IntSize& size)
-{
- unsigned offscreenColorTexture = context->createTexture();
- if (!offscreenColorTexture)
- return 0;
-
- context->bindTexture(GraphicsContext3D::TEXTURE_2D, offscreenColorTexture);
- context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR);
- context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR);
- context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE);
- context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE);
- context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, size.width(), size.height(), 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE);
-
- return offscreenColorTexture;
-}
-
-DrawingBuffer::DrawingBuffer(GraphicsContext3D* context,
- const IntSize& size,
- bool multisampleExtensionSupported,
- bool packedDepthStencilExtensionSupported,
- PreserveDrawingBuffer preserve,
- AlphaRequirement alpha)
- : m_preserveDrawingBuffer(preserve)
- , m_alpha(alpha)
- , m_scissorEnabled(false)
- , m_texture2DBinding(0)
- , m_framebufferBinding(0)
- , m_activeTextureUnit(GraphicsContext3D::TEXTURE0)
- , m_context(context)
- , m_size(-1, -1)
- , m_multisampleExtensionSupported(multisampleExtensionSupported)
- , m_packedDepthStencilExtensionSupported(packedDepthStencilExtensionSupported)
- , m_fbo(0)
- , m_colorBuffer(0)
- , m_frontColorBuffer(0)
- , m_depthStencilBuffer(0)
- , m_depthBuffer(0)
- , m_stencilBuffer(0)
- , m_multisampleFBO(0)
- , m_multisampleColorBuffer(0)
- , m_contentsChanged(true)
-{
- // Used by browser tests to detect the use of a DrawingBuffer.
- TRACE_EVENT_INSTANT0("test_gpu", "DrawingBufferCreation");
-
- // We need a separate front and back textures if ...
- m_separateFrontTexture = m_preserveDrawingBuffer == Preserve // ... we have to preserve contents after compositing, which is done with a copy or ...
- || WebKit::Platform::current()->compositorSupport()->isThreadingEnabled(); // ... if we're in threaded mode and need to double buffer.
- initialize(size);
-}
-
-DrawingBuffer::~DrawingBuffer()
-{
- if (!m_context)
- return;
-
- clear();
-}
-
-void DrawingBuffer::initialize(const IntSize& size)
-{
- m_fbo = m_context->createFramebuffer();
-
- if (m_separateFrontTexture)
- m_frontColorBuffer = generateColorTexture(m_context.get(), size);
-
- m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
- m_colorBuffer = generateColorTexture(m_context.get(), size);
- m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_colorBuffer, 0);
- createSecondaryBuffers();
- if (!reset(size)) {
- m_context.clear();
- return;
- }
-}
-
-#if USE(ACCELERATED_COMPOSITING)
-void DrawingBuffer::prepareBackBuffer()
-{
- if (!m_contentsChanged)
- return;
-
- m_context->makeContextCurrent();
-
- if (multisample())
- commit();
-
- if (m_preserveDrawingBuffer == Discard && m_separateFrontTexture) {
- swap(m_frontColorBuffer, m_colorBuffer);
- // It appears safe to overwrite the context's framebuffer binding in the Discard case since there will always be a
- // WebGLRenderingContext::clearIfComposited() call made before the next draw call which restores the framebuffer binding.
- // If this stops being true at some point, we should track the current framebuffer binding in the DrawingBuffer and restore
- // it after attaching the new back buffer here.
- m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
- m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_colorBuffer, 0);
- }
-
- if (multisample() && !m_framebufferBinding)
- bind();
- else
- restoreFramebufferBinding();
-
- m_contentsChanged = false;
-}
-
-bool DrawingBuffer::requiresCopyFromBackToFrontBuffer() const
-{
- return m_separateFrontTexture && m_preserveDrawingBuffer == Preserve;
-}
-
-unsigned DrawingBuffer::frontColorBuffer() const
-{
- return m_separateFrontTexture ? m_frontColorBuffer : m_colorBuffer;
-}
-#endif
-
-class DrawingBufferPrivate : public WebKit::WebExternalTextureLayerClient {
- WTF_MAKE_NONCOPYABLE(DrawingBufferPrivate);
-public:
- explicit DrawingBufferPrivate(DrawingBuffer* drawingBuffer)
- : m_drawingBuffer(drawingBuffer)
- , m_layer(adoptPtr(WebKit::Platform::current()->compositorSupport()->createExternalTextureLayer(this)))
- {
-
- GraphicsContext3D::Attributes attributes = m_drawingBuffer->graphicsContext3D()->getContextAttributes();
- m_layer->setOpaque(!attributes.alpha);
- m_layer->setPremultipliedAlpha(attributes.premultipliedAlpha);
- GraphicsLayerChromium::registerContentsLayer(m_layer->layer());
- }
-
- virtual ~DrawingBufferPrivate()
- {
- GraphicsLayerChromium::unregisterContentsLayer(m_layer->layer());
- }
-
- virtual unsigned prepareTexture(WebKit::WebTextureUpdater& updater) OVERRIDE
- {
- m_drawingBuffer->prepareBackBuffer();
-
- m_drawingBuffer->graphicsContext3D()->flush();
- m_drawingBuffer->graphicsContext3D()->markLayerComposited();
-
- unsigned textureId = m_drawingBuffer->frontColorBuffer();
- if (m_drawingBuffer->requiresCopyFromBackToFrontBuffer())
- updater.appendCopy(m_drawingBuffer->colorBuffer(), textureId, m_drawingBuffer->size());
-
- return textureId;
- }
-
- virtual WebKit::WebGraphicsContext3D* context() OVERRIDE
- {
- return GraphicsContext3DPrivate::extractWebGraphicsContext3D(m_drawingBuffer->graphicsContext3D());
- }
-
- WebKit::WebLayer* layer() { return m_layer->layer(); }
-
-private:
- DrawingBuffer* m_drawingBuffer;
- OwnPtr<WebKit::WebExternalTextureLayer> m_layer;
-};
-
-#if USE(ACCELERATED_COMPOSITING)
-PlatformLayer* DrawingBuffer::platformLayer()
-{
- if (!m_private)
- m_private = adoptPtr(new DrawingBufferPrivate(this));
-
- return m_private->layer();
-}
-#endif
-
-Platform3DObject DrawingBuffer::framebuffer() const
-{
- return m_fbo;
-}
-
-#if USE(ACCELERATED_COMPOSITING)
-void DrawingBuffer::paintCompositedResultsToCanvas(ImageBuffer* imageBuffer)
-{
- if (!m_context->makeContextCurrent() || m_context->getExtensions()->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERROR)
- return;
-
- IntSize framebufferSize = m_context->getInternalFramebufferSize();
-
- // Since we're using the same context as WebGL, we have to restore any state we change (in this case, just the framebuffer binding).
- // FIXME: The WebGLRenderingContext tracks the current framebuffer binding, it would be slightly more efficient to use this value
- // rather than querying it off of the context.
- GC3Dint previousFramebuffer = 0;
- m_context->getIntegerv(GraphicsContext3D::FRAMEBUFFER_BINDING, &previousFramebuffer);
-
- Platform3DObject framebuffer = m_context->createFramebuffer();
- m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, framebuffer);
- m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, frontColorBuffer(), 0);
-
- Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(m_context->getExtensions());
- extensions->paintFramebufferToCanvas(framebuffer, framebufferSize.width(), framebufferSize.height(), !m_context->getContextAttributes().premultipliedAlpha, imageBuffer);
- m_context->deleteFramebuffer(framebuffer);
-
- m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, previousFramebuffer);
-}
-#endif
-
-}
diff --git a/Source/WebCore/platform/graphics/chromium/Extensions3DChromium.h b/Source/WebCore/platform/graphics/chromium/Extensions3DChromium.h
deleted file mode 100644
index 174056589..000000000
--- a/Source/WebCore/platform/graphics/chromium/Extensions3DChromium.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef Extensions3DChromium_h
-#define Extensions3DChromium_h
-
-#include "Extensions3D.h"
-
-namespace WebCore {
-
-class GraphicsContext3DPrivate;
-class ImageBuffer;
-
-class Extensions3DChromium : public Extensions3D {
-public:
- virtual ~Extensions3DChromium();
-
- // Supported extensions:
- // GL_CHROMIUM_shallow_flush : only supported if an ipc command buffer is used.
- // GL_CHROMIUM_resource_safe : indicating that textures/renderbuffers are always initialized before read/write.
- // GL_CHROMIUM_strict_attribs : indicating a GL error is generated for out-of-bounds buffer accesses.
- // GL_CHROMIUM_post_sub_buffer
- // GL_CHROMIUM_map_sub
- // GL_CHROMIUM_swapbuffers_complete_callback
- // GL_CHROMIUM_rate_limit_offscreen_context
- // GL_CHROMIUM_paint_framebuffer_canvas
- // GL_CHROMIUM_iosurface (Mac OS X specific)
- // GL_CHROMIUM_command_buffer_query
- // GL_ANGLE_texture_usage
- // GL_EXT_debug_marker
- // GL_EXT_texture_storage
- // GL_EXT_occlusion_query_boolean
-
- // Extensions3D methods.
- virtual bool supports(const String&);
- virtual void ensureEnabled(const String&);
- virtual bool isEnabled(const String&);
- virtual int getGraphicsResetStatusARB();
- virtual void blitFramebuffer(long srcX0, long srcY0, long srcX1, long srcY1, long dstX0, long dstY0, long dstX1, long dstY1, unsigned long mask, unsigned long filter);
- virtual void renderbufferStorageMultisample(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height);
- virtual Platform3DObject createVertexArrayOES();
- virtual void deleteVertexArrayOES(Platform3DObject);
- virtual GC3Dboolean isVertexArrayOES(Platform3DObject);
- virtual void bindVertexArrayOES(Platform3DObject);
- virtual String getTranslatedShaderSourceANGLE(Platform3DObject);
-
- enum {
- // GL_OES_EGL_image_external
- GL_TEXTURE_EXTERNAL_OES = 0x8D65,
-
- // GL_CHROMIUM_map_sub (enums inherited from GL_ARB_vertex_buffer_object)
- READ_ONLY = 0x88B8,
- WRITE_ONLY = 0x88B9,
-
- // GL_ANGLE_texture_usage
- GL_TEXTURE_USAGE_ANGLE = 0x93A2,
- GL_FRAMEBUFFER_ATTACHMENT_ANGLE = 0x93A3,
-
- // GL_EXT_texture_storage
- BGRA8_EXT = 0x93A1,
-
- // GL_EXT_occlusion_query_boolean
- ANY_SAMPLES_PASSED_EXT = 0x8C2F,
- ANY_SAMPLES_PASSED_CONSERVATIVE_EXT = 0x8D6A,
- CURRENT_QUERY_EXT = 0x8865,
- QUERY_RESULT_EXT = 0x8866,
- QUERY_RESULT_AVAILABLE_EXT = 0x8867,
-
- // GL_CHROMIUM_command_buffer_query
- COMMANDS_ISSUED_CHROMIUM = 0x84F2
- };
-
- // GL_CHROMIUM_map_sub
- void* mapBufferSubDataCHROMIUM(unsigned target, int offset, int size, unsigned access);
- void unmapBufferSubDataCHROMIUM(const void*);
- void* mapTexSubImage2DCHROMIUM(unsigned target, int level, int xoffset, int yoffset, int width, int height, unsigned format, unsigned type, unsigned access);
- void unmapTexSubImage2DCHROMIUM(const void*);
-
- // GL_CHROMIUM_rate_limit_offscreen_context
- void rateLimitOffscreenContextCHROMIUM();
-
- // GL_CHROMIUM_paint_framebuffer_canvas
- void paintFramebufferToCanvas(int framebuffer, int width, int height, bool premultiplyAlpha, ImageBuffer*);
-
- // GL_CHROMIUM_iosurface
- // To avoid needing to expose extraneous enums, assumes internal format
- // RGBA, format BGRA, and type UNSIGNED_INT_8_8_8_8_REV.
- void texImageIOSurface2DCHROMIUM(unsigned target, int width, int height, uint32_t ioSurfaceId, unsigned plane);
-
- // GL_EXT_texture_storage
- void texStorage2DEXT(unsigned target, int levels, unsigned internalformat, int width, int height);
-
- // GL_EXT_occlusion_query
- Platform3DObject createQueryEXT();
- void deleteQueryEXT(Platform3DObject);
- GC3Dboolean isQueryEXT(Platform3DObject);
- void beginQueryEXT(GC3Denum, Platform3DObject);
- void endQueryEXT(GC3Denum);
- void getQueryivEXT(GC3Denum, GC3Denum, GC3Dint*);
- void getQueryObjectuivEXT(Platform3DObject, GC3Denum, GC3Duint*);
-
- // GL_CHROMIUM_copy_texture
- void copyTextureCHROMIUM(GC3Denum, Platform3DObject, Platform3DObject, GC3Dint, GC3Denum);
-
- // GL_CHROMIUM_shallow_flush
- virtual void shallowFlushCHROMIUM();
-
- // GL_EXT_robustness
- virtual void readnPixelsEXT(int x, int y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, GC3Dsizei bufSize, void *data);
- virtual void getnUniformfvEXT(GC3Duint program, int location, GC3Dsizei bufSize, float *params);
- virtual void getnUniformivEXT(GC3Duint program, int location, GC3Dsizei bufSize, int *params);
-
- // GL_EXT_debug_marker
- virtual void insertEventMarkerEXT(const String&);
- virtual void pushGroupMarkerEXT(const String&);
- virtual void popGroupMarkerEXT(void);
-
- // Some helper methods to detect GPU functionality
- virtual bool isNVIDIA() { return false; }
- virtual bool isAMD() { return false; }
- virtual bool isIntel() { return false; }
- virtual String vendor() { return ""; }
-
- virtual bool maySupportMultisampling() { return true; }
- virtual bool requiresBuiltInFunctionEmulation() { return false; }
-
-private:
- // Instances of this class are strictly owned by the GraphicsContext3D implementation and do not
- // need to be instantiated by any other code.
- friend class GraphicsContext3DPrivate;
- explicit Extensions3DChromium(GraphicsContext3DPrivate*);
-
- // Weak pointer back to GraphicsContext3DPrivate
- GraphicsContext3DPrivate* m_private;
-};
-
-} // namespace WebCore
-
-#endif // Extensions3DChromium_h
diff --git a/Source/WebCore/platform/graphics/chromium/FontCacheAndroid.cpp b/Source/WebCore/platform/graphics/chromium/FontCacheAndroid.cpp
deleted file mode 100644
index aa54dc101..000000000
--- a/Source/WebCore/platform/graphics/chromium/FontCacheAndroid.cpp
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Copyright (c) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FontCache.h"
-
-#include "Font.h"
-#include "FontDescription.h"
-#include "FontPlatformData.h"
-#include "NotImplemented.h"
-#include "SimpleFontData.h"
-
-#include "SkPaint.h"
-#include "SkTypeface_android.h"
-#include "SkUtils.h"
-
-#include <unicode/locid.h>
-#include <wtf/Assertions.h>
-#include <wtf/text/AtomicString.h>
-#include <wtf/text/CString.h>
-
-namespace WebCore {
-
-static const char* getFallbackFontName(const FontDescription& fontDescription)
-{
- switch (fontDescription.genericFamily()) {
- case FontDescription::StandardFamily:
- case FontDescription::SerifFamily:
- return "serif";
- case FontDescription::SansSerifFamily:
- return "sans-serif";
- case FontDescription::MonospaceFamily:
- return "monospace";
- case FontDescription::CursiveFamily:
- return "cursive";
- case FontDescription::FantasyFamily:
- return "fantasy";
- case FontDescription::NoFamily:
- default:
- return "";
- }
-}
-
-static bool isFallbackFamily(String family)
-{
- return family.startsWith("-webkit-")
- || equalIgnoringCase(family, "serif")
- || equalIgnoringCase(family, "sans-serif")
- || equalIgnoringCase(family, "sans")
- || equalIgnoringCase(family, "monospace")
- || equalIgnoringCase(family, "cursive")
- || equalIgnoringCase(family, "fantasy")
- || equalIgnoringCase(family, "times") // Skia aliases for serif
- || equalIgnoringCase(family, "times new roman")
- || equalIgnoringCase(family, "palatino")
- || equalIgnoringCase(family, "georgia")
- || equalIgnoringCase(family, "baskerville")
- || equalIgnoringCase(family, "goudy")
- || equalIgnoringCase(family, "ITC Stone Serif")
- || equalIgnoringCase(family, "arial") // Skia aliases for sans-serif
- || equalIgnoringCase(family, "helvetica")
- || equalIgnoringCase(family, "tahoma")
- || equalIgnoringCase(family, "verdana")
- || equalIgnoringCase(family, "courier") // Skia aliases for monospace
- || equalIgnoringCase(family, "courier new")
- || equalIgnoringCase(family, "monaco");
-}
-
-void FontCache::platformInit()
-{
-}
-
-PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
-{
- if (!length)
- return 0;
-
- SkUnichar skiaChar;
- if (U16_IS_LEAD(characters[0])) {
- ASSERT(length >= 2);
- skiaChar = U16_GET_SUPPLEMENTARY(characters[0], characters[1]);
- } else
- skiaChar = characters[0];
-
- SkString skiaFamilyName;
- if (!SkGetFallbackFamilyNameForChar(skiaChar, &skiaFamilyName) || skiaFamilyName.isEmpty())
- return 0;
- return getCachedFontData(getCachedFontPlatformData(font.fontDescription(), AtomicString(skiaFamilyName.c_str()), DoNotRetain), DoNotRetain);
-}
-
-PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font& font)
-{
- return 0;
-}
-
-PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& description, ShouldRetain shouldRetain)
-{
- DEFINE_STATIC_LOCAL(const AtomicString, serif, ("Serif", AtomicString::ConstructFromLiteral));
- DEFINE_STATIC_LOCAL(const AtomicString, monospace, ("Monospace", AtomicString::ConstructFromLiteral));
- DEFINE_STATIC_LOCAL(const AtomicString, sans, ("Sans", AtomicString::ConstructFromLiteral));
-
- FontPlatformData* fontPlatformData = 0;
- switch (description.genericFamily()) {
- case FontDescription::SerifFamily:
- fontPlatformData = getCachedFontPlatformData(description, serif);
- break;
- case FontDescription::MonospaceFamily:
- fontPlatformData = getCachedFontPlatformData(description, monospace);
- break;
- case FontDescription::SansSerifFamily:
- default:
- fontPlatformData = getCachedFontPlatformData(description, sans);
- break;
- }
-
- ASSERT(fontPlatformData);
- return getCachedFontData(fontPlatformData, shouldRetain);
-}
-
-void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigned>& traitsMasks)
-{
- notImplemented();
-}
-
-FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
-{
- const char* name = 0;
- CString nameString; // Keeps name valid within scope of this function in case that name is from a family.
-
- // If a fallback font is being created (e.g. "-webkit-monospace"), convert
- // it in to the fallback name (e.g. "monospace").
- if (!family.length() || family.startsWith("-webkit-"))
- name = getFallbackFontName(fontDescription);
- else {
- nameString = family.string().utf8();
- name = nameString.data();
- }
-
- int style = SkTypeface::kNormal;
- if (fontDescription.weight() >= FontWeightBold)
- style |= SkTypeface::kBold;
- if (fontDescription.italic())
- style |= SkTypeface::kItalic;
-
- SkTypeface* typeface = 0;
- FontPlatformData* result = 0;
- FallbackScripts fallbackScript = SkGetFallbackScriptFromID(name);
- if (SkTypeface_ValidScript(fallbackScript)) {
- typeface = SkCreateTypefaceForScript(fallbackScript);
- if (typeface)
- result = new FontPlatformData(typeface, name, fontDescription.computedSize(),
- (style & SkTypeface::kBold) && !typeface->isBold(),
- (style & SkTypeface::kItalic) && !typeface->isItalic(),
- fontDescription.orientation(),
- fontDescription.textOrientation());
- } else {
- typeface = SkTypeface::CreateFromName(name, SkTypeface::kNormal);
-
- // CreateFromName always returns a typeface, falling back to a default font
- // if the one requested could not be found. Calling Equal() with a null
- // pointer will compare the returned font against the default, with the
- // caveat that the default is always of normal style. When that happens,
- // ignore the default font and allow WebCore to provide the next font on the
- // CSS fallback list. The only exception to this occurs when the family name
- // is a commonly used generic family, which is the case when called by
- // getSimilarFontPlatformData() or getLastResortFallbackFont(). In that case
- // the default font is an acceptable result.
-
- if (!SkTypeface::Equal(typeface, 0) || isFallbackFamily(family.string())) {
- // We had to use normal styling to see if this was a default font. If
- // we need bold or italic, replace with the corrected typeface.
- if (style != SkTypeface::kNormal) {
- typeface->unref();
- typeface = SkTypeface::CreateFromName(name, static_cast<SkTypeface::Style>(style));
- }
- result = new FontPlatformData(typeface, name, fontDescription.computedSize(),
- (style & SkTypeface::kBold) && !typeface->isBold(),
- (style & SkTypeface::kItalic) && !typeface->isItalic(),
- fontDescription.orientation(),
- fontDescription.textOrientation());
- }
- }
-
- SkSafeUnref(typeface);
- return result;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/chromium/FontCacheChromiumLinux.cpp b/Source/WebCore/platform/graphics/chromium/FontCacheChromiumLinux.cpp
deleted file mode 100644
index 3746b2225..000000000
--- a/Source/WebCore/platform/graphics/chromium/FontCacheChromiumLinux.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "FontCache.h"
-
-#include <public/Platform.h>
-#include <public/linux/WebFontFamily.h>
-#include <public/linux/WebFontInfo.h>
-#include <public/linux/WebSandboxSupport.h>
-
-namespace WebCore {
-
-void FontCache::getFontFamilyForCharacters(const UChar* characters, size_t numCharacters, const char* preferredLocale, FontCache::SimpleFontFamily* family)
-{
- WebKit::WebFontFamily webFamily;
- if (WebKit::Platform::current()->sandboxSupport())
- WebKit::Platform::current()->sandboxSupport()->getFontFamilyForCharacters(characters, numCharacters, preferredLocale, &webFamily);
- else
- WebKit::WebFontInfo::familyForChars(characters, numCharacters, preferredLocale, &webFamily);
- family->name = String::fromUTF8(webFamily.name.data(), webFamily.name.length());
- family->isBold = webFamily.isBold;
- family->isItalic = webFamily.isItalic;
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/chromium/FontCacheChromiumWin.cpp b/Source/WebCore/platform/graphics/chromium/FontCacheChromiumWin.cpp
deleted file mode 100644
index d41fd14a8..000000000
--- a/Source/WebCore/platform/graphics/chromium/FontCacheChromiumWin.cpp
+++ /dev/null
@@ -1,636 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Computer, Inc.
- * Copyright (c) 2006, 2007, 2008, 2009, 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FontCache.h"
-
-#include "Font.h"
-#include "FontPlatformDataChromiumWin.h"
-#include "FontUtilsChromiumWin.h"
-#include "HWndDC.h"
-#include "LayoutTestSupport.h"
-#include "SimpleFontData.h"
-#include <unicode/uniset.h>
-#include <wtf/HashMap.h>
-#include <wtf/HashSet.h>
-#include <wtf/text/StringHash.h>
-
-#include <windows.h>
-#include <objidl.h>
-#include <mlang.h>
-
-using std::min;
-
-namespace WebCore
-{
-
-// When asked for a CJK font with a native name under a non-CJK locale or
-// asked for a CJK font with a Romanized name under a CJK locale,
-// |GetTextFace| (after |CreateFont*|) returns a 'bogus' value (e.g. Arial).
-// This is not consistent with what MSDN says !!
-// Therefore, before we call |CreateFont*|, we have to map a Romanized name to
-// the corresponding native name under a CJK locale and vice versa
-// under a non-CJK locale.
-// See the corresponding gecko bugs at
-// https://bugzilla.mozilla.org/show_bug.cgi?id=373952
-// https://bugzilla.mozilla.org/show_bug.cgi?id=231426
-static bool LookupAltName(const String& name, String& altName)
-{
- struct FontCodepage {
- WCHAR* name;
- int codePage;
- };
-
- struct NamePair {
- WCHAR* name;
- FontCodepage altNameCodepage;
- };
-
- const int japaneseCodepage = 932;
- const int simplifiedChineseCodepage = 936;
- const int koreanCodepage = 949;
- const int traditionalChineseCodepage = 950;
-
- // FIXME(jungshik) : This list probably covers 99% of cases.
- // To cover the remaining 1% and cut down the file size,
- // consider accessing 'NAME' table of a truetype font
- // using |GetFontData| and caching the mapping.
- // In the table below, the ASCII keys are all lower-cased for
- // case-insensitive matching.
- static const NamePair namePairs[] = {
- // MS Pゴシック, MS PGothic
- {L"\xFF2D\xFF33 \xFF30\x30B4\x30B7\x30C3\x30AF", {L"MS PGothic", japaneseCodepage}},
- {L"ms pgothic", {L"\xFF2D\xFF33 \xFF30\x30B4\x30B7\x30C3\x30AF", japaneseCodepage}},
- // MS P明朝, MS PMincho
- {L"\xFF2D\xFF33 \xFF30\x660E\x671D", {L"MS PMincho", japaneseCodepage}},
- {L"ms pmincho", {L"\xFF2D\xFF33 \xFF30\x660E\x671D", japaneseCodepage}},
- // MSゴシック, MS Gothic
- {L"\xFF2D\xFF33 \x30B4\x30B7\x30C3\x30AF", {L"MS Gothic", japaneseCodepage}},
- {L"ms gothic", {L"\xFF2D\xFF33 \x30B4\x30B7\x30C3\x30AF", japaneseCodepage}},
- // MS 明朝, MS Mincho
- {L"\xFF2D\xFF33 \x660E\x671D", {L"MS Mincho", japaneseCodepage}},
- {L"ms mincho", {L"\xFF2D\xFF33 \x660E\x671D", japaneseCodepage}},
- // メイリオ, Meiryo
- {L"\x30E1\x30A4\x30EA\x30AA", {L"Meiryo", japaneseCodepage}},
- {L"meiryo", {L"\x30E1\x30A4\x30EA\x30AA", japaneseCodepage}},
- // 바탕, Batang
- {L"\xBC14\xD0D5", {L"Batang", koreanCodepage}},
- {L"batang", {L"\xBC14\xD0D5", koreanCodepage}},
- // 바탕체, Batangche
- {L"\xBC14\xD0D5\xCCB4", {L"Batangche", koreanCodepage}},
- {L"batangche", {L"\xBC14\xD0D5\xCCB4", koreanCodepage}},
- // 굴림, Gulim
- {L"\xAD74\xB9BC", {L"Gulim", koreanCodepage}},
- {L"gulim", {L"\xAD74\xB9BC", koreanCodepage}},
- // 굴림체, Gulimche
- {L"\xAD74\xB9BC\xCCB4", {L"Gulimche", koreanCodepage}},
- {L"gulimche", {L"\xAD74\xB9BC\xCCB4", koreanCodepage}},
- // 돋움, Dotum
- {L"\xB3CB\xC6C0", {L"Dotum", koreanCodepage}},
- {L"dotum", {L"\xB3CB\xC6C0", koreanCodepage}},
- // 돋움체, Dotumche
- {L"\xB3CB\xC6C0\xCCB4", {L"Dotumche", koreanCodepage}},
- {L"dotumche", {L"\xB3CB\xC6C0\xCCB4", koreanCodepage}},
- // 궁서, Gungsuh
- {L"\xAD81\xC11C", {L"Gungsuh", koreanCodepage}},
- {L"gungsuh", {L"\xAD81\xC11C", koreanCodepage}},
- // 궁서체, Gungsuhche
- {L"\xAD81\xC11C\xCCB4", {L"Gungsuhche", koreanCodepage}},
- {L"gungsuhche", {L"\xAD81\xC11C\xCCB4", koreanCodepage}},
- // 맑은 고딕, Malgun Gothic
- {L"\xB9D1\xC740 \xACE0\xB515", {L"Malgun Gothic", koreanCodepage}},
- {L"malgun gothic", {L"\xB9D1\xC740 \xACE0\xB515", koreanCodepage}},
- // 宋体, SimSun
- {L"\x5B8B\x4F53", {L"SimSun", simplifiedChineseCodepage}},
- {L"simsun", {L"\x5B8B\x4F53", simplifiedChineseCodepage}},
- // 宋体-ExtB, SimSun-ExtB
- {L"\x5B8B\x4F53-ExtB", {L"SimSun-ExtB", simplifiedChineseCodepage}},
- {L"simsun-extb", {L"\x5B8B\x4F53-extb", simplifiedChineseCodepage}},
- // 黑体, SimHei
- {L"\x9ED1\x4F53", {L"SimHei", simplifiedChineseCodepage}},
- {L"simhei", {L"\x9ED1\x4F53", simplifiedChineseCodepage}},
- // 新宋体, NSimSun
- {L"\x65B0\x5B8B\x4F53", {L"NSimSun", simplifiedChineseCodepage}},
- {L"nsimsun", {L"\x65B0\x5B8B\x4F53", simplifiedChineseCodepage}},
- // 微软雅黑, Microsoft Yahei
- {L"\x5FAE\x8F6F\x96C5\x9ED1", {L"Microsoft Yahei", simplifiedChineseCodepage}},
- {L"microsoft yahei", {L"\x5FAE\x8F6F\x96C5\x9ED1", simplifiedChineseCodepage}},
- // 仿宋, FangSong
- {L"\x4EFF\x5B8B", {L"FangSong", simplifiedChineseCodepage}},
- {L"fangsong", {L"\x4EFF\x5B8B", simplifiedChineseCodepage}},
- // 楷体, KaiTi
- {L"\x6977\x4F53", {L"KaiTi", simplifiedChineseCodepage}},
- {L"kaiti", {L"\x6977\x4F53", simplifiedChineseCodepage}},
- // 仿宋_GB2312, FangSong_GB2312
- {L"\x4EFF\x5B8B_GB2312", {L"FangSong_GB2312", simplifiedChineseCodepage}},
- {L"fangsong_gb2312", {L"\x4EFF\x5B8B_gb2312", simplifiedChineseCodepage}},
- // 楷体_GB2312, KaiTi_GB2312
- {L"\x6977\x4F53", {L"KaiTi_GB2312", simplifiedChineseCodepage}},
- {L"kaiti_gb2312", {L"\x6977\x4F53_gb2312", simplifiedChineseCodepage}},
- // 新細明體, PMingLiu
- {L"\x65B0\x7D30\x660E\x9AD4", {L"PMingLiu", traditionalChineseCodepage}},
- {L"pmingliu", {L"\x65B0\x7D30\x660E\x9AD4", traditionalChineseCodepage}},
- // 新細明體-ExtB, PMingLiu-ExtB
- {L"\x65B0\x7D30\x660E\x9AD4-ExtB", {L"PMingLiu-ExtB", traditionalChineseCodepage}},
- {L"pmingliu-extb", {L"\x65B0\x7D30\x660E\x9AD4-extb", traditionalChineseCodepage}},
- // 細明體, MingLiu
- {L"\x7D30\x660E\x9AD4", {L"MingLiu", traditionalChineseCodepage}},
- {L"mingliu", {L"\x7D30\x660E\x9AD4", traditionalChineseCodepage}},
- // 細明體-ExtB, MingLiu-ExtB
- {L"\x7D30\x660E\x9AD4-ExtB", {L"MingLiu-ExtB", traditionalChineseCodepage}},
- {L"mingliu-extb", {L"x65B0\x7D30\x660E\x9AD4-extb", traditionalChineseCodepage}},
- // 微軟正黑體, Microsoft JhengHei
- {L"\x5FAE\x8EDF\x6B63\x9ED1\x9AD4", {L"Microsoft JhengHei", traditionalChineseCodepage}},
- {L"microsoft jhengHei", {L"\x5FAE\x8EDF\x6B63\x9ED1\x9AD4", traditionalChineseCodepage}},
- // 標楷體, DFKai-SB
- {L"\x6A19\x6977\x9AD4", {L"DFKai-SB", traditionalChineseCodepage}},
- {L"dfkai-sb", {L"\x6A19\x6977\x9AD4", traditionalChineseCodepage}},
- // WenQuanYi Zen Hei
- {L"\x6587\x6cc9\x9a5b\x6b63\x9ed1", {L"WenQuanYi Zen Hei", traditionalChineseCodepage}},
- {L"wenquanyi zen hei", {L"\x6587\x6cc9\x9a5b\x6b63\x9ed1", traditionalChineseCodepage}},
- // WenQuanYi Zen Hei
- {L"\x6587\x6cc9\x9a7f\x6b63\x9ed1", {L"WenQuanYi Zen Hei", simplifiedChineseCodepage}},
- {L"wenquanyi zen hei", {L"\x6587\x6cc9\x9a7f\x6b63\x9ed1", simplifiedChineseCodepage}},
- // AR PL ShanHeiSun Uni,
- {L"\x6587\x9f0e\x0050\x004c\x7d30\x4e0a\x6d77\x5b8b\x0055\x006e\x0069",
- {L"AR PL ShanHeiSun Uni", traditionalChineseCodepage}},
- {L"ar pl shanheisun uni",
- {L"\x6587\x9f0e\x0050\x004c\x7d30\x4e0a\x6d77\x5b8b\x0055\x006e\x0069", traditionalChineseCodepage}},
- // AR PL ShanHeiSun Uni,
- {L"\x6587\x9f0e\x0050\x004c\x7ec6\x4e0a\x6d77\x5b8b\x0055\x006e\x0069",
- {L"AR PL ShanHeiSun Uni", simplifiedChineseCodepage}},
- {L"ar pl shanheisun uni",
- {L"\x6587\x9f0e\x0050\x004c\x7ec6\x4e0a\x6d77\x5b8b\x0055\x006e\x0069", simplifiedChineseCodepage}},
- // AR PL ZenKai Uni
- // Traditional Chinese and Simplified Chinese names are
- // identical.
- {L"\x6587\x0050\x004C\x4E2D\x6977\x0055\x006E\x0069", {L"AR PL ZenKai Uni", traditionalChineseCodepage}},
- {L"ar pl zenkai uni", {L"\x6587\x0050\x004C\x4E2D\x6977\x0055\x006E\x0069", traditionalChineseCodepage}},
- {L"\x6587\x0050\x004C\x4E2D\x6977\x0055\x006E\x0069", {L"AR PL ZenKai Uni", simplifiedChineseCodepage}},
- {L"ar pl zenkai uni", {L"\x6587\x0050\x004C\x4E2D\x6977\x0055\x006E\x0069", simplifiedChineseCodepage}},
- };
-
- typedef HashMap<String, const FontCodepage*> NameMap;
- static NameMap* fontNameMap = 0;
-
- if (!fontNameMap) {
- fontNameMap = new NameMap;
- for (size_t i = 0; i < WTF_ARRAY_LENGTH(namePairs); ++i)
- fontNameMap->set(String(namePairs[i].name), &(namePairs[i].altNameCodepage));
- }
-
- bool isAscii = false;
- String n;
- // use |lower| only for ASCII names
- // For non-ASCII names, we don't want to invoke an expensive
- // and unnecessary |lower|.
- if (name.containsOnlyASCII()) {
- isAscii = true;
- n = name.lower();
- } else
- n = name;
-
- NameMap::iterator iter = fontNameMap->find(n);
- if (iter == fontNameMap->end())
- return false;
-
- static int systemCp = ::GetACP();
- int fontCp = iter->value->codePage;
-
- if ((isAscii && systemCp == fontCp) || (!isAscii && systemCp != fontCp)) {
- altName = String(iter->value->name);
- return true;
- }
-
- return false;
-}
-
-static HFONT createFontIndirectAndGetWinName(const String& family, LOGFONT* winfont, String* winName)
-{
- int len = min(static_cast<int>(family.length()), LF_FACESIZE - 1);
- memcpy(winfont->lfFaceName, family.characters(), len * sizeof(WORD));
- winfont->lfFaceName[len] = '\0';
-
- HFONT hfont = CreateFontIndirect(winfont);
- if (!hfont)
- return 0;
-
- HWndDC dc(0);
- HGDIOBJ oldFont = static_cast<HFONT>(SelectObject(dc, hfont));
- WCHAR name[LF_FACESIZE];
- unsigned resultLength = GetTextFace(dc, LF_FACESIZE, name);
- if (resultLength > 0)
- resultLength--; // ignore the null terminator
-
- SelectObject(dc, oldFont);
- *winName = String(name, resultLength);
- return hfont;
-}
-
-// This maps font family names to their repertoires of supported Unicode
-// characters. Because it's family names rather than font faces we use
-// as keys, there might be edge cases where one face of a font family
-// has a different repertoire from another face of the same family.
-typedef HashMap<const wchar_t*, icu::UnicodeSet*> FontCmapCache;
-
-static bool fontContainsCharacter(const FontPlatformData* fontData,
- const wchar_t* family, UChar32 character)
-{
- // FIXME: For non-BMP characters, GetFontUnicodeRanges is of
- // no use. We have to read directly from the cmap table of a font.
- // Return true for now.
- if (character > 0xFFFF)
- return true;
-
- // This cache is just leaked on shutdown.
- static FontCmapCache* fontCmapCache = 0;
- if (!fontCmapCache)
- fontCmapCache = new FontCmapCache;
-
- HashMap<const wchar_t*, icu::UnicodeSet*>::iterator it = fontCmapCache->find(family);
- if (it != fontCmapCache->end())
- return it->value->contains(character);
-
- HFONT hfont = fontData->hfont();
- HWndDC hdc(0);
- HGDIOBJ oldFont = static_cast<HFONT>(SelectObject(hdc, hfont));
- int count = GetFontUnicodeRanges(hdc, 0);
- if (!count && FontPlatformData::ensureFontLoaded(hfont))
- count = GetFontUnicodeRanges(hdc, 0);
- if (!count) {
- LOG_ERROR("Unable to get the font unicode range after second attempt");
- SelectObject(hdc, oldFont);
- return true;
- }
-
- static Vector<char, 512> glyphsetBuffer;
- glyphsetBuffer.resize(GetFontUnicodeRanges(hdc, 0));
- GLYPHSET* glyphset = reinterpret_cast<GLYPHSET*>(glyphsetBuffer.data());
- // In addition, refering to the OS/2 table and converting the codepage list
- // to the coverage map might be faster.
- count = GetFontUnicodeRanges(hdc, glyphset);
- ASSERT(count > 0);
- SelectObject(hdc, oldFont);
-
- // FIXME: consider doing either of the following two:
- // 1) port back ICU 4.0's faster look-up code for UnicodeSet
- // 2) port Mozilla's CompressedCharMap or gfxSparseBitset
- unsigned i = 0;
- icu::UnicodeSet* cmap = new icu::UnicodeSet;
- while (i < glyphset->cRanges) {
- WCHAR start = glyphset->ranges[i].wcLow;
- cmap->add(start, start + glyphset->ranges[i].cGlyphs - 1);
- i++;
- }
- cmap->freeze();
- // We don't lowercase |family| because all of them are under our control
- // and they're already lowercased.
- fontCmapCache->set(family, cmap);
- return cmap->contains(character);
-}
-
-// Tries the given font and save it |outFontFamilyName| if it succeeds.
-PassRefPtr<SimpleFontData> FontCache::fontDataFromDescriptionAndLogFont(const FontDescription& fontDescription, ShouldRetain shouldRetain, const LOGFONT& font, wchar_t* outFontFamilyName)
-{
- RefPtr<SimpleFontData> fontData = getCachedFontData(fontDescription, font.lfFaceName, false, shouldRetain);
- if (fontData)
- memcpy(outFontFamilyName, font.lfFaceName, sizeof(font.lfFaceName));
- return fontData.release();
-}
-
-static LONG toGDIFontWeight(FontWeight fontWeight)
-{
- static LONG gdiFontWeights[] = {
- FW_THIN, // FontWeight100
- FW_EXTRALIGHT, // FontWeight200
- FW_LIGHT, // FontWeight300
- FW_NORMAL, // FontWeight400
- FW_MEDIUM, // FontWeight500
- FW_SEMIBOLD, // FontWeight600
- FW_BOLD, // FontWeight700
- FW_EXTRABOLD, // FontWeight800
- FW_HEAVY // FontWeight900
- };
- return gdiFontWeights[fontWeight];
-}
-
-static void FillLogFont(const FontDescription& fontDescription, LOGFONT* winfont)
-{
- // The size here looks unusual. The negative number is intentional.
- // Unlike WebKit trunk, we don't multiply the size by 32. That seems to be
- // some kind of artifact of their CG backend, or something.
- winfont->lfHeight = -fontDescription.computedPixelSize();
- winfont->lfWidth = 0;
- winfont->lfEscapement = 0;
- winfont->lfOrientation = 0;
- winfont->lfUnderline = false;
- winfont->lfStrikeOut = false;
- winfont->lfCharSet = DEFAULT_CHARSET;
- winfont->lfOutPrecision = OUT_TT_ONLY_PRECIS;
- winfont->lfQuality = isRunningLayoutTest() ? NONANTIALIASED_QUALITY : DEFAULT_QUALITY; // Honor user's desktop settings.
- winfont->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
- winfont->lfItalic = fontDescription.italic();
- winfont->lfWeight = toGDIFontWeight(fontDescription.weight());
-}
-
-struct TraitsInFamilyProcData {
- TraitsInFamilyProcData(const AtomicString& familyName)
- : m_familyName(familyName)
- {
- }
-
- const AtomicString& m_familyName;
- HashSet<unsigned> m_traitsMasks;
-};
-
-static int CALLBACK traitsInFamilyEnumProc(CONST LOGFONT* logFont, CONST TEXTMETRIC* metrics, DWORD fontType, LPARAM lParam)
-{
- TraitsInFamilyProcData* procData = reinterpret_cast<TraitsInFamilyProcData*>(lParam);
-
- unsigned traitsMask = 0;
- traitsMask |= logFont->lfItalic ? FontStyleItalicMask : FontStyleNormalMask;
- traitsMask |= FontVariantNormalMask;
- LONG weight = logFont->lfWeight;
- traitsMask |= weight == FW_THIN ? FontWeight100Mask :
- weight == FW_EXTRALIGHT ? FontWeight200Mask :
- weight == FW_LIGHT ? FontWeight300Mask :
- weight == FW_NORMAL ? FontWeight400Mask :
- weight == FW_MEDIUM ? FontWeight500Mask :
- weight == FW_SEMIBOLD ? FontWeight600Mask :
- weight == FW_BOLD ? FontWeight700Mask :
- weight == FW_EXTRABOLD ? FontWeight800Mask :
- FontWeight900Mask;
- procData->m_traitsMasks.add(traitsMask);
- return 1;
-}
-
-struct GetLastResortFallbackFontProcData {
- GetLastResortFallbackFontProcData(FontCache* fontCache, const FontDescription* fontDescription, FontCache::ShouldRetain shouldRetain, wchar_t* fontName)
- : m_fontCache(fontCache)
- , m_fontDescription(fontDescription)
- , m_shouldRetain(shouldRetain)
- , m_fontName(fontName)
- , m_fontData(0)
- {
- }
-
- FontCache* m_fontCache;
- const FontDescription* m_fontDescription;
- FontCache::ShouldRetain m_shouldRetain;
- wchar_t* m_fontName;
- RefPtr<SimpleFontData> m_fontData;
-};
-
-static int CALLBACK getLastResortFallbackFontProc(const LOGFONT* logFont, const TEXTMETRIC* metrics, DWORD fontType, LPARAM lParam)
-{
- GetLastResortFallbackFontProcData* procData = reinterpret_cast<GetLastResortFallbackFontProcData*>(lParam);
- procData->m_fontData = procData->m_fontCache->fontDataFromDescriptionAndLogFont(*procData->m_fontDescription, procData->m_shouldRetain, *logFont, procData->m_fontName);
- return !procData->m_fontData;
-}
-
-void FontCache::platformInit()
-{
- // Not needed on Windows.
-}
-
-// Given the desired base font, this will create a SimpleFontData for a specific
-// font that can be used to render the given range of characters.
-PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
-{
- // FIXME: Consider passing fontDescription.dominantScript()
- // to GetFallbackFamily here.
- FontDescription fontDescription = font.fontDescription();
- UChar32 c;
- UScriptCode script;
- const wchar_t* family = getFallbackFamily(characters, length,
- fontDescription.genericFamily(), &c, &script);
- FontPlatformData* data = 0;
- if (family)
- data = getCachedFontPlatformData(font.fontDescription(), AtomicString(family, wcslen(family)), false);
-
- // Last resort font list : PanUnicode. CJK fonts have a pretty
- // large repertoire. Eventually, we need to scan all the fonts
- // on the system to have a Firefox-like coverage.
- // Make sure that all of them are lowercased.
- const static wchar_t* const cjkFonts[] = {
- L"arial unicode ms",
- L"ms pgothic",
- L"simsun",
- L"gulim",
- L"pmingliu",
- L"wenquanyi zen hei", // partial CJK Ext. A coverage but more
- // widely known to Chinese users.
- L"ar pl shanheisun uni",
- L"ar pl zenkai uni",
- L"han nom a", // Complete CJK Ext. A coverage
- L"code2000", // Complete CJK Ext. A coverage
- // CJK Ext. B fonts are not listed here because it's of no use
- // with our current non-BMP character handling because we use
- // Uniscribe for it and that code path does not go through here.
- };
-
- const static wchar_t* const commonFonts[] = {
- L"tahoma",
- L"arial unicode ms",
- L"lucida sans unicode",
- L"microsoft sans serif",
- L"palatino linotype",
- // Six fonts below (and code2000 at the end) are not from MS, but
- // once installed, cover a very wide range of characters.
- L"dejavu serif",
- L"dejavu sasns",
- L"freeserif",
- L"freesans",
- L"gentium",
- L"gentiumalt",
- L"ms pgothic",
- L"simsun",
- L"gulim",
- L"pmingliu",
- L"code2000",
- };
-
- const wchar_t* const* panUniFonts = 0;
- int numFonts = 0;
- if (script == USCRIPT_HAN) {
- panUniFonts = cjkFonts;
- numFonts = WTF_ARRAY_LENGTH(cjkFonts);
- } else {
- panUniFonts = commonFonts;
- numFonts = WTF_ARRAY_LENGTH(commonFonts);
- }
- // Font returned from GetFallbackFamily may not cover |characters|
- // because it's based on script to font mapping. This problem is
- // critical enough for non-Latin scripts (especially Han) to
- // warrant an additional (real coverage) check with fontCotainsCharacter.
- int i;
- for (i = 0; (!data || !fontContainsCharacter(data, family, c)) && i < numFonts; ++i) {
- family = panUniFonts[i];
- data = getCachedFontPlatformData(font.fontDescription(), AtomicString(family, wcslen(family)));
- }
- // When i-th font (0-base) in |panUniFonts| contains a character and
- // we get out of the loop, |i| will be |i + 1|. That is, if only the
- // last font in the array covers the character, |i| will be numFonts.
- // So, we have to use '<=" rather than '<' to see if we found a font
- // covering the character.
- if (i <= numFonts)
- return getCachedFontData(data, DoNotRetain);
-
- return 0;
-
-}
-
-PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font& font)
-{
- return 0;
-}
-
-PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& description, ShouldRetain shouldRetain)
-{
- FontDescription::GenericFamilyType generic = description.genericFamily();
-
- // FIXME: Would be even better to somehow get the user's default font here.
- // For now we'll pick the default that the user would get without changing
- // any prefs.
- static AtomicString timesStr("Times New Roman");
- static AtomicString courierStr("Courier New");
- static AtomicString arialStr("Arial");
-
- AtomicString& fontStr = timesStr;
- if (generic == FontDescription::SansSerifFamily)
- fontStr = arialStr;
- else if (generic == FontDescription::MonospaceFamily)
- fontStr = courierStr;
-
- RefPtr<SimpleFontData> simpleFont = getCachedFontData(description, fontStr, false, shouldRetain);
- if (simpleFont)
- return simpleFont.release();
-
- // Fall back to system fonts as Win Safari does because this function must
- // return a valid font. Once we find a valid system font, we save its name
- // to a static variable and use it to prevent trying system fonts again.
- static wchar_t fallbackFontName[LF_FACESIZE] = {0};
- if (fallbackFontName[0])
- return getCachedFontData(description, fallbackFontName, false, shouldRetain);
-
- // Fall back to the DEFAULT_GUI_FONT if no known Unicode fonts are available.
- if (HFONT defaultGUIFont = static_cast<HFONT>(GetStockObject(DEFAULT_GUI_FONT))) {
- LOGFONT defaultGUILogFont;
- GetObject(defaultGUIFont, sizeof(defaultGUILogFont), &defaultGUILogFont);
- if (simpleFont = fontDataFromDescriptionAndLogFont(description, shouldRetain, defaultGUILogFont, fallbackFontName))
- return simpleFont.release();
- }
-
- // Fall back to Non-client metrics fonts.
- NONCLIENTMETRICS nonClientMetrics = {0};
- nonClientMetrics.cbSize = sizeof(nonClientMetrics);
- if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(nonClientMetrics), &nonClientMetrics, 0)) {
- if (simpleFont = fontDataFromDescriptionAndLogFont(description, shouldRetain, nonClientMetrics.lfMessageFont, fallbackFontName))
- return simpleFont.release();
- if (simpleFont = fontDataFromDescriptionAndLogFont(description, shouldRetain, nonClientMetrics.lfMenuFont, fallbackFontName))
- return simpleFont.release();
- if (simpleFont = fontDataFromDescriptionAndLogFont(description, shouldRetain, nonClientMetrics.lfStatusFont, fallbackFontName))
- return simpleFont.release();
- if (simpleFont = fontDataFromDescriptionAndLogFont(description, shouldRetain, nonClientMetrics.lfCaptionFont, fallbackFontName))
- return simpleFont.release();
- if (simpleFont = fontDataFromDescriptionAndLogFont(description, shouldRetain, nonClientMetrics.lfSmCaptionFont, fallbackFontName))
- return simpleFont.release();
- }
-
- // Fall back to all the fonts installed in this PC. When a font has a
- // localized name according to the system locale as well as an English name,
- // both GetTextFace() and EnumFontFamilies() return the localized name. So,
- // FontCache::createFontPlatformData() does not filter out the fonts
- // returned by this EnumFontFamilies() call.
- HWndDC dc(0);
- if (dc) {
- GetLastResortFallbackFontProcData procData(this, &description, shouldRetain, fallbackFontName);
- EnumFontFamilies(dc, 0, getLastResortFallbackFontProc, reinterpret_cast<LPARAM>(&procData));
-
- if (procData.m_fontData)
- return procData.m_fontData.release();
- }
-
- ASSERT_NOT_REACHED();
- return 0;
-}
-
-void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigned>& traitsMasks)
-{
- HWndDC hdc(0);
-
- LOGFONT logFont;
- logFont.lfCharSet = DEFAULT_CHARSET;
- unsigned familyLength = min(familyName.length(), static_cast<unsigned>(LF_FACESIZE - 1));
- memcpy(logFont.lfFaceName, familyName.characters(), familyLength * sizeof(UChar));
- logFont.lfFaceName[familyLength] = 0;
- logFont.lfPitchAndFamily = 0;
-
- TraitsInFamilyProcData procData(familyName);
- EnumFontFamiliesEx(hdc, &logFont, traitsInFamilyEnumProc, reinterpret_cast<LPARAM>(&procData), 0);
- copyToVector(procData.m_traitsMasks, traitsMasks);
-}
-
-FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
-{
- LOGFONT winfont = {0};
- FillLogFont(fontDescription, &winfont);
-
- // Windows will always give us a valid pointer here, even if the face name
- // is non-existent. We have to double-check and see if the family name was
- // really used.
- String winName;
- HFONT hfont = createFontIndirectAndGetWinName(family, &winfont, &winName);
- if (!hfont)
- return 0;
-
- // FIXME: Do we need to use predefined fonts "guaranteed" to exist
- // when we're running in layout-test mode?
- if (!equalIgnoringCase(family, winName)) {
- // For CJK fonts with both English and native names,
- // GetTextFace returns a native name under the font's "locale"
- // and an English name under other locales regardless of
- // lfFaceName field of LOGFONT. As a result, we need to check
- // if a font has an alternate name. If there is, we need to
- // compare it with what's requested in the first place.
- String altName;
- if (!LookupAltName(family, altName) || !equalIgnoringCase(altName, winName)) {
- DeleteObject(hfont);
- return 0;
- }
- }
-
- return new FontPlatformData(hfont,
- fontDescription.computedPixelSize(),
- fontDescription.orientation());
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/chromium/FontChromiumWin.cpp b/Source/WebCore/platform/graphics/chromium/FontChromiumWin.cpp
deleted file mode 100644
index c5903eadf..000000000
--- a/Source/WebCore/platform/graphics/chromium/FontChromiumWin.cpp
+++ /dev/null
@@ -1,676 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Computer, Inc.
- * Copyright (c) 2006, 2007, 2008, 2009, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Font.h"
-
-#include "FontFallbackList.h"
-#include "FontPlatformDataChromiumWin.h"
-#include "GlyphBuffer.h"
-#include "NotImplemented.h"
-#include "PlatformContextSkia.h"
-#include "SimpleFontData.h"
-#include "SkiaFontWin.h"
-#include "UniscribeHelperTextRun.h"
-
-#if !USE(SKIA_TEXT)
-#include "TransparencyWin.h"
-#include "skia/ext/skia_utils_win.h"
-#endif
-
-#include <windows.h>
-
-using namespace std;
-
-namespace WebCore {
-
-#if !USE(SKIA_TEXT)
-namespace {
-
-class TransparencyAwareFontPainter {
-public:
- TransparencyAwareFontPainter(GraphicsContext*, const FloatPoint&);
- ~TransparencyAwareFontPainter();
-
-protected:
- // Called by our subclass' constructor to initialize GDI if necessary. This
- // is a separate function so it can be called after the subclass finishes
- // construction (it calls virtual functions).
- void init();
-
- virtual IntRect estimateTextBounds() = 0;
-
- // Use the context from the transparency helper when drawing with GDI. It
- // may point to a temporary one.
- GraphicsContext* m_graphicsContext;
- PlatformGraphicsContext* m_platformContext;
-
- FloatPoint m_point;
-
- // Set when Windows can handle the type of drawing we're doing.
- bool m_useGDI;
-
- // These members are valid only when m_useGDI is set.
- HDC m_hdc;
- TransparencyWin m_transparency;
-
-private:
- // Call when we're using GDI mode to initialize the TransparencyWin to help
- // us draw GDI text.
- void initializeForGDI();
-
- bool m_createdTransparencyLayer; // We created a layer to give the font some alpha.
-};
-
-TransparencyAwareFontPainter::TransparencyAwareFontPainter(GraphicsContext* context,
- const FloatPoint& point)
- : m_graphicsContext(context)
- , m_platformContext(context->platformContext())
- , m_point(point)
- , m_useGDI(windowsCanHandleTextDrawing(context))
- , m_hdc(0)
- , m_createdTransparencyLayer(false)
-{
-}
-
-void TransparencyAwareFontPainter::init()
-{
- if (m_useGDI)
- initializeForGDI();
-}
-
-void TransparencyAwareFontPainter::initializeForGDI()
-{
- m_graphicsContext->save();
- SkColor color = m_platformContext->effectiveFillColor();
- // Used only when m_createdTransparencyLayer is true.
- float layerAlpha = 0.0f;
- if (SkColorGetA(color) != 0xFF) {
- // When the font has some transparency, apply it by creating a new
- // transparency layer with that opacity applied. We'll actually create
- // a new transparency layer after we calculate the bounding box.
- m_createdTransparencyLayer = true;
- layerAlpha = SkColorGetA(color) / 255.0f;
- // The color should be opaque now.
- color = SkColorSetRGB(SkColorGetR(color), SkColorGetG(color), SkColorGetB(color));
- }
-
- TransparencyWin::LayerMode layerMode;
- IntRect layerRect;
- if (m_platformContext->isDrawingToImageBuffer()) {
- // Assume if we're drawing to an image buffer that the background
- // is not opaque and we have to undo ClearType. We may want to
- // enhance this to actually check, since it will often be opaque
- // and we could do ClearType in that case.
- layerMode = TransparencyWin::TextComposite;
- layerRect = estimateTextBounds();
- m_graphicsContext->clip(layerRect);
- if (m_createdTransparencyLayer)
- m_graphicsContext->beginTransparencyLayer(layerAlpha);
-
- // The transparency helper requires that we draw text in black in
- // this mode and it will apply the color.
- m_transparency.setTextCompositeColor(color);
- color = SkColorSetRGB(0, 0, 0);
- } else if (m_createdTransparencyLayer || m_platformContext->isDrawingToLayer()) {
- // When we're drawing a web page, we know the background is opaque,
- // but if we're drawing to a layer, we still need extra work.
- layerMode = TransparencyWin::OpaqueCompositeLayer;
- layerRect = estimateTextBounds();
- m_graphicsContext->clip(layerRect);
- if (m_createdTransparencyLayer)
- m_graphicsContext->beginTransparencyLayer(layerAlpha);
- } else {
- // Common case of drawing onto the bottom layer of a web page: we
- // know everything is opaque so don't need to do anything special.
- layerMode = TransparencyWin::NoLayer;
- }
-
- // Bug 26088 - init() might fail if layerRect is invalid. Given this, we
- // need to be careful to check for null pointers everywhere after this call
- m_transparency.init(m_graphicsContext, layerMode,
- TransparencyWin::KeepTransform, layerRect);
-
- // Set up the DC, using the one from the transparency helper.
- if (m_transparency.platformContext()) {
- m_hdc = skia::BeginPlatformPaint(m_transparency.platformContext()->canvas());
- SetTextColor(m_hdc, skia::SkColorToCOLORREF(color));
- SetBkMode(m_hdc, TRANSPARENT);
- }
-}
-
-TransparencyAwareFontPainter::~TransparencyAwareFontPainter()
-{
- if (!m_useGDI || !m_graphicsContext || !m_platformContext)
- return;
- m_transparency.composite();
- if (m_createdTransparencyLayer)
- m_graphicsContext->endTransparencyLayer();
- m_graphicsContext->restore();
- if (m_transparency.platformContext())
- skia::EndPlatformPaint(m_transparency.platformContext()->canvas());
-}
-
-// Specialization for simple GlyphBuffer painting.
-class TransparencyAwareGlyphPainter : public TransparencyAwareFontPainter {
- public:
- TransparencyAwareGlyphPainter(GraphicsContext*,
- const SimpleFontData*,
- const GlyphBuffer&,
- int from, int numGlyphs,
- const FloatPoint&);
- ~TransparencyAwareGlyphPainter();
-
- // Draws the partial string of glyphs, starting at |startAdvance| to the
- // left of m_point. We express it this way so that if we're using the Skia
- // drawing path we can use floating-point positioning, even though we have
- // to use integer positioning in the GDI path.
- bool drawGlyphs(int numGlyphs, const WORD* glyphs, const int* advances, float startAdvance) const;
-
- private:
- virtual IntRect estimateTextBounds();
-
- const SimpleFontData* m_font;
- const GlyphBuffer& m_glyphBuffer;
- int m_from;
- int m_numGlyphs;
-
- // When m_useGdi is set, this stores the previous HFONT selected into the
- // m_hdc so we can restore it.
- HGDIOBJ m_oldFont; // For restoring the DC to its original state.
-};
-
-TransparencyAwareGlyphPainter::TransparencyAwareGlyphPainter(
- GraphicsContext* context,
- const SimpleFontData* font,
- const GlyphBuffer& glyphBuffer,
- int from, int numGlyphs,
- const FloatPoint& point)
- : TransparencyAwareFontPainter(context, point)
- , m_font(font)
- , m_glyphBuffer(glyphBuffer)
- , m_from(from)
- , m_numGlyphs(numGlyphs)
- , m_oldFont(0)
-{
- init();
-
- if (m_hdc)
- m_oldFont = ::SelectObject(m_hdc, m_font->platformData().hfont());
-}
-
-TransparencyAwareGlyphPainter::~TransparencyAwareGlyphPainter()
-{
- if (m_useGDI && m_hdc)
- ::SelectObject(m_hdc, m_oldFont);
-}
-
-
-// Estimates the bounding box of the given text. This is copied from
-// FontCGWin.cpp, it is possible, but a lot more work, to get the precide
-// bounds.
-IntRect TransparencyAwareGlyphPainter::estimateTextBounds()
-{
- int totalWidth = 0;
- for (int i = 0; i < m_numGlyphs; i++)
- totalWidth += lroundf(m_glyphBuffer.advanceAt(m_from + i));
-
- const FontMetrics& fontMetrics = m_font->fontMetrics();
- return IntRect(m_point.x() - (fontMetrics.ascent() + fontMetrics.descent()) / 2,
- m_point.y() - fontMetrics.ascent() - fontMetrics.lineGap(),
- totalWidth + fontMetrics.ascent() + fontMetrics.descent(),
- fontMetrics.lineSpacing());
-}
-
-bool TransparencyAwareGlyphPainter::drawGlyphs(int numGlyphs,
- const WORD* glyphs,
- const int* advances,
- float startAdvance) const
-{
- if (!m_useGDI) {
- SkPoint origin = m_point;
- origin.fX += SkFloatToScalar(startAdvance);
- paintSkiaText(m_graphicsContext, m_font->platformData(),
- numGlyphs, glyphs, advances, 0, &origin);
- return true;
- }
-
- if (!m_graphicsContext || !m_hdc)
- return true;
-
- // Windows' origin is the top-left of the bounding box, so we have
- // to subtract off the font ascent to get it.
- int x = lroundf(m_point.x() + startAdvance);
- int y = lroundf(m_point.y() - m_font->fontMetrics().ascent());
-
- // If there is a non-blur shadow and both the fill color and shadow color
- // are opaque, handle without skia.
- FloatSize shadowOffset;
- float shadowBlur;
- Color shadowColor;
- ColorSpace shadowColorSpace;
- if (m_graphicsContext->getShadow(shadowOffset, shadowBlur, shadowColor, shadowColorSpace)) {
- // If there is a shadow and this code is reached, windowsCanHandleDrawTextShadow()
- // will have already returned true during the ctor initiatization of m_useGDI
- ASSERT(shadowColor.alpha() == 255);
- ASSERT(m_graphicsContext->fillColor().alpha() == 255);
- ASSERT(!shadowBlur);
- COLORREF textColor = skia::SkColorToCOLORREF(SkColorSetARGB(255, shadowColor.red(), shadowColor.green(), shadowColor.blue()));
- COLORREF savedTextColor = GetTextColor(m_hdc);
- SetTextColor(m_hdc, textColor);
- ExtTextOut(m_hdc, x + shadowOffset.width(), y + shadowOffset.height(), ETO_GLYPH_INDEX, 0, reinterpret_cast<const wchar_t*>(&glyphs[0]), numGlyphs, &advances[0]);
- SetTextColor(m_hdc, savedTextColor);
- }
-
- return !!ExtTextOut(m_hdc, x, y, ETO_GLYPH_INDEX, 0, reinterpret_cast<const wchar_t*>(&glyphs[0]), numGlyphs, &advances[0]);
-}
-
-class TransparencyAwareUniscribePainter : public TransparencyAwareFontPainter {
- public:
- TransparencyAwareUniscribePainter(GraphicsContext*,
- const Font*,
- const TextRun&,
- int from, int to,
- const FloatPoint&);
- ~TransparencyAwareUniscribePainter();
-
- // Uniscibe will draw directly into our buffer, so we need to expose our DC.
- HDC hdc() const { return m_hdc; }
-
- private:
- virtual IntRect estimateTextBounds();
-
- const Font* m_font;
- const TextRun& m_run;
- int m_from;
- int m_to;
-};
-
-TransparencyAwareUniscribePainter::TransparencyAwareUniscribePainter(
- GraphicsContext* context,
- const Font* font,
- const TextRun& run,
- int from, int to,
- const FloatPoint& point)
- : TransparencyAwareFontPainter(context, point)
- , m_font(font)
- , m_run(run)
- , m_from(from)
- , m_to(to)
-{
- init();
-}
-
-TransparencyAwareUniscribePainter::~TransparencyAwareUniscribePainter()
-{
-}
-
-IntRect TransparencyAwareUniscribePainter::estimateTextBounds()
-{
- // This case really really sucks. There is no convenient way to estimate
- // the bounding box. So we run Uniscribe twice. If we find this happens a
- // lot, the way to fix it is to make the extra layer after the
- // UniscribeHelper has measured the text.
- IntPoint intPoint(lroundf(m_point.x()),
- lroundf(m_point.y()));
-
- UniscribeHelperTextRun state(m_run, *m_font);
- int left = lroundf(m_point.x()) + state.characterToX(m_from);
- int right = lroundf(m_point.x()) + state.characterToX(m_to);
-
- // Adjust for RTL script since we just want to know the text bounds.
- if (left > right)
- std::swap(left, right);
-
- // This algorithm for estimating how much extra space we need (the text may
- // go outside the selection rect) is based roughly on
- // TransparencyAwareGlyphPainter::estimateTextBounds above.
- const FontMetrics& fontMetrics = m_font->fontMetrics();
- return IntRect(left - (fontMetrics.ascent() + fontMetrics.descent()) / 2,
- m_point.y() - fontMetrics.ascent() - fontMetrics.lineGap(),
- (right - left) + fontMetrics.ascent() + fontMetrics.descent(),
- fontMetrics.lineSpacing());
-}
-
-} // namespace
-#endif
-
-bool Font::canReturnFallbackFontsForComplexText()
-{
- return false;
-}
-
-bool Font::canExpandAroundIdeographsInComplexText()
-{
- return false;
-}
-
-#if USE(SKIA_TEXT)
-void Font::drawGlyphs(GraphicsContext* graphicsContext,
- const SimpleFontData* font,
- const GlyphBuffer& glyphBuffer,
- int from,
- int numGlyphs,
- const FloatPoint& point) const
-{
- SkColor color = graphicsContext->platformContext()->effectiveFillColor();
- unsigned char alpha = SkColorGetA(color);
- // Skip 100% transparent text; no need to draw anything.
- if (!alpha && graphicsContext->platformContext()->getStrokeStyle() == NoStroke && !graphicsContext->hasShadow())
- return;
-
- // We draw the glyphs in chunks to avoid having to do a heap allocation for
- // the arrays of characters and advances.
- const int kMaxBufferLength = 256;
- Vector<int, kMaxBufferLength> advances;
- int glyphIndex = 0; // The starting glyph of the current chunk.
-
- float horizontalOffset = point.x(); // The floating point offset of the left side of the current glyph.
-#if ENABLE(OPENTYPE_VERTICAL)
- const OpenTypeVerticalData* verticalData = font->verticalData();
- if (verticalData) {
- Vector<FloatPoint, kMaxBufferLength> translations;
- Vector<GOFFSET, kMaxBufferLength> offsets;
-
- // Skia doesn't have matrix for glyph coordinate space, so we rotate back the CTM.
- AffineTransform savedMatrix = graphicsContext->getCTM();
- graphicsContext->concatCTM(AffineTransform(0, -1, 1, 0, point.x(), point.y()));
- graphicsContext->concatCTM(AffineTransform(1, 0, 0, 1, -point.x(), -point.y()));
-
- const FontMetrics& metrics = font->fontMetrics();
- SkScalar verticalOriginX = SkFloatToScalar(point.x() + metrics.floatAscent() - metrics.floatAscent(IdeographicBaseline));
- while (glyphIndex < numGlyphs) {
- // How many chars will be in this chunk?
- int curLen = std::min(kMaxBufferLength, numGlyphs - glyphIndex);
-
- const Glyph* glyphs = glyphBuffer.glyphs(from + glyphIndex);
- translations.resize(curLen);
- verticalData->getVerticalTranslationsForGlyphs(font, &glyphs[0], curLen, reinterpret_cast<float*>(&translations[0]));
- // To position glyphs vertically, we use offsets instead of advances.
- advances.resize(curLen);
- advances.fill(0);
- offsets.resize(curLen);
- float currentWidth = 0;
- for (int i = 0; i < curLen; ++i, ++glyphIndex) {
- offsets[i].du = lroundf(translations[i].x());
- offsets[i].dv = -lroundf(currentWidth - translations[i].y());
- currentWidth += glyphBuffer.advanceAt(from + glyphIndex);
- }
- SkPoint origin;
- origin.set(verticalOriginX, SkFloatToScalar(point.y() + horizontalOffset - point.x()));
- horizontalOffset += currentWidth;
- paintSkiaText(graphicsContext, font->platformData(), curLen, &glyphs[0], &advances[0], &offsets[0], &origin);
- }
-
- graphicsContext->setCTM(savedMatrix);
- return;
- }
-#endif
-
- // In order to round all offsets to the correct pixel boundary, this code keeps track of the absolute position
- // of each glyph in floating point units and rounds to integer advances at the last possible moment.
-
- int lastHorizontalOffsetRounded = lroundf(horizontalOffset); // The rounded offset of the left side of the last glyph rendered.
- Vector<WORD, kMaxBufferLength> glyphs;
- while (glyphIndex < numGlyphs) {
- // How many chars will be in this chunk?
- int curLen = std::min(kMaxBufferLength, numGlyphs - glyphIndex);
- glyphs.resize(curLen);
- advances.resize(curLen);
-
- float currentWidth = 0;
- for (int i = 0; i < curLen; ++i, ++glyphIndex) {
- glyphs[i] = glyphBuffer.glyphAt(from + glyphIndex);
- horizontalOffset += glyphBuffer.advanceAt(from + glyphIndex);
- advances[i] = lroundf(horizontalOffset) - lastHorizontalOffsetRounded;
- lastHorizontalOffsetRounded += advances[i];
- currentWidth += glyphBuffer.advanceAt(from + glyphIndex);
-
- // Bug 26088 - very large positive or negative runs can fail to
- // render so we clamp the size here. In the specs, negative
- // letter-spacing is implementation-defined, so this should be
- // fine, and it matches Safari's implementation. The call actually
- // seems to crash if kMaxNegativeRun is set to somewhere around
- // -32830, so we give ourselves a little breathing room.
- const int maxNegativeRun = -32768;
- const int maxPositiveRun = 32768;
- if ((currentWidth + advances[i] < maxNegativeRun) || (currentWidth + advances[i] > maxPositiveRun))
- advances[i] = 0;
- }
-
- SkPoint origin = point;
- origin.fX += SkFloatToScalar(horizontalOffset - point.x() - currentWidth);
- paintSkiaText(graphicsContext, font->platformData(), curLen, &glyphs[0], &advances[0], 0, &origin);
- }
-}
-#else
-static void drawGlyphsWin(GraphicsContext* graphicsContext,
- const SimpleFontData* font,
- const GlyphBuffer& glyphBuffer,
- int from,
- int numGlyphs,
- const FloatPoint& point) {
- TransparencyAwareGlyphPainter painter(graphicsContext, font, glyphBuffer, from, numGlyphs, point);
-
- // We draw the glyphs in chunks to avoid having to do a heap allocation for
- // the arrays of characters and advances. Since ExtTextOut is the
- // lowest-level text output function on Windows, there should be little
- // penalty for splitting up the text. On the other hand, the buffer cannot
- // be bigger than 4094 or the function will fail.
- const int kMaxBufferLength = 256;
- Vector<WORD, kMaxBufferLength> glyphs;
- Vector<int, kMaxBufferLength> advances;
- int glyphIndex = 0; // The starting glyph of the current chunk.
-
- // In order to round all offsets to the correct pixel boundary, this code keeps track of the absolute position
- // of each glyph in floating point units and rounds to integer advances at the last possible moment.
-
- float horizontalOffset = point.x(); // The floating point offset of the left side of the current glyph.
- int lastHorizontalOffsetRounded = lroundf(horizontalOffset); // The rounded offset of the left side of the last glyph rendered.
- while (glyphIndex < numGlyphs) {
- // How many chars will be in this chunk?
- int curLen = min(kMaxBufferLength, numGlyphs - glyphIndex);
- glyphs.resize(curLen);
- advances.resize(curLen);
-
- float currentWidth = 0;
- for (int i = 0; i < curLen; ++i, ++glyphIndex) {
- glyphs[i] = glyphBuffer.glyphAt(from + glyphIndex);
- horizontalOffset += glyphBuffer.advanceAt(from + glyphIndex);
- advances[i] = lroundf(horizontalOffset) - lastHorizontalOffsetRounded;
- lastHorizontalOffsetRounded += advances[i];
- currentWidth += glyphBuffer.advanceAt(from + glyphIndex);
-
- // Bug 26088 - very large positive or negative runs can fail to
- // render so we clamp the size here. In the specs, negative
- // letter-spacing is implementation-defined, so this should be
- // fine, and it matches Safari's implementation. The call actually
- // seems to crash if kMaxNegativeRun is set to somewhere around
- // -32830, so we give ourselves a little breathing room.
- const int maxNegativeRun = -32768;
- const int maxPositiveRun = 32768;
- if ((currentWidth + advances[i] < maxNegativeRun) || (currentWidth + advances[i] > maxPositiveRun))
- advances[i] = 0;
- }
-
- // Actually draw the glyphs (with retry on failure).
- bool success = false;
- for (int executions = 0; executions < 2; ++executions) {
- success = painter.drawGlyphs(curLen, &glyphs[0], &advances[0], horizontalOffset - point.x() - currentWidth);
- if (!success && !executions) {
- // Ask the browser to load the font for us and retry.
- FontPlatformData::ensureFontLoaded(font->platformData().hfont());
- continue;
- }
- break;
- }
-
- if (!success)
- LOG_ERROR("Unable to draw the glyphs after second attempt");
- }
-}
-
-void Font::drawGlyphs(GraphicsContext* graphicsContext,
- const SimpleFontData* font,
- const GlyphBuffer& glyphBuffer,
- int from,
- int numGlyphs,
- const FloatPoint& point) const
-{
- SkColor color = graphicsContext->platformContext()->effectiveFillColor();
- unsigned char alpha = SkColorGetA(color);
- // Skip 100% transparent text; no need to draw anything.
- if (!alpha && graphicsContext->platformContext()->getStrokeStyle() == NoStroke && !graphicsContext->hasShadow())
- return;
- if (!alpha || windowsCanHandleDrawTextShadow(graphicsContext) || !windowsCanHandleTextDrawingWithoutShadow(graphicsContext)) {
- drawGlyphsWin(graphicsContext, font, glyphBuffer, from, numGlyphs, point);
- return;
- }
- // Draw in two passes: skia for the shadow, GDI for foreground text
- // pass1: shadow (will use skia)
- graphicsContext->save();
- graphicsContext->setFillColor(Color::transparent, graphicsContext->fillColorSpace());
- drawGlyphsWin(graphicsContext, font, glyphBuffer, from, numGlyphs, point);
- graphicsContext->restore();
- // pass2: foreground text (will use GDI)
- FloatSize shadowOffset;
- float shadowBlur;
- Color shadowColor;
- ColorSpace shadowColorSpace;
- graphicsContext->getShadow(shadowOffset, shadowBlur, shadowColor, shadowColorSpace);
- graphicsContext->setShadow(shadowOffset, shadowBlur, Color::transparent, shadowColorSpace);
- drawGlyphsWin(graphicsContext, font, glyphBuffer, from, numGlyphs, point);
- graphicsContext->setShadow(shadowOffset, shadowBlur, shadowColor, shadowColorSpace);
-}
-#endif
-
-FloatRect Font::selectionRectForComplexText(const TextRun& run,
- const FloatPoint& point,
- int h,
- int from,
- int to) const
-{
- UniscribeHelperTextRun state(run, *this);
- float left = static_cast<float>(point.x() + state.characterToX(from));
- float right = static_cast<float>(point.x() + state.characterToX(to));
-
- // If the text is RTL, left will actually be after right.
- if (left < right)
- return FloatRect(left, point.y(),
- right - left, static_cast<float>(h));
-
- return FloatRect(right, point.y(),
- left - right, static_cast<float>(h));
-}
-
-void Font::drawComplexText(GraphicsContext* graphicsContext,
- const TextRun& run,
- const FloatPoint& point,
- int from,
- int to) const
-{
- PlatformGraphicsContext* context = graphicsContext->platformContext();
- UniscribeHelperTextRun state(run, *this);
-
- SkColor color = graphicsContext->platformContext()->effectiveFillColor();
- unsigned char alpha = SkColorGetA(color);
- // Skip 100% transparent text; no need to draw anything.
- if (!alpha && graphicsContext->platformContext()->getStrokeStyle() == NoStroke)
- return;
-
-#if USE(SKIA_TEXT)
- HDC hdc = 0;
-#else
- TransparencyAwareUniscribePainter painter(graphicsContext, this, run, from, to, point);
-
- HDC hdc = painter.hdc();
- if (windowsCanHandleTextDrawing(graphicsContext) && !hdc)
- return;
-
- // TODO(maruel): http://b/700464 SetTextColor doesn't support transparency.
- // Enforce non-transparent color.
- color = SkColorSetRGB(SkColorGetR(color), SkColorGetG(color), SkColorGetB(color));
- if (hdc) {
- SetTextColor(hdc, skia::SkColorToCOLORREF(color));
- SetBkMode(hdc, TRANSPARENT);
- }
-
- // If there is a non-blur shadow and both the fill color and shadow color
- // are opaque, handle without skia.
- FloatSize shadowOffset;
- float shadowBlur;
- Color shadowColor;
- ColorSpace shadowColorSpace;
- if (graphicsContext->getShadow(shadowOffset, shadowBlur, shadowColor, shadowColorSpace) && windowsCanHandleDrawTextShadow(graphicsContext)) {
- COLORREF textColor = skia::SkColorToCOLORREF(SkColorSetARGB(255, shadowColor.red(), shadowColor.green(), shadowColor.blue()));
- COLORREF savedTextColor = GetTextColor(hdc);
- SetTextColor(hdc, textColor);
- state.draw(graphicsContext, hdc, static_cast<int>(point.x()) + shadowOffset.width(),
- static_cast<int>(point.y() - fontMetrics().ascent()) + shadowOffset.height(), from, to);
- SetTextColor(hdc, savedTextColor);
- }
-#endif
- // Uniscribe counts the coordinates from the upper left, while WebKit uses
- // the baseline, so we have to subtract off the ascent.
- state.draw(graphicsContext, hdc, lroundf(point.x()), lroundf(point.y() - fontMetrics().ascent()), from, to);
-}
-
-void Font::drawEmphasisMarksForComplexText(GraphicsContext* /* context */, const TextRun& /* run */, const AtomicString& /* mark */, const FloatPoint& /* point */, int /* from */, int /* to */) const
-{
- notImplemented();
-}
-
-float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>* /* fallbackFonts */, GlyphOverflow* /* glyphOverflow */) const
-{
- UniscribeHelperTextRun state(run, *this);
- return static_cast<float>(state.width());
-}
-
-int Font::offsetForPositionForComplexText(const TextRun& run, float xFloat,
- bool includePartialGlyphs) const
-{
- // FIXME: This truncation is not a problem for HTML, but only affects SVG, which passes floating-point numbers
- // to Font::offsetForPosition(). Bug http://webkit.org/b/40673 tracks fixing this problem.
- int x = static_cast<int>(xFloat);
-
- // Mac code ignores includePartialGlyphs, and they don't know what it's
- // supposed to do, so we just ignore it as well.
- UniscribeHelperTextRun state(run, *this);
- int charIndex = state.xToCharacter(x);
-
- // XToCharacter will return -1 if the position is before the first
- // character (we get called like this sometimes).
- if (charIndex < 0)
- charIndex = 0;
- return charIndex;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/chromium/FontPlatformData.h b/Source/WebCore/platform/graphics/chromium/FontPlatformData.h
deleted file mode 100644
index f4f63529c..000000000
--- a/Source/WebCore/platform/graphics/chromium/FontPlatformData.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2007, 2008, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef FontPlatformData_h
-#define FontPlatformData_h
-
-#if OS(WINDOWS)
-#include "FontPlatformDataChromiumWin.h"
-#elif OS(UNIX) && !OS(DARWIN)
-#include "FontPlatformDataHarfBuzz.h"
-#endif
-
-#endif // FontPlatformData_h
diff --git a/Source/WebCore/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp b/Source/WebCore/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp
deleted file mode 100644
index f912027b4..000000000
--- a/Source/WebCore/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Computer, Inc.
- * Copyright (c) 2006, 2007, 2008, 2009, 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FontPlatformData.h"
-
-#include "FontCache.h"
-#include "HWndDC.h"
-#include "SharedBuffer.h"
-#include "SkTypeface_win.h"
-#include "SkiaFontWin.h"
-#include <mlang.h>
-#include <objidl.h>
-#include <public/Platform.h>
-#include <public/win/WebSandboxSupport.h>
-#include <windows.h>
-#include <wtf/StdLibExtras.h>
-
-namespace WebCore {
-
-SkTypeface* CreateTypefaceFromHFont(HFONT hfont, int* size, int* lfQuality)
-{
- LOGFONT info;
- GetObject(hfont, sizeof(info), &info);
- if (size) {
- int height = info.lfHeight;
- if (height < 0)
- height = -height;
- *size = height;
- }
- if (lfQuality)
- *lfQuality = info.lfQuality;
- return SkCreateTypefaceFromLOGFONT(info);
-}
-
-FontPlatformData::FontPlatformData(WTF::HashTableDeletedValueType)
- : m_font(hashTableDeletedFontValue())
- , m_size(-1)
- , m_orientation(Horizontal)
- , m_scriptCache(0)
- , m_scriptFontProperties(0)
- , m_typeface(0)
- , m_lfQuality(DEFAULT_QUALITY)
-{
-}
-
-FontPlatformData::FontPlatformData()
- : m_font(0)
- , m_size(0)
- , m_orientation(Horizontal)
- , m_scriptCache(0)
- , m_scriptFontProperties(0)
- , m_typeface(0)
- , m_lfQuality(DEFAULT_QUALITY)
-{
-}
-
-FontPlatformData::FontPlatformData(HFONT font, float size, FontOrientation orientation)
- : m_font(RefCountedHFONT::create(font))
- , m_size(size)
- , m_orientation(orientation)
- , m_scriptCache(0)
- , m_scriptFontProperties(0)
- , m_typeface(CreateTypefaceFromHFont(font, 0, &m_lfQuality))
-{
-}
-
-// FIXME: this constructor is needed for SVG fonts but doesn't seem to do much
-FontPlatformData::FontPlatformData(float size, bool bold, bool oblique)
- : m_font(0)
- , m_size(size)
- , m_orientation(Horizontal)
- , m_scriptCache(0)
- , m_scriptFontProperties(0)
- , m_typeface(0)
- , m_lfQuality(DEFAULT_QUALITY)
-{
-}
-
-FontPlatformData::FontPlatformData(const FontPlatformData& data)
- : m_font(data.m_font)
- , m_size(data.m_size)
- , m_orientation(data.m_orientation)
- , m_scriptCache(0)
- , m_scriptFontProperties(0)
- , m_typeface(data.m_typeface)
- , m_lfQuality(data.m_lfQuality)
-{
- SkSafeRef(m_typeface);
-}
-
-FontPlatformData& FontPlatformData::operator=(const FontPlatformData& data)
-{
- if (this != &data) {
- m_font = data.m_font;
- m_size = data.m_size;
- m_orientation = data.m_orientation;
- SkRefCnt_SafeAssign(m_typeface, data.m_typeface);
- m_lfQuality = data.m_lfQuality;
-
- // The following fields will get re-computed if necessary.
- ScriptFreeCache(&m_scriptCache);
- m_scriptCache = 0;
-
- delete m_scriptFontProperties;
- m_scriptFontProperties = 0;
- }
- return *this;
-}
-
-FontPlatformData::~FontPlatformData()
-{
- SkSafeUnref(m_typeface);
-
- ScriptFreeCache(&m_scriptCache);
- m_scriptCache = 0;
-
- delete m_scriptFontProperties;
- m_scriptFontProperties = 0;
-}
-
-FontPlatformData::RefCountedHFONT::~RefCountedHFONT()
-{
- if (m_hfont != reinterpret_cast<HFONT>(-1)) {
- DeleteObject(m_hfont);
- }
-}
-
-FontPlatformData::RefCountedHFONT* FontPlatformData::hashTableDeletedFontValue()
-{
- DEFINE_STATIC_LOCAL(RefPtr<RefCountedHFONT>, deletedValue,
- (RefCountedHFONT::create(reinterpret_cast<HFONT>(-1))));
- return deletedValue.get();
-}
-
-SCRIPT_FONTPROPERTIES* FontPlatformData::scriptFontProperties() const
-{
- if (!m_scriptFontProperties) {
- m_scriptFontProperties = new SCRIPT_FONTPROPERTIES;
- memset(m_scriptFontProperties, 0, sizeof(SCRIPT_FONTPROPERTIES));
- m_scriptFontProperties->cBytes = sizeof(SCRIPT_FONTPROPERTIES);
- HRESULT result = ScriptGetFontProperties(0, scriptCache(),
- m_scriptFontProperties);
- if (result == E_PENDING) {
- HWndDC dc(0);
- HGDIOBJ oldFont = SelectObject(dc, hfont());
- HRESULT hr = ScriptGetFontProperties(dc, scriptCache(),
- m_scriptFontProperties);
- if (S_OK != hr) {
- if (FontPlatformData::ensureFontLoaded(hfont())) {
- // FIXME: Handle gracefully the error if this call also fails.
- hr = ScriptGetFontProperties(dc, scriptCache(),
- m_scriptFontProperties);
- if (S_OK != hr) {
- LOG_ERROR("Unable to get the font properties after second attempt");
- }
- }
- }
-
- SelectObject(dc, oldFont);
- }
- }
- return m_scriptFontProperties;
-}
-
-#if ENABLE(OPENTYPE_VERTICAL)
-PassRefPtr<OpenTypeVerticalData> FontPlatformData::verticalData() const
-{
- SkFontID id = typeface()->uniqueID();
- return fontCache()->getVerticalData(id, *this);
-}
-
-PassRefPtr<SharedBuffer> FontPlatformData::openTypeTable(uint32_t table) const
-{
- HWndDC hdc(0);
- HGDIOBJ oldFont = SelectObject(hdc, hfont());
-
- DWORD size = GetFontData(hdc, table, 0, 0, 0);
- RefPtr<SharedBuffer> buffer;
- if (size != GDI_ERROR) {
- buffer = SharedBuffer::create(size);
- DWORD result = GetFontData(hdc, table, 0, (PVOID)buffer->data(), size);
- ASSERT(result == size);
- }
-
- SelectObject(hdc, oldFont);
- return buffer.release();
-}
-#endif
-
-#ifndef NDEBUG
-String FontPlatformData::description() const
-{
- return String();
-}
-#endif
-
-bool FontPlatformData::ensureFontLoaded(HFONT font)
-{
- WebKit::WebSandboxSupport* sandboxSupport = WebKit::Platform::current()->sandboxSupport();
- // if there is no sandbox, then we can assume the font
- // was able to be loaded successfully already
- return sandboxSupport ? sandboxSupport->ensureFontLoaded(font) : true;
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/chromium/FontPlatformDataChromiumWin.h b/Source/WebCore/platform/graphics/chromium/FontPlatformDataChromiumWin.h
deleted file mode 100644
index b3ea594b9..000000000
--- a/Source/WebCore/platform/graphics/chromium/FontPlatformDataChromiumWin.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Computer, Inc.
- * Copyright (c) 2006, 2007, 2008, 2009, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef FontPlatformDataChromiumWin_h
-#define FontPlatformDataChromiumWin_h
-
-#include "config.h"
-
-#include "FontOrientation.h"
-#include "OpenTypeVerticalData.h"
-#include "SharedBuffer.h"
-#include "SkTypeface.h"
-#include <wtf/Forward.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/text/StringImpl.h>
-
-#include <usp10.h>
-
-typedef struct HFONT__ *HFONT;
-
-namespace WebCore {
-
-// Return a typeface associated with the hfont, and return its size and
-// lfQuality from the hfont's LOGFONT. The caller is now an owner of the
-// typeface.
-SkTypeface* CreateTypefaceFromHFont(HFONT, int* size, int* lfQuality);
-
-class FontDescription;
-
-class FontPlatformData {
-public:
- // Used for deleted values in the font cache's hash tables. The hash table
- // will create us with this structure, and it will compare other values
- // to this "Deleted" one. It expects the Deleted one to be differentiable
- // from the NULL one (created with the empty constructor), so we can't just
- // set everything to NULL.
- FontPlatformData(WTF::HashTableDeletedValueType);
- FontPlatformData();
- // This constructor takes ownership of the HFONT
- FontPlatformData(HFONT, float size, FontOrientation);
- FontPlatformData(float size, bool bold, bool oblique);
- FontPlatformData(const FontPlatformData&);
-
- FontPlatformData& operator=(const FontPlatformData&);
-
- bool isHashTableDeletedValue() const { return m_font == hashTableDeletedFontValue(); }
-
- ~FontPlatformData();
-
- HFONT hfont() const { return m_font ? m_font->hfont() : 0; }
- float size() const { return m_size; }
- SkTypeface* typeface() const { return m_typeface; }
- int lfQuality() const { return m_lfQuality; }
-
- FontOrientation orientation() const { return m_orientation; }
- void setOrientation(FontOrientation orientation) { m_orientation = orientation; }
-
- unsigned hash() const
- {
- return m_font ? m_font->hash() : NULL;
- }
-
- bool operator==(const FontPlatformData& other) const
- {
- return m_font == other.m_font && m_size == other.m_size && m_orientation == other.m_orientation;
- }
-
-#if ENABLE(OPENTYPE_VERTICAL)
- PassRefPtr<OpenTypeVerticalData> verticalData() const;
- PassRefPtr<SharedBuffer> openTypeTable(uint32_t table) const;
-#endif
-
-#ifndef NDEBUG
- String description() const;
-#endif
-
- SCRIPT_FONTPROPERTIES* scriptFontProperties() const;
- SCRIPT_CACHE* scriptCache() const { return &m_scriptCache; }
-
- static bool ensureFontLoaded(HFONT);
-
-private:
- // We refcount the internal HFONT so that FontPlatformData can be
- // efficiently copied. WebKit depends on being able to copy it, and we
- // don't really want to re-create the HFONT.
- class RefCountedHFONT : public RefCounted<RefCountedHFONT> {
- public:
- static PassRefPtr<RefCountedHFONT> create(HFONT hfont)
- {
- return adoptRef(new RefCountedHFONT(hfont));
- }
-
- ~RefCountedHFONT();
-
- HFONT hfont() const { return m_hfont; }
- unsigned hash() const
- {
- return StringHasher::hashMemory<sizeof(HFONT)>(&m_hfont);
- }
-
- bool operator==(const RefCountedHFONT& other) const
- {
- return m_hfont == other.m_hfont;
- }
-
- private:
- // The create() function assumes there is already a refcount of one
- // so it can do adoptRef.
- RefCountedHFONT(HFONT hfont) : m_hfont(hfont)
- {
- }
-
- HFONT m_hfont;
- };
-
- static RefCountedHFONT* hashTableDeletedFontValue();
-
- RefPtr<RefCountedHFONT> m_font;
- float m_size; // Point size of the font in pixels.
- FontOrientation m_orientation;
-
- SkTypeface* m_typeface; // cached from m_font
- int m_lfQuality; // cached from m_font
-
- mutable SCRIPT_CACHE m_scriptCache;
- mutable SCRIPT_FONTPROPERTIES* m_scriptFontProperties;
-};
-
-} // WebCore
-
-#endif // FontPlatformDataChromiumWin_h
diff --git a/Source/WebCore/platform/graphics/chromium/FontRenderStyle.h b/Source/WebCore/platform/graphics/chromium/FontRenderStyle.h
deleted file mode 100644
index e44abb447..000000000
--- a/Source/WebCore/platform/graphics/chromium/FontRenderStyle.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* Copyright (c) 2010, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef FontRenderStyle_h
-#define FontRenderStyle_h
-
-namespace WebCore {
-
-// FontRenderStyle describes the user's preferences for rendering a font at a
-// given size.
-struct FontRenderStyle {
- enum {
- NoPreference = 2,
- };
-
- FontRenderStyle()
- : useBitmaps(0)
- , useAutoHint(0)
- , useHinting(0)
- , hintStyle(0)
- , useAntiAlias(0)
- , useSubpixelRendering(0)
- , useSubpixelPositioning(0) { }
-
- bool operator==(const FontRenderStyle& a) const
- {
- return useBitmaps == a.useBitmaps
- && useAutoHint == a.useAutoHint
- && useHinting == a.useHinting
- && hintStyle == a.hintStyle
- && useAntiAlias == a.useAntiAlias
- && useSubpixelRendering == a.useSubpixelRendering
- && useSubpixelPositioning == a.useSubpixelPositioning;
- }
-
- // Each of the use* members below can take one of three values:
- // 0: off
- // 1: on
- // NoPreference: no preference expressed
- char useBitmaps; // use embedded bitmap strike if possible
- char useAutoHint; // use 'auto' hinting (FreeType specific)
- char useHinting; // hint glyphs to the pixel grid
- char hintStyle; // level of hinting, 0..3
- char useAntiAlias; // antialias glyph shapes
- char useSubpixelRendering; // use subpixel rendering (partially-filled pixels)
- char useSubpixelPositioning; // use subpixel positioning (fractional X positions for glyphs)
-};
-
-}
-
-#endif // FontRenderStyle_h
diff --git a/Source/WebCore/platform/graphics/chromium/FontUtilsChromiumWin.cpp b/Source/WebCore/platform/graphics/chromium/FontUtilsChromiumWin.cpp
deleted file mode 100644
index 10f1fd078..000000000
--- a/Source/WebCore/platform/graphics/chromium/FontUtilsChromiumWin.cpp
+++ /dev/null
@@ -1,453 +0,0 @@
-/*
- * Copyright (c) 2006, 2007, 2008, 2009, 2010, 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FontUtilsChromiumWin.h"
-
-#include <limits>
-
-#include "HWndDC.h"
-#include "UniscribeHelper.h"
-#include <unicode/locid.h>
-#include <unicode/uchar.h>
-#include <wtf/HashMap.h>
-#include <wtf/text/StringHash.h>
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
-
-namespace {
-
-bool isFontPresent(const UChar* fontName)
-{
- HFONT hfont = CreateFont(12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- fontName);
- if (!hfont)
- return false;
- HWndDC dc(0);
- HGDIOBJ oldFont = static_cast<HFONT>(SelectObject(dc, hfont));
- WCHAR actualFontName[LF_FACESIZE];
- GetTextFace(dc, LF_FACESIZE, actualFontName);
- actualFontName[LF_FACESIZE - 1] = 0;
- SelectObject(dc, oldFont);
- DeleteObject(hfont);
- // We don't have to worry about East Asian fonts with locale-dependent
- // names here for now.
- return !wcscmp(fontName, actualFontName);
-}
-
-// A simple mapping from UScriptCode to family name. This is a sparse array,
-// which works well since the range of UScriptCode values is small.
-typedef const UChar* ScriptToFontMap[USCRIPT_CODE_LIMIT];
-
-void initializeScriptFontMap(ScriptToFontMap& scriptFontMap)
-{
- struct FontMap {
- UScriptCode script;
- const UChar* family;
- };
-
- static const FontMap fontMap[] = {
- {USCRIPT_LATIN, L"times new roman"},
- {USCRIPT_GREEK, L"times new roman"},
- {USCRIPT_CYRILLIC, L"times new roman"},
- // FIXME: Consider trying new Vista fonts before XP fonts for CJK.
- // Some Vista users do want to use Vista cleartype CJK fonts. If we
- // did, the results of tests with CJK characters would have to be
- // regenerated for Vista.
- {USCRIPT_SIMPLIFIED_HAN, L"simsun"},
- {USCRIPT_TRADITIONAL_HAN, L"pmingliu"},
- {USCRIPT_HIRAGANA, L"ms pgothic"},
- {USCRIPT_KATAKANA, L"ms pgothic"},
- {USCRIPT_KATAKANA_OR_HIRAGANA, L"ms pgothic"},
- {USCRIPT_HANGUL, L"gulim"},
- {USCRIPT_THAI, L"tahoma"},
- {USCRIPT_HEBREW, L"david"},
- {USCRIPT_ARABIC, L"tahoma"},
- {USCRIPT_DEVANAGARI, L"mangal"},
- {USCRIPT_BENGALI, L"vrinda"},
- {USCRIPT_GURMUKHI, L"raavi"},
- {USCRIPT_GUJARATI, L"shruti"},
- {USCRIPT_TAMIL, L"latha"},
- {USCRIPT_TELUGU, L"gautami"},
- {USCRIPT_KANNADA, L"tunga"},
- {USCRIPT_GEORGIAN, L"sylfaen"},
- {USCRIPT_ARMENIAN, L"sylfaen"},
- {USCRIPT_THAANA, L"mv boli"},
- {USCRIPT_CANADIAN_ABORIGINAL, L"euphemia"},
- {USCRIPT_CHEROKEE, L"plantagenet cherokee"},
- {USCRIPT_MONGOLIAN, L"mongolian balti"},
- // For USCRIPT_COMMON, we map blocks to scripts when
- // that makes sense.
- };
-
- struct ScriptToFontFamilies {
- UScriptCode script;
- const UChar** families;
- };
-
- // Kartika on Vista or earlier lacks the support for Chillu
- // letters added to Unicode 5.1.
- // Try AnjaliOldLipi (a very widely used Malaylalam font with the full
- // Unicode 5.x support) before falling back to Kartika.
- static const UChar* malayalamFonts[] = {L"AnjaliOldLipi", L"Lohit Malayalam", L"Kartika", L"Rachana", 0};
- // Try Khmer OS before Vista fonts because 'Khmer OS' goes along better
- // with Latin and looks better/larger for the same size.
- static const UChar* khmerFonts[] = {L"Khmer OS", L"MoolBoran", L"DaunPenh", L"Code2000", 0};
- // For the following 6 scripts, two or fonts are listed. The fonts in
- // the 1st slot are not available on Windows XP. To support these
- // scripts on XP, listed in the rest of slots are widely used
- // fonts.
- static const UChar* ethiopicFonts[] = {L"Nyala", L"Abyssinica SIL", L"Ethiopia Jiret", L"Visual Geez Unicode", L"GF Zemen Unicode", 0};
- static const UChar* oriyaFonts[] = {L"Kalinga", L"ori1Uni", L"Lohit Oriya", 0};
- static const UChar* laoFonts[] = {L"DokChampa", L"Saysettha OT", L"Phetsarath OT", L"Code2000", 0};
- static const UChar* tibetanFonts[] = {L"Microsoft Himalaya", L"Jomolhari", L"Tibetan Machine Uni", 0};
- static const UChar* sinhalaFonts[] = {L"Iskoola Pota", L"AksharUnicode", 0};
- static const UChar* yiFonts[] = {L"Microsoft Yi Balti", L"Nuosu SIL", L"Code2000", 0};
- // http://www.bethmardutho.org/support/meltho/download/index.php
- static const UChar* syriacFonts[] = {L"Estrangelo Edessa", L"Estrangelo Nisibin", L"Code2000", 0};
- // No Myanmar/Burmese font is shipped with Windows, yet. Try a few
- // widely available/used ones that supports Unicode 5.1 or later.
- static const UChar* myanmarFonts[] = {L"Padauk", L"Parabaik", L"Myanmar3", L"Code2000", 0};
-
- static const ScriptToFontFamilies scriptToFontFamilies[] = {
- {USCRIPT_MALAYALAM, malayalamFonts},
- {USCRIPT_KHMER, khmerFonts},
- {USCRIPT_ETHIOPIC, ethiopicFonts},
- {USCRIPT_ORIYA, oriyaFonts},
- {USCRIPT_LAO, laoFonts},
- {USCRIPT_TIBETAN, tibetanFonts},
- {USCRIPT_SINHALA, sinhalaFonts},
- {USCRIPT_YI, yiFonts},
- {USCRIPT_SYRIAC, syriacFonts},
- {USCRIPT_MYANMAR, myanmarFonts},
- };
-
- for (size_t i = 0; i < WTF_ARRAY_LENGTH(fontMap); ++i)
- scriptFontMap[fontMap[i].script] = fontMap[i].family;
-
- // FIXME: Instead of scanning the hard-coded list, we have to
- // use EnumFont* to 'inspect' fonts to pick up fonts covering scripts
- // when it's possible (e.g. using OS/2 table). If we do that, this
- // had better be pulled out of here.
- for (size_t i = 0; i < WTF_ARRAY_LENGTH(scriptToFontFamilies); ++i) {
- UScriptCode script = scriptToFontFamilies[i].script;
- scriptFontMap[script] = 0;
- const UChar** familyPtr = scriptToFontFamilies[i].families;
- while (*familyPtr) {
- if (isFontPresent(*familyPtr)) {
- scriptFontMap[script] = *familyPtr;
- break;
- }
- ++familyPtr;
- }
- }
-
- // Initialize the locale-dependent mapping.
- // Since Chrome synchronizes the ICU default locale with its UI locale,
- // this ICU locale tells the current UI locale of Chrome.
- icu::Locale locale = icu::Locale::getDefault();
- const UChar* localeFamily = 0;
- if (locale == icu::Locale::getJapanese())
- localeFamily = scriptFontMap[USCRIPT_HIRAGANA];
- else if (locale == icu::Locale::getKorean())
- localeFamily = scriptFontMap[USCRIPT_HANGUL];
- else if (locale == icu::Locale::getTraditionalChinese())
- localeFamily = scriptFontMap[USCRIPT_TRADITIONAL_HAN];
- else {
- // For other locales, use the simplified Chinese font for Han.
- localeFamily = scriptFontMap[USCRIPT_SIMPLIFIED_HAN];
- }
- if (localeFamily)
- scriptFontMap[USCRIPT_HAN] = localeFamily;
-}
-
-// There are a lot of characters in USCRIPT_COMMON that can be covered
-// by fonts for scripts closely related to them. See
-// http://unicode.org/cldr/utility/list-unicodeset.jsp?a=[:Script=Common:]
-// FIXME: make this more efficient with a wider coverage
-UScriptCode getScriptBasedOnUnicodeBlock(int ucs4)
-{
- UBlockCode block = ublock_getCode(ucs4);
- switch (block) {
- case UBLOCK_CJK_SYMBOLS_AND_PUNCTUATION:
- return USCRIPT_HAN;
- case UBLOCK_HIRAGANA:
- case UBLOCK_KATAKANA:
- return USCRIPT_HIRAGANA;
- case UBLOCK_ARABIC:
- return USCRIPT_ARABIC;
- case UBLOCK_THAI:
- return USCRIPT_THAI;
- case UBLOCK_GREEK:
- return USCRIPT_GREEK;
- case UBLOCK_DEVANAGARI:
- // For Danda and Double Danda (U+0964, U+0965), use a Devanagari
- // font for now although they're used by other scripts as well.
- // Without a context, we can't do any better.
- return USCRIPT_DEVANAGARI;
- case UBLOCK_ARMENIAN:
- return USCRIPT_ARMENIAN;
- case UBLOCK_GEORGIAN:
- return USCRIPT_GEORGIAN;
- case UBLOCK_KANNADA:
- return USCRIPT_KANNADA;
- default:
- return USCRIPT_COMMON;
- }
-}
-
-UScriptCode getScript(int ucs4)
-{
- UErrorCode err = U_ZERO_ERROR;
- UScriptCode script = uscript_getScript(ucs4, &err);
- // If script is invalid, common or inherited or there's an error,
- // infer a script based on the unicode block of a character.
- if (script <= USCRIPT_INHERITED || U_FAILURE(err))
- script = getScriptBasedOnUnicodeBlock(ucs4);
- return script;
-}
-
-const int kUndefinedAscent = std::numeric_limits<int>::min();
-
-// Given an HFONT, return the ascent. If GetTextMetrics fails,
-// kUndefinedAscent is returned, instead.
-int getAscent(HFONT hfont)
-{
- HWndDC dc(0);
- HGDIOBJ oldFont = SelectObject(dc, hfont);
- TEXTMETRIC tm;
- BOOL gotMetrics = GetTextMetrics(dc, &tm);
- SelectObject(dc, oldFont);
- return gotMetrics ? tm.tmAscent : kUndefinedAscent;
-}
-
-WORD getSpaceGlyph(HFONT hfont)
-{
- HWndDC dc(0);
- HGDIOBJ oldFont = SelectObject(dc, hfont);
- WCHAR space = L' ';
- WORD spaceGlyph = 0;
- GetGlyphIndices(dc, &space, 1, &spaceGlyph, 0);
- SelectObject(dc, oldFont);
- return spaceGlyph;
-}
-
-struct FontData {
- FontData()
- : hfont(0)
- , ascent(kUndefinedAscent)
- , scriptCache(0)
- , spaceGlyph(0)
- {
- }
-
- HFONT hfont;
- int ascent;
- mutable SCRIPT_CACHE scriptCache;
- WORD spaceGlyph;
-};
-
-// Again, using hash_map does not earn us much here. page_cycler_test intl2
-// gave us a 'better' result with map than with hash_map even though they're
-// well-within 1-sigma of each other so that the difference is not significant.
-// On the other hand, some pages in intl2 seem to take longer to load with map
-// in the 1st pass. Need to experiment further.
-typedef HashMap<String, FontData> FontDataCache;
-
-} // namespace
-
-// FIXME: this is font fallback code version 0.1
-// - Cover all the scripts
-// - Get the default font for each script/generic family from the
-// preference instead of hardcoding in the source.
-// (at least, read values from the registry for IE font settings).
-// - Support generic families (from FontDescription)
-// - If the default font for a script is not available,
-// try some more fonts known to support it. Finally, we can
-// use EnumFontFamilies or similar APIs to come up with a list of
-// fonts supporting the script and cache the result.
-// - Consider using UnicodeSet (or UnicodeMap) converted from
-// GLYPHSET (BMP) or directly read from truetype cmap tables to
-// keep track of which character is supported by which font
-// - Update script_font_cache in response to WM_FONTCHANGE
-
-const UChar* getFontFamilyForScript(UScriptCode script,
- FontDescription::GenericFamilyType generic)
-{
- static ScriptToFontMap scriptFontMap;
- static bool initialized = false;
- if (!initialized) {
- initializeScriptFontMap(scriptFontMap);
- initialized = true;
- }
- if (script == USCRIPT_INVALID_CODE)
- return 0;
- ASSERT(script < USCRIPT_CODE_LIMIT);
- return scriptFontMap[script];
-}
-
-// FIXME:
-// - Handle 'Inherited', 'Common' and 'Unknown'
-// (see http://www.unicode.org/reports/tr24/#Usage_Model )
-// For 'Inherited' and 'Common', perhaps we need to
-// accept another parameter indicating the previous family
-// and just return it.
-// - All the characters (or characters up to the point a single
-// font can cover) need to be taken into account
-const UChar* getFallbackFamily(const UChar* characters,
- int length,
- FontDescription::GenericFamilyType generic,
- UChar32* charChecked,
- UScriptCode* scriptChecked)
-{
- ASSERT(characters && characters[0] && length > 0);
- UScriptCode script = USCRIPT_COMMON;
-
- // Sometimes characters common to script (e.g. space) is at
- // the beginning of a string so that we need to skip them
- // to get a font required to render the string.
- int i = 0;
- UChar32 ucs4 = 0;
- while (i < length && script == USCRIPT_COMMON) {
- U16_NEXT(characters, i, length, ucs4);
- script = getScript(ucs4);
- }
-
- // For the full-width ASCII characters (U+FF00 - U+FF5E), use the font for
- // Han (determined in a locale-dependent way above). Full-width ASCII
- // characters are rather widely used in Japanese and Chinese documents and
- // they're fully covered by Chinese, Japanese and Korean fonts.
- if (0xFF00 < ucs4 && ucs4 < 0xFF5F)
- script = USCRIPT_HAN;
-
- if (script == USCRIPT_COMMON)
- script = getScriptBasedOnUnicodeBlock(ucs4);
-
- const UChar* family = getFontFamilyForScript(script, generic);
- // Another lame work-around to cover non-BMP characters.
- // If the font family for script is not found or the character is
- // not in BMP (> U+FFFF), we resort to the hard-coded list of
- // fallback fonts for now.
- if (!family || ucs4 > 0xFFFF) {
- int plane = ucs4 >> 16;
- switch (plane) {
- case 1:
- family = L"code2001";
- break;
- case 2:
- // Use a Traditional Chinese ExtB font if in Traditional Chinese locale.
- // Otherwise, use a Simplified Chinese ExtB font. Windows Japanese
- // fonts do support a small subset of ExtB (that are included in JIS X 0213),
- // but its coverage is rather sparse.
- // Eventually, this should be controlled by lang/xml:lang.
- if (icu::Locale::getDefault() == icu::Locale::getTraditionalChinese())
- family = L"pmingliu-extb";
- else
- family = L"simsun-extb";
- break;
- default:
- family = L"lucida sans unicode";
- }
- }
-
- if (charChecked)
- *charChecked = ucs4;
- if (scriptChecked)
- *scriptChecked = script;
- return family;
-}
-
-// Be aware that this is not thread-safe.
-bool getDerivedFontData(const UChar* family,
- int style,
- LOGFONT* logfont,
- int* ascent,
- HFONT* hfont,
- SCRIPT_CACHE** scriptCache,
- WORD* spaceGlyph)
-{
- ASSERT(logfont);
- ASSERT(family);
- ASSERT(*family);
-
- // It does not matter that we leak font data when we exit.
- static FontDataCache fontDataCache;
-
- // FIXME: This comes up pretty high in the profile so that
- // we need to measure whether using SHA256 (after coercing all the
- // fields to char*) is faster than String::format.
- String fontKey = String::format("%1d:%d:%ls", style, logfont->lfHeight, family);
- FontDataCache::iterator iter = fontDataCache.find(fontKey);
- FontData* derived;
- if (iter == fontDataCache.end()) {
- ASSERT(wcslen(family) < LF_FACESIZE);
- wcscpy_s(logfont->lfFaceName, LF_FACESIZE, family);
- // FIXME: CreateFontIndirect always comes up with
- // a font even if there's no font matching the name. Need to
- // check it against what we actually want (as is done in
- // FontCacheWin.cpp)
- FontDataCache::AddResult entry = fontDataCache.add(fontKey, FontData());
- derived = &entry.iterator->value;
- derived->hfont = CreateFontIndirect(logfont);
- // GetAscent may return kUndefinedAscent, but we still want to
- // cache it so that we won't have to call CreateFontIndirect once
- // more for HFONT next time.
- derived->ascent = getAscent(derived->hfont);
- derived->spaceGlyph = getSpaceGlyph(derived->hfont);
- } else {
- derived = &iter->value;
- // Last time, GetAscent failed so that only HFONT was
- // cached. Try once more assuming that TryPreloadFont
- // was called by a caller between calls.
- if (kUndefinedAscent == derived->ascent)
- derived->ascent = getAscent(derived->hfont);
- }
- *hfont = derived->hfont;
- *ascent = derived->ascent;
- *scriptCache = &(derived->scriptCache);
- *spaceGlyph = derived->spaceGlyph;
- return *ascent != kUndefinedAscent;
-}
-
-int getStyleFromLogfont(const LOGFONT* logfont)
-{
- // FIXME: consider defining UNDEFINED or INVALID for style and
- // returning it when logfont is 0
- if (!logfont) {
- ASSERT_NOT_REACHED();
- return FontStyleNormal;
- }
- return (logfont->lfItalic ? FontStyleItalic : FontStyleNormal) |
- (logfont->lfUnderline ? FontStyleUnderlined : FontStyleNormal) |
- (logfont->lfWeight >= 700 ? FontStyleBold : FontStyleNormal);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/chromium/FontUtilsChromiumWin.h b/Source/WebCore/platform/graphics/chromium/FontUtilsChromiumWin.h
deleted file mode 100644
index d9de0029c..000000000
--- a/Source/WebCore/platform/graphics/chromium/FontUtilsChromiumWin.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (c) 2006, 2007, 2008, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-// A collection of utilities for font handling.
-
-// FIXME: Move all methods to the files that have their callsites and remove this file.
-// *Utils files are not very WebKit-ty.
-
-#ifndef FontUtilsChromiumWin_h
-#define FontUtilsChromiumWin_h
-
-#include <usp10.h>
-#include <wchar.h>
-#include <windows.h>
-
-#include "FontDescription.h"
-#include <unicode/uscript.h>
-
-namespace WebCore {
-
-// Return a font family that supports a script and belongs to |generic| font
-// family. It can return NULL and a caller has to implement its own fallback.
-const UChar* getFontFamilyForScript(UScriptCode, FontDescription::GenericFamilyType);
-
-// Return a font family that can render |characters| based on
-// what script characters belong to. When char_checked is non-NULL,
-// it's filled with the character used to determine the script.
-// When script_checked is non-NULL, the script used to determine
-// the family is returned.
-// FIXME: This function needs a total overhaul.
-const UChar* getFallbackFamily(const UChar* characters, int length,
- FontDescription::GenericFamilyType,
- UChar32* charChecked,
- UScriptCode* scriptChecked);
-
-// Derive a new HFONT by replacing lfFaceName of LOGFONT with |family|,
-// calculate the ascent for the derived HFONT, and initialize SCRIPT_CACHE
-// in FontData.
-// |style| is only used for cache key generation. |style| is
-// bit-wise OR of BOLD(1), UNDERLINED(2) and ITALIC(4) and
-// should match what's contained in LOGFONT. It should be calculated
-// by calling GetStyleFromLogFont.
-// Returns false if the font is not accessible, in which case |ascent| field
-// of |fontdata| is set to kUndefinedAscent.
-// Be aware that this is not thread-safe.
-// FIXME: Instead of having three out params, we'd better have one
-// (|*FontData|), but somehow it mysteriously messes up the layout for
-// certain complex script pages (e.g. hi.wikipedia.org) and also crashes
-// at the start-up if recently visited page list includes pages with complex
-// scripts in their title. Moreover, somehow the very first-pass of
-// intl2 page-cycler test is noticeably slower with one out param than
-// the current version although the subsequent 9 passes take about the
-// same time.
-bool getDerivedFontData(const UChar* family, int style, LOGFONT*, int* ascent, HFONT*, SCRIPT_CACHE**, WORD* spaceGlyph);
-
-enum {
- FontStyleNormal = 0,
- FontStyleBold = 1,
- FontStyleItalic = 2,
- FontStyleUnderlined = 4
-};
-
-// Derive style (bit-wise OR of FONT_STYLE_BOLD, FONT_STYLE_UNDERLINED, and
-// FONT_STYLE_ITALIC) from LOGFONT. Returns 0 if |*logfont| is NULL.
-int getStyleFromLogfont(const LOGFONT*);
-
-} // namespace WebCore
-
-#endif // FontUtilsChromiumWin_h
diff --git a/Source/WebCore/platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp b/Source/WebCore/platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp
deleted file mode 100644
index f1bd65f38..000000000
--- a/Source/WebCore/platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include <windows.h>
-#include <vector>
-
-#include "Font.h"
-#include "FontPlatformDataChromiumWin.h"
-#include "GlyphPageTreeNode.h"
-#include "HWndDC.h"
-#include "SimpleFontData.h"
-#include "SystemInfo.h"
-#include "UniscribeHelperTextRun.h"
-
-namespace WebCore {
-
-// Fills one page of font data pointers with 0 to indicate that there
-// are no glyphs for the characters.
-static void fillEmptyGlyphs(GlyphPage* page)
-{
- for (int i = 0; i < GlyphPage::size; ++i)
- page->setGlyphDataForIndex(i, 0, 0);
-}
-
-// Convert characters to glyph ids by GetGlyphIndices(), during which, we
-// ensure the font is loaded in memory to make it work in a sandboxed process.
-static bool getGlyphIndices(HFONT font, HDC dc, const UChar* characters, unsigned charactersLength, WORD* glyphBuffer, DWORD flag)
-{
- if (GetGlyphIndices(dc, characters, charactersLength, glyphBuffer, flag) != GDI_ERROR)
- return true;
- if (FontPlatformData::ensureFontLoaded(font)) {
- if (GetGlyphIndices(dc, characters, charactersLength, glyphBuffer, flag) != GDI_ERROR)
- return true;
- // FIXME: Handle gracefully the error if this call also fails.
- // See http://crbug.com/6401
- LOG_ERROR("Unable to get the glyph indices after second attempt");
- }
- return false;
-}
-
-// Initializes space glyph
-static bool initSpaceGlyph(HFONT font, HDC dc, Glyph* spaceGlyph)
-{
- static wchar_t space = ' ';
- return getGlyphIndices(font, dc, &space, 1, spaceGlyph, 0);
-}
-
-// Fills |length| glyphs starting at |offset| in a |page| in the Basic
-// Multilingual Plane (<= U+FFFF). The input buffer size should be the
-// same as |length|. We can use the standard Windows GDI functions here.
-// Returns true if any glyphs were found.
-static bool fillBMPGlyphs(unsigned offset,
- unsigned length,
- UChar* buffer,
- GlyphPage* page,
- const SimpleFontData* fontData)
-{
- HWndDC dc(0);
- HGDIOBJ oldFont = SelectObject(dc, fontData->platformData().hfont());
-
- TEXTMETRIC tm = {0};
- if (!GetTextMetrics(dc, &tm)) {
- if (FontPlatformData::ensureFontLoaded(fontData->platformData().hfont())) {
- if (!GetTextMetrics(dc, &tm)) {
- // FIXME: Handle gracefully the error if this call also fails.
- // See http://crbug.com/6401
- LOG_ERROR("Unable to get the text metrics after second attempt");
-
- SelectObject(dc, oldFont);
- fillEmptyGlyphs(page);
- return false;
- }
- } else {
- SelectObject(dc, oldFont);
- fillEmptyGlyphs(page);
- return false;
- }
- }
-
- // FIXME: GetGlyphIndices() sets each item of localGlyphBuffer[]
- // with the one of the values listed below.
- // * With the GGI_MARK_NONEXISTING_GLYPHS flag
- // + If the font has a glyph available for the character,
- // localGlyphBuffer[i] > 0x0.
- // + If the font does not have glyphs available for the character,
- // localGlyphBuffer[i] = 0x1F (TrueType Collection?) or
- // 0xFFFF (OpenType?).
- // * Without the GGI_MARK_NONEXISTING_GLYPHS flag
- // + If the font has a glyph available for the character,
- // localGlyphBuffer[i] > 0x0.
- // + If the font does not have glyphs available for the character,
- // localGlyphBuffer[i] = 0x80.
- // (Windows automatically assigns the glyph for a box character to
- // prevent ExtTextOut() from returning errors.)
- // To avoid from hurting the rendering performance, this code just
- // tells WebKit whether or not the all glyph indices for the given
- // characters are 0x80 (i.e. a possibly-invalid glyph) and let it
- // use alternative fonts for the characters.
- // Although this may cause a problem, it seems to work fine as far as I
- // have tested. (Obviously, I need more tests.)
- WORD localGlyphBuffer[GlyphPage::size];
-
- // FIXME: I find some Chinese characters can not be correctly displayed
- // when call GetGlyphIndices without flag GGI_MARK_NONEXISTING_GLYPHS,
- // because the corresponding glyph index is set as 0x20 when current font
- // does not have glyphs available for the character. According a blog post
- // http://blogs.msdn.com/michkap/archive/2006/06/28/649791.aspx
- // I think we should switch to the way about calling GetGlyphIndices with
- // flag GGI_MARK_NONEXISTING_GLYPHS, it should be OK according the
- // description of MSDN.
- // Also according to Jungshik and Hironori's suggestion and modification
- // we treat turetype and raster Font as different way when windows version
- // is less than Vista.
- if (!getGlyphIndices(fontData->platformData().hfont(), dc, buffer, length, localGlyphBuffer, GGI_MARK_NONEXISTING_GLYPHS)) {
- SelectObject(dc, oldFont);
- fillEmptyGlyphs(page);
- return false;
- }
-
- // Copy the output to the GlyphPage
- bool haveGlyphs = false;
- int invalidGlyph = 0xFFFF;
- const DWORD cffTableTag = 0x20464643; // 4-byte identifier for OpenType CFF table ('CFF ').
- if ((windowsVersion() < WindowsVista) && !(tm.tmPitchAndFamily & TMPF_TRUETYPE) && (GetFontData(dc, cffTableTag, 0, 0, 0) == GDI_ERROR))
- invalidGlyph = 0x1F;
-
- Glyph spaceGlyph = 0; // Glyph for a space. Lazily filled.
- bool spaceGlyphInitialized = false;
-
- for (unsigned i = 0; i < length; i++) {
- UChar c = buffer[i];
- Glyph glyph = localGlyphBuffer[i];
- const SimpleFontData* glyphFontData = fontData;
- // When this character should be a space, we ignore whatever the font
- // says and use a space. Otherwise, if fonts don't map one of these
- // space or zero width glyphs, we will get a box.
- if (Font::treatAsSpace(c)) {
- // Hard code the glyph indices for characters that should be
- // treated like spaces.
- if (!spaceGlyphInitialized) {
- // If initSpaceGlyph fails, spaceGlyph stays 0 (= glyph is not present).
- initSpaceGlyph(fontData->platformData().hfont(), dc, &spaceGlyph);
- spaceGlyphInitialized = true;
- }
- glyph = spaceGlyph;
- } else if (glyph == invalidGlyph) {
- // WebKit expects both the glyph index and FontData
- // pointer to be 0 if the glyph is not present
- glyph = 0;
- glyphFontData = 0;
- } else
- haveGlyphs = true;
- page->setGlyphDataForCharacter(offset + i, glyph, glyphFontData);
- }
-
- SelectObject(dc, oldFont);
- return haveGlyphs;
-}
-
-// For non-BMP characters, each is two words (UTF-16) and the input buffer
-// size is 2 * |length|. Since GDI doesn't know how to handle non-BMP
-// characters, we must use Uniscribe to tell us the glyph indices.
-//
-// We don't want to call this in the case of "regular" characters since some
-// fonts may not have the correct combining rules for accents. See the notes
-// at the bottom of ScriptGetCMap. We can't use ScriptGetCMap, though, since
-// it doesn't seem to support UTF-16, despite what this blog post says:
-// http://blogs.msdn.com/michkap/archive/2006/06/29/650680.aspx
-//
-// So we fire up the full Uniscribe doohicky, give it our string, and it will
-// correctly handle the UTF-16 for us. The hard part is taking this and getting
-// the glyph indices back out that correspond to the correct input characters,
-// since they may be missing.
-//
-// Returns true if any glyphs were found.
-static bool fillNonBMPGlyphs(unsigned offset,
- unsigned length,
- UChar* buffer,
- GlyphPage* page,
- const SimpleFontData* fontData)
-{
- bool haveGlyphs = false;
-
- UniscribeHelperTextRun state(buffer, length * 2, false,
- fontData->platformData().hfont(),
- fontData->platformData().scriptCache(),
- fontData->platformData().scriptFontProperties());
- state.setInhibitLigate(true);
- state.setDisableFontFallback(true);
- state.init();
-
- for (unsigned i = 0; i < length; i++) {
- // Each character in this input buffer is a surrogate pair, which
- // consists of two UChars. So, the offset for its i-th character is
- // (i * 2).
- WORD glyph = state.firstGlyphForCharacter(i * 2);
- if (glyph) {
- haveGlyphs = true;
- page->setGlyphDataForIndex(offset + i, glyph, fontData);
- } else
- // Clear both glyph and fontData fields.
- page->setGlyphDataForIndex(offset + i, 0, 0);
- }
- return haveGlyphs;
-}
-
-// We're supposed to return true if there are any glyphs in the range
-// specified by |offset| and |length| in our font,
-// false if there are none.
-bool GlyphPage::fill(unsigned offset, unsigned length, UChar* characterBuffer,
- unsigned bufferLength, const SimpleFontData* fontData)
-{
- // We have to handle BMP and non-BMP characters differently.
- // FIXME: Add assertions to make sure that buffer is entirely in BMP
- // or entirely in non-BMP.
- if (bufferLength == length)
- return fillBMPGlyphs(offset, length, characterBuffer, this, fontData);
-
- if (bufferLength == 2 * length) {
- // A non-BMP input buffer will be twice as long as output glyph buffer
- // because each character in the non-BMP input buffer will be
- // represented by a surrogate pair (two UChar's).
- return fillNonBMPGlyphs(offset, length, characterBuffer, this, fontData);
- }
-
- ASSERT_NOT_REACHED();
- return false;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp
deleted file mode 100644
index 8a0af1530..000000000
--- a/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp
+++ /dev/null
@@ -1,884 +0,0 @@
-/*
- * Copyright (C) 2010 Google Inc. All rights reserved.
- * Copyright (C) 2009 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-
-/** FIXME
- * This file borrows code heavily from platform/graphics/win/GraphicsLayerCACF.cpp
- * (and hence it includes both copyrights)
- * Ideally the common code (mostly the code that keeps track of the layer hierarchy)
- * should be kept separate and shared between platforms. It would be a well worthwhile
- * effort once the Windows implementation (binaries and headers) of CoreAnimation is
- * checked in to the WebKit repository. Until then only Apple can make this happen.
- */
-
-#include "config.h"
-
-#if USE(ACCELERATED_COMPOSITING)
-
-#include "GraphicsLayerChromium.h"
-
-#include "AnimationTranslationUtil.h"
-#include "FloatConversion.h"
-#include "FloatRect.h"
-#include "GraphicsContext.h"
-#include "GraphicsLayerFactory.h"
-#include "Image.h"
-#include "NativeImageSkia.h"
-#include "PlatformContextSkia.h"
-#include "ScrollableArea.h"
-#include "SkImageFilter.h"
-#include "SkMatrix44.h"
-#include "SkiaImageFilterBuilder.h"
-#include "SystemTime.h"
-#include <public/Platform.h>
-#include <public/WebAnimation.h>
-#include <public/WebCompositorSupport.h>
-#include <public/WebFilterOperation.h>
-#include <public/WebFilterOperations.h>
-#include <public/WebFloatPoint.h>
-#include <public/WebFloatRect.h>
-#include <public/WebImageLayer.h>
-#include <public/WebSize.h>
-#include <public/WebTransformationMatrix.h>
-#include <wtf/CurrentTime.h>
-#include <wtf/HashSet.h>
-#include <wtf/StringExtras.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/StringHash.h>
-#include <wtf/text/WTFString.h>
-
-using namespace std;
-using namespace WebKit;
-
-namespace WebCore {
-
-PassOwnPtr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient* client)
-{
- if (!factory)
- return adoptPtr(new GraphicsLayerChromium(client));
-
- return factory->createGraphicsLayer(client);
-}
-
-PassOwnPtr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerClient* client)
-{
- return adoptPtr(new GraphicsLayerChromium(client));
-}
-
-GraphicsLayerChromium::GraphicsLayerChromium(GraphicsLayerClient* client)
- : GraphicsLayer(client)
- , m_contentsLayer(0)
- , m_contentsLayerId(0)
- , m_linkHighlight(0)
- , m_contentsLayerPurpose(NoContentsLayer)
- , m_contentsLayerHasBackgroundColor(false)
- , m_inSetChildren(false)
- , m_scrollableArea(0)
-{
- m_opaqueRectTrackingContentLayerDelegate = adoptPtr(new OpaqueRectTrackingContentLayerDelegate(this));
- m_layer = adoptPtr(Platform::current()->compositorSupport()->createContentLayer(m_opaqueRectTrackingContentLayerDelegate.get()));
- m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible);
- m_layer->layer()->setScrollClient(this);
- m_layer->setAutomaticallyComputeRasterScale(true);
-}
-
-GraphicsLayerChromium::~GraphicsLayerChromium()
-{
- willBeDestroyed();
-}
-
-void GraphicsLayerChromium::willBeDestroyed()
-{
- if (m_linkHighlight) {
- m_linkHighlight->clearCurrentGraphicsLayer();
- m_linkHighlight = 0;
- }
-
- GraphicsLayer::willBeDestroyed();
-}
-
-void GraphicsLayerChromium::setName(const String& inName)
-{
- m_nameBase = inName;
- String name = String::format("GraphicsLayer(%p) ", this) + inName;
- GraphicsLayer::setName(name);
- updateNames();
-}
-
-void GraphicsLayerChromium::updateNames()
-{
- String debugName = "Layer for " + m_nameBase;
- m_layer->layer()->setDebugName(debugName);
-
- if (m_transformLayer) {
- String debugName = "TransformLayer for " + m_nameBase;
- m_transformLayer->setDebugName(debugName);
- }
- if (WebLayer* contentsLayer = contentsLayerIfRegistered()) {
- String debugName = "ContentsLayer for " + m_nameBase;
- contentsLayer->setDebugName(debugName);
- }
- if (m_linkHighlight) {
- String debugName = "LinkHighlight for " + m_nameBase;
- m_linkHighlight->layer()->setDebugName(debugName);
- }
-}
-
-bool GraphicsLayerChromium::setChildren(const Vector<GraphicsLayer*>& children)
-{
- m_inSetChildren = true;
- bool childrenChanged = GraphicsLayer::setChildren(children);
-
- if (childrenChanged)
- updateChildList();
- m_inSetChildren = false;
-
- return childrenChanged;
-}
-
-void GraphicsLayerChromium::addChild(GraphicsLayer* childLayer)
-{
- GraphicsLayer::addChild(childLayer);
- if (!m_inSetChildren)
- updateChildList();
-}
-
-void GraphicsLayerChromium::addChildAtIndex(GraphicsLayer* childLayer, int index)
-{
- GraphicsLayer::addChildAtIndex(childLayer, index);
- updateChildList();
-}
-
-void GraphicsLayerChromium::addChildBelow(GraphicsLayer* childLayer, GraphicsLayer* sibling)
-{
- GraphicsLayer::addChildBelow(childLayer, sibling);
- updateChildList();
-}
-
-void GraphicsLayerChromium::addChildAbove(GraphicsLayer* childLayer, GraphicsLayer *sibling)
-{
- GraphicsLayer::addChildAbove(childLayer, sibling);
- updateChildList();
-}
-
-bool GraphicsLayerChromium::replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild)
-{
- if (GraphicsLayer::replaceChild(oldChild, newChild)) {
- updateChildList();
- return true;
- }
- return false;
-}
-
-void GraphicsLayerChromium::removeFromParent()
-{
- GraphicsLayer::removeFromParent();
- platformLayer()->removeFromParent();
-}
-
-void GraphicsLayerChromium::setPosition(const FloatPoint& point)
-{
- GraphicsLayer::setPosition(point);
- updateLayerPosition();
-}
-
-void GraphicsLayerChromium::setAnchorPoint(const FloatPoint3D& point)
-{
- GraphicsLayer::setAnchorPoint(point);
- updateAnchorPoint();
-}
-
-void GraphicsLayerChromium::setSize(const FloatSize& size)
-{
- // We are receiving negative sizes here that cause assertions to fail in the compositor. Clamp them to 0 to
- // avoid those assertions.
- // FIXME: This should be an ASSERT instead, as negative sizes should not exist in WebCore.
- FloatSize clampedSize = size;
- if (clampedSize.width() < 0 || clampedSize.height() < 0)
- clampedSize = FloatSize();
-
- if (clampedSize == m_size)
- return;
-
- GraphicsLayer::setSize(clampedSize);
- updateLayerSize();
-}
-
-void GraphicsLayerChromium::setTransform(const TransformationMatrix& transform)
-{
- GraphicsLayer::setTransform(transform);
- updateTransform();
-}
-
-void GraphicsLayerChromium::setChildrenTransform(const TransformationMatrix& transform)
-{
- GraphicsLayer::setChildrenTransform(transform);
- updateChildrenTransform();
-}
-
-void GraphicsLayerChromium::setPreserves3D(bool preserves3D)
-{
- if (preserves3D == m_preserves3D)
- return;
-
- GraphicsLayer::setPreserves3D(preserves3D);
- updateLayerPreserves3D();
-}
-
-void GraphicsLayerChromium::setMasksToBounds(bool masksToBounds)
-{
- GraphicsLayer::setMasksToBounds(masksToBounds);
- updateMasksToBounds();
-}
-
-void GraphicsLayerChromium::setDrawsContent(bool drawsContent)
-{
- // Note carefully this early-exit is only correct because we also properly call
- // WebLayer::setDrawsContent whenever m_contentsLayer is set to a new layer in setupContentsLayer().
- if (drawsContent == m_drawsContent)
- return;
-
- GraphicsLayer::setDrawsContent(drawsContent);
- updateLayerIsDrawable();
-}
-
-void GraphicsLayerChromium::setContentsVisible(bool contentsVisible)
-{
- // Note carefully this early-exit is only correct because we also properly call
- // WebLayer::setDrawsContent whenever m_contentsLayer is set to a new layer in setupContentsLayer().
- if (contentsVisible == m_contentsVisible)
- return;
-
- GraphicsLayer::setContentsVisible(contentsVisible);
- updateLayerIsDrawable();
-}
-
-void GraphicsLayerChromium::setBackgroundColor(const Color& color)
-{
- GraphicsLayer::setBackgroundColor(color.rgb());
-
- m_contentsLayerHasBackgroundColor = true;
- updateLayerBackgroundColor();
-}
-
-void GraphicsLayerChromium::clearBackgroundColor()
-{
- GraphicsLayer::clearBackgroundColor();
-
- if (WebLayer* contentsLayer = contentsLayerIfRegistered())
- contentsLayer->setBackgroundColor(static_cast<RGBA32>(0));
-}
-
-void GraphicsLayerChromium::setContentsOpaque(bool opaque)
-{
- GraphicsLayer::setContentsOpaque(opaque);
- m_layer->layer()->setOpaque(m_contentsOpaque);
- m_opaqueRectTrackingContentLayerDelegate->setOpaque(m_contentsOpaque);
-}
-
-static bool copyWebCoreFilterOperationsToWebFilterOperations(const FilterOperations& filters, WebFilterOperations& webFilters)
-{
- for (size_t i = 0; i < filters.size(); ++i) {
- const FilterOperation& op = *filters.at(i);
- switch (op.getOperationType()) {
- case FilterOperation::REFERENCE:
- return false; // Not supported.
- case FilterOperation::GRAYSCALE:
- case FilterOperation::SEPIA:
- case FilterOperation::SATURATE:
- case FilterOperation::HUE_ROTATE: {
- float amount = static_cast<const BasicColorMatrixFilterOperation*>(&op)->amount();
- switch (op.getOperationType()) {
- case FilterOperation::GRAYSCALE:
- webFilters.append(WebFilterOperation::createGrayscaleFilter(amount));
- break;
- case FilterOperation::SEPIA:
- webFilters.append(WebFilterOperation::createSepiaFilter(amount));
- break;
- case FilterOperation::SATURATE:
- webFilters.append(WebFilterOperation::createSaturateFilter(amount));
- break;
- case FilterOperation::HUE_ROTATE:
- webFilters.append(WebFilterOperation::createHueRotateFilter(amount));
- break;
- default:
- ASSERT_NOT_REACHED();
- }
- break;
- }
- case FilterOperation::INVERT:
- case FilterOperation::OPACITY:
- case FilterOperation::BRIGHTNESS:
- case FilterOperation::CONTRAST: {
- float amount = static_cast<const BasicComponentTransferFilterOperation*>(&op)->amount();
- switch (op.getOperationType()) {
- case FilterOperation::INVERT:
- webFilters.append(WebFilterOperation::createInvertFilter(amount));
- break;
- case FilterOperation::OPACITY:
- webFilters.append(WebFilterOperation::createOpacityFilter(amount));
- break;
- case FilterOperation::BRIGHTNESS:
- webFilters.append(WebFilterOperation::createBrightnessFilter(amount));
- break;
- case FilterOperation::CONTRAST:
- webFilters.append(WebFilterOperation::createContrastFilter(amount));
- break;
- default:
- ASSERT_NOT_REACHED();
- }
- break;
- }
- case FilterOperation::BLUR: {
- float pixelRadius = static_cast<const BlurFilterOperation*>(&op)->stdDeviation().getFloatValue();
- webFilters.append(WebFilterOperation::createBlurFilter(pixelRadius));
- break;
- }
- case FilterOperation::DROP_SHADOW: {
- const DropShadowFilterOperation& dropShadowOp = *static_cast<const DropShadowFilterOperation*>(&op);
- webFilters.append(WebFilterOperation::createDropShadowFilter(WebPoint(dropShadowOp.x(), dropShadowOp.y()), dropShadowOp.stdDeviation(), dropShadowOp.color().rgb()));
- break;
- }
-#if ENABLE(CSS_SHADERS)
- case FilterOperation::CUSTOM:
- case FilterOperation::VALIDATED_CUSTOM:
- return false; // Not supported.
-#endif
- case FilterOperation::PASSTHROUGH:
- case FilterOperation::NONE:
- break;
- }
- }
- return true;
-}
-
-bool GraphicsLayerChromium::setFilters(const FilterOperations& filters)
-{
- // FIXME: For now, we only use SkImageFilters if there is a reference
- // filter in the chain. Once all issues have been ironed out, we should
- // switch all filtering over to this path, and remove setFilters() and
- // WebFilterOperations altogether.
- if (filters.hasReferenceFilter()) {
- if (filters.hasCustomFilter()) {
- // Make sure the filters are removed from the platform layer, as they are
- // going to fallback to software mode.
- m_layer->layer()->setFilter(0);
- GraphicsLayer::setFilters(FilterOperations());
- return false;
- }
- SkiaImageFilterBuilder builder;
- SkAutoTUnref<SkImageFilter> imageFilter(builder.build(filters));
- m_layer->layer()->setFilter(imageFilter);
- } else {
- WebFilterOperations webFilters;
- if (!copyWebCoreFilterOperationsToWebFilterOperations(filters, webFilters)) {
- // Make sure the filters are removed from the platform layer, as they are
- // going to fallback to software mode.
- m_layer->layer()->setFilters(WebFilterOperations());
- GraphicsLayer::setFilters(FilterOperations());
- return false;
- }
- m_layer->layer()->setFilters(webFilters);
- }
- return GraphicsLayer::setFilters(filters);
-}
-
-void GraphicsLayerChromium::setBackgroundFilters(const FilterOperations& filters)
-{
- WebFilterOperations webFilters;
- if (!copyWebCoreFilterOperationsToWebFilterOperations(filters, webFilters))
- return;
- m_layer->layer()->setBackgroundFilters(webFilters);
-}
-
-void GraphicsLayerChromium::setMaskLayer(GraphicsLayer* maskLayer)
-{
- if (maskLayer == m_maskLayer)
- return;
-
- GraphicsLayer::setMaskLayer(maskLayer);
-
- WebLayer* maskWebLayer = m_maskLayer ? m_maskLayer->platformLayer() : 0;
- m_layer->layer()->setMaskLayer(maskWebLayer);
-}
-
-void GraphicsLayerChromium::setBackfaceVisibility(bool visible)
-{
- GraphicsLayer::setBackfaceVisibility(visible);
- m_layer->setDoubleSided(m_backfaceVisibility);
-}
-
-void GraphicsLayerChromium::setOpacity(float opacity)
-{
- float clampedOpacity = max(min(opacity, 1.0f), 0.0f);
- GraphicsLayer::setOpacity(clampedOpacity);
- platformLayer()->setOpacity(opacity);
-}
-
-void GraphicsLayerChromium::setReplicatedByLayer(GraphicsLayer* layer)
-{
- GraphicsLayerChromium* layerChromium = static_cast<GraphicsLayerChromium*>(layer);
- GraphicsLayer::setReplicatedByLayer(layer);
-
- WebLayer* webReplicaLayer = layerChromium ? layerChromium->platformLayer() : 0;
- platformLayer()->setReplicaLayer(webReplicaLayer);
-}
-
-
-void GraphicsLayerChromium::setContentsNeedsDisplay()
-{
- if (WebLayer* contentsLayer = contentsLayerIfRegistered()) {
- contentsLayer->invalidate();
- addRepaintRect(contentsRect());
- }
-}
-
-void GraphicsLayerChromium::setNeedsDisplay()
-{
- if (drawsContent()) {
- m_layer->layer()->invalidate();
- addRepaintRect(FloatRect(FloatPoint(), m_size));
- if (m_linkHighlight)
- m_linkHighlight->invalidate();
- }
-}
-
-void GraphicsLayerChromium::setNeedsDisplayInRect(const FloatRect& rect)
-{
- if (drawsContent()) {
- m_layer->layer()->invalidateRect(rect);
- addRepaintRect(rect);
- if (m_linkHighlight)
- m_linkHighlight->invalidate();
- }
-}
-
-void GraphicsLayerChromium::setContentsRect(const IntRect& rect)
-{
- if (rect == m_contentsRect)
- return;
-
- GraphicsLayer::setContentsRect(rect);
- updateContentsRect();
-}
-
-void GraphicsLayerChromium::setContentsToImage(Image* image)
-{
- bool childrenChanged = false;
- NativeImageSkia* nativeImage = image ? image->nativeImageForCurrentFrame() : 0;
- if (nativeImage) {
- if (m_contentsLayerPurpose != ContentsLayerForImage) {
- m_imageLayer = adoptPtr(Platform::current()->compositorSupport()->createImageLayer());
- registerContentsLayer(m_imageLayer->layer());
-
- setupContentsLayer(m_imageLayer->layer());
- m_contentsLayerPurpose = ContentsLayerForImage;
- childrenChanged = true;
- }
- m_imageLayer->setBitmap(nativeImage->bitmap());
- m_imageLayer->layer()->setOpaque(image->isBitmapImage() && !image->currentFrameHasAlpha());
- updateContentsRect();
- } else {
- if (m_imageLayer) {
- childrenChanged = true;
-
- unregisterContentsLayer(m_imageLayer->layer());
- m_imageLayer.clear();
- }
- // The old contents layer will be removed via updateChildList.
- m_contentsLayer = 0;
- }
-
- if (childrenChanged)
- updateChildList();
-}
-
-static HashSet<int>* s_registeredLayerSet;
-
-void GraphicsLayerChromium::registerContentsLayer(WebLayer* layer)
-{
- if (!s_registeredLayerSet)
- s_registeredLayerSet = new HashSet<int>;
- if (s_registeredLayerSet->contains(layer->id()))
- CRASH();
- s_registeredLayerSet->add(layer->id());
-}
-
-void GraphicsLayerChromium::unregisterContentsLayer(WebLayer* layer)
-{
- ASSERT(s_registeredLayerSet);
- if (!s_registeredLayerSet->contains(layer->id()))
- CRASH();
- s_registeredLayerSet->remove(layer->id());
-}
-
-void GraphicsLayerChromium::clearContentsLayerIfUnregistered()
-{
- if (!m_contentsLayerId || s_registeredLayerSet->contains(m_contentsLayerId))
- return;
-
- m_contentsLayer = 0;
- m_contentsLayerId = 0;
-}
-
-WebLayer* GraphicsLayerChromium::contentsLayerIfRegistered()
-{
- clearContentsLayerIfUnregistered();
- return m_contentsLayer;
-}
-
-void GraphicsLayerChromium::setContentsToCanvas(PlatformLayer* layer)
-{
- setContentsTo(ContentsLayerForCanvas, layer);
-}
-
-void GraphicsLayerChromium::setContentsToMedia(PlatformLayer* layer)
-{
- setContentsTo(ContentsLayerForVideo, layer);
-}
-
-void GraphicsLayerChromium::setContentsTo(ContentsLayerPurpose purpose, WebLayer* layer)
-{
- bool childrenChanged = false;
- if (layer) {
- ASSERT(s_registeredLayerSet);
- if (!s_registeredLayerSet->contains(layer->id()))
- CRASH();
- if (m_contentsLayerId != layer->id()) {
- setupContentsLayer(layer);
- m_contentsLayerPurpose = purpose;
- childrenChanged = true;
- }
- updateContentsRect();
- } else {
- if (m_contentsLayer) {
- childrenChanged = true;
-
- // The old contents layer will be removed via updateChildList.
- m_contentsLayer = 0;
- }
- }
-
- if (childrenChanged)
- updateChildList();
-}
-
-bool GraphicsLayerChromium::addAnimation(const KeyframeValueList& values, const IntSize& boxSize, const Animation* animation, const String& animationName, double timeOffset)
-{
- platformLayer()->setAnimationDelegate(this);
-
- int animationId = 0;
-
- if (m_animationIdMap.contains(animationName))
- animationId = m_animationIdMap.get(animationName);
-
- OwnPtr<WebAnimation> toAdd(createWebAnimation(values, animation, animationId, timeOffset, boxSize));
-
- if (toAdd) {
- animationId = toAdd->id();
- m_animationIdMap.set(animationName, animationId);
-
- // Remove any existing animations with the same animation id and target property.
- platformLayer()->removeAnimation(animationId, toAdd->targetProperty());
- return platformLayer()->addAnimation(toAdd.get());
- }
-
- return false;
-}
-
-void GraphicsLayerChromium::pauseAnimation(const String& animationName, double timeOffset)
-{
- if (m_animationIdMap.contains(animationName))
- platformLayer()->pauseAnimation(m_animationIdMap.get(animationName), timeOffset);
-}
-
-void GraphicsLayerChromium::removeAnimation(const String& animationName)
-{
- if (m_animationIdMap.contains(animationName))
- platformLayer()->removeAnimation(m_animationIdMap.get(animationName));
-}
-
-void GraphicsLayerChromium::suspendAnimations(double wallClockTime)
-{
- // |wallClockTime| is in the wrong time base. Need to convert here.
- // FIXME: find a more reliable way to do this.
- double monotonicTime = wallClockTime + monotonicallyIncreasingTime() - currentTime();
- platformLayer()->suspendAnimations(monotonicTime);
-}
-
-void GraphicsLayerChromium::resumeAnimations()
-{
- platformLayer()->resumeAnimations(monotonicallyIncreasingTime());
-}
-
-void GraphicsLayerChromium::setLinkHighlight(LinkHighlightClient* linkHighlight)
-{
- m_linkHighlight = linkHighlight;
- updateChildList();
-}
-
-PlatformLayer* GraphicsLayerChromium::platformLayer() const
-{
- return m_transformLayer ? m_transformLayer.get() : m_layer->layer();
-}
-
-void GraphicsLayerChromium::updateChildList()
-{
- WebLayer* childHost = m_transformLayer ? m_transformLayer.get() : m_layer->layer();
- childHost->removeAllChildren();
-
- clearContentsLayerIfUnregistered();
-
- if (m_transformLayer) {
- // Add the primary layer first. Even if we have negative z-order children, the primary layer always comes behind.
- childHost->addChild(m_layer->layer());
- } else if (m_contentsLayer) {
- // FIXME: add the contents layer in the correct order with negative z-order children.
- // This does not cause visible rendering issues because currently contents layers are only used
- // for replaced elements that don't have children.
- childHost->addChild(m_contentsLayer);
- }
-
- const Vector<GraphicsLayer*>& childLayers = children();
- size_t numChildren = childLayers.size();
- for (size_t i = 0; i < numChildren; ++i) {
- GraphicsLayerChromium* curChild = static_cast<GraphicsLayerChromium*>(childLayers[i]);
-
- childHost->addChild(curChild->platformLayer());
- }
-
- if (m_linkHighlight)
- childHost->addChild(m_linkHighlight->layer());
-
- if (m_transformLayer && m_contentsLayer) {
- // If we have a transform layer, then the contents layer is parented in the
- // primary layer (which is itself a child of the transform layer).
- m_layer->layer()->removeAllChildren();
- m_layer->layer()->addChild(m_contentsLayer);
- }
-}
-
-void GraphicsLayerChromium::updateLayerPosition()
-{
- platformLayer()->setPosition(m_position);
-}
-
-void GraphicsLayerChromium::updateLayerSize()
-{
- IntSize layerSize(m_size.width(), m_size.height());
- if (m_transformLayer) {
- m_transformLayer->setBounds(layerSize);
- m_layer->layer()->setPosition(FloatPoint());
- }
-
- m_layer->layer()->setBounds(layerSize);
-
- // Note that we don't resize m_contentsLayer-> It's up the caller to do that.
-}
-
-void GraphicsLayerChromium::updateAnchorPoint()
-{
- platformLayer()->setAnchorPoint(FloatPoint(m_anchorPoint.x(), m_anchorPoint.y()));
- platformLayer()->setAnchorPointZ(m_anchorPoint.z());
-}
-
-void GraphicsLayerChromium::updateTransform()
-{
- platformLayer()->setTransform(WebTransformationMatrix(m_transform));
-}
-
-void GraphicsLayerChromium::updateChildrenTransform()
-{
- platformLayer()->setSublayerTransform(WebTransformationMatrix(m_childrenTransform));
-}
-
-void GraphicsLayerChromium::updateMasksToBounds()
-{
- m_layer->layer()->setMasksToBounds(m_masksToBounds);
-}
-
-void GraphicsLayerChromium::updateLayerPreserves3D()
-{
- if (m_preserves3D && !m_transformLayer) {
- m_transformLayer = adoptPtr(Platform::current()->compositorSupport()->createLayer());
- m_transformLayer->setPreserves3D(true);
- m_transformLayer->setAnimationDelegate(this);
- m_layer->layer()->transferAnimationsTo(m_transformLayer.get());
-
- // Copy the position from this layer.
- updateLayerPosition();
- updateLayerSize();
- updateAnchorPoint();
- updateTransform();
- updateChildrenTransform();
-
- m_layer->layer()->setPosition(FloatPoint::zero());
-
- m_layer->layer()->setAnchorPoint(FloatPoint(0.5f, 0.5f));
- m_layer->layer()->setTransform(SkMatrix44());
-
- // Set the old layer to opacity of 1. Further down we will set the opacity on the transform layer.
- m_layer->layer()->setOpacity(1);
-
- // Move this layer to be a child of the transform layer.
- if (parent())
- parent()->platformLayer()->replaceChild(m_layer->layer(), m_transformLayer.get());
- m_transformLayer->addChild(m_layer->layer());
-
- updateChildList();
- } else if (!m_preserves3D && m_transformLayer) {
- // Replace the transformLayer in the parent with this layer.
- m_layer->layer()->removeFromParent();
- if (parent())
- parent()->platformLayer()->replaceChild(m_transformLayer.get(), m_layer->layer());
-
- m_layer->layer()->setAnimationDelegate(this);
- m_transformLayer->transferAnimationsTo(m_layer->layer());
-
- // Release the transform layer.
- m_transformLayer->setAnimationDelegate(0);
- m_transformLayer.clear();
-
- updateLayerPosition();
- updateLayerSize();
- updateAnchorPoint();
- updateTransform();
- updateChildrenTransform();
-
- updateChildList();
- }
-
- m_layer->layer()->setPreserves3D(m_preserves3D);
- platformLayer()->setOpacity(m_opacity);
- updateNames();
-}
-
-void GraphicsLayerChromium::updateLayerIsDrawable()
-{
- // For the rest of the accelerated compositor code, there is no reason to make a
- // distinction between drawsContent and contentsVisible. So, for m_layer->layer(), these two
- // flags are combined here. m_contentsLayer shouldn't receive the drawsContent flag
- // so it is only given contentsVisible.
-
- m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible);
- if (WebLayer* contentsLayer = contentsLayerIfRegistered())
- contentsLayer->setDrawsContent(m_contentsVisible);
-
- if (m_drawsContent) {
- m_layer->layer()->invalidate();
- if (m_linkHighlight)
- m_linkHighlight->invalidate();
- }
-}
-
-void GraphicsLayerChromium::updateLayerBackgroundColor()
-{
- WebLayer* contentsLayer = contentsLayerIfRegistered();
- if (!contentsLayer)
- return;
-
- // We never create the contents layer just for background color yet.
- if (m_backgroundColorSet)
- contentsLayer->setBackgroundColor(m_backgroundColor.rgb());
- else
- contentsLayer->setBackgroundColor(static_cast<RGBA32>(0));
-}
-
-void GraphicsLayerChromium::updateContentsVideo()
-{
- // FIXME: Implement
-}
-
-void GraphicsLayerChromium::updateContentsRect()
-{
- WebLayer* contentsLayer = contentsLayerIfRegistered();
- if (!contentsLayer)
- return;
-
- contentsLayer->setPosition(FloatPoint(m_contentsRect.x(), m_contentsRect.y()));
- contentsLayer->setBounds(IntSize(m_contentsRect.width(), m_contentsRect.height()));
-}
-
-void GraphicsLayerChromium::setupContentsLayer(WebLayer* contentsLayer)
-{
- m_contentsLayer = contentsLayer;
- m_contentsLayerId = m_contentsLayer->id();
-
- if (m_contentsLayer) {
- m_contentsLayer->setAnchorPoint(FloatPoint(0, 0));
- m_contentsLayer->setUseParentBackfaceVisibility(true);
-
- // It is necessary to call setDrawsContent as soon as we receive the new contentsLayer, for
- // the correctness of early exit conditions in setDrawsContent() and setContentsVisible().
- m_contentsLayer->setDrawsContent(m_contentsVisible);
-
- // Insert the content layer first. Video elements require this, because they have
- // shadow content that must display in front of the video.
- m_layer->layer()->insertChild(m_contentsLayer, 0);
- }
- updateNames();
-}
-
-void GraphicsLayerChromium::setAppliesPageScale(bool appliesScale)
-{
- m_layer->setBoundsContainPageScale(appliesScale);
-}
-
-bool GraphicsLayerChromium::appliesPageScale() const
-{
- return m_layer->boundsContainPageScale();
-}
-
-void GraphicsLayerChromium::paint(GraphicsContext& context, const IntRect& clip)
-{
- paintGraphicsLayerContents(context, clip);
-}
-
-void GraphicsLayerChromium::notifyAnimationStarted(double startTime)
-{
- if (m_client)
- m_client->notifyAnimationStarted(this, startTime);
-}
-
-void GraphicsLayerChromium::notifyAnimationFinished(double)
-{
- // Do nothing.
-}
-
-void GraphicsLayerChromium::didScroll()
-{
- if (m_scrollableArea)
- m_scrollableArea->scrollToOffsetWithoutAnimation(IntPoint(m_layer->layer()->scrollPosition()));
-}
-
-} // namespace WebCore
-
-#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.h b/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.h
deleted file mode 100644
index f332e9444..000000000
--- a/Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.h
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Copyright (C) 2010 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GraphicsLayerChromium_h
-#define GraphicsLayerChromium_h
-
-#if USE(ACCELERATED_COMPOSITING)
-
-#include "GraphicsContext.h"
-#include "GraphicsLayer.h"
-#include "OpaqueRectTrackingContentLayerDelegate.h"
-
-#include <public/WebAnimationDelegate.h>
-#include <public/WebContentLayer.h>
-#include <public/WebImageLayer.h>
-#include <public/WebLayer.h>
-#include <public/WebLayerScrollClient.h>
-#include <wtf/HashMap.h>
-
-namespace WebCore {
-
-class Path;
-class ScrollableArea;
-
-class LinkHighlightClient {
-public:
- virtual void invalidate() = 0;
- virtual void clearCurrentGraphicsLayer() = 0;
- virtual WebKit::WebLayer* layer() = 0;
-
-protected:
- virtual ~LinkHighlightClient() { }
-};
-
-class GraphicsLayerChromium : public GraphicsLayer, public GraphicsContextPainter, public WebKit::WebAnimationDelegate, public WebKit::WebLayerScrollClient {
-public:
- GraphicsLayerChromium(GraphicsLayerClient*);
- virtual ~GraphicsLayerChromium();
-
- virtual void willBeDestroyed() OVERRIDE;
-
- virtual void setName(const String&);
-
- virtual bool setChildren(const Vector<GraphicsLayer*>&);
- virtual void addChild(GraphicsLayer*);
- virtual void addChildAtIndex(GraphicsLayer*, int index);
- virtual void addChildAbove(GraphicsLayer*, GraphicsLayer* sibling);
- virtual void addChildBelow(GraphicsLayer*, GraphicsLayer* sibling);
- virtual bool replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild);
-
- virtual void removeFromParent();
-
- virtual void setPosition(const FloatPoint&);
- virtual void setAnchorPoint(const FloatPoint3D&);
- virtual void setSize(const FloatSize&);
-
- virtual void setTransform(const TransformationMatrix&);
-
- virtual void setChildrenTransform(const TransformationMatrix&);
-
- virtual void setPreserves3D(bool);
- virtual void setMasksToBounds(bool);
- virtual void setDrawsContent(bool);
- virtual void setContentsVisible(bool);
- virtual void setMaskLayer(GraphicsLayer*);
-
- virtual void setBackgroundColor(const Color&);
- virtual void clearBackgroundColor();
-
- virtual void setContentsOpaque(bool);
- virtual void setBackfaceVisibility(bool);
-
- virtual void setReplicatedByLayer(GraphicsLayer*);
-
- virtual void setOpacity(float);
-
- // Returns true if filter can be rendered by the compositor
- virtual bool setFilters(const FilterOperations&);
- void setBackgroundFilters(const FilterOperations&);
-
- virtual void setNeedsDisplay();
- virtual void setNeedsDisplayInRect(const FloatRect&);
- virtual void setContentsNeedsDisplay();
-
- virtual void setContentsRect(const IntRect&);
-
- static void registerContentsLayer(WebKit::WebLayer*);
- static void unregisterContentsLayer(WebKit::WebLayer*);
-
- virtual void setContentsToImage(Image*);
- virtual void setContentsToMedia(PlatformLayer*);
- virtual void setContentsToCanvas(PlatformLayer*);
- virtual bool hasContentsLayer() const { return m_contentsLayer; }
-
- virtual bool addAnimation(const KeyframeValueList&, const IntSize& boxSize, const Animation*, const String&, double timeOffset);
- virtual void pauseAnimation(const String& animationName, double timeOffset);
- virtual void removeAnimation(const String& animationName);
- virtual void suspendAnimations(double wallClockTime);
- virtual void resumeAnimations();
-
- void setLinkHighlight(LinkHighlightClient*);
- // Next function for testing purposes.
- LinkHighlightClient* linkHighlight() { return m_linkHighlight; }
-
- virtual WebKit::WebLayer* platformLayer() const;
-
- virtual void setAppliesPageScale(bool appliesScale) OVERRIDE;
- virtual bool appliesPageScale() const OVERRIDE;
-
- void setScrollableArea(ScrollableArea* scrollableArea) { m_scrollableArea = scrollableArea; }
- ScrollableArea* scrollableArea() const { return m_scrollableArea; }
-
- // GraphicsContextPainter implementation.
- virtual void paint(GraphicsContext&, const IntRect& clip) OVERRIDE;
-
- // WebAnimationDelegate implementation.
- virtual void notifyAnimationStarted(double startTime) OVERRIDE;
- virtual void notifyAnimationFinished(double finishTime) OVERRIDE;
-
- // WebLayerScrollClient implementation.
- virtual void didScroll() OVERRIDE;
-
- WebKit::WebContentLayer* contentLayer() const { return m_layer.get(); }
-
- // Exposed for tests.
- WebKit::WebLayer* contentsLayer() const { return m_contentsLayer; }
-
-private:
- void updateNames();
- void updateChildList();
- void updateLayerPosition();
- void updateLayerSize();
- void updateAnchorPoint();
- void updateTransform();
- void updateChildrenTransform();
- void updateMasksToBounds();
- void updateLayerPreserves3D();
- void updateLayerIsDrawable();
- void updateLayerBackgroundColor();
-
- void updateContentsImage();
- void updateContentsVideo();
- void updateContentsRect();
-
- enum ContentsLayerPurpose {
- NoContentsLayer = 0,
- ContentsLayerForImage,
- ContentsLayerForVideo,
- ContentsLayerForCanvas,
- };
-
- void setContentsTo(ContentsLayerPurpose, WebKit::WebLayer*);
- void setupContentsLayer(WebKit::WebLayer*);
- void clearContentsLayerIfUnregistered();
- WebKit::WebLayer* contentsLayerIfRegistered();
-
- String m_nameBase;
-
- OwnPtr<WebKit::WebContentLayer> m_layer;
- OwnPtr<WebKit::WebLayer> m_transformLayer;
- OwnPtr<WebKit::WebImageLayer> m_imageLayer;
- WebKit::WebLayer* m_contentsLayer;
- // We don't have ownership of m_contentsLayer, but we do want to know if a given layer is the
- // same as our current layer in setContentsTo(). Since m_contentsLayer may be deleted at this point,
- // we stash an ID away when we know m_contentsLayer is alive and use that for comparisons from that point
- // on.
- int m_contentsLayerId;
-
- LinkHighlightClient* m_linkHighlight;
-
- OwnPtr<OpaqueRectTrackingContentLayerDelegate> m_opaqueRectTrackingContentLayerDelegate;
-
- ContentsLayerPurpose m_contentsLayerPurpose;
- bool m_contentsLayerHasBackgroundColor : 1;
- bool m_inSetChildren;
-
- typedef HashMap<String, int> AnimationIdMap;
- AnimationIdMap m_animationIdMap;
-
- ScrollableArea* m_scrollableArea;
-};
-
-} // namespace WebCore
-
-#endif // USE(ACCELERATED_COMPOSITING)
-
-#endif
diff --git a/Source/WebCore/platform/graphics/chromium/IconChromium.cpp b/Source/WebCore/platform/graphics/chromium/IconChromium.cpp
deleted file mode 100644
index 6427ded23..000000000
--- a/Source/WebCore/platform/graphics/chromium/IconChromium.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2011, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Icon.h"
-
-#include "GraphicsContext.h"
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
-
-Icon::Icon(PassRefPtr<PlatformIcon> icon)
- : m_icon(icon)
-{
-}
-
-Icon::~Icon()
-{
-}
-
-void Icon::paint(GraphicsContext* context, const IntRect& rect)
-{
- if (context->paintingDisabled())
- return;
-
- // An Icon doesn't know the color space of the file upload control.
- // So use ColorSpaceDeviceRGB.
- context->drawImage(m_icon.get(), ColorSpaceDeviceRGB, rect);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/chromium/IconChromiumAndroid.cpp b/Source/WebCore/platform/graphics/chromium/IconChromiumAndroid.cpp
deleted file mode 100644
index 6e28a237d..000000000
--- a/Source/WebCore/platform/graphics/chromium/IconChromiumAndroid.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Icon.h"
-
-#include "GraphicsContext.h"
-#include "NotImplemented.h"
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
-
-Icon::Icon(PassRefPtr<PlatformIcon> icon)
- : m_icon(icon)
-{
-}
-
-Icon::~Icon()
-{
-}
-
-void Icon::paint(GraphicsContext*, const IntRect&)
-{
- notImplemented();
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/chromium/ImageBufferDataSkia.h b/Source/WebCore/platform/graphics/chromium/ImageBufferDataSkia.h
deleted file mode 100644
index 160eb0faa..000000000
--- a/Source/WebCore/platform/graphics/chromium/ImageBufferDataSkia.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "PlatformContextSkia.h"
-
-#include "skia/ext/platform_canvas.h"
-
-namespace WebCore {
-
-#if USE(ACCELERATED_COMPOSITING)
-class Canvas2DLayerBridge;
-#endif
-
-class ImageBufferData {
-public:
- ImageBufferData(const IntSize&);
-
- void reportMemoryUsage(MemoryObjectInfo*) const;
-
- OwnPtr<SkCanvas> m_canvas;
- PlatformContextSkia m_platformContext;
-#if USE(ACCELERATED_COMPOSITING)
- OwnPtr<Canvas2DLayerBridge> m_layerBridge;
-#endif
-};
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/chromium/ImageChromium.cpp b/Source/WebCore/platform/graphics/chromium/ImageChromium.cpp
deleted file mode 100644
index b9afa9edb..000000000
--- a/Source/WebCore/platform/graphics/chromium/ImageChromium.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2008-2010, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "BitmapImage.h"
-#include "Image.h"
-#include "SharedBuffer.h"
-
-#include <public/Platform.h>
-#include <public/WebData.h>
-
-namespace WebCore {
-
-// Other Image methods are implemented in ImageSkia.cpp
-
-PassRefPtr<Image> Image::loadPlatformResource(const char *name)
-{
- const WebKit::WebData& resource = WebKit::Platform::current()->loadResource(name);
- if (resource.isEmpty())
- return Image::nullImage();
-
- RefPtr<Image> image = BitmapImage::create();
- image->setData(resource, true);
- return image.release();
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/chromium/ImageDecodingStore.cpp b/Source/WebCore/platform/graphics/chromium/ImageDecodingStore.cpp
deleted file mode 100644
index 489fddc42..000000000
--- a/Source/WebCore/platform/graphics/chromium/ImageDecodingStore.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ImageDecodingStore.h"
-
-#include "ImageFrameGenerator.h"
-#include "ScaledImageFragment.h"
-#include "SharedBuffer.h"
-
-namespace WebCore {
-
-namespace {
-
-ImageDecodingStore* s_instance = 0;
-
-static void setInstance(ImageDecodingStore* imageDecodingStore)
-{
- delete s_instance;
- s_instance = imageDecodingStore;
-}
-
-} // namespace
-
-ImageDecodingStore::ImageDecodingStore()
-{
-}
-
-ImageDecodingStore::~ImageDecodingStore()
-{
-}
-
-ImageDecodingStore* ImageDecodingStore::instance()
-{
- return s_instance;
-}
-
-void ImageDecodingStore::initializeOnce()
-{
- setInstance(ImageDecodingStore::create().leakPtr());
-}
-
-void ImageDecodingStore::shutdown()
-{
- setInstance(0);
-}
-
-const ScaledImageFragment* ImageDecodingStore::lockCompleteCache(const ImageFrameGenerator* generator, const SkISize& scaledSize)
-{
- CacheEntry* cacheEntry = 0;
- {
- MutexLocker lock(m_mutex);
- CacheMap::iterator iter = m_cacheMap.find(std::make_pair(generator, scaledSize));
- if (iter == m_cacheMap.end())
- return 0;
- cacheEntry = iter->value;
- if (!cacheEntry->cachedImage->isComplete())
- return 0;
-
- // Increment use count such that it doesn't get evicted.
- ++cacheEntry->useCount;
- }
- cacheEntry->cachedImage->bitmap().lockPixels();
- return cacheEntry->cachedImage.get();
-}
-
-const ScaledImageFragment* ImageDecodingStore::lockIncompleteCache(const ImageFrameGenerator* generator, const SkISize& scaledSize)
-{
- // TODO: Implement.
- return 0;
-}
-
-void ImageDecodingStore::unlockCache(const ImageFrameGenerator* generator, const ScaledImageFragment* cachedImage)
-{
- cachedImage->bitmap().unlockPixels();
- if (!cachedImage->isComplete()) {
- // Delete the image if it is incomplete. It was never stored in cache.
- delete cachedImage;
- return;
- }
-
- MutexLocker lock(m_mutex);
- CacheMap::iterator iter = m_cacheMap.find(std::make_pair(generator, cachedImage->scaledSize()));
- ASSERT(iter != m_cacheMap.end());
-
- CacheEntry* cacheEntry = iter->value;
- --cacheEntry->useCount;
- ASSERT(cacheEntry->useCount >= 0);
-}
-
-const ScaledImageFragment* ImageDecodingStore::insertAndLockCache(const ImageFrameGenerator* generator, PassOwnPtr<ScaledImageFragment> image)
-{
- // Prune old cache entries to give space for the new one.
- prune();
-
- // Lock the underlying SkBitmap to prevent it from being purged.
- image->bitmap().lockPixels();
-
- if (!image->isComplete()) {
- // Incomplete image is not stored in the cache and deleted after use.
- // See unlockCache().
- // TODO: We should allow incomplete images to be stored together with
- // the corresponding ImageDecoder.
- return image.leakPtr();
- }
-
- ScaledImageFragment* cachedImage = image.get();
- OwnPtr<CacheEntry> newCacheEntry = CacheEntry::createAndUse(image);
-
- CacheIdentifier key = std::make_pair(generator, cachedImage->scaledSize());
- MutexLocker lock(m_mutex);
- ASSERT(!m_cacheMap.contains(key));
-
- // m_cacheMap is used for indexing and quick lookup of a cached image.
- // m_cacheEntries is used to support LRU operations to reorder cache
- // entries quickly. It also owns cached images.
- m_cacheMap.add(key, newCacheEntry.get());
- m_cacheEntries.append(newCacheEntry.release());
- return cachedImage;
-}
-
-void ImageDecodingStore::prune()
-{
- // TODO: Implement.
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/chromium/ImageDecodingStore.h b/Source/WebCore/platform/graphics/chromium/ImageDecodingStore.h
deleted file mode 100644
index 0aea2e969..000000000
--- a/Source/WebCore/platform/graphics/chromium/ImageDecodingStore.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ImageDecodingStore_h
-#define ImageDecodingStore_h
-
-#include "ScaledImageFragment.h"
-#include "SkTypes.h"
-#include "SkSize.h"
-#include "SkSizeHash.h"
-
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/ThreadingPrimitives.h>
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-class ImageDecoder;
-class ImageFrameGenerator;
-class SharedBuffer;
-
-class ImageDecodingStore {
-public:
- static PassOwnPtr<ImageDecodingStore> create() { return adoptPtr(new ImageDecodingStore); }
- ~ImageDecodingStore();
-
- static ImageDecodingStore* instance();
- static void initializeOnce();
- static void shutdown();
-
- const ScaledImageFragment* lockCompleteCache(const ImageFrameGenerator*, const SkISize& scaledSize);
- const ScaledImageFragment* lockIncompleteCache(const ImageFrameGenerator*, const SkISize& scaledSize);
- void unlockCache(const ImageFrameGenerator*, const ScaledImageFragment*);
- const ScaledImageFragment* insertAndLockCache(const ImageFrameGenerator*, PassOwnPtr<ScaledImageFragment>);
-
-private:
- struct CacheEntry {
- static PassOwnPtr<CacheEntry> create() { return adoptPtr(new CacheEntry()); }
- static PassOwnPtr<CacheEntry> createAndUse(PassOwnPtr<ScaledImageFragment> image) { return adoptPtr(new CacheEntry(image, 1)); }
-
- CacheEntry()
- : useCount(0)
- {
- }
-
- CacheEntry(PassOwnPtr<ScaledImageFragment> image, int count)
- : cachedImage(image)
- , useCount(count)
- {
- }
-
- ~CacheEntry()
- {
- ASSERT(!useCount);
- }
-
- OwnPtr<ScaledImageFragment> cachedImage;
- int useCount;
- };
-
- ImageDecodingStore();
- void prune();
-
- Vector<OwnPtr<CacheEntry> > m_cacheEntries;
-
- typedef std::pair<const ImageFrameGenerator*, SkISize> CacheIdentifier;
- typedef HashMap<CacheIdentifier, CacheEntry*> CacheMap;
- CacheMap m_cacheMap;
-
- // Protect concurrent access to all instances of CacheEntry stored in m_cacheEntries and
- // m_cacheMap as well as the containers.
- Mutex m_mutex;
-};
-
-} // namespace WebCore
-
-#endif
diff --git a/Source/WebCore/platform/graphics/chromium/ImageFrameGenerator.cpp b/Source/WebCore/platform/graphics/chromium/ImageFrameGenerator.cpp
deleted file mode 100644
index 220a57d45..000000000
--- a/Source/WebCore/platform/graphics/chromium/ImageFrameGenerator.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "ImageFrameGenerator.h"
-
-#include "ImageDecoder.h"
-#include "ImageDecodingStore.h"
-#include "ScaledImageFragment.h"
-#include "SharedBuffer.h"
-
-#include "skia/ext/image_operations.h"
-
-namespace WebCore {
-
-namespace {
-
-skia::ImageOperations::ResizeMethod resizeMethod()
-{
- return skia::ImageOperations::RESIZE_LANCZOS3;
-}
-
-} // namespace
-
-ImageFrameGenerator::ImageFrameGenerator(const SkISize& fullSize, PassRefPtr<SharedBuffer> data, bool allDataReceived)
- : m_fullSize(fullSize)
- , m_allDataReceived(false)
-{
- setData(data, allDataReceived);
-}
-
-ImageFrameGenerator::~ImageFrameGenerator()
-{
- // TODO: Call ImageDecodingStore to remove all cache entries indexed
- // by this object.
-}
-
-void ImageFrameGenerator::setData(PassRefPtr<SharedBuffer> data, bool allDataReceived)
-{
- // FIXME: Doing a full copy is expensive, instead copy only new data.
- RefPtr<SharedBuffer> dataCopy = data->copy();
-
- MutexLocker lock(m_dataMutex);
- m_data = dataCopy;
- m_allDataReceived = allDataReceived;
-}
-
-const ScaledImageFragment* ImageFrameGenerator::decodeAndScale(const SkISize& scaledSize)
-{
- // Prevents concurrent decode or scale operations on the same image data.
- // Multiple LazyDecodingPixelRefs can call this method at the same time.
- MutexLocker lock(m_decodeMutex);
- const ScaledImageFragment* cachedImage = 0;
-
- cachedImage = tryToLockCache(scaledSize);
- if (cachedImage)
- return cachedImage;
-
- cachedImage = tryToScale(0, scaledSize);
- if (cachedImage)
- return cachedImage;
-
- cachedImage = tryToDecodeAndScale(scaledSize);
- if (cachedImage)
- return cachedImage;
- return 0;
-}
-
-const ScaledImageFragment* ImageFrameGenerator::tryToLockCache(const SkISize& scaledSize)
-{
- return ImageDecodingStore::instance()->lockCompleteCache(this, scaledSize);
-}
-
-const ScaledImageFragment* ImageFrameGenerator::tryToScale(const ScaledImageFragment* fullSizeImage, const SkISize& scaledSize)
-{
- // If the requested scaled size is the same as the full size then exit
- // early. This saves a cache lookup.
- if (scaledSize == m_fullSize)
- return 0;
-
- if (!fullSizeImage)
- fullSizeImage = ImageDecodingStore::instance()->lockCompleteCache(this, m_fullSize);
-
- if (!fullSizeImage)
- return 0;
-
- SkBitmap scaledBitmap = skia::ImageOperations::Resize(
- fullSizeImage->bitmap(), resizeMethod(), scaledSize.width(), scaledSize.height());
- OwnPtr<ScaledImageFragment> scaledImage = ScaledImageFragment::create(scaledSize, scaledBitmap, fullSizeImage->isComplete());
-
- ImageDecodingStore::instance()->unlockCache(this, fullSizeImage);
- return ImageDecodingStore::instance()->insertAndLockCache(this, scaledImage.release());
-}
-
-const ScaledImageFragment* ImageFrameGenerator::tryToDecodeAndScale(const SkISize& scaledSize)
-{
- RefPtr<SharedBuffer> data;
- bool allDataReceived = false;
- {
- MutexLocker lock(m_dataMutex);
-
- // FIXME: We should do a shallow copy instead. Now we're restricted by the API of SharedBuffer.
- data = m_data->copy();
- allDataReceived = m_allDataReceived;
- }
-
- OwnPtr<ImageDecoder> decoder(adoptPtr(ImageDecoder::create(*data.get(), ImageSource::AlphaPremultiplied, ImageSource::GammaAndColorProfileApplied)));
- if (!decoder && m_imageDecoderFactory)
- decoder = m_imageDecoderFactory->create();
- if (!decoder)
- return 0;
-
- decoder->setData(data.get(), allDataReceived);
- ImageFrame* frame = decoder->frameBufferAtIndex(0);
- if (!frame || frame->status() == ImageFrame::FrameEmpty)
- return 0;
-
- bool isComplete = frame->status() == ImageFrame::FrameComplete;
- SkBitmap fullSizeBitmap = frame->getSkBitmap();
- ASSERT(fullSizeBitmap.width() == m_fullSize.width() && fullSizeBitmap.height() == m_fullSize.height());
-
- const ScaledImageFragment* fullSizeImage = ImageDecodingStore::instance()->insertAndLockCache(
- this, ScaledImageFragment::create(m_fullSize, fullSizeBitmap, isComplete));
-
- if (m_fullSize == scaledSize)
- return fullSizeImage;
- return tryToScale(fullSizeImage, scaledSize);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/chromium/ImageFrameGenerator.h b/Source/WebCore/platform/graphics/chromium/ImageFrameGenerator.h
deleted file mode 100644
index 0831c4498..000000000
--- a/Source/WebCore/platform/graphics/chromium/ImageFrameGenerator.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ImageFrameGenerator_h
-#define ImageFrameGenerator_h
-
-#include "SkTypes.h"
-#include "SkBitmap.h"
-#include "SkSize.h"
-#include <wtf/PassOwnPtr.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-#include <wtf/ThreadSafeRefCounted.h>
-#include <wtf/ThreadingPrimitives.h>
-
-namespace WebCore {
-
-class ImageDecoder;
-class ScaledImageFragment;
-class SharedBuffer;
-
-class ImageDecoderFactory {
-public:
- virtual ~ImageDecoderFactory() { }
- virtual PassOwnPtr<ImageDecoder> create() = 0;
-};
-
-class ImageFrameGenerator : public ThreadSafeRefCounted<ImageFrameGenerator> {
-public:
- static PassRefPtr<ImageFrameGenerator> create(const SkISize& fullSize, PassRefPtr<SharedBuffer> data, bool allDataReceived)
- {
- return adoptRef(new ImageFrameGenerator(fullSize, data, allDataReceived));
- }
-
- ImageFrameGenerator(const SkISize& fullSize, PassRefPtr<SharedBuffer>, bool allDataReceived);
- ~ImageFrameGenerator();
-
- const ScaledImageFragment* decodeAndScale(const SkISize& scaledSize);
-
- void setData(PassRefPtr<SharedBuffer>, bool allDataReceived);
-
- void setImageDecoderFactoryForTesting(PassOwnPtr<ImageDecoderFactory> factory) { m_imageDecoderFactory = factory; }
-
-private:
- // These methods are called while m_decodeMutex is locked.
- const ScaledImageFragment* tryToLockCache(const SkISize& scaledSize);
- const ScaledImageFragment* tryToScale(const ScaledImageFragment* fullSizeImage, const SkISize& scaledSize);
- const ScaledImageFragment* tryToDecodeAndScale(const SkISize& scaledSize);
-
- SkISize m_fullSize;
- RefPtr<SharedBuffer> m_data;
- bool m_allDataReceived;
-
- OwnPtr<ImageDecoderFactory> m_imageDecoderFactory;
-
- // Prevents multiple decode operations on the same data.
- Mutex m_decodeMutex;
-
- // Prevents concurrent access to m_data.
- Mutex m_dataMutex;
-};
-
-} // namespace WebCore
-
-#endif
diff --git a/Source/WebCore/platform/graphics/chromium/LazyDecodingPixelRef.cpp b/Source/WebCore/platform/graphics/chromium/LazyDecodingPixelRef.cpp
deleted file mode 100644
index 555266362..000000000
--- a/Source/WebCore/platform/graphics/chromium/LazyDecodingPixelRef.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "LazyDecodingPixelRef.h"
-
-#include "ImageDecoder.h"
-#include "ImageDecodingStore.h"
-#include "ImageFrameGenerator.h"
-#include <wtf/MainThread.h>
-
-namespace WebCore {
-
-LazyDecodingPixelRef::LazyDecodingPixelRef(PassRefPtr<ImageFrameGenerator> frameGenerator, const SkISize& scaledSize, const SkIRect& scaledSubset)
- : SkPixelRef(0)
- , m_frameGenerator(frameGenerator)
- , m_scaledSize(scaledSize)
- , m_scaledSubset(scaledSubset)
- , m_lockedCachedImage(0)
-{
-}
-
-LazyDecodingPixelRef::~LazyDecodingPixelRef()
-{
-}
-
-bool LazyDecodingPixelRef::isScaled(const SkISize& fullSize) const
-{
- return fullSize != m_scaledSize;
-}
-
-bool LazyDecodingPixelRef::isClipped() const
-{
- return m_scaledSize.width() != m_scaledSubset.width() || m_scaledSize.height() != m_scaledSubset.height();
-}
-
-void* LazyDecodingPixelRef::onLockPixels(SkColorTable**)
-{
- m_mutex.lock();
- ASSERT(!m_lockedCachedImage);
-
- m_lockedCachedImage = ImageDecodingStore::instance()->lockCompleteCache(m_frameGenerator.get(), m_scaledSize);
-
- // Use ImageFrameGenerator to generate the image. It will lock the cache
- // entry for us.
- if (!m_lockedCachedImage)
- m_lockedCachedImage = m_frameGenerator->decodeAndScale(m_scaledSize);
-
- if (!m_lockedCachedImage)
- return 0;
-
- ASSERT(!m_lockedCachedImage->bitmap().isNull());
- ASSERT(m_lockedCachedImage->scaledSize() == m_scaledSize);
- return m_lockedCachedImage->bitmap().getAddr(m_scaledSubset.x(), m_scaledSubset.y());
-}
-
-void LazyDecodingPixelRef::onUnlockPixels()
-{
- if (m_lockedCachedImage) {
- ImageDecodingStore::instance()->unlockCache(m_frameGenerator.get(), m_lockedCachedImage);
- m_lockedCachedImage = 0;
- }
- m_mutex.unlock();
-}
-
-bool LazyDecodingPixelRef::onLockPixelsAreWritable() const
-{
- return false;
-}
-
-} // namespace WebKit
diff --git a/Source/WebCore/platform/graphics/chromium/LazyDecodingPixelRef.h b/Source/WebCore/platform/graphics/chromium/LazyDecodingPixelRef.h
deleted file mode 100644
index 9b2a46d4e..000000000
--- a/Source/WebCore/platform/graphics/chromium/LazyDecodingPixelRef.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LazyDecodingPixelRef_h
-#define LazyDecodingPixelRef_h
-
-#include "SkTypes.h"
-#include "SkFlattenableBuffers.h"
-#include "SkPixelRef.h"
-#include "SkRect.h"
-#include "SkSize.h"
-
-#include <wtf/RefPtr.h>
-#include <wtf/ThreadingPrimitives.h>
-
-namespace WebCore {
-
-class ImageFrameGenerator;
-class ScaledImageFragment;
-
-class LazyDecodingPixelRef : public SkPixelRef {
-public:
- LazyDecodingPixelRef(PassRefPtr<ImageFrameGenerator>, const SkISize& scaledSize, const SkIRect& scaledSubset);
- virtual ~LazyDecodingPixelRef();
-
- SK_DECLARE_UNFLATTENABLE_OBJECT()
-
- PassRefPtr<ImageFrameGenerator> frameGenerator() const { return m_frameGenerator; }
- bool isScaled(const SkISize& fullSize) const;
- bool isClipped() const;
-
-protected:
- // SkPixelRef implementation.
- virtual void* onLockPixels(SkColorTable**);
- virtual void onUnlockPixels();
- virtual bool onLockPixelsAreWritable() const;
-
-private:
- RefPtr<ImageFrameGenerator> m_frameGenerator;
- SkISize m_scaledSize;
- SkIRect m_scaledSubset;
-
- const ScaledImageFragment* m_lockedCachedImage;
- Mutex m_mutex;
-};
-
-} // namespace WebCore
-
-#endif // LazyDecodingPixelRef_h_
diff --git a/Source/WebCore/platform/graphics/chromium/MediaPlayerPrivateChromium.h b/Source/WebCore/platform/graphics/chromium/MediaPlayerPrivateChromium.h
deleted file mode 100644
index 534244d76..000000000
--- a/Source/WebCore/platform/graphics/chromium/MediaPlayerPrivateChromium.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef MediaPlayerPrivateChromium_h
-#define MediaPlayerPrivateChromium_h
-
-#if ENABLE(VIDEO)
-
-#include "MediaPlayerPrivate.h"
-
-namespace WebCore {
-
-class MediaPlayerPrivate {
-public:
- static void registerMediaEngine(MediaEngineRegistrar);
-};
-
-} // namespace WebCore
-
-#endif
-
-#endif // MediaPlayerPrivateChromium_h
diff --git a/Source/WebCore/platform/graphics/chromium/OpaqueRectTrackingContentLayerDelegate.cpp b/Source/WebCore/platform/graphics/chromium/OpaqueRectTrackingContentLayerDelegate.cpp
deleted file mode 100644
index 62edced17..000000000
--- a/Source/WebCore/platform/graphics/chromium/OpaqueRectTrackingContentLayerDelegate.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "OpaqueRectTrackingContentLayerDelegate.h"
-
-#include "AffineTransform.h"
-#include "FloatRect.h"
-#include "GraphicsContext.h"
-#include "IntRect.h"
-#include "PlatformContextSkia.h"
-#include <public/WebFloatRect.h>
-#include <public/WebRect.h>
-
-using WebKit::WebFloatRect;
-using WebKit::WebRect;
-
-namespace WebCore {
-
-OpaqueRectTrackingContentLayerDelegate::OpaqueRectTrackingContentLayerDelegate(GraphicsContextPainter* painter)
- : m_painter(painter)
- , m_opaque(false)
-{
-}
-
-OpaqueRectTrackingContentLayerDelegate::~OpaqueRectTrackingContentLayerDelegate()
-{
-}
-
-void OpaqueRectTrackingContentLayerDelegate::paintContents(SkCanvas* canvas, const WebRect& clip, bool canPaintLCDText, WebFloatRect& opaque)
-{
- PlatformContextSkia platformContext(canvas);
-#if defined(SK_SUPPORT_HINTING_SCALE_FACTOR)
- if (canvas)
- platformContext.setHintingScaleFactor(canvas->getTotalMatrix().getScaleX());
-#endif
- platformContext.setTrackOpaqueRegion(!m_opaque);
- // FIXME: Rename PlatformContextSkia::setDrawingToImageBuffer to setCanPaintLCDText.
- // I also suspect that a function on PlatformContextSkia is not really needed.
- // GraphicsContext::setAllowsFontSmoothing can be used for this purpose.
- platformContext.setDrawingToImageBuffer(!(canPaintLCDText && m_opaque));
- GraphicsContext context(&platformContext);
-
- // Record transform prior to painting, as all opaque tracking will be
- // relative to this current value.
- AffineTransform canvasToContentTransform = context.getCTM().inverse();
-
- m_painter->paint(context, clip);
-
- // Transform tracked opaque paints back to our layer's content space.
- ASSERT(canvasToContentTransform.isInvertible());
- ASSERT(canvasToContentTransform.preservesAxisAlignment());
- opaque = canvasToContentTransform.mapRect(platformContext.opaqueRegion().asRect());
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/chromium/OpaqueRectTrackingContentLayerDelegate.h b/Source/WebCore/platform/graphics/chromium/OpaqueRectTrackingContentLayerDelegate.h
deleted file mode 100644
index 451b647b1..000000000
--- a/Source/WebCore/platform/graphics/chromium/OpaqueRectTrackingContentLayerDelegate.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef OpaqueRectTrackingContentLayerDelegate_h
-#define OpaqueRectTrackingContentLayerDelegate_h
-
-#include <public/WebContentLayerClient.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/PassOwnPtr.h>
-
-class SkCanvas;
-
-namespace WebCore {
-
-class GraphicsContext;
-class IntRect;
-
-class GraphicsContextPainter {
-public:
- virtual void paint(GraphicsContext&, const IntRect& clip) = 0;
-
-protected:
- virtual ~GraphicsContextPainter() { }
-};
-
-class OpaqueRectTrackingContentLayerDelegate : public WebKit::WebContentLayerClient {
- WTF_MAKE_NONCOPYABLE(OpaqueRectTrackingContentLayerDelegate);
-public:
- explicit OpaqueRectTrackingContentLayerDelegate(GraphicsContextPainter*);
- virtual ~OpaqueRectTrackingContentLayerDelegate();
-
- // If we know that everything that will be painted through this delegate, then we don't bother
- // tracking opaqueness.
- void setOpaque(bool opaque) { m_opaque = opaque; }
-
- // WebKit::WebContentLayerClient implementation.
- virtual void paintContents(SkCanvas*, const WebKit::WebRect& clip, bool canPaintLCDText, WebKit::WebFloatRect& opaque) OVERRIDE;
-
-private:
- GraphicsContextPainter* m_painter;
- bool m_opaque;
-};
-
-}
-
-#endif // OpaqueRectTrackingContentLayerDelegate_h
diff --git a/Source/WebCore/platform/graphics/chromium/PlatformIcon.h b/Source/WebCore/platform/graphics/chromium/PlatformIcon.h
deleted file mode 100644
index b485917f2..000000000
--- a/Source/WebCore/platform/graphics/chromium/PlatformIcon.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef PlatformIcon_h
-#define PlatformIcon_h
-
-namespace WebCore {
-
-class Image;
-
-typedef Image PlatformIcon;
-
-} // namespace WebCore
-
-#endif // PlatformIcon_h
diff --git a/Source/WebCore/platform/graphics/chromium/ScaledImageFragment.h b/Source/WebCore/platform/graphics/chromium/ScaledImageFragment.h
deleted file mode 100644
index f0707b3ce..000000000
--- a/Source/WebCore/platform/graphics/chromium/ScaledImageFragment.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScaledImageFragment_h
-#define ScaledImageFragment_h
-
-#include "SkBitmap.h"
-#include "SkRect.h"
-#include "SkSize.h"
-
-#include <wtf/PassOwnPtr.h>
-
-namespace WebCore {
-
-// ScaledImageFragment is a scaled version of an image.
-class ScaledImageFragment {
-public:
- static PassOwnPtr<ScaledImageFragment> create(const SkISize& scaledSize, const SkBitmap& bitmap, bool isComplete)
- {
- return adoptPtr(new ScaledImageFragment(scaledSize, bitmap, isComplete));
- }
-
- ScaledImageFragment(const SkISize&, const SkBitmap&, bool isComplete);
- ~ScaledImageFragment();
-
- const SkISize& scaledSize() const { return m_scaledSize; }
- const SkBitmap& bitmap() const { return m_bitmap; }
- SkBitmap& bitmap() { return m_bitmap; }
- bool isComplete() const { return m_isComplete; }
-
-private:
- SkISize m_scaledSize;
- SkBitmap m_bitmap;
- bool m_isComplete;
-};
-
-} // namespace WebCore
-
-#endif
diff --git a/Source/WebCore/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp b/Source/WebCore/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp
deleted file mode 100644
index 289c1cd65..000000000
--- a/Source/WebCore/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All Rights Reserved.
- * Copyright (c) 2008, 2009, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SimpleFontData.h"
-
-#include "FloatRect.h"
-#include "Font.h"
-#include "FontCache.h"
-#include "FontDescription.h"
-#include "FontPlatformDataChromiumWin.h"
-#include "HWndDC.h"
-#include <mlang.h>
-#include <objidl.h>
-#include <unicode/uchar.h>
-#include <unicode/unorm.h>
-#include <wtf/MathExtras.h>
-
-namespace WebCore {
-
-void SimpleFontData::platformInit()
-{
- if (!m_platformData.size()) {
- m_fontMetrics.reset();
- m_avgCharWidth = 0;
- m_maxCharWidth = 0;
- return;
- }
-
- HWndDC dc(0);
- HGDIOBJ oldFont = SelectObject(dc, m_platformData.hfont());
-
- TEXTMETRIC textMetric = {0};
- if (!GetTextMetrics(dc, &textMetric)) {
- if (FontPlatformData::ensureFontLoaded(m_platformData.hfont())) {
- // Retry GetTextMetrics.
- // FIXME: Handle gracefully the error if this call also fails.
- // See http://crbug.com/6401.
- if (!GetTextMetrics(dc, &textMetric))
- LOG_ERROR("Unable to get the text metrics after second attempt");
- }
- }
-
- m_avgCharWidth = textMetric.tmAveCharWidth;
- m_maxCharWidth = textMetric.tmMaxCharWidth;
-
- // FIXME: Access ascent/descent/lineGap with floating point precision.
- float ascent = textMetric.tmAscent;
- float descent = textMetric.tmDescent;
- float lineGap = textMetric.tmExternalLeading;
- float xHeight = ascent * 0.56f; // Best guess for xHeight for non-Truetype fonts.
-
- OUTLINETEXTMETRIC outlineTextMetric;
- if (GetOutlineTextMetrics(dc, sizeof(outlineTextMetric), &outlineTextMetric) > 0) {
- m_fontMetrics.setUnitsPerEm(outlineTextMetric.otmEMSquare);
-
- // This is a TrueType font. We might be able to get an accurate xHeight.
- GLYPHMETRICS glyphMetrics = {0};
- MAT2 identityMatrix = {{0, 1}, {0, 0}, {0, 0}, {0, 1}};
- DWORD len = GetGlyphOutlineW(dc, 'x', GGO_METRICS, &glyphMetrics, 0, 0, &identityMatrix);
- if (len != GDI_ERROR && glyphMetrics.gmBlackBoxY > 0)
- xHeight = static_cast<float>(glyphMetrics.gmBlackBoxY);
- }
-
- m_fontMetrics.setAscent(ascent);
- m_fontMetrics.setDescent(descent);
- m_fontMetrics.setLineGap(lineGap);
- m_fontMetrics.setXHeight(xHeight);
- m_fontMetrics.setLineSpacing(ascent + descent + lineGap);
-
- SelectObject(dc, oldFont);
-}
-
-void SimpleFontData::platformCharWidthInit()
-{
- // charwidths are set in platformInit.
-}
-
-void SimpleFontData::platformDestroy()
-{
-}
-
-PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
-{
- LOGFONT winFont;
- GetObject(m_platformData.hfont(), sizeof(LOGFONT), &winFont);
- float scaledSize = scaleFactor * fontDescription.computedSize();
- winFont.lfHeight = -lroundf(scaledSize);
- HFONT hfont = CreateFontIndirect(&winFont);
- return SimpleFontData::create(FontPlatformData(hfont, scaledSize, m_platformData.orientation()), isCustomFont(), false);
-}
-
-bool SimpleFontData::containsCharacters(const UChar* characters, int length) const
-{
- // This used to be implemented with IMLangFontLink2, but since that code has
- // been disabled, this would always return false anyway.
- return false;
-}
-
-void SimpleFontData::determinePitch()
-{
- // TEXTMETRICS have this. Set m_treatAsFixedPitch based off that.
- HWndDC dc(0);
- HGDIOBJ oldFont = SelectObject(dc, m_platformData.hfont());
-
- // Yes, this looks backwards, but the fixed pitch bit is actually set if the font
- // is *not* fixed pitch. Unbelievable but true.
- TEXTMETRIC textMetric = {0};
- if (!GetTextMetrics(dc, &textMetric)) {
- if (FontPlatformData::ensureFontLoaded(m_platformData.hfont())) {
- // Retry GetTextMetrics.
- // FIXME: Handle gracefully the error if this call also fails.
- // See http://crbug.com/6401.
- if (!GetTextMetrics(dc, &textMetric))
- LOG_ERROR("Unable to get the text metrics after second attempt");
- }
- }
-
- m_treatAsFixedPitch = ((textMetric.tmPitchAndFamily & TMPF_FIXED_PITCH) == 0);
-
- SelectObject(dc, oldFont);
-}
-
-FloatRect SimpleFontData::platformBoundsForGlyph(Glyph glyph) const
-{
- HWndDC hdc(0);
- SetGraphicsMode(hdc, GM_ADVANCED);
- HGDIOBJ oldFont = SelectObject(hdc, m_platformData.hfont());
-
- GLYPHMETRICS gdiMetrics;
- static const MAT2 identity = { 0, 1, 0, 0, 0, 0, 0, 1 };
- if (GetGlyphOutline(hdc, glyph, GGO_METRICS | GGO_GLYPH_INDEX, &gdiMetrics, 0, 0, &identity) == -1) {
- if (FontPlatformData::ensureFontLoaded(m_platformData.hfont())) {
- // Retry GetTextMetrics.
- // FIXME: Handle gracefully the error if this call also fails.
- // See http://crbug.com/6401.
- if (GetGlyphOutline(hdc, glyph, GGO_METRICS | GGO_GLYPH_INDEX, &gdiMetrics, 0, 0, &identity) == -1)
- LOG_ERROR("Unable to get the glyph metrics after second attempt");
- }
- }
-
- SelectObject(hdc, oldFont);
-
- return FloatRect(gdiMetrics.gmptGlyphOrigin.x, -gdiMetrics.gmptGlyphOrigin.y,
- gdiMetrics.gmBlackBoxX, gdiMetrics.gmBlackBoxY);
-}
-
-float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
-{
- if (!m_platformData.size())
- return 0;
-
- HWndDC dc(0);
- HGDIOBJ oldFont = SelectObject(dc, m_platformData.hfont());
-
- int width = 0;
- if (!GetCharWidthI(dc, glyph, 1, 0, &width)) {
- // Ask the browser to preload the font and retry.
- if (FontPlatformData::ensureFontLoaded(m_platformData.hfont())) {
- // FIXME: Handle gracefully the error if this call also fails.
- // See http://crbug.com/6401.
- if (!GetCharWidthI(dc, glyph, 1, 0, &width))
- LOG_ERROR("Unable to get the char width after second attempt");
- }
- }
-
- SelectObject(dc, oldFont);
-
- return static_cast<float>(width);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/chromium/SkSizeHash.h b/Source/WebCore/platform/graphics/chromium/SkSizeHash.h
deleted file mode 100644
index 6f297cfdf..000000000
--- a/Source/WebCore/platform/graphics/chromium/SkSizeHash.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SkSizeHash_h
-#define SkSizeHash_h
-
-#include "SkScalar.h"
-#include "SkSize.h"
-
-#include <wtf/HashMap.h>
-
-namespace WTF {
-
-template<> struct IntHash<SkSize> {
- static unsigned hash(const SkSize& key) { return pairIntHash(key.width(), key.height()); }
- static bool equal(const SkSize& a, const SkSize& b) { return a == b; }
- static const bool safeToCompareToEmptyOrDeleted = true;
-};
-
-template<> struct DefaultHash<SkSize> {
- typedef IntHash<SkSize> Hash;
-};
-
-template<> struct HashTraits<SkSize> : GenericHashTraits<SkSize> {
- static const bool emptyValueIsZero = true;
- static const bool needsDestruction = false;
- static SkSize emptyValue() { return SkSize::Make(0, 0); }
- static void constructDeletedValue(SkSize& slot)
- {
- slot = SkSize::Make(-1, -1);
- }
- static bool isDeletedValue(const SkSize& value)
- {
- return value.width() == -1 && value.height() == -1;
- }
-};
-
-template<> struct IntHash<SkISize> {
- static unsigned hash(const SkISize& key) { return pairIntHash(key.width(), key.height()); }
- static bool equal(const SkISize& a, const SkISize& b) { return a == b; }
- static const bool safeToCompareToEmptyOrDeleted = true;
-};
-
-template<> struct DefaultHash<SkISize> {
- typedef IntHash<SkISize> Hash;
-};
-
-template<> struct HashTraits<SkISize> : GenericHashTraits<SkISize> {
- static const bool emptyValueIsZero = true;
- static const bool needsDestruction = false;
- static SkISize emptyValue() { return SkISize::Make(0, 0); }
- static void constructDeletedValue(SkISize& slot)
- {
- slot = SkISize::Make(-1, -1);
- }
- static bool isDeletedValue(const SkISize& value)
- {
- return value.width() == -1 && value.height() == -1;
- }
-};
-
-} // namespace WTF
-
-#endif // SkSizeHash_h
diff --git a/Source/WebCore/platform/graphics/chromium/TextureUploader.h b/Source/WebCore/platform/graphics/chromium/TextureUploader.h
deleted file mode 100644
index 0a861612e..000000000
--- a/Source/WebCore/platform/graphics/chromium/TextureUploader.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2012, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef TextureUploader_h
-#define TextureUploader_h
-
-#include "LayerTextureUpdater.h"
-
-namespace WebCore {
-
-class TextureUploader {
-public:
- struct Parameters {
- LayerTextureUpdater::Texture* texture;
- IntRect sourceRect;
- IntSize destOffset;
- };
-
- virtual ~TextureUploader() { }
-
- virtual bool isBusy() = 0;
- virtual void beginUploads() = 0;
- virtual void endUploads() = 0;
- virtual void uploadTexture(CCResourceProvider*, Parameters) = 0;
-};
-
-}
-
-#endif
diff --git a/Source/WebCore/platform/graphics/chromium/TransparencyWin.cpp b/Source/WebCore/platform/graphics/chromium/TransparencyWin.cpp
deleted file mode 100644
index 88c153ea8..000000000
--- a/Source/WebCore/platform/graphics/chromium/TransparencyWin.cpp
+++ /dev/null
@@ -1,515 +0,0 @@
-/*
- * Copyright (C) 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include <windows.h>
-
-#include "AffineTransform.h"
-#include "GraphicsContext.h"
-#include "ImageBuffer.h"
-#include "PlatformContextSkia.h"
-#include "SimpleFontData.h"
-#include "TransparencyWin.h"
-
-#include "SkColorPriv.h"
-#include "skia/ext/platform_canvas.h"
-
-namespace WebCore {
-
-namespace {
-
-// The maximum size in pixels of the buffer we'll keep around for drawing text
-// into. Buffers larger than this will be destroyed when we're done with them.
-const int maxCachedBufferPixelSize = 65536;
-
-inline const SkBitmap& bitmapForContext(const GraphicsContext& context)
-{
- return context.platformContext()->layerBitmap();
-}
-
-void compositeToCopy(const GraphicsContext& sourceLayers,
- GraphicsContext& destContext,
- const AffineTransform& matrix)
-{
- // Make a list of all devices. The iterator goes top-down, and we want
- // bottom-up. Note that each layer can also have an offset in canvas
- // coordinates, which is the (x, y) position.
- struct DeviceInfo {
- DeviceInfo(SkDevice* d, int lx, int ly)
- : device(d)
- , x(lx)
- , y(ly) {}
- SkDevice* device;
- int x;
- int y;
- };
- Vector<DeviceInfo> devices;
- SkCanvas* sourceCanvas = sourceLayers.platformContext()->canvas();
- SkCanvas::LayerIter iter(sourceCanvas, false);
- while (!iter.done()) {
- devices.append(DeviceInfo(iter.device(), iter.x(), iter.y()));
- iter.next();
- }
-
- // Create a temporary canvas for the compositing into the destination.
- SkBitmap* destBmp = const_cast<SkBitmap*>(&bitmapForContext(destContext));
- SkCanvas destCanvas(*destBmp);
- destCanvas.setMatrix(matrix);
-
- for (int i = devices.size() - 1; i >= 0; i--) {
- const SkBitmap& srcBmp = devices[i].device->accessBitmap(false);
-
- SkRect destRect;
- destRect.fLeft = devices[i].x;
- destRect.fTop = devices[i].y;
- destRect.fRight = destRect.fLeft + srcBmp.width();
- destRect.fBottom = destRect.fTop + srcBmp.height();
-
- destCanvas.drawBitmapRect(srcBmp, 0, destRect);
- }
-}
-
-} // namespace
-
-// If either of these pointers is non-null, both must be valid and point to
-// bitmaps of the same size.
-class TransparencyWin::OwnedBuffers {
-public:
- OwnedBuffers(const IntSize& size, bool needReferenceBuffer)
- {
- m_destBitmap = ImageBuffer::create(size, 1);
-
- if (needReferenceBuffer) {
- m_referenceBitmap.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height());
- m_referenceBitmap.allocPixels();
- m_referenceBitmap.eraseARGB(0, 0, 0, 0);
- }
- }
-
- ImageBuffer* destBitmap() { return m_destBitmap.get(); }
-
- // This bitmap will be empty if you don't specify needReferenceBuffer to the
- // constructor.
- SkBitmap* referenceBitmap() { return &m_referenceBitmap; }
-
- // Returns whether the current layer will fix a buffer of the given size.
- bool canHandleSize(const IntSize& size) const
- {
- return m_destBitmap->internalSize().width() >= size.width() && m_destBitmap->internalSize().height() >= size.height();
- }
-
-private:
- // The destination bitmap we're drawing into.
- OwnPtr<ImageBuffer> m_destBitmap;
-
- // This could be an ImageBuffer but this is an optimization. Since this is
- // only ever used as a reference, we don't need to make a full
- // PlatformCanvas using Skia on Windows. Just allocating a regular SkBitmap
- // is much faster since it's just a Malloc rather than a GDI call.
- SkBitmap m_referenceBitmap;
-};
-
-TransparencyWin::OwnedBuffers* TransparencyWin::m_cachedBuffers = 0;
-
-TransparencyWin::TransparencyWin()
- : m_destContext(0)
- , m_orgTransform()
- , m_layerMode(NoLayer)
- , m_transformMode(KeepTransform)
- , m_drawContext(0)
- , m_savedOnDrawContext(false)
- , m_layerBuffer(0)
- , m_referenceBitmap(0)
- , m_validLayer(false)
-{
-}
-
-TransparencyWin::~TransparencyWin()
-{
- // This should be false, since calling composite() is mandatory.
- ASSERT(!m_savedOnDrawContext);
-}
-
-void TransparencyWin::composite()
-{
- // Matches the save() in initializeNewTextContext (or the constructor for
- // SCALE) to put the context back into the same state we found it.
- if (m_savedOnDrawContext) {
- m_drawContext->restore();
- m_savedOnDrawContext = false;
- }
-
- switch (m_layerMode) {
- case NoLayer:
- break;
- case OpaqueCompositeLayer:
- case WhiteLayer:
- compositeOpaqueComposite();
- break;
- case TextComposite:
- compositeTextComposite();
- break;
- }
-}
-
-void TransparencyWin::init(GraphicsContext* dest,
- LayerMode layerMode,
- TransformMode transformMode,
- const IntRect& region)
-{
- m_destContext = dest;
- m_orgTransform = dest->getCTM();
- m_layerMode = layerMode;
- m_transformMode = transformMode;
- m_sourceRect = region;
-
- computeLayerSize();
- setupLayer();
- setupTransform(region);
-}
-
-void TransparencyWin::computeLayerSize()
-{
- if (m_transformMode == Untransform) {
- // The meaning of the "transformed" source rect is a little ambigous
- // here. The rest of the code doesn't care about it in the Untransform
- // case since we're using our own happy coordinate system. So we set it
- // to be the source rect since that matches how the code below actually
- // uses the variable: to determine how to translate things to account
- // for the offset of the layer.
- m_transformedSourceRect = m_sourceRect;
- } else if (m_transformMode == KeepTransform && m_layerMode != TextComposite) {
- // FIXME: support clipping for other modes
- IntRect clippedSourceRect = m_sourceRect;
- SkRect clipBounds;
- if (m_destContext->platformContext()->getClipBounds(&clipBounds)) {
- FloatRect clipRect(clipBounds.left(), clipBounds.top(), clipBounds.width(), clipBounds.height());
- clippedSourceRect.intersect(enclosingIntRect(clipRect));
- }
- m_transformedSourceRect = m_orgTransform.mapRect(clippedSourceRect);
- } else
- m_transformedSourceRect = m_orgTransform.mapRect(m_sourceRect);
-
- m_layerSize = IntSize(m_transformedSourceRect.width(), m_transformedSourceRect.height());
-}
-
-void TransparencyWin::setupLayer()
-{
- switch (m_layerMode) {
- case NoLayer:
- setupLayerForNoLayer();
- break;
- case OpaqueCompositeLayer:
- setupLayerForOpaqueCompositeLayer();
- break;
- case TextComposite:
- setupLayerForTextComposite();
- break;
- case WhiteLayer:
- setupLayerForWhiteLayer();
- break;
- }
-}
-
-void TransparencyWin::setupLayerForNoLayer()
-{
- m_drawContext = m_destContext; // Draw to the source context.
- m_validLayer = true;
-}
-
-void TransparencyWin::setupLayerForOpaqueCompositeLayer()
-{
- initializeNewContext();
- if (!m_validLayer)
- return;
-
- AffineTransform mapping;
- mapping.translate(-m_transformedSourceRect.x(), -m_transformedSourceRect.y());
- if (m_transformMode == Untransform){
- // Compute the inverse mapping from the canvas space to the
- // coordinate space of our bitmap.
- mapping *= m_orgTransform.inverse();
- }
- compositeToCopy(*m_destContext, *m_drawContext, mapping);
-
- // Save the reference layer so we can tell what changed.
- SkCanvas referenceCanvas(*m_referenceBitmap);
- referenceCanvas.drawBitmap(bitmapForContext(*m_drawContext), 0, 0);
- // Layer rect represents the part of the original layer.
-}
-
-void TransparencyWin::setupLayerForTextComposite()
-{
- ASSERT(m_transformMode == KeepTransform);
- // Fall through to filling with white.
- setupLayerForWhiteLayer();
-}
-
-void TransparencyWin::setupLayerForWhiteLayer()
-{
- initializeNewContext();
- if (!m_validLayer)
- return;
-
- m_drawContext->fillRect(IntRect(IntPoint(0, 0), m_layerSize), Color::white, ColorSpaceDeviceRGB);
- // Layer rect represents the part of the original layer.
-}
-
-void TransparencyWin::setupTransform(const IntRect& region)
-{
- switch (m_transformMode) {
- case KeepTransform:
- setupTransformForKeepTransform(region);
- break;
- case Untransform:
- setupTransformForUntransform();
- break;
- case ScaleTransform:
- setupTransformForScaleTransform();
- break;
- }
-}
-
-void TransparencyWin::setupTransformForKeepTransform(const IntRect& region)
-{
- if (!m_validLayer)
- return;
-
- if (m_layerMode != NoLayer) {
- // Need to save things since we're modifying the transform.
- m_drawContext->save();
- m_savedOnDrawContext = true;
-
- // Account for the fact that the layer may be offset from the
- // original. This only happens when we create a layer that has the
- // same coordinate space as the parent.
- AffineTransform xform;
- xform.translate(-m_transformedSourceRect.x(), -m_transformedSourceRect.y());
-
- // We're making a layer, so apply the old transform to the new one
- // so it's maintained. We know the new layer has the identity
- // transform now, we we can just multiply it.
- xform *= m_orgTransform;
- m_drawContext->concatCTM(xform);
- }
- m_drawRect = m_sourceRect;
-}
-
-void TransparencyWin::setupTransformForUntransform()
-{
- ASSERT(m_layerMode != NoLayer);
- // We now have a new layer with the identity transform, which is the
- // Untransformed space we'll use for drawing.
- m_drawRect = IntRect(IntPoint(0, 0), m_layerSize);
-}
-
-void TransparencyWin::setupTransformForScaleTransform()
-{
- if (!m_validLayer)
- return;
-
- if (m_layerMode == NoLayer) {
- // Need to save things since we're modifying the layer.
- m_drawContext->save();
- m_savedOnDrawContext = true;
-
- // Undo the transform on the current layer when we're re-using the
- // current one.
- m_drawContext->concatCTM(m_drawContext->getCTM().inverse());
-
- // We're drawing to the original layer with just a different size.
- m_drawRect = m_transformedSourceRect;
- } else {
- // Just go ahead and use the layer's coordinate space to draw into.
- // It will have the scaled size, and an identity transform loaded.
- m_drawRect = IntRect(IntPoint(0, 0), m_layerSize);
- }
-}
-
-void TransparencyWin::setTextCompositeColor(Color color)
-{
- m_textCompositeColor = color;
-}
-
-void TransparencyWin::initializeNewContext()
-{
- int pixelSize = m_layerSize.width() * m_layerSize.height();
- if (pixelSize <= 0)
- return;
-
- if (pixelSize > maxCachedBufferPixelSize) {
- // Create a 1-off buffer for drawing into. We only need the reference
- // buffer if we're making an OpaqueCompositeLayer.
- bool needReferenceBitmap = m_layerMode == OpaqueCompositeLayer;
- m_ownedBuffers = adoptPtr(new OwnedBuffers(m_layerSize, needReferenceBitmap));
- m_layerBuffer = m_ownedBuffers->destBitmap();
- if (!m_layerBuffer)
- return;
-
- m_drawContext = m_layerBuffer->context();
- if (needReferenceBitmap) {
- m_referenceBitmap = m_ownedBuffers->referenceBitmap();
- if (!m_referenceBitmap || !m_referenceBitmap->getPixels())
- return;
- }
- m_validLayer = true;
- return;
- }
-
- if (m_cachedBuffers && m_cachedBuffers->canHandleSize(m_layerSize)) {
- // We can re-use the existing buffer. We don't need to clear it since
- // all layer modes will clear it in their initialization.
- m_layerBuffer = m_cachedBuffers->destBitmap();
- m_drawContext = m_cachedBuffers->destBitmap()->context();
- bitmapForContext(*m_drawContext).eraseARGB(0, 0, 0, 0);
- m_referenceBitmap = m_cachedBuffers->referenceBitmap();
- m_referenceBitmap->eraseARGB(0, 0, 0, 0);
- m_validLayer = true;
- return;
- }
-
- // Create a new cached buffer.
- if (m_cachedBuffers)
- delete m_cachedBuffers;
- m_cachedBuffers = new OwnedBuffers(m_layerSize, true);
-
- m_layerBuffer = m_cachedBuffers->destBitmap();
- m_drawContext = m_cachedBuffers->destBitmap()->context();
- m_referenceBitmap = m_cachedBuffers->referenceBitmap();
- m_validLayer = true;
-}
-
-void TransparencyWin::compositeOpaqueComposite()
-{
- if (!m_validLayer)
- return;
-
- PlatformContextSkia* destPlatformContext = m_destContext->platformContext();
- destPlatformContext->save();
-
- SkBitmap* bitmap = const_cast<SkBitmap*>(
- &bitmapForContext(*m_layerBuffer->context()));
-
- // This function will be called for WhiteLayer as well, which we don't want
- // to change.
- if (m_layerMode == OpaqueCompositeLayer) {
- // Fix up our bitmap, making it contain only the pixels which changed
- // and transparent everywhere else.
- SkAutoLockPixels sourceLock(*m_referenceBitmap);
- SkAutoLockPixels lock(*bitmap);
- for (int y = 0; y < bitmap->height(); y++) {
- uint32_t* source = m_referenceBitmap->getAddr32(0, y);
- uint32_t* dest = bitmap->getAddr32(0, y);
- for (int x = 0; x < bitmap->width(); x++) {
- // Clear out any pixels that were untouched.
- if (dest[x] == source[x])
- dest[x] = 0;
- else
- dest[x] |= (0xFF << SK_A32_SHIFT);
- }
- }
- } else
- makeLayerOpaque();
-
- SkRect destRect;
- if (m_transformMode != Untransform) {
- // We want to use Untransformed space.
- //
- // Note that we DON'T call m_layerBuffer->image() here. This actually
- // makes a copy of the image, which is unnecessary and slow. Instead, we
- // just draw the image from inside the destination context.
- SkMatrix identity;
- identity.reset();
- destPlatformContext->setMatrix(identity);
-
- destRect.set(m_transformedSourceRect.x(), m_transformedSourceRect.y(), m_transformedSourceRect.maxX(), m_transformedSourceRect.maxY());
- } else
- destRect.set(m_sourceRect.x(), m_sourceRect.y(), m_sourceRect.maxX(), m_sourceRect.maxY());
-
- SkPaint paint;
- paint.setFilterBitmap(true);
- paint.setAntiAlias(true);
-
- // Note that we need to specify the source layer subset, since the bitmap
- // may have been cached and it could be larger than what we're using.
- SkIRect sourceRect = { 0, 0, m_layerSize.width(), m_layerSize.height() };
- destPlatformContext->drawBitmapRect(*bitmap, &sourceRect, destRect, &paint);
- destPlatformContext->restore();
-}
-
-void TransparencyWin::compositeTextComposite()
-{
- if (!m_validLayer)
- return;
-
- const SkBitmap& bitmap = m_layerBuffer->context()->platformContext()->layerBitmap(PlatformContextSkia::ReadWrite);
- SkColor textColor = m_textCompositeColor.rgb();
- for (int y = 0; y < m_layerSize.height(); y++) {
- uint32_t* row = bitmap.getAddr32(0, y);
- for (int x = 0; x < m_layerSize.width(); x++) {
- // The alpha is the average of the R, G, and B channels.
- int alpha = (SkGetPackedR32(row[x]) + SkGetPackedG32(row[x]) + SkGetPackedB32(row[x])) / 3;
-
- // Apply that alpha to the text color and write the result.
- row[x] = SkAlphaMulQ(textColor, SkAlpha255To256(255 - alpha));
- }
- }
-
- // Now the layer has text with the proper color and opacity.
- PlatformContextSkia* destPlatformContext = m_destContext->platformContext();
- destPlatformContext->save();
-
- // We want to use Untransformed space (see above)
- SkMatrix identity;
- identity.reset();
- destPlatformContext->setMatrix(identity);
- SkRect destRect = { m_transformedSourceRect.x(), m_transformedSourceRect.y(), m_transformedSourceRect.maxX(), m_transformedSourceRect.maxY() };
-
- // Note that we need to specify the source layer subset, since the bitmap
- // may have been cached and it could be larger than what we're using.
- SkIRect sourceRect = { 0, 0, m_layerSize.width(), m_layerSize.height() };
- destPlatformContext->drawBitmapRect(bitmap, &sourceRect, destRect, 0);
- destPlatformContext->restore();
-}
-
-void TransparencyWin::makeLayerOpaque()
-{
- if (!m_validLayer)
- return;
-
- SkBitmap& bitmap = const_cast<SkBitmap&>(m_drawContext->platformContext()->layerBitmap(PlatformContextSkia::ReadWrite));
- for (int y = 0; y < m_layerSize.height(); y++) {
- uint32_t* row = bitmap.getAddr32(0, y);
- for (int x = 0; x < m_layerSize.width(); x++)
- row[x] |= 0xFF000000;
- }
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/chromium/TransparencyWin.h b/Source/WebCore/platform/graphics/chromium/TransparencyWin.h
deleted file mode 100644
index 14f97b156..000000000
--- a/Source/WebCore/platform/graphics/chromium/TransparencyWin.h
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Copyright (C) 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef TransparencyWin_h
-#define TransparencyWin_h
-
-#include <windows.h>
-
-#include "AffineTransform.h"
-#include "ImageBuffer.h"
-
-#include <wtf/Noncopyable.h>
-#include <wtf/OwnPtr.h>
-
-class SkBitmap;
-class SkCanvas;
-
-namespace WebCore {
-
-class GraphicsContext;
-class TransparencyWin_NoLayer_Test;
-class TransparencyWin_WhiteLayer_Test;
-class TransparencyWin_TextComposite_Test;
-class TransparencyWin_OpaqueCompositeLayer_Test;
-
-// Helper class that abstracts away drawing ClearType text and Windows form
-// controls either to the original context directly, or to an offscreen context
-// that is composited later manually. This is to get around Windows' inability
-// to handle the alpha channel, semitransparent text, and transformed form
-// controls.
-class TransparencyWin {
- WTF_MAKE_NONCOPYABLE(TransparencyWin);
-public:
- enum LayerMode {
- // No extra layer is created. Drawing will happen to the source.
- // Valid only with KeepTransform and ScaleTransform. The region being
- // drawn onto must be opaque, since the modified region will be forced
- // to opaque when drawing is complete.
- NoLayer,
-
- // Makes a temporary layer consisting of the composited layers below
- // it. This result must be opaque. When complete, the result will be
- // compared to the original, and the difference will be added to a thee
- // destination layer.
- //
- // This mode only works if the lower layers are opque (normally the
- // case for a web page) and layers are only drawn in the stack order,
- // meaning you can never draw underneath a layer.
- //
- // This doesn't technically produce the correct answer in all cases. If
- // you have an opaque base, a transparency layer, than a semitransparent
- // drawing on top, the result will actually be blended in twice. But
- // this isn't a very important case. This mode is used for form
- // controls which are always opaque except for occationally some
- // antialiasing. It means form control antialiasing will be too light in
- // some cases, but only if you have extra layers.
- OpaqueCompositeLayer,
-
- // Allows semitransparent text to be drawn on any background (even if it
- // is itself semitransparent), but disables ClearType.
- //
- // It makes a trmporary layer filled with white. This is composited with
- // the lower layer with a custom color applied to produce the result.
- // The caller must draw the text in black, and set the desired final
- // text color by calling setTextCompositeColor().
- //
- // Only valid with KeepTransform, which is the only mode where drawing
- // text in this fashion makes sense.
- TextComposite,
-
- // Makes a temporary layer filled with white. When complete, the layer
- // will be forced to be opqaue (since Windows may have messed up the
- // alpha channel) and composited down. Any areas not drawn into will
- // remain white.
- //
- // This is the mode of last resort. If the opacity of the final image
- // is unknown and we can't do the text trick (since we know its color),
- // then we have to live with potential white halos. This is used for
- // form control drawing, for example.
- WhiteLayer,
- };
-
- enum TransformMode {
- // There are no changes to the transform. Use this when drawing
- // horizontal text. The current transform must not have rotation.
- KeepTransform,
-
- // Drawing happens in an Untransformed space, and then that bitmap is
- // transformed according to the current context when it is copied down.
- // Requires that a layer be created (layer mode is not NoLayer).
- Untransform,
-
- // When the current transform only has a scaling factor applied and
- // you're drawing form elements, use this parameter. This will unscale
- // the coordinate space, so the OS will just draw the form controls
- // larger or smaller depending on the destination size.
- ScaleTransform,
- };
-
- // You MUST call init() below.
- // |region| is expressed relative to the current transformation.
- TransparencyWin();
- ~TransparencyWin();
-
- // Initializes the members if you use the 0-argument constructor. Don't call
- // this if you use the multiple-argument constructor.
- void init(GraphicsContext* dest,
- LayerMode layerMode,
- TransformMode transformMode,
- const IntRect& region);
-
- // Combines the source and destination bitmaps using the given mode.
- // Calling this function before the destructor runs is mandatory in most
- // cases, and harmless otherwise. The mandatory cases are:
- // (m_layerMode != NoLayer) || (m_transformMode == ScaleTransform)
- void composite();
-
- // Returns the context for drawing into, which may be the destination
- // context, or a temporary one.
- GraphicsContext* context() const { return m_drawContext; }
-
- PlatformGraphicsContext* platformContext() const { return m_drawContext ? m_drawContext->platformContext() : 0; }
-
- // When the mode is TextComposite, this sets the color that the text will
- // get. See the enum above for more.
- void setTextCompositeColor(Color color);
-
- // Returns the input bounds translated into the destination space. This is
- // not necessary for KeepTransform since the rectangle will be unchanged.
- const IntRect& drawRect() { return m_drawRect; }
-
-private:
- friend TransparencyWin_NoLayer_Test;
- friend TransparencyWin_WhiteLayer_Test;
- friend TransparencyWin_TextComposite_Test;
- friend TransparencyWin_OpaqueCompositeLayer_Test;
-
- class OwnedBuffers;
-
- void computeLayerSize();
-
- // Sets up a new layer, if any. setupLayer() will call the appopriate layer-
- // specific helper. Must be called after computeLayerSize();
- void setupLayer();
- void setupLayerForNoLayer();
- void setupLayerForOpaqueCompositeLayer();
- void setupLayerForTextComposite();
- void setupLayerForWhiteLayer();
-
- // Sets up the transformation on the newly created layer. setupTransform()
- // will call the appropriate transform-specific helper. Must be called after
- // setupLayer().
- void setupTransform(const IntRect& region);
- void setupTransformForKeepTransform(const IntRect& region);
- void setupTransformForUntransform();
- void setupTransformForScaleTransform();
-
- void initializeNewContext();
-
- void compositeOpaqueComposite();
- void compositeTextComposite();
-
- // Fixes the alpha channel to make the region inside m_transformedRect
- // opaque.
- void makeLayerOpaque();
-
- // The context our drawing will eventually end up in.
- GraphicsContext* m_destContext;
-
- // The original transform from the destination context.
- AffineTransform m_orgTransform;
-
- LayerMode m_layerMode;
- TransformMode m_transformMode;
-
- // The rectangle we're drawing in the destination's coordinate space
- IntRect m_sourceRect;
-
- // The source rectangle transformed into pixels in the final image. For
- // Untransform this has no meaning, since the destination might not be a
- // rectangle.
- IntRect m_transformedSourceRect;
-
- // The size of the layer we created. If there's no layer, this is the size
- // of the region we're using in the source.
- IntSize m_layerSize;
-
- // The rectangle we're drawing to in the draw context's coordinate space.
- // This will be the same as the source rectangle except for ScaleTransform
- // where we create a new virtual coordinate space for the layer.
- IntRect m_drawRect;
-
- // Points to the graphics context to draw text to, which will either be
- // the original context or the copy, depending on our mode.
- GraphicsContext* m_drawContext;
-
- // This flag is set when we call save() on the draw context during
- // initialization. It allows us to avoid doing an extra save()/restore()
- // when one is unnecessary.
- bool m_savedOnDrawContext;
-
- // Used only when m_mode = TextComposite, this is the color that the text
- // will end up being once we figure out the transparency.
- Color m_textCompositeColor;
-
- // Layer we're drawing to.
- ImageBuffer* m_layerBuffer;
-
- // When the layer type is OpaqueCompositeLayer, this will contain a copy
- // of the original contents of the m_layerBuffer before Windows drew on it.
- // It allows us to re-create what Windows did to the layer. It is an
- // SkBitmap instead of an ImageBuffer because an SkBitmap is lighter-weight
- // (ImageBuffers are also GDI surfaces, which we don't need here).
- SkBitmap* m_referenceBitmap;
-
- // If the given size of bitmap can be cached, they will be stored here. Both
- // the bitmap and the reference are guaranteed to be allocated if this
- // member is non-null.
- static OwnedBuffers* m_cachedBuffers;
-
- // If a buffer was too big to be cached, it will be created temporarily, and
- // this member tracks its scope to make sure it gets deleted. Always use
- // m_layerBuffer, which will either point to this object, or the statically
- // cached one. Don't access directly.
- OwnPtr<OwnedBuffers> m_ownedBuffers;
-
- // Sometimes we're asked to create layers that have negative dimensions.
- // This API is not designed to fail to initialize, so we hide the fact
- // that they are illegal and can't be rendered (failing silently, drawing
- // nothing).
- bool m_validLayer;
-};
-
-} // namespace WebCore
-
-#endif // TransaprencyWin_h
diff --git a/Source/WebCore/platform/graphics/chromium/UniscribeHelper.cpp b/Source/WebCore/platform/graphics/chromium/UniscribeHelper.cpp
deleted file mode 100644
index fa8ec9467..000000000
--- a/Source/WebCore/platform/graphics/chromium/UniscribeHelper.cpp
+++ /dev/null
@@ -1,1101 +0,0 @@
-/*
- * Copyright (c) 2006, 2007, 2008, 2009, 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "UniscribeHelper.h"
-
-#include "Font.h"
-#include "FontUtilsChromiumWin.h"
-#include "HWndDC.h"
-#include "PlatformContextSkia.h"
-#include "SkiaFontWin.h"
-#include "SkPoint.h"
-#include <windows.h>
-#include <wtf/Assertions.h>
-
-namespace WebCore {
-
-// The function types for ScriptItemizeOpenType() and ScriptShapeOpenType().
-// We want to use these functions for OpenType feature support, but we can't
-// call them directly because usp10.dll does not always have them.
-// Instead, we use GetProcAddress() to check whether we can actually use these
-// function. If we can't use these functions, we substitute ScriptItemze() and
-// ScriptShape().
-typedef HRESULT (WINAPI *ScriptItemizeOpenTypeFunc)(const WCHAR*, int, int,
- const SCRIPT_CONTROL*,
- const SCRIPT_STATE*,
- SCRIPT_ITEM*,
- OPENTYPE_TAG*, int*);
-typedef HRESULT (WINAPI *ScriptShapeOpenTypeFunc)(HDC, SCRIPT_CACHE*,
- SCRIPT_ANALYSIS*,
- OPENTYPE_TAG, OPENTYPE_TAG,
- int*, TEXTRANGE_PROPERTIES**,
- int, const WCHAR*, int, int,
- WORD*, SCRIPT_CHARPROP*,
- WORD*, SCRIPT_GLYPHPROP*,
- int*);
-
-static ScriptItemizeOpenTypeFunc gScriptItemizeOpenTypeFunc = 0;
-static ScriptShapeOpenTypeFunc gScriptShapeOpenTypeFunc = 0;
-static bool gOpenTypeFunctionsLoaded = false;
-
-static void loadOpenTypeFunctions()
-{
- HMODULE hModule = GetModuleHandle(L"usp10");
- if (hModule) {
- gScriptItemizeOpenTypeFunc = reinterpret_cast<ScriptItemizeOpenTypeFunc>(GetProcAddress(hModule, "ScriptItemizeOpenType"));
- gScriptShapeOpenTypeFunc = reinterpret_cast<ScriptShapeOpenTypeFunc>(GetProcAddress(hModule, "ScriptShapeOpenType"));
- }
- if (!gScriptItemizeOpenTypeFunc || !gScriptShapeOpenTypeFunc) {
- gScriptItemizeOpenTypeFunc = 0;
- gScriptShapeOpenTypeFunc = 0;
- }
- gOpenTypeFunctionsLoaded = true;
-}
-
-// HFONT is the 'incarnation' of 'everything' about font, but it's an opaque
-// handle and we can't directly query it to make a new HFONT sharing
-// its characteristics (height, style, etc) except for family name.
-// This function uses GetObject to convert HFONT back to LOGFONT,
-// resets the fields of LOGFONT and calculates style to use later
-// for the creation of a font identical to HFONT other than family name.
-static void setLogFontAndStyle(HFONT hfont, LOGFONT *logfont, int *style)
-{
- ASSERT(hfont && logfont);
- if (!hfont || !logfont)
- return;
-
- GetObject(hfont, sizeof(LOGFONT), logfont);
- // We reset these fields to values appropriate for CreateFontIndirect.
- // while keeping lfHeight, which is the most important value in creating
- // a new font similar to hfont.
- logfont->lfWidth = 0;
- logfont->lfEscapement = 0;
- logfont->lfOrientation = 0;
- logfont->lfCharSet = DEFAULT_CHARSET;
- logfont->lfOutPrecision = OUT_TT_ONLY_PRECIS;
- logfont->lfQuality = DEFAULT_QUALITY; // Honor user's desktop settings.
- logfont->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
- if (style)
- *style = getStyleFromLogfont(logfont);
-}
-
-// This memory DC will NOT be released but it's OK
-// since we want to keep it for the whole life span of the process.
-HDC UniscribeHelper::m_cachedDC = 0;
-
-static bool canUseGlyphIndex(const SCRIPT_ITEM& run)
-{
- // On early version of Uniscribe, ScriptShape() sets run.a.fNoGlyphIndex
- // to TRUE when it can't shape the run with glyph indexes. This could
- // occur when we use CFF webfonts(See http://crbug.com/39017).
- // We don't use the font in that case and try to use fallback fonts.
- return !run.a.fNoGlyphIndex;
-}
-
-UniscribeHelper::UniscribeHelper(const UChar* input,
- int inputLength,
- bool isRtl,
- HFONT hfont,
- SCRIPT_CACHE* scriptCache,
- SCRIPT_FONTPROPERTIES* fontProperties,
- WORD spaceGlyph)
- : m_input(input)
- , m_inputLength(inputLength)
- , m_isRtl(isRtl)
- , m_hfont(hfont)
- , m_scriptCache(scriptCache)
- , m_fontProperties(fontProperties)
- , m_spaceGlyph(spaceGlyph)
- , m_directionalOverride(false)
- , m_inhibitLigate(false)
- , m_letterSpacing(0)
- , m_spaceWidth(0)
- , m_wordSpacing(0)
- , m_ascent(0)
- , m_disableFontFallback(false)
-
-{
- m_logfont.lfFaceName[0] = 0;
- if (!gOpenTypeFunctionsLoaded)
- loadOpenTypeFunctions();
-}
-
-UniscribeHelper::~UniscribeHelper()
-{
-}
-
-void UniscribeHelper::initWithOptionalLengthProtection(bool lengthProtection)
-{
- // We cap the input length and just don't do anything. We'll allocate a lot
- // of things of the size of the number of characters, so the allocated
- // memory will be several times the input length. Plus shaping such a large
- // buffer may be a form of denial of service. No legitimate text should be
- // this long. It also appears that Uniscribe flatly rejects very long
- // strings, so we don't lose anything by doing this.
- //
- // The input length protection may be disabled by the unit tests to cause
- // an error condition.
- static const int kMaxInputLength = 65535;
- if (m_inputLength == 0 || (lengthProtection && m_inputLength > kMaxInputLength))
- return;
-
- fillRuns();
- fillShapes();
- fillScreenOrder();
-}
-
-int UniscribeHelper::width() const
-{
- int width = 0;
- for (int itemIndex = 0; itemIndex < static_cast<int>(m_runs.size()); itemIndex++)
- width += advanceForItem(itemIndex);
- return width;
-}
-
-void UniscribeHelper::justify(int additionalSpace)
-{
- // Count the total number of glyphs we have so we know how big to make the
- // buffers below.
- int totalGlyphs = 0;
- for (size_t run = 0; run < m_runs.size(); run++) {
- int runIndex = m_screenOrder[run];
- totalGlyphs += static_cast<int>(m_shapes[runIndex].glyphLength());
- }
- if (totalGlyphs == 0)
- return; // Nothing to do.
-
- // We make one big buffer in screen order of all the glyphs we are drawing
- // across runs so that the justification function will adjust evenly across
- // all glyphs.
- Vector<SCRIPT_VISATTR, 64> visualAttributes;
- visualAttributes.resize(totalGlyphs);
- Vector<int, 64> advances;
- advances.resize(totalGlyphs);
- Vector<int, 64> justify;
- justify.resize(totalGlyphs);
-
- // Build the packed input.
- int destIndex = 0;
- for (size_t run = 0; run < m_runs.size(); run++) {
- int runIndex = m_screenOrder[run];
- const Shaping& shaping = m_shapes[runIndex];
-
- for (int i = 0; i < shaping.glyphLength(); i++, destIndex++) {
- memcpy(&visualAttributes[destIndex], &shaping.m_visualAttributes[i],
- sizeof(SCRIPT_VISATTR));
- advances[destIndex] = shaping.m_advance[i];
- }
- }
-
- // The documentation for Scriptjustify is wrong, the parameter is the space
- // to add and not the width of the column you want.
- int minKashida;
-#if USE(SKIA_TEXT)
- // Disable kashida justification based on
- // http://blogs.msdn.com/b/michkap/archive/2010/08/31/10056140.aspx.
- for (int i = 0; i < totalGlyphs; ++i) {
- if (visualAttributes[i].uJustification == SCRIPT_JUSTIFY_ARABIC_KASHIDA)
- visualAttributes[i].uJustification = SCRIPT_JUSTIFY_NONE;
- }
- minKashida = 0;
-#else
- minKashida = 1; // How do we decide what this should be?
-#endif
- ScriptJustify(&visualAttributes[0], &advances[0], totalGlyphs,
- additionalSpace, minKashida, &justify[0]);
-
- // Now we have to unpack the justification amounts back into the runs so
- // the glyph indices match.
- int globalGlyphIndex = 0;
- for (size_t run = 0; run < m_runs.size(); run++) {
- int runIndex = m_screenOrder[run];
- Shaping& shaping = m_shapes[runIndex];
-
- shaping.m_justify.resize(shaping.glyphLength());
- for (int i = 0; i < shaping.glyphLength(); i++, globalGlyphIndex++)
- shaping.m_justify[i] = justify[globalGlyphIndex];
- }
-}
-
-int UniscribeHelper::characterToX(int offset) const
-{
- HRESULT hr;
- ASSERT(offset <= m_inputLength);
-
- // Our algorithm is to traverse the items in screen order from left to
- // right, adding in each item's screen width until we find the item with
- // the requested character in it.
- int width = 0;
- for (size_t screenIndex = 0; screenIndex < m_runs.size(); screenIndex++) {
- // Compute the length of this run.
- int itemIndex = m_screenOrder[screenIndex];
- const SCRIPT_ITEM& item = m_runs[itemIndex];
- const Shaping& shaping = m_shapes[itemIndex];
- int itemLength = shaping.charLength();
-
- if (offset >= item.iCharPos && offset <= item.iCharPos + itemLength) {
- // Character offset is in this run.
- int charLength = offset - item.iCharPos;
-
- int curX = 0;
- hr = ScriptCPtoX(charLength, FALSE, itemLength,
- shaping.glyphLength(),
- &shaping.m_logs[0], &shaping.m_visualAttributes[0],
- shaping.effectiveAdvances(), &item.a, &curX);
- if (FAILED(hr))
- return 0;
-
- width += curX + shaping.m_prePadding;
- ASSERT(width >= 0);
- return width;
- }
-
- // Move to the next item.
- width += advanceForItem(itemIndex);
- }
- ASSERT(width >= 0);
- return width;
-}
-
-int UniscribeHelper::xToCharacter(int x) const
-{
- // We iterate in screen order until we find the item with the given pixel
- // position in it. When we find that guy, we ask Uniscribe for the
- // character index.
- HRESULT hr;
- for (size_t screenIndex = 0; screenIndex < m_runs.size(); screenIndex++) {
- int itemIndex = m_screenOrder[screenIndex];
- int itemAdvance = advanceForItem(itemIndex);
-
- // Note that the run may be empty if shaping failed, so we want to skip
- // over it.
- const Shaping& shaping = m_shapes[itemIndex];
- int itemLength = shaping.charLength();
- if (x <= itemAdvance && itemLength > 0) {
- // The requested offset is within this item.
- const SCRIPT_ITEM& item = m_runs[itemIndex];
-
- // Account for the leading space we've added to this run that
- // Uniscribe doesn't know about.
- x -= shaping.m_prePadding;
-
- int charX = 0;
- int trailing;
- hr = ScriptXtoCP(x, itemLength, shaping.glyphLength(),
- &shaping.m_logs[0], &shaping.m_visualAttributes[0],
- shaping.effectiveAdvances(), &item.a, &charX,
- &trailing);
-
- // The character offset is within the item. We need to add the
- // item's offset to transform it into the space of the TextRun
- return charX + item.iCharPos;
- }
-
- // The offset is beyond this item, account for its length and move on.
- x -= itemAdvance;
- }
-
- // Error condition, we don't know what to do if we don't have that X
- // position in any of our items.
- return 0;
-}
-
-void UniscribeHelper::draw(GraphicsContext* graphicsContext,
- HDC dc, int x, int y, int from, int to)
-{
- HGDIOBJ oldFont = 0;
- int curX = x;
- bool firstRun = true;
-#if !USE(SKIA_TEXT)
- bool useWindowsDrawing = windowsCanHandleTextDrawing(graphicsContext);
-#endif
-
- for (size_t screenIndex = 0; screenIndex < m_runs.size(); screenIndex++) {
- int itemIndex = m_screenOrder[screenIndex];
- const SCRIPT_ITEM& item = m_runs[itemIndex];
- const Shaping& shaping = m_shapes[itemIndex];
-
- // Character offsets within this run. THESE MAY NOT BE IN RANGE and may
- // be negative, etc. The code below handles this.
- int fromChar = from - item.iCharPos;
- int toChar = to - item.iCharPos;
-
- // See if we need to draw any characters in this item.
- if (shaping.charLength() == 0 ||
- fromChar >= shaping.charLength() || toChar <= 0) {
- // No chars in this item to display.
- curX += advanceForItem(itemIndex);
- continue;
- }
-
- // Compute the starting glyph within this span. |from| and |to| are
- // global offsets that may intersect arbitrarily with our local run.
- int fromGlyph, afterGlyph;
- if (item.a.fRTL) {
- // To compute the first glyph when going RTL, we use |to|.
- if (toChar >= shaping.charLength())
- // The end of the text is after (to the left) of us.
- fromGlyph = 0;
- else {
- // Since |to| is exclusive, the first character we draw on the
- // left is actually the one right before (to the right) of
- // |to|.
- fromGlyph = shaping.m_logs[toChar - 1];
- }
-
- // The last glyph is actually the first character in the range.
- if (fromChar <= 0) {
- // The first character to draw is before (to the right) of this
- // span, so draw all the way to the end.
- afterGlyph = shaping.glyphLength();
- } else {
- // We want to draw everything up until the character to the
- // right of |from|. To the right is - 1, so we look that up
- // (remember our character could be more than one glyph, so we
- // can't look up our glyph and add one).
- afterGlyph = shaping.m_logs[fromChar - 1];
- }
- } else {
- // Easy case, everybody agrees about directions. We only need to
- // handle boundary conditions to get a range inclusive at the
- // beginning, and exclusive at the ending. We have to do some
- // computation to see the glyph one past the end.
- fromGlyph = shaping.m_logs[fromChar < 0 ? 0 : fromChar];
- if (toChar >= shaping.charLength())
- afterGlyph = shaping.glyphLength();
- else
- afterGlyph = shaping.m_logs[toChar];
- }
-
- // Account for the characters that were skipped in this run. When
- // WebKit asks us to draw a subset of the run, it actually tells us
- // to draw at the X offset of the beginning of the run, since it
- // doesn't know the internal position of any of our characters.
- const int* effectiveAdvances = shaping.effectiveAdvances();
- int innerOffset = 0;
- for (int i = 0; i < fromGlyph; i++)
- innerOffset += effectiveAdvances[i];
-
- // Actually draw the glyphs we found.
- int glyphCount = afterGlyph - fromGlyph;
- if (fromGlyph >= 0 && glyphCount > 0) {
- // Account for the preceding space we need to add to this run. We
- // don't need to count for the following space because that will be
- // counted in advanceForItem below when we move to the next run.
- innerOffset += shaping.m_prePadding;
-
- // Pass 0 in when there is no justification.
- const int* justify = shaping.m_justify.size() == 0 ? 0 : &shaping.m_justify[fromGlyph];
-
-#if USE(SKIA_TEXT)
- const int* advances = shaping.m_justify.size() ?
- &shaping.m_justify[fromGlyph]
- : &shaping.m_advance[fromGlyph];
-#else
- if (useWindowsDrawing) {
- if (firstRun) {
- oldFont = SelectObject(dc, shaping.m_hfont);
- firstRun = false;
- } else
- SelectObject(dc, shaping.m_hfont);
- }
-
-#endif
- // Fonts with different ascents can be used to render different
- // runs. 'Across-runs' y-coordinate correction needs to be
- // adjusted for each font.
- bool textOutOk = false;
- for (int executions = 0; executions < 2; ++executions) {
-#if USE(SKIA_TEXT)
- SkPoint origin;
- origin.fX = curX + + innerOffset;
- origin.fY = y + m_ascent;
- paintSkiaText(graphicsContext,
- shaping.m_hfont,
- glyphCount,
- &shaping.m_glyphs[fromGlyph],
- advances,
- &shaping.m_offsets[fromGlyph],
- &origin);
- textOutOk = true;
-#else
- if (useWindowsDrawing) {
- HRESULT hr = ScriptTextOut(dc, shaping.m_scriptCache,
- curX + innerOffset,
- y - shaping.m_ascentOffset,
- 0, 0, &item.a, 0, 0,
- &shaping.m_glyphs[fromGlyph],
- glyphCount,
- &shaping.m_advance[fromGlyph],
- justify,
- &shaping.m_offsets[fromGlyph]);
- textOutOk = (hr == S_OK);
- } else {
- SkPoint origin;
- origin.fX = curX + + innerOffset;
- origin.fY = y + m_ascent;
- paintSkiaText(graphicsContext,
- shaping.m_hfont,
- glyphCount,
- &shaping.m_glyphs[fromGlyph],
- &shaping.m_advance[fromGlyph],
- &shaping.m_offsets[fromGlyph],
- &origin);
- textOutOk = true;
- }
-#endif
-
- if (!textOutOk && 0 == executions) {
- // If TextOut is called from the renderer it might fail
- // because the sandbox is preventing it from opening the
- // font files. If we are running in the renderer,
- // TryToPreloadFont is overridden to ask the browser to
- // preload the font for us so we can access it.
- tryToPreloadFont(shaping.m_hfont);
- continue;
- }
- break;
- }
- }
-
- curX += advanceForItem(itemIndex);
- }
-
- if (oldFont)
- SelectObject(dc, oldFont);
-}
-
-WORD UniscribeHelper::firstGlyphForCharacter(int charOffset) const
-{
- // Find the run for the given character.
- for (int i = 0; i < static_cast<int>(m_runs.size()); i++) {
- int firstChar = m_runs[i].iCharPos;
- const Shaping& shaping = m_shapes[i];
- int localOffset = charOffset - firstChar;
- if (localOffset >= 0 && localOffset < shaping.charLength()) {
- // The character is in this run, return the first glyph for it
- // (should generally be the only glyph). It seems Uniscribe gives
- // glyph 0 for empty, which is what we want to return in the
- // "missing" case.
- size_t glyphIndex = shaping.m_logs[localOffset];
- if (glyphIndex >= shaping.m_glyphs.size()) {
- // The glyph should be in this run, but the run has too few
- // actual characters. This can happen when shaping the run
- // fails, in which case, we should have no data in the logs at
- // all.
- ASSERT(shaping.m_glyphs.size() == 0);
- return 0;
- }
- return shaping.m_glyphs[glyphIndex];
- }
- }
-
- return 0;
-}
-
-void UniscribeHelper::fillRuns()
-{
- HRESULT hr;
- m_runs.resize(cUniscribeHelperStackRuns);
- m_scriptTags.resize(cUniscribeHelperStackRuns);
-
- SCRIPT_STATE inputState;
- inputState.uBidiLevel = m_isRtl;
- inputState.fOverrideDirection = m_directionalOverride;
- inputState.fInhibitSymSwap = false;
- inputState.fCharShape = false; // Not implemented in Uniscribe
- inputState.fDigitSubstitute = false; // Do we want this for Arabic?
- inputState.fInhibitLigate = m_inhibitLigate;
- inputState.fDisplayZWG = false; // Don't draw control characters.
- inputState.fArabicNumContext = m_isRtl; // Do we want this for Arabic?
- inputState.fGcpClusters = false;
- inputState.fReserved = 0;
- inputState.fEngineReserved = 0;
- // The psControl argument to ScriptItemize should be non-0 for RTL text,
- // per http://msdn.microsoft.com/en-us/library/ms776532.aspx . So use a
- // SCRIPT_CONTROL that is set to all zeros. Zero as a locale ID means the
- // neutral locale per http://msdn.microsoft.com/en-us/library/ms776294.aspx
- static SCRIPT_CONTROL inputControl = {0, // uDefaultLanguage :16;
- 0, // fContextDigits :1;
- 0, // fInvertPreBoundDir :1;
- 0, // fInvertPostBoundDir :1;
- 0, // fLinkStringBefore :1;
- 0, // fLinkStringAfter :1;
- 0, // fNeutralOverride :1;
- 0, // fNumericOverride :1;
- 0, // fLegacyBidiClass :1;
- 0, // fMergeNeutralItems :1;
- 0};// fReserved :7;
- // Calling ScriptApplyDigitSubstitution( 0, &inputControl, &inputState)
- // here would be appropriate if we wanted to set the language ID, and get
- // local digit substitution behavior. For now, don't do it.
-
- while (true) {
- int numberOfItems = 0;
-
- // Ideally, we would have a way to know the runs before and after this
- // one, and put them into the control parameter of ScriptItemize. This
- // would allow us to shape characters properly that cross style
- // boundaries (WebKit bug 6148).
- //
- // We tell ScriptItemize that the output list of items is one smaller
- // than it actually is. According to Mozilla bug 366643, if there is
- // not enough room in the array on pre-SP2 systems, ScriptItemize will
- // write one past the end of the buffer.
- //
- // ScriptItemize is very strange. It will often require a much larger
- // ITEM buffer internally than it will give us as output. For example,
- // it will say a 16-item buffer is not big enough, and will write
- // interesting numbers into all those items. But when we give it a 32
- // item buffer and it succeeds, it only has one item output.
- //
- // It seems to be doing at least two passes, the first where it puts a
- // lot of intermediate data into our items, and the second where it
- // collates them.
- if (gScriptItemizeOpenTypeFunc) {
- hr = gScriptItemizeOpenTypeFunc(m_input, m_inputLength,
- static_cast<int>(m_runs.size()) - 1,
- &inputControl, &inputState,
- &m_runs[0], &m_scriptTags[0],
- &numberOfItems);
-
- if (SUCCEEDED(hr)) {
- // Pack consecutive runs, the script tag of which are
- // SCRIPT_TAG_UNKNOWN, to reduce the number of runs.
- for (int i = 0; i < numberOfItems; ++i) {
- if (m_scriptTags[i] == SCRIPT_TAG_UNKNOWN) {
- int j = 1;
- while (i + j < numberOfItems && m_scriptTags[i + j] == SCRIPT_TAG_UNKNOWN)
- ++j;
- if (--j) {
- m_runs.remove(i + 1, j);
- m_scriptTags.remove(i + 1, j);
- numberOfItems -= j;
- }
- }
- }
- m_scriptTags.resize(numberOfItems);
- }
- } else {
- hr = ScriptItemize(m_input, m_inputLength,
- static_cast<int>(m_runs.size()) - 1,
- &inputControl, &inputState, &m_runs[0],
- &numberOfItems);
- }
- if (SUCCEEDED(hr)) {
- m_runs.resize(numberOfItems);
- break;
- }
- if (hr != E_OUTOFMEMORY) {
- // Some kind of unexpected error.
- m_runs.resize(0);
- break;
- }
- // There was not enough items for it to write into, expand.
- m_runs.resize(m_runs.size() * 2);
- m_scriptTags.resize(m_runs.size());
- }
-}
-
-bool UniscribeHelper::shape(const UChar* input,
- int itemLength,
- int numGlyphs,
- SCRIPT_ITEM& run,
- OPENTYPE_TAG scriptTag,
- Shaping& shaping)
-{
- HFONT hfont = m_hfont;
- SCRIPT_CACHE* scriptCache = m_scriptCache;
- SCRIPT_FONTPROPERTIES* fontProperties = m_fontProperties;
- Vector<SCRIPT_CHARPROP, cUniscribeHelperStackChars> charProps;
- Vector<SCRIPT_GLYPHPROP, cUniscribeHelperStackChars> glyphProps;
- int ascent = m_ascent;
- WORD spaceGlyph = m_spaceGlyph;
- HRESULT hr;
- // When used to fill up glyph pages for simple scripts in non-BMP,
- // we don't want any font fallback in this class. The simple script
- // font path can take care of font fallback.
- bool lastFallbackTried = m_disableFontFallback;
- bool result;
-
- int generatedGlyphs = 0;
-
- // In case HFONT passed in ctor cannot render this run, we have to scan
- // other fonts from the beginning of the font list.
- resetFontIndex();
-
- // Compute shapes.
- while (true) {
- shaping.m_logs.resize(itemLength);
- shaping.m_glyphs.resize(numGlyphs);
- shaping.m_visualAttributes.resize(numGlyphs);
- charProps.resize(itemLength);
- glyphProps.resize(numGlyphs);
- run.a.fNoGlyphIndex = FALSE;
-
-#ifdef PURIFY
- // http://code.google.com/p/chromium/issues/detail?id=5309
- // Purify isn't able to track the assignments that ScriptShape makes to
- // shaping.m_glyphs. Consequently, any bytes with value 0xCD that it
- // writes, will be considered un-initialized data.
- //
- // This hack avoid the false-positive UMRs by marking the buffer as
- // initialized.
- //
- // FIXME: A better solution would be to use Purify's API and mark only
- // the populated range as initialized:
- //
- // PurifyMarkAsInitialized(
- // &shaping.m_glyphs[0],
- // sizeof(shaping.m_glyphs[0] * generatedGlyphs);
-
- ZeroMemory(&shaping.m_glyphs[0],
- sizeof(shaping.m_glyphs[0]) * shaping.m_glyphs.size());
-#endif
- // If our DC is already created, select the font in it so we can use it now.
- // Otherwise, we'll create it as needed afterward...
- if (m_cachedDC)
- SelectObject(m_cachedDC, hfont);
-
- // Firefox sets SCRIPT_ANALYSIS.SCRIPT_STATE.fDisplayZWG to true
- // here. Is that what we want? It will display control characters.
- if (gScriptShapeOpenTypeFunc) {
- TEXTRANGE_PROPERTIES* rangeProps = m_featureRecords.size() ? &m_rangeProperties : 0;
- hr = gScriptShapeOpenTypeFunc(m_cachedDC, scriptCache, &run.a,
- scriptTag, 0, &itemLength,
- &rangeProps, rangeProps ? 1 : 0,
- input, itemLength, numGlyphs,
- &shaping.m_logs[0], &charProps[0],
- &shaping.m_glyphs[0], &glyphProps[0],
- &generatedGlyphs);
- } else {
- hr = ScriptShape(m_cachedDC, scriptCache, input, itemLength,
- numGlyphs, &run.a,
- &shaping.m_glyphs[0], &shaping.m_logs[0],
- &shaping.m_visualAttributes[0], &generatedGlyphs);
- }
- // We receive E_PENDING when we need to try again with a Drawing Context,
- // but we don't want to retry again if we already tried with non-zero DC.
- if (hr == E_PENDING && !m_cachedDC) {
- EnsureCachedDCCreated();
- continue;
- }
- if (hr == E_OUTOFMEMORY) {
- numGlyphs *= 2;
- continue;
- }
- if (SUCCEEDED(hr) && (lastFallbackTried || !containsMissingGlyphs(shaping, run, fontProperties) && canUseGlyphIndex(run)))
- break;
-
- // The current font can't render this run, try next font.
- if (!m_disableFontFallback &&
- nextWinFontData(&hfont, &scriptCache, &fontProperties, &ascent)) {
- // The primary font does not support this run. Try next font.
- // In case of web page rendering, they come from fonts specified in
- // CSS stylesheets.
- continue;
- } else if (!lastFallbackTried) {
- lastFallbackTried = true;
-
- // Generate a last fallback font based on the script of
- // a character to draw while inheriting size and styles
- // from the primary font
- if (!m_logfont.lfFaceName[0])
- setLogFontAndStyle(m_hfont, &m_logfont, &m_style);
-
- // TODO(jungshik): generic type should come from webkit for
- // UniscribeHelperTextRun (a derived class used in webkit).
- const UChar *family = getFallbackFamily(input, itemLength,
- FontDescription::StandardFamily, 0, 0);
- bool fontOk = getDerivedFontData(family, m_style, &m_logfont,
- &ascent, &hfont, &scriptCache,
- &spaceGlyph);
-
-
- if (!fontOk) {
- // If this GetDerivedFontData is called from the renderer it
- // might fail because the sandbox is preventing it from opening
- // the font files. If we are running in the renderer,
- // TryToPreloadFont is overridden to ask the browser to preload
- // the font for us so we can access it.
- tryToPreloadFont(hfont);
-
- // Try again.
- fontOk = getDerivedFontData(family, m_style, &m_logfont,
- &ascent, &hfont, &scriptCache,
- &spaceGlyph);
- ASSERT(fontOk);
- }
-
- // TODO(jungshik) : Currently GetDerivedHFont always returns a
- // a valid HFONT, but in the future, I may change it to return 0.
- ASSERT(hfont);
-
- // We don't need a font_properties for the last resort fallback font
- // because we don't have anything more to try and are forced to
- // accept empty glyph boxes. If we tried a series of fonts as
- // 'last-resort fallback', we'd need it, but currently, we don't.
- continue;
- } else if (hr == USP_E_SCRIPT_NOT_IN_FONT) {
- run.a.eScript = SCRIPT_UNDEFINED;
- continue;
- } else if (FAILED(hr)) {
- // Error shaping.
- generatedGlyphs = 0;
- result = false;
- goto cleanup;
- }
- }
-
- // Sets Windows font data for this run to those corresponding to
- // a font supporting this run. we don't need to store font_properties
- // because it's not used elsewhere.
- shaping.m_hfont = hfont;
- shaping.m_scriptCache = scriptCache;
- shaping.m_spaceGlyph = spaceGlyph;
-
- // The ascent of a font for this run can be different from
- // that of the primary font so that we need to keep track of
- // the difference per run and take that into account when calling
- // ScriptTextOut in |draw|. Otherwise, different runs rendered by
- // different fonts would not be aligned vertically.
- shaping.m_ascentOffset = m_ascent ? ascent - m_ascent : 0;
- result = true;
-
- cleanup:
- shaping.m_glyphs.resize(generatedGlyphs);
- shaping.m_visualAttributes.resize(generatedGlyphs);
- // If we use ScriptShapeOpenType(), visual attributes information for each
- // characters are stored in |glyphProps[i].sva|.
- if (gScriptShapeOpenTypeFunc) {
- for (int i = 0; i < generatedGlyphs; ++i)
- memcpy(&shaping.m_visualAttributes[i], &glyphProps[i].sva, sizeof(SCRIPT_VISATTR));
- }
- shaping.m_advance.resize(generatedGlyphs);
- shaping.m_offsets.resize(generatedGlyphs);
-
- // On failure, our logs don't mean anything, so zero those out.
- if (!result)
- shaping.m_logs.clear();
-
- return result;
-}
-
-void UniscribeHelper::EnsureCachedDCCreated()
-{
- if (m_cachedDC)
- return;
- // Allocate a memory DC that is compatible with the Desktop DC since we don't have any window,
- // and we don't want to use the Desktop DC directly since it can have nasty side effects
- // as identified in Chrome Issue http://crbug.com/59315.
- HWndDC screenDC(0);
- m_cachedDC = ::CreateCompatibleDC(screenDC);
- ASSERT(m_cachedDC);
-}
-
-void UniscribeHelper::fillShapes()
-{
- m_shapes.resize(m_runs.size());
- for (size_t i = 0; i < m_runs.size(); i++) {
- int startItem = m_runs[i].iCharPos;
- int itemLength = m_inputLength - startItem;
- if (i < m_runs.size() - 1)
- itemLength = m_runs[i + 1].iCharPos - startItem;
-
- int numGlyphs;
- if (itemLength < cUniscribeHelperStackChars) {
- // We'll start our buffer sizes with the current stack space
- // available in our buffers if the current input fits. As long as
- // it doesn't expand past that we'll save a lot of time mallocing.
- numGlyphs = cUniscribeHelperStackChars;
- } else {
- // When the input doesn't fit, give up with the stack since it will
- // almost surely not be enough room (unless the input actually
- // shrinks, which is unlikely) and just start with the length
- // recommended by the Uniscribe documentation as a "usually fits"
- // size.
- numGlyphs = itemLength * 3 / 2 + 16;
- }
-
- // Convert a string to a glyph string trying the primary font, fonts in
- // the fallback list and then script-specific last resort font.
- Shaping& shaping = m_shapes[i];
- if (!shape(&m_input[startItem], itemLength, numGlyphs, m_runs[i], m_scriptTags[i], shaping))
- continue;
-
- // At the moment, the only time m_disableFontFallback is set is
- // when we look up glyph indices for non-BMP code ranges. So,
- // we can skip the glyph placement. When that becomes not the case
- // any more, we have to add a new flag to control glyph placement.
- if (m_disableFontFallback)
- continue;
-
- // Compute placements. Note that offsets is documented incorrectly
- // and is actually an array.
- EnsureCachedDCCreated();
- SelectObject(m_cachedDC, shaping.m_hfont);
- shaping.m_prePadding = 0;
- if (FAILED(ScriptPlace(m_cachedDC, shaping.m_scriptCache,
- &shaping.m_glyphs[0],
- static_cast<int>(shaping.m_glyphs.size()),
- &shaping.m_visualAttributes[0], &m_runs[i].a,
- &shaping.m_advance[0], &shaping.m_offsets[0],
- &shaping.m_abc))) {
- // Some error we don't know how to handle. Nuke all of our data
- // since we can't deal with partially valid data later.
- m_runs.clear();
- m_scriptTags.clear();
- m_shapes.clear();
- m_screenOrder.clear();
- }
- }
-
- adjustSpaceAdvances();
-
- if (m_letterSpacing != 0 || m_wordSpacing != 0)
- applySpacing();
-}
-
-void UniscribeHelper::fillScreenOrder()
-{
- m_screenOrder.resize(m_runs.size());
-
- // We assume that the input has only one text direction in it.
- // TODO(brettw) are we sure we want to keep this restriction?
- if (m_isRtl) {
- for (int i = 0; i < static_cast<int>(m_screenOrder.size()); i++)
- m_screenOrder[static_cast<int>(m_screenOrder.size()) - i - 1] = i;
- } else {
- for (int i = 0; i < static_cast<int>(m_screenOrder.size()); i++)
- m_screenOrder[i] = i;
- }
-}
-
-void UniscribeHelper::adjustSpaceAdvances()
-{
- if (m_spaceWidth == 0)
- return;
-
- int spaceWidthWithoutLetterSpacing = m_spaceWidth - m_letterSpacing;
-
- // This mostly matches what WebKit's UniscribeController::shapeAndPlaceItem.
- for (size_t run = 0; run < m_runs.size(); run++) {
- Shaping& shaping = m_shapes[run];
-
- // FIXME: This loop is not UTF-16-safe. Unicode 6.0 has a couple
- // of complex script blocks in Plane 1.
- for (int i = 0; i < shaping.charLength(); i++) {
- UChar c = m_input[m_runs[run].iCharPos + i];
- bool treatAsSpace = Font::treatAsSpace(c);
- if (!treatAsSpace && !Font::treatAsZeroWidthSpaceInComplexScript(c))
- continue;
-
- int glyphIndex = shaping.m_logs[i];
- int currentAdvance = shaping.m_advance[glyphIndex];
-
- shaping.m_glyphs[glyphIndex] = shaping.m_spaceGlyph;
-
- if (treatAsSpace) {
- // currentAdvance does not include additional letter-spacing,
- // but m_spaceWidth does. Here we find out how off we are from
- // the correct width (spaceWidthWithoutLetterSpacing) and
- // just subtract that diff.
- int diff = currentAdvance - spaceWidthWithoutLetterSpacing;
- // The shaping can consist of a run of text, so only subtract
- // the difference in the width of the glyph.
- shaping.m_advance[glyphIndex] -= diff;
- shaping.m_abc.abcB -= diff;
- continue;
- }
-
- // For characters treated as zero-width space in complex
- // scripts, set the advance width to zero, adjust
- // |abcB| of the current run accordingly and set
- // the glyph to m_spaceGlyph (invisible).
- shaping.m_advance[glyphIndex] = 0;
- shaping.m_abc.abcB -= currentAdvance;
- shaping.m_offsets[glyphIndex].du = 0;
- shaping.m_offsets[glyphIndex].dv = 0;
- }
- }
-}
-
-void UniscribeHelper::applySpacing()
-{
- for (size_t run = 0; run < m_runs.size(); run++) {
- Shaping& shaping = m_shapes[run];
- bool isRtl = m_runs[run].a.fRTL;
-
- if (m_letterSpacing != 0) {
- // RTL text gets padded to the left of each character. We increment
- // the run's advance to make this happen. This will be balanced out
- // by NOT adding additional advance to the last glyph in the run.
- if (isRtl)
- shaping.m_prePadding += m_letterSpacing;
-
- // Go through all the glyphs in this run and increase the "advance"
- // to account for letter spacing. We adjust letter spacing only on
- // cluster boundaries.
- //
- // This works for most scripts, but may have problems with some
- // indic scripts. This behavior is better than Firefox or IE for
- // Hebrew.
- for (int i = 0; i < shaping.glyphLength(); i++) {
- if (shaping.m_visualAttributes[i].fClusterStart) {
- // Ick, we need to assign the extra space so that the glyph
- // comes first, then is followed by the space. This is
- // opposite for RTL.
- if (isRtl) {
- if (i != shaping.glyphLength() - 1) {
- // All but the last character just get the spacing
- // applied to their advance. The last character
- // doesn't get anything,
- shaping.m_advance[i] += m_letterSpacing;
- shaping.m_abc.abcB += m_letterSpacing;
- }
- } else {
- // LTR case is easier, we just add to the advance.
- shaping.m_advance[i] += m_letterSpacing;
- shaping.m_abc.abcB += m_letterSpacing;
- }
- }
- }
- }
-
- // Go through all the characters to find whitespace and insert the
- // extra wordspacing amount for the glyphs they correspond to.
- if (m_wordSpacing != 0) {
- for (int i = 0; i < shaping.charLength(); i++) {
- if (!Font::treatAsSpace(m_input[m_runs[run].iCharPos + i]))
- continue;
-
- // The char in question is a word separator...
- int glyphIndex = shaping.m_logs[i];
-
- // Spaces will not have a glyph in Uniscribe, it will just add
- // additional advance to the character to the left of the
- // space. The space's corresponding glyph will be the character
- // following it in reading order.
- if (isRtl) {
- // In RTL, the glyph to the left of the space is the same
- // as the first glyph of the following character, so we can
- // just increment it.
- shaping.m_advance[glyphIndex] += m_wordSpacing;
- shaping.m_abc.abcB += m_wordSpacing;
- } else {
- // LTR is actually more complex here, we apply it to the
- // previous character if there is one, otherwise we have to
- // apply it to the leading space of the run.
- if (glyphIndex == 0)
- shaping.m_prePadding += m_wordSpacing;
- else {
- shaping.m_advance[glyphIndex - 1] += m_wordSpacing;
- shaping.m_abc.abcB += m_wordSpacing;
- }
- }
- }
- } // m_wordSpacing != 0
-
- // Loop for next run...
- }
-}
-
-// The advance is the ABC width of the run
-int UniscribeHelper::advanceForItem(int itemIndex) const
-{
- int accum = 0;
- const Shaping& shaping = m_shapes[itemIndex];
-
- if (shaping.m_justify.size() == 0) {
- // Easy case with no justification, the width is just the ABC width of
- // the run. (The ABC width is the sum of the advances).
- return shaping.m_abc.abcA + shaping.m_abc.abcB +
- shaping.m_abc.abcC + shaping.m_prePadding;
- }
-
- // With justification, we use the justified amounts instead. The
- // justification array contains both the advance and the extra space
- // added for justification, so is the width we want.
- int justification = 0;
- for (size_t i = 0; i < shaping.m_justify.size(); i++)
- justification += shaping.m_justify[i];
-
- return shaping.m_prePadding + justification;
-}
-
-// SCRIPT_FONTPROPERTIES contains glyph indices for default, invalid
-// and blank glyphs. Just because ScriptShape succeeds does not mean
-// that a text run is rendered correctly. Some characters may be rendered
-// with default/invalid/blank glyphs. Therefore, we need to check if the glyph
-// array returned by ScriptShape contains any of those glyphs to make
-// sure that the text run is rendered successfully.
-// However, we should not subject zero-width characters to this test.
-
-bool UniscribeHelper::containsMissingGlyphs(const Shaping& shaping,
- const SCRIPT_ITEM& run,
- const SCRIPT_FONTPROPERTIES* properties) const
-{
- for (int i = 0; i < shaping.charLength(); i++) {
- UChar c = m_input[run.iCharPos + i];
- // Skip zero-width space characters because they're not considered to be missing in a font.
- if (Font::treatAsZeroWidthSpaceInComplexScript(c))
- continue;
- int glyphIndex = shaping.m_logs[i];
- WORD glyph = shaping.m_glyphs[glyphIndex];
- if (glyph == properties->wgDefault
- || (glyph == properties->wgInvalid && glyph != properties->wgBlank))
- return true;
- }
- return false;
-}
-
-static OPENTYPE_TAG convertFeatureTag(const String& tag)
-{
- return ((tag[0] & 0xFF) | ((tag[1] & 0xFF) << 8) | ((tag[2] & 0xFF) << 16) | ((tag[3] & 0xFF) << 24));
-}
-
-void UniscribeHelper::setRangeProperties(const FontFeatureSettings* featureSettings)
-{
- if (!featureSettings || !featureSettings->size()) {
- m_featureRecords.resize(0);
- return;
- }
-
- m_featureRecords.resize(featureSettings->size());
- for (unsigned i = 0; i < featureSettings->size(); ++i) {
- m_featureRecords[i].lParameter = featureSettings->at(i).value();
- m_featureRecords[i].tagFeature = convertFeatureTag(featureSettings->at(i).tag());
- }
- m_rangeProperties.potfRecords = &m_featureRecords[0];
- m_rangeProperties.cotfRecords = m_featureRecords.size();
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/chromium/UniscribeHelper.h b/Source/WebCore/platform/graphics/chromium/UniscribeHelper.h
deleted file mode 100644
index 27a30931c..000000000
--- a/Source/WebCore/platform/graphics/chromium/UniscribeHelper.h
+++ /dev/null
@@ -1,441 +0,0 @@
-/*
- * Copyright (c) 2006, 2007, 2008, 2009, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-// A wrapper around Uniscribe that provides a reasonable API.
-
-#ifndef UniscribeHelper_h
-#define UniscribeHelper_h
-
-#include <windows.h>
-#include <usp10.h>
-#include <map>
-
-#include <unicode/uchar.h>
-#include <wtf/Vector.h>
-
-class UniscribeTest_TooBig_Test; // A gunit test for UniscribeHelper.
-
-namespace WebCore {
-
-class FontFeatureSettings;
-class GraphicsContext;
-
-const unsigned cUniscribeHelperStackRuns = 8;
-const unsigned cUniscribeHelperStackChars = 32;
-const unsigned cUniscribeHelperFeatures = 4;
-
-// This object should be safe to create & destroy frequently, as long as the
-// caller preserves the script_cache when possible (this data may be slow to
-// compute).
-//
-// This object is "kind of large" (~1K) because it reserves a lot of space for
-// working with to avoid expensive heap operations. Therefore, not only should
-// you not worry about creating and destroying it, you should try to not keep
-// them around.
-class UniscribeHelper {
-public:
- // Initializes this Uniscribe run with the text pointed to by |run| with
- // |length|. The input is NOT null terminated.
- //
- // The is_rtl flag should be set if the input script is RTL. It is assumed
- // that the caller has already divided up the input text (using ICU, for
- // example) into runs of the same direction of script. This avoids
- // disagreements between the caller and Uniscribe later (see FillItems).
- //
- // A script cache should be provided by the caller that is initialized to
- // NULL. When the caller is done with the cache (it may be stored between
- // runs as long as it is used consistently with the same HFONT), it should
- // call ScriptFreeCache().
- UniscribeHelper(const UChar* input,
- int inputLength,
- bool isRtl,
- HFONT,
- SCRIPT_CACHE*,
- SCRIPT_FONTPROPERTIES*,
- WORD);
-
- virtual ~UniscribeHelper();
-
- // Sets Uniscribe's directional override flag. False by default.
- bool directionalOverride() const
- {
- return m_directionalOverride;
- }
- void setDirectionalOverride(bool override)
- {
- m_directionalOverride = override;
- }
-
- // Set's Uniscribe's no-ligate override flag. False by default.
- bool inhibitLigate() const
- {
- return m_inhibitLigate;
- }
- void setInhibitLigate(bool inhibit)
- {
- m_inhibitLigate = inhibit;
- }
-
- // Set letter spacing. We will try to insert this much space between
- // graphemes (one or more glyphs perceived as a single unit by ordinary
- // users of a script). Positive values increase letter spacing, negative
- // values decrease it. 0 by default.
- int letterSpacing() const
- {
- return m_letterSpacing;
- }
- void setLetterSpacing(int letterSpacing)
- {
- m_letterSpacing = letterSpacing;
- }
-
- // Set the width of a standard space character. We use this to normalize
- // space widths. Windows will make spaces after Hindi characters larger than
- // other spaces. A space_width of 0 means to use the default space width.
- //
- // Must be set before Init() is called.
- int spaceWidth() const
- {
- return m_spaceWidth;
- }
- void setSpaceWidth(int spaceWidth)
- {
- m_spaceWidth = spaceWidth;
- }
-
- // Set word spacing. We will try to insert this much extra space between
- // each word in the input (beyond whatever whitespace character separates
- // words). Positive values lead to increased letter spacing, negative values
- // decrease it. 0 by default.
- //
- // Must be set before Init() is called.
- int wordSpacing() const
- {
- return m_wordSpacing;
- }
- void setWordSpacing(int wordSpacing)
- {
- m_wordSpacing = wordSpacing;
- }
-
- void setAscent(int ascent)
- {
- m_ascent = ascent;
- }
-
- // When set to true, this class is used only to look up glyph
- // indices for a range of Unicode characters without glyph placement.
- // By default, it's false. This should be set to true when this
- // class is used for glyph index look-up for non-BMP characters
- // in GlyphPageNodeChromiumWin.cpp.
- void setDisableFontFallback(bool disableFontFallback)
- {
- m_disableFontFallback = true;
- }
-
- // Set TEXTRANGE_PROPERTIES structure which contains
- // OpenType feature records generated from FontFeatureSettings.
- void setRangeProperties(const FontFeatureSettings*);
-
- // You must call this after setting any options but before doing any
- // other calls like asking for widths or drawing.
- void init()
- {
- initWithOptionalLengthProtection(true);
- }
-
- // Returns the total width in pixels of the text run.
- int width() const;
-
- // Call to justify the text, with the amount of space that should be ADDED
- // to get the desired width that the column should be justified to.
- // Normally, spaces are inserted, but for Arabic there will be kashidas
- // (extra strokes) inserted instead.
- //
- // This function MUST be called AFTER Init().
- void justify(int additionalSpace);
-
- // Computes the given character offset into a pixel offset of the beginning
- // of that character.
- int characterToX(int offset) const;
-
- // Converts the given pixel X position into a logical character offset into
- // the run. For positions appearing before the first character, this will
- // return -1.
- int xToCharacter(int x) const;
-
- // Draws the given characters to (x, y) in the given DC. The font will be
- // handled by this function, but the font color and other attributes should
- // be pre-set.
- //
- // The y position is the upper left corner, NOT the baseline.
- void draw(GraphicsContext* graphicsContext, HDC dc, int x, int y, int from,
- int to);
-
- // Returns the first glyph assigned to the character at the given offset.
- // This function is used to retrieve glyph information when Uniscribe is
- // being used to generate glyphs for non-complex, non-BMP (above U+FFFF)
- // characters. These characters are not otherwise special and have no
- // complex shaping rules, so we don't otherwise need Uniscribe, except
- // Uniscribe is the only way to get glyphs for non-BMP characters.
- //
- // Returns 0 if there is no glyph for the given character.
- WORD firstGlyphForCharacter(int charOffset) const;
-
-protected:
- // Backend for init. The flag allows the unit test to specify whether we
- // should fail early for very long strings like normal, or try to pass the
- // long string to Uniscribe. The latter provides a way to force failure of
- // shaping.
- void initWithOptionalLengthProtection(bool lengthProtection);
-
- // Tries to preload the font when the it is not accessible.
- // This is the default implementation and it does not do anything.
- virtual void tryToPreloadFont(HFONT) {}
-
-private:
- friend class UniscribeTest_TooBig_Test;
-
- // An array corresponding to each item in runs_ containing information
- // on each of the glyphs that were generated. Like runs_, this is in
- // reading order. However, for rtl text, the characters within each
- // item will be reversed.
- struct Shaping {
- Shaping()
- : m_prePadding(0)
- , m_hfont(NULL)
- , m_scriptCache(NULL)
- , m_ascentOffset(0)
- , m_spaceGlyph(0)
- {
- m_abc.abcA = 0;
- m_abc.abcB = 0;
- m_abc.abcC = 0;
- }
-
- // Returns the number of glyphs (which will be drawn to the screen)
- // in this run.
- int glyphLength() const
- {
- return static_cast<int>(m_glyphs.size());
- }
-
- // Returns the number of characters (that we started with) in this run.
- int charLength() const
- {
- return static_cast<int>(m_logs.size());
- }
-
- // Returns the advance array that should be used when measuring glyphs.
- // The returned pointer will indicate an array with glyph_length()
- // elements and the advance that should be used for each one. This is
- // either the real advance, or the justified advances if there is one,
- // and is the array we want to use for measurement.
- const int* effectiveAdvances() const
- {
- if (m_advance.size() == 0)
- return 0;
- if (m_justify.size() == 0)
- return &m_advance[0];
- return &m_justify[0];
- }
-
- // This is the advance amount of space that we have added to the
- // beginning of the run. It is like the ABC's |A| advance but one that
- // we create and must handle internally whenever computing with pixel
- // offsets.
- int m_prePadding;
-
- // Glyph indices in the font used to display this item. These indices
- // are in screen order.
- Vector<WORD, cUniscribeHelperStackChars> m_glyphs;
-
- // For each input character, this tells us the first glyph index it
- // generated. This is the only array with size of the input chars.
- //
- // All offsets are from the beginning of this run. Multiple characters
- // can generate one glyph, in which case there will be adjacent
- // duplicates in this list. One character can also generate multiple
- // glyphs, in which case there will be skipped indices in this list.
- Vector<WORD, cUniscribeHelperStackChars> m_logs;
-
- // Flags and such for each glyph.
- Vector<SCRIPT_VISATTR, cUniscribeHelperStackChars> m_visualAttributes;
-
- // Horizontal advances for each glyph listed above, this is basically
- // how wide each glyph is.
- Vector<int, cUniscribeHelperStackChars> m_advance;
-
- // This contains glyph offsets, from the nominal position of a glyph.
- // It is used to adjust the positions of multiple combining characters
- // around/above/below base characters in a context-sensitive manner so
- // that they don't bump against each other and the base character.
- Vector<GOFFSET, cUniscribeHelperStackChars> m_offsets;
-
- // Filled by a call to Justify, this is empty for nonjustified text.
- // If nonempty, this contains the array of justify characters for each
- // character as returned by ScriptJustify.
- //
- // This is the same as the advance array, but with extra space added
- // for some characters. The difference between a glyph's |justify|
- // width and it's |advance| width is the extra space added.
- Vector<int, cUniscribeHelperStackChars> m_justify;
-
- // Sizing information for this run. This treats the entire run as a
- // character with a preceeding advance, width, and ending advance. The
- // B width is the sum of the |advance| array, and the A and C widths
- // are any extra spacing applied to each end.
- //
- // It is unclear from the documentation what this actually means. From
- // experimentation, it seems that the sum of the character advances is
- // always the sum of the ABC values, and I'm not sure what you're
- // supposed to do with the ABC values.
- ABC m_abc;
-
- // Pointers to windows font data used to render this run.
- HFONT m_hfont;
- SCRIPT_CACHE* m_scriptCache;
-
- // Ascent offset between the ascent of the primary font
- // and that of the fallback font. The offset needs to be applied,
- // when drawing a string, to align multiple runs rendered with
- // different fonts.
- int m_ascentOffset;
-
- WORD m_spaceGlyph;
- };
-
- // Computes the runs_ array from the text run.
- void fillRuns();
-
- // Computes the shapes_ array given an runs_ array already filled in.
- void fillShapes();
-
- // Fills in the screen_order_ array (see below).
- void fillScreenOrder();
-
- // Called to update the glyph positions based on the current spacing
- // options that are set.
- void applySpacing();
-
- // Normalizes all advances for spaces to the same width. This keeps windows
- // from making spaces after Hindi characters larger, which is then
- // inconsistent with our meaure of the width since WebKit doesn't include
- // spaces in text-runs sent to uniscribe unless white-space:pre.
- void adjustSpaceAdvances();
-
- // Returns the total width of a single item.
- int advanceForItem(int) const;
-
- bool containsMissingGlyphs(const Shaping&,
- const SCRIPT_ITEM&,
- const SCRIPT_FONTPROPERTIES*) const;
-
- // Shapes a run (pointed to by |input|) using |hfont| first.
- // Tries a series of fonts specified retrieved with NextWinFontData
- // and finally a font covering characters in |*input|. A string pointed
- // by |input| comes from ScriptItemize and is supposed to contain
- // characters belonging to a single script aside from characters common to
- // all scripts (e.g. space).
- bool shape(const UChar* input, int itemLength, int numGlyphs, SCRIPT_ITEM& run, OPENTYPE_TAG, Shaping&);
-
- // Gets Windows font data for the next best font to try in the list
- // of fonts. When there's no more font available, returns false
- // without touching any of out params. Need to call ResetFontIndex
- // to start scanning of the font list from the beginning.
- virtual bool nextWinFontData(HFONT*, SCRIPT_CACHE**, SCRIPT_FONTPROPERTIES**, int* ascent)
- {
- return false;
- }
-
- // Resets the font index to the first in the list of fonts to try after the
- // primaryFont turns out not to work. With fontIndex reset,
- // NextWinFontData scans fallback fonts from the beginning.
- virtual void resetFontIndex() {}
-
- // If m_cachedDC is 0, creates one that is compatible with the screen DC.
- void EnsureCachedDCCreated();
-
- // The input data for this run of Uniscribe. See the constructor.
- const UChar* m_input;
- const int m_inputLength;
- const bool m_isRtl;
-
- // Windows font data for the primary font. In a sense, m_logfont and m_style
- // are redundant because m_hfont contains all the information. However,
- // invoking GetObject, everytime we need the height and the style, is rather
- // expensive so that we cache them. Would it be better to add getter and
- // (virtual) setter for the height and the style of the primary font,
- // instead of m_logfont? Then, a derived class ctor can set m_ascent,
- // m_height and m_style if they're known. Getters for them would have to
- // 'infer' their values from m_hfont ONLY when they're not set.
- HFONT m_hfont;
- // We cache the DC to use with ScriptShape/ScriptPlace.
- static HDC m_cachedDC;
- SCRIPT_CACHE* m_scriptCache;
- SCRIPT_FONTPROPERTIES* m_fontProperties;
- int m_ascent;
- LOGFONT m_logfont;
- int m_style;
- WORD m_spaceGlyph;
-
- // Options, see the getters/setters above.
- bool m_directionalOverride;
- bool m_inhibitLigate;
- int m_letterSpacing;
- int m_spaceWidth;
- int m_wordSpacing;
- bool m_disableFontFallback;
-
- // Uniscribe breaks the text into Runs. These are one length of text that is
- // in one script and one direction. This array is in reading order.
- Vector<SCRIPT_ITEM, cUniscribeHelperStackRuns> m_runs;
-
- Vector<Shaping, cUniscribeHelperStackRuns> m_shapes;
- Vector<OPENTYPE_TAG, cUniscribeHelperStackRuns> m_scriptTags;
-
- // This is a mapping between reading order and screen order for the items.
- // Uniscribe's items array are in reading order. For right-to-left text,
- // or mixed (although WebKit's |TextRun| should really be only one
- // direction), this makes it very difficult to compute character offsets
- // and positions. This list is in screen order from left to right, and
- // gives the index into the |m_runs| and |m_shapes| arrays of each
- // subsequent item.
- Vector<int, cUniscribeHelperStackRuns> m_screenOrder;
-
- // This contains Uniscribe's OpenType feature settings. This structure
- // is filled by using WebKit's |FontFeatureSettings|.
- TEXTRANGE_PROPERTIES m_rangeProperties;
- Vector<OPENTYPE_FEATURE_RECORD, cUniscribeHelperFeatures> m_featureRecords;
-};
-
-} // namespace WebCore
-
-#endif // UniscribeHelper_h
diff --git a/Source/WebCore/platform/graphics/chromium/UniscribeHelperTextRun.cpp b/Source/WebCore/platform/graphics/chromium/UniscribeHelperTextRun.cpp
deleted file mode 100644
index ab4331b2b..000000000
--- a/Source/WebCore/platform/graphics/chromium/UniscribeHelperTextRun.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (c) 2006, 2007, 2008, 2009, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "UniscribeHelperTextRun.h"
-
-#include "Font.h"
-#include "FontPlatformDataChromiumWin.h"
-#include "SimpleFontData.h"
-#include "TextRun.h"
-
-namespace WebCore {
-
-UniscribeHelperTextRun::UniscribeHelperTextRun(const TextRun& run,
- const Font& font)
- : UniscribeHelper(run.characters16(), run.length(), run.rtl(),
- font.primaryFont()->platformData().hfont(),
- font.primaryFont()->platformData().scriptCache(),
- font.primaryFont()->platformData().scriptFontProperties(),
- font.primaryFont()->spaceGlyph())
- , m_font(&font)
- , m_fontIndex(0)
-{
- setDirectionalOverride(run.directionalOverride());
- setLetterSpacing(font.letterSpacing());
- setSpaceWidth(font.spaceWidth());
- setWordSpacing(font.wordSpacing());
- setAscent(font.fontMetrics().ascent());
- setRangeProperties(font.fontDescription().featureSettings());
-
- init();
-
- // Expansion is the amount to add to make justification happen. This
- // should be done after Init() so all the runs are already measured.
- if (run.expansion() > 0)
- justify(run.expansion());
-}
-
-UniscribeHelperTextRun::UniscribeHelperTextRun(
- const wchar_t* input,
- int inputLength,
- bool isRtl,
- HFONT hfont,
- SCRIPT_CACHE* scriptCache,
- SCRIPT_FONTPROPERTIES* fontProperties)
- : UniscribeHelper(input, inputLength, isRtl, hfont,
- scriptCache, fontProperties, 0)
- , m_font(0)
- , m_fontIndex(-1)
-{
-}
-
-void UniscribeHelperTextRun::tryToPreloadFont(HFONT font)
-{
- // Ask the browser to get the font metrics for this font.
- // That will preload the font and it should now be accessible
- // from the renderer.
- FontPlatformData::ensureFontLoaded(font);
-}
-
-bool UniscribeHelperTextRun::nextWinFontData(
- HFONT* hfont,
- SCRIPT_CACHE** scriptCache,
- SCRIPT_FONTPROPERTIES** fontProperties,
- int* ascent)
-{
- // This check is necessary because NextWinFontData can be called again
- // after we already ran out of fonts. fontDataAt behaves in a strange
- // manner when the difference between param passed and # of fonts stored in
- // WebKit::Font is larger than one. We can avoid this check by setting
- // font_index_ to # of elements in hfonts_ when we run out of font. In that
- // case, we'd have to go through a couple of more checks before returning
- // false.
- if (m_fontIndex == -1 || !m_font)
- return false;
-
- // If the font data for a fallback font requested is not yet retrieved, add
- // them to our vectors. Note that '>' rather than '>=' is used to test that
- // condition. primaryFont is not stored in hfonts_, and friends so that
- // indices for fontDataAt and our vectors for font data are 1 off from each
- // other. That is, when fully populated, hfonts_ and friends have one font
- // fewer than what's contained in font_.
- if (static_cast<size_t>(++m_fontIndex) > m_hfonts.size()) {
- const FontData *fontData = m_font->fontDataAt(m_fontIndex);
- if (!fontData) {
- // Ran out of fonts.
- m_fontIndex = -1;
- return false;
- }
-
- // FIXME: this won't work for SegmentedFontData
- // http://crbug.com/6425
- const SimpleFontData* simpleFontData =
- fontData->fontDataForCharacter(' ');
-
- m_hfonts.append(simpleFontData->platformData().hfont());
- m_scriptCaches.append(simpleFontData->platformData().scriptCache());
- m_fontProperties.append(simpleFontData->platformData().scriptFontProperties());
- m_ascents.append(simpleFontData->fontMetrics().ascent());
- }
-
- *hfont = m_hfonts[m_fontIndex - 1];
- *scriptCache = m_scriptCaches[m_fontIndex - 1];
- *fontProperties = m_fontProperties[m_fontIndex - 1];
- *ascent = m_ascents[m_fontIndex - 1];
- return true;
-}
-
-void UniscribeHelperTextRun::resetFontIndex()
-{
- m_fontIndex = 0;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/chromium/UniscribeHelperTextRun.h b/Source/WebCore/platform/graphics/chromium/UniscribeHelperTextRun.h
deleted file mode 100644
index b5c54a0dd..000000000
--- a/Source/WebCore/platform/graphics/chromium/UniscribeHelperTextRun.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (c) 2006, 2007, 2008, 2009, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef UniscribeHelperTextRun_h
-#define UniscribeHelperTextRun_h
-
-#include "UniscribeHelper.h"
-
-namespace WebCore {
-
-class Font;
-class TextRun;
-
-// Wrapper around the Uniscribe helper that automatically sets it up with the
-// WebKit types we supply.
-class UniscribeHelperTextRun : public UniscribeHelper {
-public:
- // Regular constructor used for WebCore text run processing.
- UniscribeHelperTextRun(const TextRun&, const Font&);
-
- // Constructor with the same interface as the gfx::UniscribeState. Using
- // this constructor will not give you font fallback, but it will provide
- // the ability to load fonts that may not be in the OS cache
- // ("TryToPreloadFont") if the caller does not have a TextRun/Font.
- UniscribeHelperTextRun(const wchar_t* input,
- int inputLength,
- bool isRtl,
- HFONT hfont,
- SCRIPT_CACHE*,
- SCRIPT_FONTPROPERTIES*);
-
-protected:
- virtual void tryToPreloadFont(HFONT);
-
-private:
- // This function retrieves the Windows font data (HFONT, etc) for the next
- // WebKit font in the list. If the font data corresponding to font_index_
- // has been obtained before, returns the values stored in our internal
- // vectors (hfonts_, etc). Otherwise, it gets next SimpleFontData from
- // WebKit and adds them to in hfonts_ and friends so that font data can be
- // returned quickly next time they're requested.
- virtual bool nextWinFontData(HFONT*, SCRIPT_CACHE**, SCRIPT_FONTPROPERTIES**, int* ascent);
- virtual void resetFontIndex();
-
- // Reference to WebKit::Font that contains all the information about fonts
- // we can use to render this input run of text. It is used in
- // NextWinFontData to retrieve Windows font data for a series of
- // non-primary fonts.
- //
- // This pointer can be NULL for no font fallback handling.
- const Font* m_font;
-
- // It's rare that many fonts are listed in stylesheets.
- // Four would be large enough in most cases.
- const static size_t kNumberOfFonts = 4;
-
- // These vectors are used to store Windows font data for non-primary fonts.
- Vector<HFONT, kNumberOfFonts> m_hfonts;
- Vector<SCRIPT_CACHE*, kNumberOfFonts> m_scriptCaches;
- Vector<SCRIPT_FONTPROPERTIES*, kNumberOfFonts> m_fontProperties;
- Vector<int, kNumberOfFonts> m_ascents;
-
- // Index of the fallback font we're currently using for NextWinFontData.
- int m_fontIndex;
-};
-
-} // namespace WebCore
-
-#endif // UniscribeHelperTextRun_h
diff --git a/Source/WebCore/platform/graphics/chromium/VDMXParser.cpp b/Source/WebCore/platform/graphics/chromium/VDMXParser.cpp
deleted file mode 100644
index 1d6d3d0c2..000000000
--- a/Source/WebCore/platform/graphics/chromium/VDMXParser.cpp
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <wtf/ByteOrder.h>
-
-// Buffer helper class
-//
-// This class perform some trival buffer operations while checking for
-// out-of-bounds errors. As a family they return false if anything is amiss,
-// updating the current offset otherwise.
-class Buffer {
-public:
- Buffer(const uint8_t* buffer, size_t length)
- : m_buffer(buffer)
- , m_length(length)
- , m_offset(0) { }
-
- bool skip(size_t numBytes)
- {
- if (m_offset + numBytes > m_length)
- return false;
- m_offset += numBytes;
- return true;
- }
-
- bool readU8(uint8_t* value)
- {
- if (m_offset + sizeof(uint8_t) > m_length)
- return false;
- *value = m_buffer[m_offset];
- m_offset += sizeof(uint8_t);
- return true;
- }
-
- bool readU16(uint16_t* value)
- {
- if (m_offset + sizeof(uint16_t) > m_length)
- return false;
- memcpy(value, m_buffer + m_offset, sizeof(uint16_t));
- *value = ntohs(*value);
- m_offset += sizeof(uint16_t);
- return true;
- }
-
- bool readS16(int16_t* value)
- {
- return readU16(reinterpret_cast<uint16_t*>(value));
- }
-
- size_t offset() const
- {
- return m_offset;
- }
-
- void setOffset(size_t newoffset)
- {
- m_offset = newoffset;
- }
-
-private:
- const uint8_t *const m_buffer;
- const size_t m_length;
- size_t m_offset;
-};
-
-// VDMX parsing code.
-//
-// VDMX tables are found in some TrueType/OpenType fonts and contain
-// ascender/descender overrides for certain (usually small) sizes. This is
-// needed in order to match font metrics on Windows.
-//
-// Freetype does not parse these tables so we do so here.
-
-namespace WebCore {
-
-// Parse a TrueType VDMX table.
-// yMax: (output) the ascender value from the table
-// yMin: (output) the descender value from the table (negative!)
-// vdmx: the table bytes
-// vdmxLength: length of @vdmx, in bytes
-// targetPixelSize: the pixel size of the font (e.g. 16)
-//
-// Returns true iff a suitable match are found. Otherwise, *yMax and *yMin are
-// untouched. size_t must be 32-bits to avoid overflow.
-//
-// See http://www.microsoft.com/opentype/otspec/vdmx.htm
-bool parseVDMX(int* yMax, int* yMin,
- const uint8_t* vdmx, size_t vdmxLength,
- unsigned targetPixelSize)
-{
- Buffer buf(vdmx, vdmxLength);
-
- // We ignore the version. Future tables should be backwards compatible with
- // this layout.
- uint16_t numRatios;
- if (!buf.skip(4) || !buf.readU16(&numRatios))
- return false;
-
- // Now we have two tables. Firstly we have @numRatios Ratio records, then a
- // matching array of @numRatios offsets. We save the offset of the beginning
- // of this second table.
- //
- // Range 6 <= x <= 262146
- unsigned long offsetTableOffset =
- buf.offset() + 4 /* sizeof struct ratio */ * numRatios;
-
- unsigned desiredRatio = 0xffffffff;
- // We read 4 bytes per record, so the offset range is
- // 6 <= x <= 524286
- for (unsigned i = 0; i < numRatios; ++i) {
- uint8_t xRatio, yRatio1, yRatio2;
-
- if (!buf.skip(1)
- || !buf.readU8(&xRatio)
- || !buf.readU8(&yRatio1)
- || !buf.readU8(&yRatio2))
- return false;
-
- // This either covers 1:1, or this is the default entry (0, 0, 0)
- if ((xRatio == 1 && yRatio1 <= 1 && yRatio2 >= 1)
- || (xRatio == 0 && yRatio1 == 0 && yRatio2 == 0)) {
- desiredRatio = i;
- break;
- }
- }
-
- if (desiredRatio == 0xffffffff) // no ratio found
- return false;
-
- // Range 10 <= x <= 393216
- buf.setOffset(offsetTableOffset + sizeof(uint16_t) * desiredRatio);
-
- // Now we read from the offset table to get the offset of another array
- uint16_t groupOffset;
- if (!buf.readU16(&groupOffset))
- return false;
- // Range 0 <= x <= 65535
- buf.setOffset(groupOffset);
-
- uint16_t numRecords;
- if (!buf.readU16(&numRecords) || !buf.skip(sizeof(uint16_t)))
- return false;
-
- // We read 6 bytes per record, so the offset range is
- // 4 <= x <= 458749
- for (unsigned i = 0; i < numRecords; ++i) {
- uint16_t pixelSize;
- if (!buf.readU16(&pixelSize))
- return false;
- // the entries are sorted, so we can abort early if need be
- if (pixelSize > targetPixelSize)
- return false;
-
- if (pixelSize == targetPixelSize) {
- int16_t tempYMax, tempYMin;
- if (!buf.readS16(&tempYMax)
- || !buf.readS16(&tempYMin))
- return false;
- *yMin = tempYMin;
- *yMax = tempYMax;
- return true;
- }
- if (!buf.skip(2 * sizeof(int16_t)))
- return false;
- }
-
- return false;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/chromium/VDMXParser.h b/Source/WebCore/platform/graphics/chromium/VDMXParser.h
deleted file mode 100644
index ef625b78d..000000000
--- a/Source/WebCore/platform/graphics/chromium/VDMXParser.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2009, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef VDMXParser_h
-#define VDMXParser_h
-
-namespace WebCore {
- bool parseVDMX(int* ymax, int* ymin,
- const uint8_t* vdmx, size_t vdmxLength,
- unsigned targetPixelSize);
-} // namespace WebCore
-
-#endif
diff --git a/Source/WebCore/platform/graphics/clutter/DrawingBufferClutter.cpp b/Source/WebCore/platform/graphics/clutter/DrawingBufferClutter.cpp
deleted file mode 100644
index b52ab8dd2..000000000
--- a/Source/WebCore/platform/graphics/clutter/DrawingBufferClutter.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2010, Google Inc. All rights reserved.
- * Copyright (c) 2012, Collabora Ltd.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(ACCELERATED_2D_CANVAS) || USE(3D_GRAPHICS)
-
-#include "DrawingBuffer.h"
-
-#include "Extensions3D.h"
-
-namespace WebCore {
-
-DrawingBuffer::DrawingBuffer(GraphicsContext3D* context,
- const IntSize& size,
- bool multisampleExtensionSupported,
- bool packedDepthStencilExtensionSupported,
- PreserveDrawingBuffer preserveDrawingBuffer,
- AlphaRequirement alpha)
- : m_preserveDrawingBuffer(preserveDrawingBuffer)
- , m_alpha(alpha)
- , m_frontColorBuffer(0)
- , m_separateFrontTexture(false)
-{
-}
-
-DrawingBuffer::~DrawingBuffer()
-{
-}
-
-#if USE(ACCELERATED_COMPOSITING)
-void DrawingBuffer::prepareBackBuffer()
-{
-}
-
-bool DrawingBuffer::requiresCopyFromBackToFrontBuffer() const
-{
- return false;
-}
-
-unsigned DrawingBuffer::frontColorBuffer() const
-{
- return colorBuffer();
-}
-
-void DrawingBuffer::paintCompositedResultsToCanvas(ImageBuffer*)
-{
-}
-#endif
-
-}
-
-#endif
diff --git a/Source/WebCore/platform/graphics/clutter/GraphicsContext3DClutter.cpp b/Source/WebCore/platform/graphics/clutter/GraphicsContext3DClutter.cpp
deleted file mode 100644
index 7df1ee92d..000000000
--- a/Source/WebCore/platform/graphics/clutter/GraphicsContext3DClutter.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
- * Copyright (C) 2010 Google Inc. All rights reserved.
- * Copyright (C) 2011 Igalia S.L.
- * Copyright (C) 2012 Collabora Ltd.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "GraphicsContext3D.h"
-
-#if USE(3D_GRAPHICS)
-
-#include "Extensions3DOpenGL.h"
-#include "GraphicsContext3DPrivate.h"
-#include "NotImplemented.h"
-#include <wtf/NotFound.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-
-namespace WebCore {
-
-PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attributes, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
-{
- RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attributes, hostWindow, renderStyle));
- return context.release();
-}
-
-GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attributes, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
-{
- notImplemented();
-}
-
-GraphicsContext3D::~GraphicsContext3D()
-{
- notImplemented();
-}
-
-bool GraphicsContext3D::getImageData(Image* image, unsigned int format, unsigned int type, bool premultiplyAlpha, bool ignoreGammaAndColorProfile, Vector<uint8_t>& outputVector)
-{
- notImplemented();
- return false;
-}
-
-void GraphicsContext3D::paintToCanvas(const unsigned char* imagePixels, int imageWidth, int imageHeight, int canvasWidth, int canvasHeight, PlatformContextCairo* context)
-{
- notImplemented();
-}
-
-void GraphicsContext3D::setContextLostCallback(PassOwnPtr<ContextLostCallback>)
-{
-}
-
-void GraphicsContext3D::setErrorMessageCallback(PassOwnPtr<ErrorMessageCallback>)
-{
-}
-
-bool GraphicsContext3D::makeContextCurrent()
-{
- if (!m_private)
- return false;
- return m_private->makeContextCurrent();
-}
-PlatformGraphicsContext3D GraphicsContext3D::platformGraphicsContext3D()
-{
- return m_private->platformContext();
-}
-
-bool GraphicsContext3D::isGLES2Compliant() const
-{
- return false;
-}
-
-#if USE(ACCELERATED_COMPOSITING)
-PlatformLayer* GraphicsContext3D::platformLayer() const
-{
- return m_private->platformLayer();
-}
-#endif
-
-} // namespace WebCore
-
-#endif // USE(3D_GRAPHICS)
diff --git a/Source/WebCore/platform/graphics/clutter/GraphicsContext3DPrivate.cpp b/Source/WebCore/platform/graphics/clutter/GraphicsContext3DPrivate.cpp
deleted file mode 100644
index 2aebb65e6..000000000
--- a/Source/WebCore/platform/graphics/clutter/GraphicsContext3DPrivate.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2011, 2012 Igalia S.L.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#include "config.h"
-#include "GraphicsContext3DPrivate.h"
-
-#if USE(3D_GRAPHICS)
-
-#include "HostWindow.h"
-#include "NotImplemented.h"
-
-
-namespace WebCore {
-
-PassOwnPtr<GraphicsContext3DPrivate> GraphicsContext3DPrivate::create(GraphicsContext3D* context, HostWindow* window)
-{
- return adoptPtr(new GraphicsContext3DPrivate(context, window));
-}
-
-GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, HostWindow* window)
- : m_context(context)
- , m_window(window)
-{
-}
-
-GraphicsContext3DPrivate::~GraphicsContext3DPrivate()
-{
-}
-
-bool GraphicsContext3DPrivate::makeContextCurrent()
-{
- return false;
-}
-
-PlatformGraphicsContext3D GraphicsContext3DPrivate::platformContext()
-{
- return 0;
-}
-
-#if USE(ACCELERATED_COMPOSITING) && USE(CLUTTER)
-void GraphicsContext3DPrivate::paintToGraphicsLayerActor(ClutterActor*, const FloatRect& target, const TransformationMatrix& matrix, float opacity)
-{
-}
-#endif // USE(ACCELERATED_COMPOSITING)
-
-} // namespace WebCore
-
-#endif // USE(3D_GRAPHICS)
diff --git a/Source/WebCore/platform/graphics/clutter/GraphicsContext3DPrivate.h b/Source/WebCore/platform/graphics/clutter/GraphicsContext3DPrivate.h
deleted file mode 100644
index 570f82f5c..000000000
--- a/Source/WebCore/platform/graphics/clutter/GraphicsContext3DPrivate.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2011 Igalia S.L.
- * Copyright (C) 2012 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef GraphicsContext3DPrivate_h
-#define GraphicsContext3DPrivate_h
-
-#include "GraphicsContext3D.h"
-#include <wtf/PassOwnPtr.h>
-
-#if USE(ACCELERATED_COMPOSITING) && USE(CLUTTER)
-#include <clutter/clutter.h>
-#endif
-
-namespace WebCore {
-
-class GraphicsContext3DPrivate {
-public:
- static PassOwnPtr<GraphicsContext3DPrivate> create(GraphicsContext3D*, HostWindow*);
- ~GraphicsContext3DPrivate();
- bool makeContextCurrent();
- PlatformGraphicsContext3D platformContext();
- ClutterActor* platformLayer() { return m_layer; }
-
-#if USE(ACCELERATED_COMPOSITING) && USE(CLUTTER)
- virtual void paintToGraphicsLayerActor(ClutterActor*, const FloatRect& target, const TransformationMatrix&, float opacity);
-#endif
-
-private:
- GraphicsContext3DPrivate(GraphicsContext3D*, HostWindow*);
-
- GraphicsContext3D* m_context;
- HostWindow* m_window;
- ClutterActor* m_layer;
-};
-
-}
-
-#endif // GraphicsContext3DPrivate_h
diff --git a/Source/WebCore/platform/graphics/clutter/GraphicsLayerClutter.cpp b/Source/WebCore/platform/graphics/clutter/GraphicsLayerClutter.cpp
deleted file mode 100644
index 58bf38d5b..000000000
--- a/Source/WebCore/platform/graphics/clutter/GraphicsLayerClutter.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
- * Copyright (C) 2011 Collabora Ltd.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if USE(ACCELERATED_COMPOSITING)
-#include "GraphicsLayerClutter.h"
-#include "GraphicsLayerFactory.h"
-
-#include "NotImplemented.h"
-
-namespace WebCore {
-
-PassOwnPtr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient* client)
-{
- if (!factory)
- return adoptPtr(new GraphicsLayerClutter(client));
-
- return factory->createGraphicsLayer(client);
-}
-
-PassOwnPtr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerClient* client)
-{
- return adoptPtr(new GraphicsLayerClutter(client));
-}
-
-GraphicsLayerClutter::GraphicsLayerClutter(GraphicsLayerClient* client)
- : GraphicsLayer(client)
-{
- // ClutterRectangle will be used to show the debug border.
- m_layer = adoptGRef(clutter_rectangle_new());
-}
-
-GraphicsLayerClutter::~GraphicsLayerClutter()
-{
- willBeDestroyed();
-}
-
-ClutterActor* GraphicsLayerClutter::platformLayer() const
-{
- return m_layer.get();
-}
-
-void GraphicsLayerClutter::setNeedsDisplay()
-{
- notImplemented();
- addRepaintRect(FloatRect(FloatPoint(), m_size));
-}
-
-void GraphicsLayerClutter::setNeedsDisplayInRect(const FloatRect& rect)
-{
- notImplemented();
- addRepaintRect(rect);
-}
-
-} // namespace WebCore
-
-#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebCore/platform/graphics/clutter/TransformationMatrixClutter.cpp b/Source/WebCore/platform/graphics/clutter/TransformationMatrixClutter.cpp
deleted file mode 100644
index d5c3f2ae4..000000000
--- a/Source/WebCore/platform/graphics/clutter/TransformationMatrixClutter.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2011 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#include "config.h"
-#include "TransformationMatrix.h"
-
-#include <cogl/cogl.h>
-
-namespace WebCore {
-
-TransformationMatrix::operator CoglMatrix() const
-{
- CoglMatrix matrix;
-
- matrix.xx = m11();
- matrix.xy = m21();
- matrix.xz = m31();
- matrix.xw = m41();
-
- matrix.yx = m12();
- matrix.yy = m22();
- matrix.yz = m32();
- matrix.yw = m42();
-
- matrix.zx = m13();
- matrix.zy = m23();
- matrix.zz = m33();
- matrix.zw = m43();
-
- matrix.wx = m14();
- matrix.wy = m24();
- matrix.wz = m34();
- matrix.ww = m44();
-
- return matrix;
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm b/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm
index 2700fa7d6..fab3025fc 100644
--- a/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm
+++ b/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm
@@ -28,10 +28,6 @@
#import <AppKit/NSFont.h>
#import <wtf/text/WTFString.h>
-#if PLATFORM(CHROMIUM) && OS(DARWIN)
-#import "HarfBuzzNGFace.h"
-#endif
-
namespace WebCore {
// These CoreText Text Spacing feature selectors are not defined in CoreText.
@@ -45,12 +41,10 @@ void FontPlatformData::loadFont(NSFont* nsFont, float, NSFont*& outNSFont, CGFon
}
#endif // PLATFORM(MAC)
-FontPlatformData::FontPlatformData(NSFont *nsFont, float size, bool isPrinterFont, bool syntheticBold, bool syntheticOblique, FontOrientation orientation,
- TextOrientation textOrientation, FontWidthVariant widthVariant)
+FontPlatformData::FontPlatformData(NSFont *nsFont, float size, bool isPrinterFont, bool syntheticBold, bool syntheticOblique, FontOrientation orientation, FontWidthVariant widthVariant)
: m_syntheticBold(syntheticBold)
, m_syntheticOblique(syntheticOblique)
, m_orientation(orientation)
- , m_textOrientation(textOrientation)
, m_size(size)
, m_widthVariant(widthVariant)
, m_font(nsFont)
@@ -64,8 +58,6 @@ FontPlatformData::FontPlatformData(NSFont *nsFont, float size, bool isPrinterFon
loadFont(nsFont, size, m_font, cgFont);
#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
- // FIXME: Chromium: The following code isn't correct for the Chromium port since the sandbox might
- // have blocked font loading, in which case we'll only have the real loaded font file after the call to loadFont().
{
CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(toCTFontRef(m_font));
m_isColorBitmapFont = traits & kCTFontColorGlyphsTrait;
@@ -78,7 +70,7 @@ FontPlatformData::FontPlatformData(NSFont *nsFont, float size, bool isPrinterFon
if (m_font)
CFRetain(m_font);
- m_cgFont.adoptCF(cgFont);
+ m_cgFont = adoptCF(cgFont);
}
FontPlatformData:: ~FontPlatformData()
@@ -93,11 +85,6 @@ void FontPlatformData::platformDataInit(const FontPlatformData& f)
m_cgFont = f.m_cgFont;
m_CTFont = f.m_CTFont;
-
-#if PLATFORM(CHROMIUM) && OS(DARWIN)
- m_inMemoryFont = f.m_inMemoryFont;
- m_harfbuzzFace = f.m_harfbuzzFace;
-#endif
}
const FontPlatformData& FontPlatformData::platformDataAssign(const FontPlatformData& f)
@@ -111,10 +98,6 @@ const FontPlatformData& FontPlatformData::platformDataAssign(const FontPlatformD
CFRelease(m_font);
m_font = f.m_font;
m_CTFont = f.m_CTFont;
-#if PLATFORM(CHROMIUM) && OS(DARWIN)
- m_inMemoryFont = f.m_inMemoryFont;
- m_harfbuzzFace = f.m_harfbuzzFace;
-#endif
return *this;
}
@@ -142,18 +125,8 @@ void FontPlatformData::setFont(NSFont *font)
CGFontRef cgFont = 0;
NSFont* loadedFont = 0;
loadFont(m_font, m_size, loadedFont, cgFont);
-
-#if PLATFORM(CHROMIUM) && OS(DARWIN)
- // If loadFont replaced m_font with a fallback font, then release the
- // previous font to counter the retain above. Then retain the new font.
- if (loadedFont != m_font) {
- CFRelease(m_font);
- CFRetain(loadedFont);
- m_font = loadedFont;
- }
-#endif
-
- m_cgFont.adoptCF(cgFont);
+
+ m_cgFont = adoptCF(cgFont);
#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
{
CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(toCTFontRef(m_font));
@@ -198,8 +171,8 @@ inline int mapFontWidthVariantToCTFeatureSelector(FontWidthVariant variant)
static CFDictionaryRef createFeatureSettingDictionary(int featureTypeIdentifier, int featureSelectorIdentifier)
{
- RetainPtr<CFNumberRef> featureTypeIdentifierNumber(AdoptCF, CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &featureTypeIdentifier));
- RetainPtr<CFNumberRef> featureSelectorIdentifierNumber(AdoptCF, CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &featureSelectorIdentifier));
+ RetainPtr<CFNumberRef> featureTypeIdentifierNumber = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &featureTypeIdentifier));
+ RetainPtr<CFNumberRef> featureSelectorIdentifierNumber = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &featureSelectorIdentifier));
const void* settingKeys[] = { kCTFontFeatureTypeIdentifierKey, kCTFontFeatureSelectorIdentifierKey };
const void* settingValues[] = { featureTypeIdentifierNumber.get(), featureSelectorIdentifierNumber.get() };
@@ -216,7 +189,7 @@ static CTFontDescriptorRef cascadeToLastResortFontDescriptor()
const void* keys[] = { kCTFontCascadeListAttribute };
const void* descriptors[] = { CTFontDescriptorCreateWithNameAndSize(CFSTR("LastResort"), 0) };
const void* values[] = { CFArrayCreate(kCFAllocatorDefault, descriptors, WTF_ARRAY_LENGTH(descriptors), &kCFTypeArrayCallBacks) };
- RetainPtr<CFDictionaryRef> attributes(AdoptCF, CFDictionaryCreate(kCFAllocatorDefault, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+ RetainPtr<CFDictionaryRef> attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
descriptor = CTFontDescriptorCreateWithAttributes(attributes.get());
@@ -229,64 +202,47 @@ static CTFontDescriptorRef cascadeToLastResortAndDisableSwashesFontDescriptor()
if (descriptor)
return descriptor;
- RetainPtr<CFDictionaryRef> lineInitialSwashesOffSetting(AdoptCF, createFeatureSettingDictionary(kSmartSwashType, kLineInitialSwashesOffSelector));
- RetainPtr<CFDictionaryRef> lineFinalSwashesOffSetting(AdoptCF, createFeatureSettingDictionary(kSmartSwashType, kLineFinalSwashesOffSelector));
+ RetainPtr<CFDictionaryRef> lineInitialSwashesOffSetting = adoptCF(createFeatureSettingDictionary(kSmartSwashType, kLineInitialSwashesOffSelector));
+ RetainPtr<CFDictionaryRef> lineFinalSwashesOffSetting = adoptCF(createFeatureSettingDictionary(kSmartSwashType, kLineFinalSwashesOffSelector));
const void* settingDictionaries[] = { lineInitialSwashesOffSetting.get(), lineFinalSwashesOffSetting.get() };
- RetainPtr<CFArrayRef> featureSettings(AdoptCF, CFArrayCreate(kCFAllocatorDefault, settingDictionaries, WTF_ARRAY_LENGTH(settingDictionaries), &kCFTypeArrayCallBacks));
+ RetainPtr<CFArrayRef> featureSettings = adoptCF(CFArrayCreate(kCFAllocatorDefault, settingDictionaries, WTF_ARRAY_LENGTH(settingDictionaries), &kCFTypeArrayCallBacks));
const void* keys[] = { kCTFontFeatureSettingsAttribute };
const void* values[] = { featureSettings.get() };
- RetainPtr<CFDictionaryRef> attributes(AdoptCF, CFDictionaryCreate(kCFAllocatorDefault, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+ RetainPtr<CFDictionaryRef> attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
descriptor = CTFontDescriptorCreateCopyWithAttributes(cascadeToLastResortFontDescriptor(), attributes.get());
return descriptor;
}
-// Adding a cascade list breaks the font on Leopard
-static bool canSetCascadeListForCustomFont()
-{
-#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
- return true;
-#else
- return false;
-#endif
-}
-
CTFontRef FontPlatformData::ctFont() const
{
if (m_CTFont)
return m_CTFont.get();
-#if PLATFORM(CHROMIUM)
- if (m_inMemoryFont) {
- m_CTFont.adoptCF(CTFontCreateWithGraphicsFont(m_inMemoryFont->cgFont(), m_size, 0, canSetCascadeListForCustomFont() ? cascadeToLastResortFontDescriptor() : 0));
- return m_CTFont.get();
- }
-#endif
-
m_CTFont = toCTFontRef(m_font);
if (m_CTFont) {
CTFontDescriptorRef fontDescriptor;
- RetainPtr<CFStringRef> postScriptName(AdoptCF, CTFontCopyPostScriptName(m_CTFont.get()));
+ RetainPtr<CFStringRef> postScriptName = adoptCF(CTFontCopyPostScriptName(m_CTFont.get()));
// Hoefler Text Italic has line-initial and -final swashes enabled by default, so disable them.
if (CFEqual(postScriptName.get(), CFSTR("HoeflerText-Italic")) || CFEqual(postScriptName.get(), CFSTR("HoeflerText-BlackItalic")))
fontDescriptor = cascadeToLastResortAndDisableSwashesFontDescriptor();
else
fontDescriptor = cascadeToLastResortFontDescriptor();
- m_CTFont.adoptCF(CTFontCreateCopyWithAttributes(m_CTFont.get(), m_size, 0, fontDescriptor));
+ m_CTFont = adoptCF(CTFontCreateCopyWithAttributes(m_CTFont.get(), m_size, 0, fontDescriptor));
} else
- m_CTFont.adoptCF(CTFontCreateWithGraphicsFont(m_cgFont.get(), m_size, 0, canSetCascadeListForCustomFont() ? cascadeToLastResortFontDescriptor() : 0));
+ m_CTFont = adoptCF(CTFontCreateWithGraphicsFont(m_cgFont.get(), m_size, 0, cascadeToLastResortFontDescriptor()));
if (m_widthVariant != RegularWidth) {
int featureTypeValue = kTextSpacingType;
int featureSelectorValue = mapFontWidthVariantToCTFeatureSelector(m_widthVariant);
- RetainPtr<CTFontDescriptorRef> sourceDescriptor(AdoptCF, CTFontCopyFontDescriptor(m_CTFont.get()));
- RetainPtr<CFNumberRef> featureType(AdoptCF, CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &featureTypeValue));
- RetainPtr<CFNumberRef> featureSelector(AdoptCF, CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &featureSelectorValue));
- RetainPtr<CTFontDescriptorRef> newDescriptor(AdoptCF, CTFontDescriptorCreateCopyWithFeature(sourceDescriptor.get(), featureType.get(), featureSelector.get()));
- RetainPtr<CTFontRef> newFont(AdoptCF, CTFontCreateWithFontDescriptor(newDescriptor.get(), m_size, 0));
+ RetainPtr<CTFontDescriptorRef> sourceDescriptor = adoptCF(CTFontCopyFontDescriptor(m_CTFont.get()));
+ RetainPtr<CFNumberRef> featureType = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &featureTypeValue));
+ RetainPtr<CFNumberRef> featureSelector = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &featureSelectorValue));
+ RetainPtr<CTFontDescriptorRef> newDescriptor = adoptCF(CTFontDescriptorCreateCopyWithFeature(sourceDescriptor.get(), featureType.get(), featureSelector.get()));
+ RetainPtr<CTFontRef> newFont = adoptCF(CTFontCreateWithFontDescriptor(newDescriptor.get(), m_size, 0));
if (newFont)
m_CTFont = newFont;
@@ -295,41 +251,10 @@ CTFontRef FontPlatformData::ctFont() const
return m_CTFont.get();
}
-#if PLATFORM(CHROMIUM) && OS(DARWIN)
-static bool isAATFont(CTFontRef ctFont)
-{
- CFDataRef table = CTFontCopyTable(ctFont, kCTFontTableMort, 0);
- if (table) {
- CFRelease(table);
- return true;
- }
- table = CTFontCopyTable(ctFont, kCTFontTableMorx, 0);
- if (table) {
- CFRelease(table);
- return true;
- }
- return false;
-}
-
-HarfBuzzNGFace* FontPlatformData::harfbuzzFace()
-{
- CTFontRef font = ctFont();
- // HarfBuzz can't handle AAT font
- if (isAATFont(font))
- return 0;
-
- if (!m_harfbuzzFace) {
- uint64_t uniqueID = reinterpret_cast<uintptr_t>(font);
- m_harfbuzzFace = HarfBuzzNGFace::create(const_cast<FontPlatformData*>(this), uniqueID);
- }
- return m_harfbuzzFace.get();
-}
-#endif
-
#ifndef NDEBUG
String FontPlatformData::description() const
{
- RetainPtr<CFStringRef> cgFontDescription(AdoptCF, CFCopyDescription(cgFont()));
+ RetainPtr<CFStringRef> cgFontDescription = adoptCF(CFCopyDescription(cgFont()));
return String(cgFontDescription.get()) + " " + String::number(m_size)
+ (m_syntheticBold ? " synthetic bold" : "") + (m_syntheticOblique ? " synthetic oblique" : "") + (m_orientation ? " vertical orientation" : "");
}
diff --git a/Source/WebCore/platform/graphics/cpu/arm/GraphicsContext3DNEON.h b/Source/WebCore/platform/graphics/cpu/arm/GraphicsContext3DNEON.h
index a10f65d05..c043fedd4 100644
--- a/Source/WebCore/platform/graphics/cpu/arm/GraphicsContext3DNEON.h
+++ b/Source/WebCore/platform/graphics/cpu/arm/GraphicsContext3DNEON.h
@@ -32,10 +32,93 @@
namespace WebCore {
-namespace ARM {
+namespace SIMD {
-ALWAYS_INLINE void unpackOneRowOfRGBA4444ToRGBA8NEON(const uint16_t* source, uint8_t* destination, unsigned pixelSize)
+ALWAYS_INLINE void unpackOneRowOfRGBA16LittleToRGBA8(const uint16_t*& source, uint8_t*& destination, unsigned& pixelsPerRow)
{
+ unsigned componentsPerRow = pixelsPerRow * 4;
+ unsigned tailComponents = componentsPerRow % 16;
+ unsigned componentsSize = componentsPerRow - tailComponents;
+ const uint8_t* src = reinterpret_cast<const uint8_t*>(source);
+
+ for (unsigned i = 0; i < componentsSize; i += 16) {
+ uint8x16x2_t components = vld2q_u8(src + i * 2);
+ vst1q_u8(destination + i, components.val[1]);
+ }
+
+ source += componentsSize;
+ destination += componentsSize;
+ pixelsPerRow = tailComponents / 4;
+}
+
+ALWAYS_INLINE void unpackOneRowOfRGB16LittleToRGBA8(const uint16_t*& source, uint8_t*& destination, unsigned& pixelsPerRow)
+{
+ unsigned componentsPerRow = pixelsPerRow * 3;
+ unsigned tailComponents = componentsPerRow % 24;
+ unsigned componentsSize = componentsPerRow - tailComponents;
+
+ uint8x8_t componentA = vdup_n_u8(0xFF);
+ for (unsigned i = 0; i < componentsSize; i += 24) {
+ uint16x8x3_t RGB16 = vld3q_u16(source + i);
+ uint8x8_t componentR = vqmovn_u16(vshrq_n_u16(RGB16.val[0], 8));
+ uint8x8_t componentG = vqmovn_u16(vshrq_n_u16(RGB16.val[1], 8));
+ uint8x8_t componentB = vqmovn_u16(vshrq_n_u16(RGB16.val[2], 8));
+ uint8x8x4_t RGBA8 = {{componentR, componentG, componentB, componentA}};
+ vst4_u8(destination, RGBA8);
+ destination += 32;
+ }
+
+ source += componentsSize;
+ pixelsPerRow = tailComponents / 3;
+}
+
+ALWAYS_INLINE void unpackOneRowOfARGB16LittleToRGBA8(const uint16_t*& source, uint8_t*& destination, unsigned& pixelsPerRow)
+{
+ unsigned componentsPerRow = pixelsPerRow * 4;
+ unsigned tailComponents = componentsPerRow % 32;
+ unsigned componentsSize = componentsPerRow - tailComponents;
+
+ for (unsigned i = 0; i < componentsSize; i += 32) {
+ uint16x8x4_t ARGB16 = vld4q_u16(source + i);
+ uint8x8_t componentA = vqmovn_u16(vshrq_n_u16(ARGB16.val[0], 8));
+ uint8x8_t componentR = vqmovn_u16(vshrq_n_u16(ARGB16.val[1], 8));
+ uint8x8_t componentG = vqmovn_u16(vshrq_n_u16(ARGB16.val[2], 8));
+ uint8x8_t componentB = vqmovn_u16(vshrq_n_u16(ARGB16.val[3], 8));
+ uint8x8x4_t RGBA8 = {{componentR, componentG, componentB, componentA}};
+ vst4_u8(destination + i, RGBA8);
+ }
+
+ source += componentsSize;
+ destination += componentsSize;
+ pixelsPerRow = tailComponents / 4;
+}
+
+ALWAYS_INLINE void unpackOneRowOfBGRA16LittleToRGBA8(const uint16_t*& source, uint8_t*& destination, unsigned& pixelsPerRow)
+{
+ unsigned componentsPerRow = pixelsPerRow * 4;
+ unsigned tailComponents = componentsPerRow % 32;
+ unsigned componentsSize = componentsPerRow - tailComponents;
+
+ for (unsigned i = 0; i < componentsSize; i += 32) {
+ uint16x8x4_t ARGB16 = vld4q_u16(source + i);
+ uint8x8_t componentB = vqmovn_u16(vshrq_n_u16(ARGB16.val[0], 8));
+ uint8x8_t componentG = vqmovn_u16(vshrq_n_u16(ARGB16.val[1], 8));
+ uint8x8_t componentR = vqmovn_u16(vshrq_n_u16(ARGB16.val[2], 8));
+ uint8x8_t componentA = vqmovn_u16(vshrq_n_u16(ARGB16.val[3], 8));
+ uint8x8x4_t RGBA8 = {{componentR, componentG, componentB, componentA}};
+ vst4_u8(destination + i, RGBA8);
+ }
+
+ source += componentsSize;
+ destination += componentsSize;
+ pixelsPerRow = tailComponents / 4;
+}
+
+ALWAYS_INLINE void unpackOneRowOfRGBA4444ToRGBA8(const uint16_t*& source, uint8_t*& destination, unsigned& pixelsPerRow)
+{
+ unsigned tailPixels = pixelsPerRow % 8;
+ unsigned pixelSize = pixelsPerRow - tailPixels;
+
uint16x8_t immediate0x0f = vdupq_n_u16(0x0F);
for (unsigned i = 0; i < pixelSize; i += 8) {
uint16x8_t eightPixels = vld1q_u16(source + i);
@@ -54,10 +137,17 @@ ALWAYS_INLINE void unpackOneRowOfRGBA4444ToRGBA8NEON(const uint16_t* source, uin
vst4_u8(destination, destComponents);
destination += 32;
}
+
+ source += pixelSize;
+ pixelsPerRow = tailPixels;
}
-ALWAYS_INLINE void packOneRowOfRGBA8ToUnsignedShort4444NEON(const uint8_t* source, uint16_t* destination, unsigned componentsSize)
+ALWAYS_INLINE void packOneRowOfRGBA8ToUnsignedShort4444(const uint8_t*& source, uint16_t*& destination, unsigned& pixelsPerRow)
{
+ unsigned componentsPerRow = pixelsPerRow * 4;
+ unsigned tailComponents = componentsPerRow % 32;
+ unsigned componentsSize = componentsPerRow - tailComponents;
+
uint8_t* dst = reinterpret_cast<uint8_t*>(destination);
uint8x8_t immediate0xf0 = vdup_n_u8(0xF0);
for (unsigned i = 0; i < componentsSize; i += 32) {
@@ -74,10 +164,17 @@ ALWAYS_INLINE void packOneRowOfRGBA8ToUnsignedShort4444NEON(const uint8_t* sourc
vst2_u8(dst, RGBA4);
dst += 16;
}
+
+ source += componentsSize;
+ destination += componentsSize / 4;
+ pixelsPerRow = tailComponents / 4;
}
-ALWAYS_INLINE void unpackOneRowOfRGBA5551ToRGBA8NEON(const uint16_t* source, uint8_t* destination, unsigned pixelSize)
+ALWAYS_INLINE void unpackOneRowOfRGBA5551ToRGBA8(const uint16_t*& source, uint8_t*& destination, unsigned& pixelsPerRow)
{
+ unsigned tailPixels = pixelsPerRow % 8;
+ unsigned pixelSize = pixelsPerRow - tailPixels;
+
uint8x8_t immediate0x7 = vdup_n_u8(0x7);
uint8x8_t immediate0xff = vdup_n_u8(0xFF);
uint16x8_t immediate0x1f = vdupq_n_u16(0x1F);
@@ -100,10 +197,17 @@ ALWAYS_INLINE void unpackOneRowOfRGBA5551ToRGBA8NEON(const uint16_t* source, uin
vst4_u8(destination, destComponents);
destination += 32;
}
+
+ source += pixelSize;
+ pixelsPerRow = tailPixels;
}
-ALWAYS_INLINE void packOneRowOfRGBA8ToUnsignedShort5551NEON(const uint8_t* source, uint16_t* destination, unsigned componentsSize)
+ALWAYS_INLINE void packOneRowOfRGBA8ToUnsignedShort5551(const uint8_t*& source, uint16_t*& destination, unsigned& pixelsPerRow)
{
+ unsigned componentsPerRow = pixelsPerRow * 4;
+ unsigned tailComponents = componentsPerRow % 32;
+ unsigned componentsSize = componentsPerRow - tailComponents;
+
uint8_t* dst = reinterpret_cast<uint8_t*>(destination);
uint8x8_t immediate0xf8 = vdup_n_u8(0xF8);
@@ -124,10 +228,17 @@ ALWAYS_INLINE void packOneRowOfRGBA8ToUnsignedShort5551NEON(const uint8_t* sourc
vst2_u8(dst, RGBA5551);
dst += 16;
}
+
+ source += componentsSize;
+ destination += componentsSize / 4;
+ pixelsPerRow = tailComponents / 4;
}
-ALWAYS_INLINE void unpackOneRowOfRGB565ToRGBA8NEON(const uint16_t* source, uint8_t* destination, unsigned pixelSize)
+ALWAYS_INLINE void unpackOneRowOfRGB565ToRGBA8(const uint16_t*& source, uint8_t*& destination, unsigned& pixelsPerRow)
{
+ unsigned tailPixels = pixelsPerRow % 8;
+ unsigned pixelSize = pixelsPerRow - tailPixels;
+
uint16x8_t immediate0x3f = vdupq_n_u16(0x3F);
uint16x8_t immediate0x1f = vdupq_n_u16(0x1F);
uint8x8_t immediate0x3 = vdup_n_u8(0x3);
@@ -150,10 +261,16 @@ ALWAYS_INLINE void unpackOneRowOfRGB565ToRGBA8NEON(const uint16_t* source, uint8
vst4_u8(destination, destComponents);
destination += 32;
}
+
+ source += pixelSize;
+ pixelsPerRow = tailPixels;
}
-ALWAYS_INLINE void packOneRowOfRGBA8ToUnsignedShort565NEON(const uint8_t* source, uint16_t* destination, unsigned componentsSize)
+ALWAYS_INLINE void packOneRowOfRGBA8ToUnsignedShort565(const uint8_t*& source, uint16_t*& destination, unsigned& pixelsPerRow)
{
+ unsigned componentsPerRow = pixelsPerRow * 4;
+ unsigned tailComponents = componentsPerRow % 32;
+ unsigned componentsSize = componentsPerRow - tailComponents;
uint8_t* dst = reinterpret_cast<uint8_t*>(destination);
uint8x8_t immediate0xf8 = vdup_n_u8(0xF8);
@@ -172,9 +289,13 @@ ALWAYS_INLINE void packOneRowOfRGBA8ToUnsignedShort565NEON(const uint8_t* source
vst2_u8(dst, RGB565);
dst += 16;
}
+
+ source += componentsSize;
+ destination += componentsSize / 4;
+ pixelsPerRow = tailComponents / 4;
}
-} // namespace ARM
+} // namespace SIMD
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/cpu/arm/filters/FEBlendNEON.h b/Source/WebCore/platform/graphics/cpu/arm/filters/FEBlendNEON.h
index 97418f2c1..e41ffa216 100644
--- a/Source/WebCore/platform/graphics/cpu/arm/filters/FEBlendNEON.h
+++ b/Source/WebCore/platform/graphics/cpu/arm/filters/FEBlendNEON.h
@@ -27,8 +27,6 @@
#ifndef FEBlendNEON_h
#define FEBlendNEON_h
-#include <wtf/Platform.h>
-
#if ENABLE(FILTERS) && HAVE(ARM_NEON_INTRINSICS)
#include "FEBlend.h"
diff --git a/Source/WebCore/platform/graphics/cpu/arm/filters/NEONHelpers.h b/Source/WebCore/platform/graphics/cpu/arm/filters/NEONHelpers.h
index 53cdc77b6..3708b9d0a 100644
--- a/Source/WebCore/platform/graphics/cpu/arm/filters/NEONHelpers.h
+++ b/Source/WebCore/platform/graphics/cpu/arm/filters/NEONHelpers.h
@@ -27,8 +27,6 @@
#ifndef NEONHelpers_h
#define NEONHelpers_h
-#include <wtf/Platform.h>
-
#if ENABLE(FILTERS) && HAVE(ARM_NEON_INTRINSICS)
#include <arm_neon.h>
diff --git a/Source/WebCore/platform/graphics/efl/CairoUtilitiesEfl.cpp b/Source/WebCore/platform/graphics/efl/CairoUtilitiesEfl.cpp
index aa4d74990..679f59e3a 100644
--- a/Source/WebCore/platform/graphics/efl/CairoUtilitiesEfl.cpp
+++ b/Source/WebCore/platform/graphics/efl/CairoUtilitiesEfl.cpp
@@ -32,20 +32,20 @@ PassRefPtr<Evas_Object> evasObjectFromCairoImageSurface(Evas* canvas, cairo_surf
cairo_status_t status = cairo_surface_status(surface);
if (status != CAIRO_STATUS_SUCCESS) {
- fprintf(stderr, "cairo surface is invalid: %s", cairo_status_to_string(status));
+ EINA_LOG_ERR("cairo surface is invalid: %s", cairo_status_to_string(status));
return 0;
}
cairo_surface_type_t type = cairo_surface_get_type(surface);
if (type != CAIRO_SURFACE_TYPE_IMAGE) {
- fprintf(stderr, "unknown surface type %d, required %d (CAIRO_SURFACE_TYPE_IMAGE).",
+ EINA_LOG_ERR("unknown surface type %d, required %d (CAIRO_SURFACE_TYPE_IMAGE).",
type, CAIRO_SURFACE_TYPE_IMAGE);
return 0;
}
cairo_format_t format = cairo_image_surface_get_format(surface);
if (format != CAIRO_FORMAT_ARGB32 && format != CAIRO_FORMAT_RGB24) {
- fprintf(stderr, "unknown surface format %d, expected %d or %d.",
+ EINA_LOG_ERR("unknown surface format %d, expected %d or %d.",
format, CAIRO_FORMAT_ARGB32, CAIRO_FORMAT_RGB24);
return 0;
}
@@ -54,19 +54,19 @@ PassRefPtr<Evas_Object> evasObjectFromCairoImageSurface(Evas* canvas, cairo_surf
int height = cairo_image_surface_get_height(surface);
int stride = cairo_image_surface_get_stride(surface);
if (width <= 0 || height <= 0 || stride <= 0) {
- fprintf(stderr, "invalid image size %dx%d, stride=%d", width, height, stride);
+ EINA_LOG_ERR("invalid image size %dx%d, stride=%d", width, height, stride);
return 0;
}
void* data = cairo_image_surface_get_data(surface);
if (!data) {
- fprintf(stderr, "could not get source data.");
+ EINA_LOG_ERR("could not get source data.");
return 0;
}
RefPtr<Evas_Object> image = adoptRef(evas_object_image_filled_add(canvas));
if (!image) {
- fprintf(stderr, "could not add image to canvas.");
+ EINA_LOG_ERR("could not add image to canvas.");
return 0;
}
@@ -75,7 +75,7 @@ PassRefPtr<Evas_Object> evasObjectFromCairoImageSurface(Evas* canvas, cairo_surf
evas_object_image_alpha_set(image.get(), format == CAIRO_FORMAT_ARGB32);
if (evas_object_image_stride_get(image.get()) != stride) {
- fprintf(stderr, "evas' stride %d diverges from cairo's %d.",
+ EINA_LOG_ERR("evas' stride %d diverges from cairo's %d.",
evas_object_image_stride_get(image.get()), stride);
return 0;
}
diff --git a/Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp b/Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp
index 2e2a49313..ea25e4355 100644
--- a/Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp
+++ b/Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp
@@ -23,25 +23,17 @@
#if USE(3D_GRAPHICS) || USE(ACCELERATED_COMPOSITING)
+#include "GLDefs.h"
#include "GraphicsContext3DPrivate.h"
-#include "ImageData.h"
+#include "Image.h"
+#include "ImageSource.h"
#include "NotImplemented.h"
-#include "OpenGLShims.h"
#include "PlatformContextCairo.h"
-#if USE(OPENGL_ES_2)
-#include "Extensions3DOpenGLES.h"
-#else
-#include "Extensions3DOpenGL.h"
-#endif
-
namespace WebCore {
PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, RenderStyle renderStyle)
{
- if (renderStyle == RenderDirectlyToHostWindow)
- return 0;
-
RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, renderStyle));
return context->m_private ? context.release() : 0;
}
@@ -62,24 +54,19 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi
, m_depthStencilBuffer(0)
, m_layerComposited(false)
, m_internalColorFormat(0)
- , m_boundFBO(0)
- , m_activeTexture(GL_TEXTURE0)
- , m_boundTexture0(0)
, m_multisampleFBO(0)
, m_multisampleDepthStencilBuffer(0)
, m_multisampleColorBuffer(0)
- , m_private(adoptPtr(new GraphicsContext3DPrivate(this, hostWindow, renderStyle)))
+ , m_private(GraphicsContext3DPrivate::create(this, hostWindow))
{
- if (!m_private || !m_private->m_platformContext) {
- m_private = nullptr;
+ if (!m_private)
return;
- }
validateAttributes();
if (renderStyle == RenderOffscreen) {
// Create buffers for the canvas FBO.
- glGenFramebuffers(/* count */ 1, &m_fbo);
+ glGenFramebuffers(1, &m_fbo);
// Create a texture to render into.
glGenTextures(1, &m_texture);
@@ -94,18 +81,18 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi
if (m_attrs.antialias) {
glGenFramebuffers(1, &m_multisampleFBO);
glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO);
- m_boundFBO = m_multisampleFBO;
+ m_state.boundFBO = m_multisampleFBO;
glGenRenderbuffers(1, &m_multisampleColorBuffer);
if (m_attrs.stencil || m_attrs.depth)
glGenRenderbuffers(1, &m_multisampleDepthStencilBuffer);
} else {
// Bind canvas FBO.
glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
- m_boundFBO = m_fbo;
+ m_state.boundFBO = m_fbo;
#if USE(OPENGL_ES_2)
if (m_attrs.depth)
glGenRenderbuffers(1, &m_depthBuffer);
- if (m_context->m_attrs.stencil)
+ if (m_attrs.stencil)
glGenRenderbuffers(1, &m_stencilBuffer);
#endif
if (m_attrs.stencil || m_attrs.depth)
@@ -127,47 +114,55 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi
// Always set to 1 for OpenGL ES.
ANGLEResources.MaxDrawBuffers = 1;
+
+ GC3Dint range[2], precision;
+ getShaderPrecisionFormat(GraphicsContext3D::FRAGMENT_SHADER, GraphicsContext3D::HIGH_FLOAT, range, &precision);
+ ANGLEResources.FragmentPrecisionHigh = (range[0] || range[1] || precision);
+
m_compiler.setResources(ANGLEResources);
#if !USE(OPENGL_ES_2)
glEnable(GL_POINT_SPRITE);
glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
#endif
- glClearColor(0.0, 0.0, 0.0, 0.0);
+ if (renderStyle != RenderToCurrentGLContext)
+ glClearColor(0.0, 0.0, 0.0, 0.0);
}
GraphicsContext3D::~GraphicsContext3D()
{
- if (!m_private || !makeContextCurrent())
+ if (!m_private || (m_renderStyle == RenderToCurrentGLContext) || !makeContextCurrent())
return;
- if (!m_fbo) {
- m_private->releaseResources();
- return;
- }
+ glBindFramebuffer(GL_FRAMEBUFFER, 0);
+ glBindTexture(GL_TEXTURE_2D, 0);
+
+ if (m_texture)
+ glDeleteTextures(1, &m_texture);
- glDeleteTextures(1, &m_texture);
+ if (m_fbo)
+ glDeleteFramebuffers(1, &m_fbo);
if (m_attrs.antialias) {
- glDeleteRenderbuffers(1, &m_multisampleColorBuffer);
+ if (m_multisampleColorBuffer)
+ glDeleteRenderbuffers(1, &m_multisampleColorBuffer);
- if (m_attrs.stencil || m_attrs.depth)
+ if (m_multisampleDepthStencilBuffer)
glDeleteRenderbuffers(1, &m_multisampleDepthStencilBuffer);
- glDeleteFramebuffers(1, &m_multisampleFBO);
+ if (m_multisampleFBO)
+ glDeleteFramebuffers(1, &m_multisampleFBO);
} else if (m_attrs.stencil || m_attrs.depth) {
#if USE(OPENGL_ES_2)
- if (m_attrs.depth)
+ if (m_depthBuffer)
glDeleteRenderbuffers(1, &m_depthBuffer);
- if (m_attrs.stencil)
+ if (m_stencilBuffer)
glDeleteRenderbuffers(1, &m_stencilBuffer);
#endif
- glDeleteRenderbuffers(1, &m_depthStencilBuffer);
+ if (m_depthStencilBuffer)
+ glDeleteRenderbuffers(1, &m_depthStencilBuffer);
}
-
- glDeleteFramebuffers(1, &m_fbo);
- m_private->releaseResources();
}
PlatformGraphicsContext3D GraphicsContext3D::platformGraphicsContext3D()
@@ -175,6 +170,11 @@ PlatformGraphicsContext3D GraphicsContext3D::platformGraphicsContext3D()
return m_private->platformGraphicsContext3D();
}
+Platform3DObject GraphicsContext3D::platformTexture() const
+{
+ return m_texture;
+}
+
#if USE(ACCELERATED_COMPOSITING)
PlatformLayer* GraphicsContext3D::platformLayer() const
{
@@ -222,14 +222,14 @@ void GraphicsContext3D::paintToCanvas(const unsigned char* imagePixels, int imag
RefPtr<cairo_surface_t> imageSurface = adoptRef(cairo_image_surface_create_for_data(
const_cast<unsigned char*>(imagePixels), CAIRO_FORMAT_ARGB32, imageWidth, imageHeight, imageWidth * 4));
- // OpenGL keeps the pixels stored bottom up, so we need to flip the image here.
- cairo_translate(cr, 0, imageHeight);
- cairo_scale(cr, 1, -1);
+ cairo_rectangle(cr, 0, 0, canvasWidth, canvasHeight);
+ // OpenGL keeps the pixels stored bottom up, so we need to flip the image here.
+ cairo_matrix_t matrix;
+ cairo_matrix_init(&matrix, 1.0, 0.0, 0.0, -1.0, 0.0, imageHeight);
+ cairo_set_matrix(cr, &matrix);
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
cairo_set_source_surface(cr, imageSurface.get(), 0, 0);
- cairo_rectangle(cr, 0, 0, canvasWidth, -canvasHeight);
-
cairo_fill(cr);
context->restore();
}
@@ -237,14 +237,78 @@ void GraphicsContext3D::paintToCanvas(const unsigned char* imagePixels, int imag
#if USE(GRAPHICS_SURFACE)
void GraphicsContext3D::createGraphicsSurfaces(const IntSize& size)
{
- m_private->createGraphicsSurfaces(size);
+ m_private->didResizeCanvas(size);
}
#endif
-bool GraphicsContext3D::getImageData(Image*, GC3Denum /* format */, GC3Denum /* type */, bool /* premultiplyAlpha */, bool /* ignoreGammaAndColorProfile */, Vector<uint8_t>& /* outputVector */)
+GraphicsContext3D::ImageExtractor::~ImageExtractor()
{
- notImplemented();
- return false;
+ delete m_decoder;
+}
+
+bool GraphicsContext3D::ImageExtractor::extractImage(bool premultiplyAlpha, bool ignoreGammaAndColorProfile)
+{
+ // This implementation is taken from GraphicsContext3DCairo.
+
+ if (!m_image)
+ return false;
+
+ // We need this to stay in scope because the native image is just a shallow copy of the data.
+ m_decoder = new ImageSource(premultiplyAlpha ? ImageSource::AlphaPremultiplied : ImageSource::AlphaNotPremultiplied, ignoreGammaAndColorProfile ? ImageSource::GammaAndColorProfileIgnored : ImageSource::GammaAndColorProfileApplied);
+
+ if (!m_decoder)
+ return false;
+
+ ImageSource& decoder = *m_decoder;
+ m_alphaOp = AlphaDoNothing;
+
+ if (m_image->data()) {
+ decoder.setData(m_image->data(), true);
+
+ if (!decoder.frameCount())
+ return false;
+
+ m_imageSurface = decoder.createFrameAtIndex(0);
+ if (!m_imageSurface || !decoder.frameIsCompleteAtIndex(0))
+ return false;
+ } else {
+ m_imageSurface = m_image->nativeImageForCurrentFrame();
+ // 1. For texImage2D with HTMLVideoElment input, assume no PremultiplyAlpha had been applied and the alpha value is 0xFF for each pixel,
+ // which is true at present and may be changed in the future and needs adjustment accordingly.
+ // 2. For texImage2D with HTMLCanvasElement input in which Alpha is already Premultiplied in this port,
+ // do AlphaDoUnmultiply if UNPACK_PREMULTIPLY_ALPHA_WEBGL is set to false.
+ if (!premultiplyAlpha && m_imageHtmlDomSource != HtmlDomVideo)
+ m_alphaOp = AlphaDoUnmultiply;
+ }
+
+ if (!m_imageSurface)
+ return false;
+
+ m_imageWidth = cairo_image_surface_get_width(m_imageSurface.get());
+ m_imageHeight = cairo_image_surface_get_height(m_imageSurface.get());
+
+ if (!m_imageWidth || !m_imageHeight)
+ return false;
+
+ if (cairo_image_surface_get_format(m_imageSurface.get()) != CAIRO_FORMAT_ARGB32)
+ return false;
+
+ uint srcUnpackAlignment = 1;
+ size_t bytesPerRow = cairo_image_surface_get_stride(m_imageSurface.get());
+ size_t bitsPerPixel = 32;
+ unsigned padding = bytesPerRow - bitsPerPixel / 8 * m_imageWidth;
+
+ if (padding) {
+ srcUnpackAlignment = padding + 1;
+ while (bytesPerRow % srcUnpackAlignment)
+ ++srcUnpackAlignment;
+ }
+
+ m_imagePixelData = cairo_image_surface_get_data(m_imageSurface.get());
+ m_imageSourceFormat = DataFormatBGRA8;
+ m_imageSourceUnpackAlignment = srcUnpackAlignment;
+
+ return true;
}
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp b/Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp
index c9fc4a0e1..c1b7b6ca0 100644
--- a/Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp
+++ b/Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp
@@ -1,6 +1,6 @@
/*
Copyright (C) 2012 Samsung Electronics
- Copyright (C) 2012 Intel Corporation.
+ Copyright (C) 2012 Intel Corporation. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -25,71 +25,86 @@
#include "HostWindow.h"
#include "NotImplemented.h"
-#include "PlatformContextCairo.h"
-
-#if USE(OPENGL_ES_2)
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-#else
-#include "OpenGLShims.h"
-#endif
namespace WebCore {
-GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
+PassOwnPtr<GraphicsContext3DPrivate> GraphicsContext3DPrivate::create(GraphicsContext3D* context, HostWindow* hostWindow)
+{
+ OwnPtr<GraphicsContext3DPrivate> platformLayer = adoptPtr(new GraphicsContext3DPrivate(context, hostWindow));
+
+ if (platformLayer && platformLayer->initialize())
+ return platformLayer.release();
+
+ return nullptr;
+}
+
+GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, HostWindow* hostWindow)
: m_context(context)
, m_hostWindow(hostWindow)
- , m_pendingSurfaceResize(false)
{
+}
+
+bool GraphicsContext3DPrivate::initialize()
+{
+ if (m_context->m_renderStyle == GraphicsContext3D::RenderDirectlyToHostWindow)
+ return false;
+
if (m_hostWindow && m_hostWindow->platformPageClient()) {
// FIXME: Implement this code path for WebKit1.
// Get Evas object from platformPageClient and set EvasGL related members.
- return;
+ return false;
}
- m_platformContext = GLPlatformContext::createContext(renderStyle);
- if (!m_platformContext)
- return;
+ m_offScreenContext = GLPlatformContext::createContext(m_context->m_renderStyle);
+ if (!m_offScreenContext)
+ return false;
- if (renderStyle == GraphicsContext3D::RenderOffscreen) {
-#if USE(GRAPHICS_SURFACE)
- m_platformSurface = GLPlatformSurface::createTransportSurface();
-#else
- m_platformSurface = GLPlatformSurface::createOffscreenSurface();
-#endif
- if (!m_platformSurface) {
- m_platformContext = nullptr;
- return;
- }
+ if (m_context->m_renderStyle == GraphicsContext3D::RenderOffscreen) {
+ m_offScreenSurface = GLPlatformSurface::createOffScreenSurface();
+
+ if (!m_offScreenSurface)
+ return false;
- if (!m_platformContext->initialize(m_platformSurface.get()) || !m_platformContext->makeCurrent(m_platformSurface.get())) {
- releaseResources();
- m_platformContext = nullptr;
- m_platformSurface = nullptr;
+ if (!m_offScreenContext->initialize(m_offScreenSurface.get()))
+ return false;
+
+ if (!makeContextCurrent())
+ return false;
#if USE(GRAPHICS_SURFACE)
- } else
- m_surfaceHandle = GraphicsSurfaceToken(m_platformSurface->handle());
-#else
- }
+ m_surfaceOperation = CreateSurface;
#endif
}
+
+ return true;
}
GraphicsContext3DPrivate::~GraphicsContext3DPrivate()
{
+ releaseResources();
}
void GraphicsContext3DPrivate::releaseResources()
{
+ if (m_context->m_renderStyle == GraphicsContext3D::RenderToCurrentGLContext)
+ return;
+
// Release the current context and drawable only after destroying any associated gl resources.
- if (m_platformContext)
- m_platformContext->destroy();
+#if USE(GRAPHICS_SURFACE)
+ if (m_previousGraphicsSurface)
+ m_previousGraphicsSurface = nullptr;
- if (m_platformSurface)
- m_platformSurface->destroy();
+ if (m_graphicsSurface)
+ m_graphicsSurface = nullptr;
- if (m_platformContext)
- m_platformContext->releaseCurrent();
+ m_surfaceHandle = GraphicsSurfaceToken();
+#endif
+ if (m_offScreenSurface)
+ m_offScreenSurface->destroy();
+
+ if (m_offScreenContext) {
+ m_offScreenContext->destroy();
+ m_offScreenContext->releaseCurrent();
+ }
}
bool GraphicsContext3DPrivate::createSurface(PageClientEfl*, bool)
@@ -105,63 +120,158 @@ void GraphicsContext3DPrivate::setContextLostCallback(PassOwnPtr<GraphicsContext
PlatformGraphicsContext3D GraphicsContext3DPrivate::platformGraphicsContext3D() const
{
- return m_platformContext->handle();
+ return m_offScreenContext->handle();
}
-bool GraphicsContext3DPrivate::makeContextCurrent()
+bool GraphicsContext3DPrivate::makeContextCurrent() const
{
- bool success = m_platformContext->makeCurrent(m_platformSurface.get());
+ bool success = m_offScreenContext->makeCurrent(m_offScreenSurface.get());
- if (!m_platformContext->isValid()) {
+ if (!m_offScreenContext->isValid()) {
// FIXME: Restore context
if (m_contextLostCallback)
m_contextLostCallback->onContextLost();
- success = false;
+ return false;
}
return success;
}
+bool GraphicsContext3DPrivate::prepareBuffer() const
+{
+ if (!makeContextCurrent())
+ return false;
+
+ m_context->markLayerComposited();
+
+ if (m_context->m_attrs.antialias) {
+ bool enableScissorTest = false;
+ int width = m_context->m_currentWidth;
+ int height = m_context->m_currentHeight;
+ // We should copy the full buffer, and not respect the current scissor bounds.
+ // FIXME: It would be more efficient to track the state of the scissor test.
+ if (m_context->isEnabled(GraphicsContext3D::SCISSOR_TEST)) {
+ enableScissorTest = true;
+ m_context->disable(GraphicsContext3D::SCISSOR_TEST);
+ }
+
+ glBindFramebuffer(Extensions3D::READ_FRAMEBUFFER, m_context->m_multisampleFBO);
+ glBindFramebuffer(Extensions3D::DRAW_FRAMEBUFFER, m_context->m_fbo);
+
+ // Use NEAREST as no scale is performed during the blit.
+ m_context->getExtensions()->blitFramebuffer(0, 0, width, height, 0, 0, width, height, GraphicsContext3D::COLOR_BUFFER_BIT, GraphicsContext3D::NEAREST);
+
+ if (enableScissorTest)
+ m_context->enable(GraphicsContext3D::SCISSOR_TEST);
+
+ glBindFramebuffer(GL_FRAMEBUFFER, m_context->m_state.boundFBO);
+ }
+
+ return true;
+}
+
#if USE(TEXTURE_MAPPER_GL)
-void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper*, const FloatRect& /* target */, const TransformationMatrix&, float /* opacity */, BitmapTexture* /* mask */)
+void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper*, const FloatRect& /* target */, const TransformationMatrix&, float /* opacity */)
{
notImplemented();
}
#endif
#if USE(GRAPHICS_SURFACE)
-void GraphicsContext3DPrivate::createGraphicsSurfaces(const IntSize&)
+void GraphicsContext3DPrivate::createGraphicsSurface()
+{
+ static PendingSurfaceOperation pendingOperation = DeletePreviousSurface | Resize | CreateSurface;
+ if (!(m_surfaceOperation & pendingOperation))
+ return;
+
+ if (m_surfaceOperation & DeletePreviousSurface) {
+ m_previousGraphicsSurface = nullptr;
+ m_surfaceOperation &= ~DeletePreviousSurface;
+ }
+
+ if (!(m_surfaceOperation & pendingOperation))
+ return;
+
+ // Don't release current graphics surface until we have prepared surface
+ // with requested size. This is to avoid flashing during resize.
+ if (m_surfaceOperation & Resize) {
+ m_previousGraphicsSurface = m_graphicsSurface;
+ m_surfaceOperation &= ~Resize;
+ m_surfaceOperation |= DeletePreviousSurface;
+ m_size = IntSize(m_context->m_currentWidth, m_context->m_currentHeight);
+ } else
+ m_surfaceOperation &= ~CreateSurface;
+
+ m_targetRect = IntRect(IntPoint(), m_size);
+
+ if (m_size.isEmpty()) {
+ if (m_graphicsSurface) {
+ m_graphicsSurface = nullptr;
+ m_surfaceHandle = GraphicsSurfaceToken();
+ makeContextCurrent();
+ }
+
+ return;
+ }
+
+ m_offScreenContext->releaseCurrent();
+ GraphicsSurface::Flags flags = GraphicsSurface::SupportsTextureTarget | GraphicsSurface::SupportsSharing;
+
+ if (m_context->m_attrs.alpha)
+ flags |= GraphicsSurface::SupportsAlpha;
+
+ m_graphicsSurface = GraphicsSurface::create(m_size, flags, m_offScreenContext->handle());
+
+ if (!m_graphicsSurface)
+ m_surfaceHandle = GraphicsSurfaceToken();
+ else
+ m_surfaceHandle = GraphicsSurfaceToken(m_graphicsSurface->exportToken());
+
+ makeContextCurrent();
+}
+
+void GraphicsContext3DPrivate::didResizeCanvas(const IntSize& size)
{
- m_pendingSurfaceResize = true;
+ if (m_surfaceOperation & CreateSurface) {
+ m_size = size;
+ createGraphicsSurface();
+ return;
+ }
+
+ m_surfaceOperation |= Resize;
}
uint32_t GraphicsContext3DPrivate::copyToGraphicsSurface()
{
- if (!m_platformContext || !makeContextCurrent())
- return 0;
+ createGraphicsSurface();
- if (m_pendingSurfaceResize) {
- m_pendingSurfaceResize = false;
- m_platformSurface->setGeometry(IntRect(0, 0, m_context->m_currentWidth, m_context->m_currentHeight));
- }
+ if (!m_graphicsSurface || m_context->m_layerComposited || !prepareBuffer())
+ return 0;
- if (m_context->m_attrs.antialias) {
-#if !USE(OPENGL_ES_2)
- glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, m_context->m_multisampleFBO);
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, m_context->m_fbo);
- glBlitFramebuffer(0, 0, m_context->m_currentWidth, m_context->m_currentHeight, 0, 0, m_context->m_currentWidth, m_context->m_currentHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR);
-#endif
- }
+ m_graphicsSurface->copyFromTexture(m_context->m_texture, m_targetRect);
+ makeContextCurrent();
- m_platformSurface->updateContents(m_context->m_texture, IntRect(0, 0, m_context->m_currentWidth, m_context->m_currentHeight), m_context->m_boundFBO);
- return 0;
+ return m_graphicsSurface->frontBuffer();
}
GraphicsSurfaceToken GraphicsContext3DPrivate::graphicsSurfaceToken() const
{
return m_surfaceHandle;
}
+
+IntSize GraphicsContext3DPrivate::platformLayerSize() const
+{
+ return m_size;
+}
+
+GraphicsSurface::Flags GraphicsContext3DPrivate::graphicsSurfaceFlags() const
+{
+ if (m_graphicsSurface)
+ return m_graphicsSurface->flags();
+
+ return TextureMapperPlatformLayer::graphicsSurfaceFlags();
+}
#endif
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.h b/Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.h
index 3d60b4e9a..3fa1a0f33 100644
--- a/Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.h
+++ b/Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.h
@@ -1,6 +1,6 @@
/*
Copyright (C) 2012 Samsung Electronics
- Copyright (C) 2012 Intel Corporation.
+ Copyright (C) 2012 Intel Corporation. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -41,36 +41,56 @@ class GraphicsContext3DPrivate
#endif
{
public:
- GraphicsContext3DPrivate(GraphicsContext3D*, HostWindow*, GraphicsContext3D::RenderStyle);
+ static PassOwnPtr<GraphicsContext3DPrivate> create(GraphicsContext3D*, HostWindow*);
~GraphicsContext3DPrivate();
bool createSurface(PageClientEfl*, bool);
PlatformGraphicsContext3D platformGraphicsContext3D() const;
- void setContextLostCallback(PassOwnPtr<GraphicsContext3D::ContextLostCallback> callBack);
-#if USE(ACCELERATED_COMPOSITING)
- PlatformLayer* platformLayer() const;
-#endif
+ void setContextLostCallback(PassOwnPtr<GraphicsContext3D::ContextLostCallback>);
#if USE(TEXTURE_MAPPER_GL)
- virtual void paintToTextureMapper(TextureMapper*, const FloatRect& target, const TransformationMatrix&, float opacity, BitmapTexture* mask);
+ virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float) OVERRIDE;
#endif
#if USE(GRAPHICS_SURFACE)
- virtual uint32_t copyToGraphicsSurface();
- virtual GraphicsSurfaceToken graphicsSurfaceToken() const;
- void createGraphicsSurfaces(const IntSize&);
+ virtual IntSize platformLayerSize() const OVERRIDE;
+ virtual uint32_t copyToGraphicsSurface() OVERRIDE;
+ virtual GraphicsSurfaceToken graphicsSurfaceToken() const OVERRIDE;
+ virtual GraphicsSurface::Flags graphicsSurfaceFlags() const OVERRIDE;
+ void didResizeCanvas(const IntSize&);
#endif
- bool makeContextCurrent();
+ bool makeContextCurrent() const;
+
+private:
+#if USE(GRAPHICS_SURFACE)
+ enum PendingOperation {
+ Default = 0x00, // No Pending Operation.
+ CreateSurface = 0x01,
+ Resize = 0x02,
+ DeletePreviousSurface = 0x04
+ };
+
+ typedef unsigned PendingSurfaceOperation;
+#endif
+
+ GraphicsContext3DPrivate(GraphicsContext3D*, HostWindow*);
+ bool initialize();
+ void createGraphicsSurface();
+ bool prepareBuffer() const;
void releaseResources();
- GraphicsContext3D::Attributes m_attributes;
+
GraphicsContext3D* m_context;
HostWindow* m_hostWindow;
- OwnPtr<GLPlatformContext> m_platformContext;
- OwnPtr<GLPlatformSurface> m_platformSurface;
+ OwnPtr<GLPlatformContext> m_offScreenContext;
+ OwnPtr<GLPlatformSurface> m_offScreenSurface;
#if USE(GRAPHICS_SURFACE)
GraphicsSurfaceToken m_surfaceHandle;
+ RefPtr<GraphicsSurface> m_graphicsSurface;
+ RefPtr<GraphicsSurface> m_previousGraphicsSurface;
+ PendingSurfaceOperation m_surfaceOperation : 3;
#endif
OwnPtr<GraphicsContext3D::ContextLostCallback> m_contextLostCallback;
ListHashSet<GC3Denum> m_syntheticErrors;
- bool m_pendingSurfaceResize;
+ IntSize m_size;
+ IntRect m_targetRect;
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/efl/ImageEfl.cpp b/Source/WebCore/platform/graphics/efl/ImageEfl.cpp
index e8d5d6ef6..c9d4b0422 100644
--- a/Source/WebCore/platform/graphics/efl/ImageEfl.cpp
+++ b/Source/WebCore/platform/graphics/efl/ImageEfl.cpp
@@ -65,8 +65,8 @@ PassRefPtr<Image> Image::loadPlatformResource(const char* name)
Evas_Object* BitmapImage::getEvasObject(Evas* evas)
{
- NativeImageCairo* image = nativeImageForCurrentFrame();
- return image ? evasObjectFromCairoImageSurface(evas, image->surface()).leakRef() : 0;
+ RefPtr<cairo_surface_t> surface = nativeImageForCurrentFrame();
+ return surface ? evasObjectFromCairoImageSurface(evas, surface.get()).leakRef() : 0;
}
}
diff --git a/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp b/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp
index b9389b483..3d5be2374 100644
--- a/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp
+++ b/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp
@@ -24,6 +24,10 @@
#include "GraphicsContext3D.h"
#include <wtf/OwnPtr.h>
+#if USE(CAIRO)
+#include <cairo.h>
+#endif
+
#if USE(OPENGL_ES_2)
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
@@ -31,6 +35,10 @@
#include "OpenGLShims.h"
#endif
+#if ENABLE(ACCELERATED_2D_CANVAS)
+#include <cairo-gl.h>
+#endif
+
namespace WebCore {
static EGLDisplay gSharedEGLDisplay = EGL_NO_DISPLAY;
@@ -168,13 +176,14 @@ PassOwnPtr<GLContextEGL> GLContextEGL::createPixmapContext(EGLContext sharingCon
return nullptr;
EGLSurface surface = eglCreatePixmapSurface(display, config, pixmap, 0);
-#else
- EGLSurface surface = EGL_NO_SURFACE;
-#endif
+
if (surface == EGL_NO_SURFACE)
return nullptr;
return adoptPtr(new GLContextEGL(context, surface, PixmapSurface));
+#else
+ return nullptr;
+#endif
}
PassOwnPtr<GLContextEGL> GLContextEGL::createContext(EGLNativeWindowType window, GLContext* sharingContext)
@@ -208,11 +217,17 @@ GLContextEGL::GLContextEGL(EGLContext context, EGLSurface surface, EGLSurfaceTyp
: m_context(context)
, m_surface(surface)
, m_type(type)
+ , m_cairoDevice(0)
{
}
GLContextEGL::~GLContextEGL()
{
+#if USE(CAIRO)
+ if (m_cairoDevice)
+ cairo_device_destroy(m_cairoDevice);
+#endif
+
EGLDisplay display = sharedEGLDisplay();
if (m_context) {
glBindFramebuffer(GL_FRAMEBUFFER, 0);
@@ -264,6 +279,18 @@ void GLContextEGL::waitNative()
eglWaitNative(EGL_CORE_NATIVE_ENGINE);
}
+cairo_device_t* GLContextEGL::cairoDevice()
+{
+ if (m_cairoDevice)
+ return m_cairoDevice;
+
+#if ENABLE(ACCELERATED_2D_CANVAS)
+ m_cairoDevice = cairo_egl_device_create(sharedEGLDisplay(), m_context);
+#endif
+
+ return m_cairoDevice;
+}
+
#if ENABLE(WEBGL)
PlatformGraphicsContext3D GLContextEGL::platformContext()
{
diff --git a/Source/WebCore/platform/graphics/egl/GLContextEGL.h b/Source/WebCore/platform/graphics/egl/GLContextEGL.h
index c5d4bf756..7516c69bd 100644
--- a/Source/WebCore/platform/graphics/egl/GLContextEGL.h
+++ b/Source/WebCore/platform/graphics/egl/GLContextEGL.h
@@ -41,7 +41,7 @@ public:
virtual void waitNative();
virtual bool canRenderToDefaultFramebuffer();
virtual IntSize defaultFrameBufferSize();
-
+ virtual cairo_device_t* cairoDevice();
#if ENABLE(WEBGL)
virtual PlatformGraphicsContext3D platformContext();
@@ -59,6 +59,7 @@ private:
EGLContext m_context;
EGLSurface m_surface;
EGLSurfaceType m_type;
+ cairo_device_t* m_cairoDevice;
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/filters/CustomFilterArrayParameter.h b/Source/WebCore/platform/graphics/filters/CustomFilterArrayParameter.h
index 3050cb445..df690a080 100644
--- a/Source/WebCore/platform/graphics/filters/CustomFilterArrayParameter.h
+++ b/Source/WebCore/platform/graphics/filters/CustomFilterArrayParameter.h
@@ -39,9 +39,9 @@ namespace WebCore {
class CustomFilterArrayParameter : public CustomFilterParameter {
public:
- static PassRefPtr<CustomFilterArrayParameter> create(const String& name)
+ static PassRefPtr<CustomFilterArrayParameter> create(const String& name, CustomFilterParameter::ParameterType parameterType = CustomFilterParameter::ARRAY)
{
- return adoptRef(new CustomFilterArrayParameter(name));
+ return adoptRef(new CustomFilterArrayParameter(parameterType, name));
}
unsigned size() const { return m_data.size(); }
@@ -76,8 +76,8 @@ public:
}
private:
- CustomFilterArrayParameter(const String& name)
- : CustomFilterParameter(ARRAY, name)
+ CustomFilterArrayParameter(ParameterType parameterType, const String& name)
+ : CustomFilterParameter(parameterType, name)
{
}
diff --git a/Source/WebCore/platform/graphics/filters/CustomFilterColorParameter.h b/Source/WebCore/platform/graphics/filters/CustomFilterColorParameter.h
new file mode 100644
index 000000000..c69245d31
--- /dev/null
+++ b/Source/WebCore/platform/graphics/filters/CustomFilterColorParameter.h
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef CustomFilterColorParameter_h
+#define CustomFilterColorParameter_h
+
+#if ENABLE(CSS_SHADERS)
+#include "Color.h"
+#include "CustomFilterParameter.h"
+
+namespace WebCore {
+
+static inline Color blendFunc(const Color& from, const Color& to, double progress)
+{
+ return blend(from, to, progress);
+}
+
+class CustomFilterColorParameter : public CustomFilterParameter {
+public:
+ static PassRefPtr<CustomFilterColorParameter> create(const String& name)
+ {
+ return adoptRef(new CustomFilterColorParameter(name));
+ }
+
+ virtual PassRefPtr<CustomFilterParameter> blend(const CustomFilterParameter* fromParameter, double progress, const LayoutSize&)
+ {
+ if (!fromParameter || !isSameType(*fromParameter))
+ return this;
+ const CustomFilterColorParameter* fromColor = static_cast<const CustomFilterColorParameter*>(fromParameter);
+
+ RefPtr<CustomFilterColorParameter> result = CustomFilterColorParameter::create(name());
+ result->setColor(blendFunc(fromColor->color(), color(), progress));
+ return result;
+ }
+
+ const Color& color() const { return m_color; }
+ void setColor(const Color& color) { m_color = color; }
+
+ virtual bool operator==(const CustomFilterParameter& o) const
+ {
+ if (!isSameType(o))
+ return false;
+ const CustomFilterColorParameter* other = static_cast<const CustomFilterColorParameter*>(&o);
+ return m_color == other->m_color;
+ }
+
+private:
+ CustomFilterColorParameter(const String& name)
+ : CustomFilterParameter(COLOR, name)
+ {
+ }
+ virtual ~CustomFilterColorParameter()
+ {
+ }
+
+ Color m_color;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(CSS_SHADERS)
+
+#endif // CustomFilterColorParameter_h
diff --git a/Source/WebCore/platform/graphics/filters/CustomFilterCompiledProgram.cpp b/Source/WebCore/platform/graphics/filters/CustomFilterCompiledProgram.cpp
index 26965d05e..34b75629c 100644
--- a/Source/WebCore/platform/graphics/filters/CustomFilterCompiledProgram.cpp
+++ b/Source/WebCore/platform/graphics/filters/CustomFilterCompiledProgram.cpp
@@ -52,6 +52,8 @@ CustomFilterCompiledProgram::CustomFilterCompiledProgram(PassRefPtr<GraphicsCont
, m_contentSamplerLocation(-1)
, m_isInitialized(false)
{
+ ASSERT(!validatedVertexShader.isNull() && !validatedFragmentShader.isNull());
+
m_context->makeContextCurrent();
Platform3DObject vertexShader = compileShader(GraphicsContext3D::VERTEX_SHADER, validatedVertexShader);
diff --git a/Source/WebCore/platform/graphics/filters/CustomFilterConstants.h b/Source/WebCore/platform/graphics/filters/CustomFilterConstants.h
index efae54c71..559dbc875 100644
--- a/Source/WebCore/platform/graphics/filters/CustomFilterConstants.h
+++ b/Source/WebCore/platform/graphics/filters/CustomFilterConstants.h
@@ -50,13 +50,6 @@ enum CustomFilterMeshType {
MeshTypeDetached
};
-enum CustomFilterMeshBoxType {
- MeshBoxTypeFilter,
- MeshBoxTypeBorder,
- MeshBoxTypePadding,
- MeshBoxTypeContent
-};
-
enum CustomFilterProgramType {
PROGRAM_TYPE_NO_ELEMENT_TEXTURE,
PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE
diff --git a/Source/WebCore/platform/graphics/filters/CustomFilterGlobalContext.cpp b/Source/WebCore/platform/graphics/filters/CustomFilterGlobalContext.cpp
index 02a96b864..4f5dd2efb 100644
--- a/Source/WebCore/platform/graphics/filters/CustomFilterGlobalContext.cpp
+++ b/Source/WebCore/platform/graphics/filters/CustomFilterGlobalContext.cpp
@@ -32,7 +32,6 @@
#if ENABLE(CSS_SHADERS) && USE(3D_GRAPHICS)
#include "CustomFilterGlobalContext.h"
-#include "CustomFilterValidatedProgram.h"
#include "GraphicsContext3D.h"
namespace WebCore {
@@ -43,8 +42,6 @@ CustomFilterGlobalContext::CustomFilterGlobalContext()
CustomFilterGlobalContext::~CustomFilterGlobalContext()
{
- for (CustomFilterValidatedProgramsMap::iterator iter = m_programs.begin(); iter != m_programs.end(); ++iter)
- iter->value->detachFromGlobalContext();
}
ANGLEWebKitBridge* CustomFilterGlobalContext::webglShaderValidator()
@@ -87,30 +84,6 @@ void CustomFilterGlobalContext::prepareContextIfNeeded(HostWindow* hostWindow)
m_context->enable(GraphicsContext3D::DEPTH_TEST);
}
-PassRefPtr<CustomFilterValidatedProgram> CustomFilterGlobalContext::getValidatedProgram(const CustomFilterProgramInfo& programInfo)
-{
- CustomFilterValidatedProgramsMap::iterator iter = m_programs.find(programInfo);
- if (iter != m_programs.end())
- return iter->value;
-
- RefPtr<CustomFilterValidatedProgram> validatedProgram = CustomFilterValidatedProgram::create(this, programInfo);
- m_programs.set(programInfo, validatedProgram.get());
- return validatedProgram.release();
-}
-
-void CustomFilterGlobalContext::removeValidatedProgram(const CustomFilterValidatedProgram* program)
-{
- CustomFilterValidatedProgramsMap::iterator iter = m_programs.find(program->programInfo());
- ASSERT(iter != m_programs.end());
- m_programs.remove(iter);
-
-#ifndef NDEBUG
- // Check that there's no way we could have the same program under a different key.
- for (iter = m_programs.begin(); iter != m_programs.end(); ++iter)
- ASSERT(iter->value != program);
-#endif
-}
-
} // namespace WebCore
#endif // ENABLE(CSS_SHADERS) && USE(3D_GRAPHICS)
diff --git a/Source/WebCore/platform/graphics/filters/CustomFilterGlobalContext.h b/Source/WebCore/platform/graphics/filters/CustomFilterGlobalContext.h
index ae0271f1c..866f6386f 100644
--- a/Source/WebCore/platform/graphics/filters/CustomFilterGlobalContext.h
+++ b/Source/WebCore/platform/graphics/filters/CustomFilterGlobalContext.h
@@ -32,18 +32,14 @@
#if ENABLE(CSS_SHADERS) && USE(3D_GRAPHICS)
#include "ANGLEWebKitBridge.h"
-#include "CustomFilterProgramInfo.h"
#include <wtf/HashMap.h>
#include <wtf/RefPtr.h>
namespace WebCore {
-class CustomFilterValidatedProgram;
class HostWindow;
class GraphicsContext3D;
-typedef HashMap<CustomFilterProgramInfo, CustomFilterValidatedProgram*> CustomFilterValidatedProgramsMap;
-
class CustomFilterGlobalContext {
public:
CustomFilterGlobalContext();
@@ -66,16 +62,12 @@ public:
ANGLEWebKitBridge* mixShaderValidator();
void prepareContextIfNeeded(HostWindow*);
-
- PassRefPtr<CustomFilterValidatedProgram> getValidatedProgram(const CustomFilterProgramInfo&);
- void removeValidatedProgram(const CustomFilterValidatedProgram*);
private:
static PassOwnPtr<ANGLEWebKitBridge> createShaderValidator(ShShaderSpec);
RefPtr<GraphicsContext3D> m_context;
OwnPtr<ANGLEWebKitBridge> m_webglShaderValidator;
OwnPtr<ANGLEWebKitBridge> m_mixShaderValidator;
- CustomFilterValidatedProgramsMap m_programs;
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/filters/CustomFilterMeshGenerator.h b/Source/WebCore/platform/graphics/filters/CustomFilterMeshGenerator.h
index 7abac12e2..7f9af648d 100644
--- a/Source/WebCore/platform/graphics/filters/CustomFilterMeshGenerator.h
+++ b/Source/WebCore/platform/graphics/filters/CustomFilterMeshGenerator.h
@@ -35,6 +35,7 @@
#include "CustomFilterConstants.h"
#include "CustomFilterOperation.h"
#include "FloatRect.h"
+#include <stdio.h>
namespace WebCore {
diff --git a/Source/WebCore/platform/graphics/filters/CustomFilterOperation.cpp b/Source/WebCore/platform/graphics/filters/CustomFilterOperation.cpp
index 2526e5820..509a76c6d 100644
--- a/Source/WebCore/platform/graphics/filters/CustomFilterOperation.cpp
+++ b/Source/WebCore/platform/graphics/filters/CustomFilterOperation.cpp
@@ -38,14 +38,12 @@
namespace WebCore {
-CustomFilterOperation::CustomFilterOperation(PassRefPtr<CustomFilterProgram> program, const CustomFilterParameterList& sortedParameters, unsigned meshRows, unsigned meshColumns, CustomFilterMeshBoxType meshBoxType, CustomFilterMeshType meshType)
+CustomFilterOperation::CustomFilterOperation(PassRefPtr<CustomFilterProgram> program, const CustomFilterParameterList& sortedParameters, unsigned meshRows, unsigned meshColumns)
: FilterOperation(CUSTOM)
, m_program(program)
, m_parameters(sortedParameters)
, m_meshRows(meshRows)
, m_meshColumns(meshColumns)
- , m_meshBoxType(meshBoxType)
- , m_meshType(meshType)
{
// Make sure that the parameters are alwyas sorted by name. We use that to merge two CustomFilterOperations in animations.
ASSERT(m_parameters.checkAlphabeticalOrder());
@@ -64,16 +62,14 @@ PassRefPtr<FilterOperation> CustomFilterOperation::blend(const FilterOperation*
return this;
const CustomFilterOperation* fromOp = static_cast<const CustomFilterOperation*>(from);
- if (*m_program.get() != *fromOp->m_program.get()
+ if (m_program.get() != fromOp->m_program.get()
|| m_meshRows != fromOp->m_meshRows
- || m_meshColumns != fromOp->m_meshColumns
- || m_meshBoxType != fromOp->m_meshBoxType
- || m_meshType != fromOp->m_meshType)
+ || m_meshColumns != fromOp->m_meshColumns)
return this;
CustomFilterParameterList animatedParameters;
m_parameters.blend(fromOp->m_parameters, progress, size, animatedParameters);
- return CustomFilterOperation::create(m_program, animatedParameters, m_meshRows, m_meshColumns, m_meshBoxType, m_meshType);
+ return CustomFilterOperation::create(m_program, animatedParameters, m_meshRows, m_meshColumns);
}
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/filters/CustomFilterOperation.h b/Source/WebCore/platform/graphics/filters/CustomFilterOperation.h
index 7153e61e7..447c6058c 100644
--- a/Source/WebCore/platform/graphics/filters/CustomFilterOperation.h
+++ b/Source/WebCore/platform/graphics/filters/CustomFilterOperation.h
@@ -43,9 +43,9 @@ namespace WebCore {
class CustomFilterOperation : public FilterOperation {
public:
- static PassRefPtr<CustomFilterOperation> create(PassRefPtr<CustomFilterProgram> program, const CustomFilterParameterList& sortedParameters, unsigned meshRows, unsigned meshColumns, CustomFilterMeshBoxType meshBoxType, CustomFilterMeshType meshType)
+ static PassRefPtr<CustomFilterOperation> create(PassRefPtr<CustomFilterProgram> program, const CustomFilterParameterList& sortedParameters, unsigned meshRows, unsigned meshColumns)
{
- return adoptRef(new CustomFilterOperation(program, sortedParameters, meshRows, meshColumns, meshBoxType, meshType));
+ return adoptRef(new CustomFilterOperation(program, sortedParameters, meshRows, meshColumns));
}
CustomFilterProgram* program() const { return m_program.get(); }
@@ -55,9 +55,8 @@ public:
unsigned meshRows() const { return m_meshRows; }
unsigned meshColumns() const { return m_meshColumns; }
-
- CustomFilterMeshBoxType meshBoxType() const { return m_meshBoxType; }
- CustomFilterMeshType meshType() const { return m_meshType; }
+
+ CustomFilterMeshType meshType() const { return program() ? program()->meshType() : MeshTypeAttached; }
virtual ~CustomFilterOperation();
@@ -68,7 +67,7 @@ public:
virtual PassRefPtr<FilterOperation> blend(const FilterOperation* from, double progress, const LayoutSize&, bool blendToPassthrough = false);
protected:
- CustomFilterOperation(PassRefPtr<CustomFilterProgram>, const CustomFilterParameterList&, unsigned meshRows, unsigned meshColumns, CustomFilterMeshBoxType, CustomFilterMeshType);
+ CustomFilterOperation(PassRefPtr<CustomFilterProgram>, const CustomFilterParameterList&, unsigned meshRows, unsigned meshColumns);
private:
virtual bool operator==(const FilterOperation& o) const
@@ -77,11 +76,9 @@ private:
return false;
const CustomFilterOperation* other = static_cast<const CustomFilterOperation*>(&o);
- return *m_program.get() == *other->m_program.get()
+ return m_program.get() == other->m_program.get()
&& m_meshRows == other->m_meshRows
&& m_meshColumns == other->m_meshColumns
- && m_meshBoxType == other->m_meshBoxType
- && m_meshType == other->m_meshType
&& m_parameters == other->m_parameters;
}
@@ -90,8 +87,6 @@ private:
unsigned m_meshRows;
unsigned m_meshColumns;
- CustomFilterMeshBoxType m_meshBoxType;
- CustomFilterMeshType m_meshType;
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/filters/CustomFilterParameter.h b/Source/WebCore/platform/graphics/filters/CustomFilterParameter.h
index 641225a56..3bab2d882 100644
--- a/Source/WebCore/platform/graphics/filters/CustomFilterParameter.h
+++ b/Source/WebCore/platform/graphics/filters/CustomFilterParameter.h
@@ -40,12 +40,11 @@ namespace WebCore {
class CustomFilterParameter : public RefCounted<CustomFilterParameter> {
public:
// FIXME: Implement other parameters types:
- // booleans: https://bugs.webkit.org/show_bug.cgi?id=76438
// textures: https://bugs.webkit.org/show_bug.cgi?id=71442
- // 3d-transforms: https://bugs.webkit.org/show_bug.cgi?id=71443
- // mat2, mat3, mat4: https://bugs.webkit.org/show_bug.cgi?id=71444
enum ParameterType {
ARRAY,
+ COLOR,
+ MATRIX,
NUMBER,
TRANSFORM
};
diff --git a/Source/WebCore/platform/graphics/filters/CustomFilterProgram.cpp b/Source/WebCore/platform/graphics/filters/CustomFilterProgram.cpp
index 2a8fce076..f2769f7a7 100644
--- a/Source/WebCore/platform/graphics/filters/CustomFilterProgram.cpp
+++ b/Source/WebCore/platform/graphics/filters/CustomFilterProgram.cpp
@@ -35,6 +35,7 @@
#include "CustomFilterCompiledProgram.h"
#include "CustomFilterProgramClient.h"
#include "CustomFilterProgramInfo.h"
+#include "CustomFilterValidatedProgram.h"
namespace WebCore {
@@ -86,11 +87,14 @@ CustomFilterProgramInfo CustomFilterProgram::programInfo() const
return CustomFilterProgramInfo(vertexShaderString(), fragmentShaderString(), m_programType, m_mixSettings, m_meshType);
}
-bool CustomFilterProgram::operator==(const CustomFilterProgram& o) const
+PassRefPtr<CustomFilterValidatedProgram> CustomFilterProgram::validatedProgram()
{
- return m_programType == o.m_programType
- && (m_programType != PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE || m_mixSettings == o.m_mixSettings)
- && m_meshType == o.m_meshType;
+ return m_validatedProgram;
+}
+
+void CustomFilterProgram::setValidatedProgram(PassRefPtr<CustomFilterValidatedProgram> validatedProgram)
+{
+ m_validatedProgram = validatedProgram;
}
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/filters/CustomFilterProgram.h b/Source/WebCore/platform/graphics/filters/CustomFilterProgram.h
index b755bb7ac..ad8965c4a 100644
--- a/Source/WebCore/platform/graphics/filters/CustomFilterProgram.h
+++ b/Source/WebCore/platform/graphics/filters/CustomFilterProgram.h
@@ -41,8 +41,8 @@
namespace WebCore {
class GraphicsContext3D;
-class CustomFilterCompiledProgram;
class CustomFilterProgramClient;
+class CustomFilterValidatedProgram;
// This is the base class for the StyleCustomFilterProgram class which knows how to keep
// references to the cached shaders.
@@ -63,8 +63,9 @@ public:
CustomFilterProgramMixSettings mixSettings() const { return m_mixSettings; }
CustomFilterMeshType meshType() const { return m_meshType; }
- virtual bool operator==(const CustomFilterProgram&) const;
- bool operator!=(const CustomFilterProgram& o) const { return !(*this == o); }
+ PassRefPtr<CustomFilterValidatedProgram> validatedProgram();
+ void setValidatedProgram(PassRefPtr<CustomFilterValidatedProgram>);
+
protected:
// StyleCustomFilterProgram can notify the clients that the cached resources are
// loaded and it is ready to create CustomFilterCompiledProgram objects.
@@ -77,11 +78,18 @@ protected:
CustomFilterProgram(CustomFilterProgramType, const CustomFilterProgramMixSettings&, CustomFilterMeshType);
private:
+ // CustomFilterPrograms are unique combinations of shaders and can be
+ // compared using just the pointer value instead.
+ // These will catch anyone doing a value equal comparison.
+ bool operator==(const CustomFilterProgram&) const;
+ bool operator!=(const CustomFilterProgram&) const;
+
typedef HashCountedSet<CustomFilterProgramClient*> CustomFilterProgramClientList;
CustomFilterProgramClientList m_clients;
CustomFilterProgramType m_programType;
CustomFilterProgramMixSettings m_mixSettings;
CustomFilterMeshType m_meshType;
+ RefPtr<CustomFilterValidatedProgram> m_validatedProgram;
};
}
diff --git a/Source/WebCore/platform/graphics/filters/CustomFilterRenderer.cpp b/Source/WebCore/platform/graphics/filters/CustomFilterRenderer.cpp
index d1a882c2d..62ed39359 100644
--- a/Source/WebCore/platform/graphics/filters/CustomFilterRenderer.cpp
+++ b/Source/WebCore/platform/graphics/filters/CustomFilterRenderer.cpp
@@ -35,6 +35,7 @@
#include "CustomFilterRenderer.h"
#include "CustomFilterArrayParameter.h"
+#include "CustomFilterColorParameter.h"
#include "CustomFilterCompiledProgram.h"
#include "CustomFilterConstants.h"
#include "CustomFilterMesh.h"
@@ -69,13 +70,13 @@ static void orthogonalProjectionMatrix(TransformationMatrix& matrix, float left,
}
PassRefPtr<CustomFilterRenderer> CustomFilterRenderer::create(PassRefPtr<GraphicsContext3D> context, CustomFilterProgramType programType, const CustomFilterParameterList& parameters,
- unsigned meshRows, unsigned meshColumns, CustomFilterMeshBoxType meshBoxType, CustomFilterMeshType meshType)
+ unsigned meshRows, unsigned meshColumns, CustomFilterMeshType meshType)
{
- return adoptRef(new CustomFilterRenderer(context, programType, parameters, meshRows, meshColumns, meshBoxType, meshType));
+ return adoptRef(new CustomFilterRenderer(context, programType, parameters, meshRows, meshColumns, meshType));
}
CustomFilterRenderer::CustomFilterRenderer(PassRefPtr<GraphicsContext3D> context, CustomFilterProgramType programType, const CustomFilterParameterList& parameters,
- unsigned meshRows, unsigned meshColumns, CustomFilterMeshBoxType, CustomFilterMeshType meshType)
+ unsigned meshRows, unsigned meshColumns, CustomFilterMeshType meshType)
: m_context(context)
, m_programType(programType)
, m_parameters(parameters)
@@ -161,6 +162,37 @@ void CustomFilterRenderer::bindProgramArrayParameters(int uniformLocation, Custo
m_context->uniform1fv(uniformLocation, parameterSize, floatVector.data());
}
+void CustomFilterRenderer::bindProgramColorParameters(int uniformLocation, CustomFilterColorParameter* colorParameter)
+{
+ float r, g, b, a;
+ colorParameter->color().getRGBA(r, g, b, a);
+
+ m_context->uniform4f(uniformLocation, r, g, b, a);
+}
+
+void CustomFilterRenderer::bindProgramMatrixParameters(int uniformLocation, CustomFilterArrayParameter* matrixParameter)
+{
+ unsigned parameterSize = matrixParameter->size();
+ Vector<GC3Dfloat, 16> floatVector;
+
+ for (unsigned i = 0; i < parameterSize; ++i)
+ floatVector.append(matrixParameter->valueAt(i));
+
+ switch (parameterSize) {
+ case 4:
+ m_context->uniformMatrix2fv(uniformLocation, 1, false, floatVector.data());
+ break;
+ case 9:
+ m_context->uniformMatrix3fv(uniformLocation, 1, false, floatVector.data());
+ break;
+ case 16:
+ m_context->uniformMatrix4fv(uniformLocation, 1, false, floatVector.data());
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+}
+
void CustomFilterRenderer::bindProgramNumberParameters(int uniformLocation, CustomFilterNumberParameter* numberParameter)
{
switch (numberParameter->size()) {
@@ -215,6 +247,12 @@ void CustomFilterRenderer::bindProgramParameters()
case CustomFilterParameter::ARRAY:
bindProgramArrayParameters(uniformLocation, static_cast<CustomFilterArrayParameter*>(parameter));
break;
+ case CustomFilterParameter::COLOR:
+ bindProgramColorParameters(uniformLocation, static_cast<CustomFilterColorParameter*>(parameter));
+ break;
+ case CustomFilterParameter::MATRIX:
+ bindProgramMatrixParameters(uniformLocation, static_cast<CustomFilterArrayParameter*>(parameter));
+ break;
case CustomFilterParameter::NUMBER:
bindProgramNumberParameters(uniformLocation, static_cast<CustomFilterNumberParameter*>(parameter));
break;
diff --git a/Source/WebCore/platform/graphics/filters/CustomFilterRenderer.h b/Source/WebCore/platform/graphics/filters/CustomFilterRenderer.h
index 962ea698f..ccdc29f30 100644
--- a/Source/WebCore/platform/graphics/filters/CustomFilterRenderer.h
+++ b/Source/WebCore/platform/graphics/filters/CustomFilterRenderer.h
@@ -44,6 +44,7 @@
namespace WebCore {
class CustomFilterArrayParameter;
+class CustomFilterColorParameter;
class CustomFilterCompiledProgram;
class CustomFilterMesh;
class CustomFilterNumberParameter;
@@ -53,7 +54,7 @@ class GraphicsContext3D;
class CustomFilterRenderer : public RefCounted<CustomFilterRenderer> {
public:
static PassRefPtr<CustomFilterRenderer> create(PassRefPtr<GraphicsContext3D>, CustomFilterProgramType, const CustomFilterParameterList&,
- unsigned meshRows, unsigned meshColumns, CustomFilterMeshBoxType, CustomFilterMeshType);
+ unsigned meshRows, unsigned meshColumns, CustomFilterMeshType);
~CustomFilterRenderer();
bool premultipliedAlpha() const;
@@ -68,7 +69,7 @@ public:
private:
CustomFilterRenderer(PassRefPtr<GraphicsContext3D>, CustomFilterProgramType, const CustomFilterParameterList&,
- unsigned meshRows, unsigned meshColumns, CustomFilterMeshBoxType, CustomFilterMeshType);
+ unsigned meshRows, unsigned meshColumns, CustomFilterMeshType);
void initializeCompiledProgramIfNeeded();
void initializeMeshIfNeeded();
@@ -76,6 +77,8 @@ private:
void bindVertexAttribute(int attributeLocation, unsigned size, unsigned offset);
void unbindVertexAttribute(int attributeLocation);
void bindProgramArrayParameters(int uniformLocation, CustomFilterArrayParameter*);
+ void bindProgramColorParameters(int uniformLocation, CustomFilterColorParameter*);
+ void bindProgramMatrixParameters(int uniformLocation, CustomFilterArrayParameter*);
void bindProgramNumberParameters(int uniformLocation, CustomFilterNumberParameter*);
void bindProgramTransformParameter(int uniformLocation, CustomFilterTransformParameter*);
void bindProgramParameters();
@@ -84,7 +87,7 @@ private:
RefPtr<GraphicsContext3D> m_context;
RefPtr<CustomFilterCompiledProgram> m_compiledProgram;
- CustomFilterProgramType m_programType;
+ CustomFilterProgramType m_programType;
RefPtr<CustomFilterMesh> m_mesh;
IntSize m_contextSize;
diff --git a/Source/WebCore/platform/graphics/filters/CustomFilterValidatedProgram.cpp b/Source/WebCore/platform/graphics/filters/CustomFilterValidatedProgram.cpp
index 72ad8ff4c..770a5e5e5 100644
--- a/Source/WebCore/platform/graphics/filters/CustomFilterValidatedProgram.cpp
+++ b/Source/WebCore/platform/graphics/filters/CustomFilterValidatedProgram.cpp
@@ -34,6 +34,7 @@
#include "CustomFilterValidatedProgram.h"
#include "ANGLEWebKitBridge.h"
+#include "CustomFilterCompiledProgram.h"
#include "CustomFilterConstants.h"
#include "CustomFilterGlobalContext.h"
#include "CustomFilterProgramInfo.h"
@@ -158,8 +159,7 @@ String CustomFilterValidatedProgram::defaultFragmentShaderString()
}
CustomFilterValidatedProgram::CustomFilterValidatedProgram(CustomFilterGlobalContext* globalContext, const CustomFilterProgramInfo& programInfo)
- : m_globalContext(globalContext)
- , m_programInfo(programInfo)
+ : m_programInfo(programInfo)
, m_isInitialized(false)
{
platformInit();
@@ -174,7 +174,7 @@ CustomFilterValidatedProgram::CustomFilterValidatedProgram(CustomFilterGlobalCon
// Shaders referenced from the CSS mix function use a different validator than regular WebGL shaders. See CustomFilterGlobalContext.h for more details.
bool blendsElementTexture = (programInfo.programType() == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE);
- ANGLEWebKitBridge* validator = blendsElementTexture ? m_globalContext->mixShaderValidator() : m_globalContext->webglShaderValidator();
+ ANGLEWebKitBridge* validator = blendsElementTexture ? globalContext->mixShaderValidator() : globalContext->webglShaderValidator();
String vertexShaderLog, fragmentShaderLog;
Vector<ANGLEShaderSymbol> symbols;
bool vertexShaderValid = validator->compileShaderSource(originalVertexShader.utf8().data(), SHADER_TYPE_VERTEX, m_validatedVertexShader, vertexShaderLog, symbols);
@@ -202,14 +202,14 @@ CustomFilterValidatedProgram::CustomFilterValidatedProgram(CustomFilterGlobalCon
PassRefPtr<CustomFilterCompiledProgram> CustomFilterValidatedProgram::compiledProgram()
{
- ASSERT(m_isInitialized && m_globalContext && !m_validatedVertexShader.isNull() && !m_validatedFragmentShader.isNull());
- if (!m_compiledProgram) {
- m_compiledProgram = CustomFilterCompiledProgram::create(m_globalContext->context(), m_validatedVertexShader, m_validatedFragmentShader, m_programInfo.programType());
- ASSERT(m_compiledProgram->samplerLocation() != -1 || !needsInputTexture());
- }
return m_compiledProgram;
}
+void CustomFilterValidatedProgram::setCompiledProgram(PassRefPtr<CustomFilterCompiledProgram> compiledProgram)
+{
+ m_compiledProgram = compiledProgram;
+}
+
bool CustomFilterValidatedProgram::needsInputTexture() const
{
return m_programInfo.programType() == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE
@@ -273,9 +273,11 @@ void CustomFilterValidatedProgram::rewriteMixFragmentShader()
{
css_main();
mediump vec4 originalColor = texture2D(css_u_texture, css_v_texCoord);
- mediump vec4 multipliedColor = css_ColorMatrix * originalColor;
- mediump vec3 blendedColor = css_BlendColor(multipliedColor.rgb, css_MixColor.rgb);
- gl_FragColor = css_Composite(multipliedColor.rgb, multipliedColor.a, blendedColor.rgb, css_MixColor.a);
+ mediump vec4 multipliedColor = clamp(css_ColorMatrix * originalColor, 0.0, 1.0);
+ mediump vec4 clampedMixColor = clamp(css_MixColor, 0.0, 1.0);
+ mediump vec3 blendedColor = css_BlendColor(multipliedColor.rgb, clampedMixColor.rgb);
+ mediump vec3 weightedColor = (1.0 - multipliedColor.a) * clampedMixColor.rgb + multipliedColor.a * blendedColor;
+ gl_FragColor = css_Composite(multipliedColor.rgb, multipliedColor.a, weightedColor.rgb, clampedMixColor.a);
}
));
m_validatedFragmentShader = builder.toString();
@@ -289,6 +291,9 @@ String CustomFilterValidatedProgram::blendFunctionString(BlendMode blendMode)
// Cb: is the backdrop color in css_BlendColor() and the backdrop color component in css_BlendComponent()
const char* blendColorExpression = "vec3(css_BlendComponent(Cb.r, Cs.r), css_BlendComponent(Cb.g, Cs.g), css_BlendComponent(Cb.b, Cs.b))";
const char* blendComponentExpression = "Co = 0.0;";
+ bool needsLuminosityHelperFunctions = false;
+ bool needsSaturationHelperFunctions = false;
+ String blendFunctionString;
switch (blendMode) {
case BlendModeNormal:
blendColorExpression = "Cs";
@@ -403,15 +408,97 @@ String CustomFilterValidatedProgram::blendFunctionString(BlendMode blendMode)
Co = Cb + (2.0 * Cs - 1.0) * (D - Cb);
);
break;
- case BlendModeHue:
- case BlendModeSaturation:
case BlendModeColor:
+ needsLuminosityHelperFunctions = true;
+ blendColorExpression = "css_SetLum(Cs, css_Lum(Cb))";
+ break;
case BlendModeLuminosity:
- notImplemented();
- return String();
+ needsLuminosityHelperFunctions = true;
+ blendColorExpression = "css_SetLum(Cb, css_Lum(Cs))";
+ break;
+ case BlendModeHue:
+ needsLuminosityHelperFunctions = true;
+ needsSaturationHelperFunctions = true;
+ blendColorExpression = "css_SetLum(css_SetSat(Cs, css_Sat(Cb)), css_Lum(Cb))";
+ break;
+ case BlendModeSaturation:
+ needsLuminosityHelperFunctions = true;
+ needsSaturationHelperFunctions = true;
+ blendColorExpression = "css_SetLum(css_SetSat(Cb, css_Sat(Cs)), css_Lum(Cb))";
+ break;
+ default:
+ ASSERT_NOT_REACHED();
}
- return String::format(SHADER(
+ if (needsLuminosityHelperFunctions) {
+ blendFunctionString.append(SHADER(
+ mediump float css_Lum(mediump vec3 C)
+ {
+ return 0.3 * C.r + 0.59 * C.g + 0.11 * C.b;
+ }
+ mediump vec3 css_ClipColor(mediump vec3 C)
+ {
+ mediump float L = css_Lum(C);
+ mediump float n = min(min(C.r, C.g), C.b);
+ mediump float x = max(max(C.r, C.g), C.b);
+ if (n < 0.0)
+ C = L + (((C - L) * L) / (L - n));
+ if (x > 1.0)
+ C = L + (((C - L) * (1.0 - L) / (x - L)));
+ return C;
+ }
+ mediump vec3 css_SetLum(mediump vec3 C, mediump float l)
+ {
+ C += l - css_Lum(C);
+ return css_ClipColor(C);
+ }
+ ));
+ }
+
+ if (needsSaturationHelperFunctions) {
+ blendFunctionString.append(SHADER(
+ mediump float css_Sat(mediump vec3 C)
+ {
+ mediump float cMin = min(min(C.r, C.g), C.b);
+ mediump float cMax = max(max(C.r, C.g), C.b);
+ return cMax - cMin;
+ }
+ void css_SetSatHelper(inout mediump float cMin, inout mediump float cMid, inout mediump float cMax, mediump float s)
+ {
+ if (cMax > cMin) {
+ cMid = (((cMid - cMin) * s) / (cMax - cMin));
+ cMax = s;
+ } else
+ cMid = cMax = 0.0;
+ cMin = 0.0;
+ }
+ mediump vec3 css_SetSat(mediump vec3 C, mediump float s)
+ {
+ if (C.r <= C.g) {
+ if (C.g <= C.b)
+ css_SetSatHelper(C.r, C.g, C.b, s);
+ else {
+ if (C.r <= C.b)
+ css_SetSatHelper(C.r, C.b, C.g, s);
+ else
+ css_SetSatHelper(C.b, C.r, C.g, s);
+ }
+ } else {
+ if (C.r <= C.b)
+ css_SetSatHelper(C.g, C.r, C.b, s);
+ else {
+ if (C.g <= C.b)
+ css_SetSatHelper(C.g, C.b, C.r, s);
+ else
+ css_SetSatHelper(C.b, C.g, C.r, s);
+ }
+ }
+ return C;
+ }
+ ));
+ }
+
+ blendFunctionString.append(String::format(SHADER(
mediump float css_BlendComponent(mediump float Cb, mediump float Cs)
{
mediump float Co;
@@ -422,7 +509,9 @@ String CustomFilterValidatedProgram::blendFunctionString(BlendMode blendMode)
{
return %s;
}
- ), blendComponentExpression, blendColorExpression);
+ ), blendComponentExpression, blendColorExpression));
+
+ return blendFunctionString;
}
String CustomFilterValidatedProgram::compositeFunctionString(CompositeOperator compositeOperator)
@@ -507,9 +596,6 @@ String CustomFilterValidatedProgram::compositeFunctionString(CompositeOperator c
CustomFilterValidatedProgram::~CustomFilterValidatedProgram()
{
platformDestroy();
-
- if (m_globalContext)
- m_globalContext->removeValidatedProgram(this);
}
CustomFilterProgramInfo CustomFilterValidatedProgram::validatedProgramInfo() const
diff --git a/Source/WebCore/platform/graphics/filters/CustomFilterValidatedProgram.h b/Source/WebCore/platform/graphics/filters/CustomFilterValidatedProgram.h
index c68f4a784..ef7919abc 100644
--- a/Source/WebCore/platform/graphics/filters/CustomFilterValidatedProgram.h
+++ b/Source/WebCore/platform/graphics/filters/CustomFilterValidatedProgram.h
@@ -32,7 +32,6 @@
#if ENABLE(CSS_SHADERS)
-#include "CustomFilterCompiledProgram.h"
#include "CustomFilterProgramInfo.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
@@ -63,15 +62,6 @@ typedef TextureMapperPlatformCompiledProgram PlatformCompiledProgram;
// All shaders are validated through ANGLE in CustomFilterValidatedProgram before being compiled by the GraphicsContext3D in CustomFilterCompiledProgram.
// For shaders that use the CSS mix function, CustomFilterValidatedProgram adds shader code to perform DOM texture access, blending, and compositing.
//
-// The CustomFilterGlobalContext caches the validated programs.
-// CustomFilterValidatedProgram owns a CustomFilterCompiledProgram if validation and compilation succeeds.
-// Thus, compiled programs are cached via their validated program owners.
-//
-// CustomFilterGlobalContext has a weak reference to the CustomFilterValidatedProgram.
-// Thus, the CustomFilterValidatedProgram destructor needs to notify the CustomFilterGlobalContext to remove the program from the cache.
-// FECustomFilter is the reference owner of the CustomFilterValidatedProgram.
-// Thus, a validated and compiled shader is only kept alive as long as there is at least one visible layer that applies the shader.
-//
class CustomFilterValidatedProgram : public RefCounted<CustomFilterValidatedProgram> {
public:
static PassRefPtr<CustomFilterValidatedProgram> create(CustomFilterGlobalContext* globalContext, const CustomFilterProgramInfo& programInfo)
@@ -85,6 +75,7 @@ public:
CustomFilterProgramInfo validatedProgramInfo() const;
PassRefPtr<CustomFilterCompiledProgram> compiledProgram();
+ void setCompiledProgram(PassRefPtr<CustomFilterCompiledProgram>);
const String& validatedVertexShader() const
{
@@ -103,10 +94,6 @@ public:
#endif
bool isInitialized() const { return m_isInitialized; }
-
- // 'detachFromGlobalContext' is called when the CustomFilterGlobalContext is deleted, and there's no need for the callback anymore.
- // Note that CustomFilterGlobalContext does not keep a strong reference to the CustomFilterValidatedProgram.
- void detachFromGlobalContext() { m_globalContext = 0; }
private:
CustomFilterValidatedProgram(CustomFilterGlobalContext*, const CustomFilterProgramInfo&);
@@ -124,7 +111,6 @@ private:
bool needsInputTexture() const;
- CustomFilterGlobalContext* m_globalContext;
CustomFilterProgramInfo m_programInfo;
String m_validatedVertexShader;
diff --git a/Source/WebCore/platform/graphics/filters/DistantLightSource.h b/Source/WebCore/platform/graphics/filters/DistantLightSource.h
index 1e19c62bd..b2ba9370c 100644
--- a/Source/WebCore/platform/graphics/filters/DistantLightSource.h
+++ b/Source/WebCore/platform/graphics/filters/DistantLightSource.h
@@ -36,9 +36,10 @@ public:
}
float azimuth() const { return m_azimuth; }
- bool setAzimuth(float);
float elevation() const { return m_elevation; }
- bool setElevation(float);
+
+ virtual bool setAzimuth(float) OVERRIDE;
+ virtual bool setElevation(float) OVERRIDE;
virtual void initPaintingData(PaintingData&);
virtual void updatePaintingData(PaintingData&, int x, int y, float z);
diff --git a/Source/WebCore/platform/graphics/filters/FEBlend.h b/Source/WebCore/platform/graphics/filters/FEBlend.h
index 5c71c2b72..6b00080a8 100644
--- a/Source/WebCore/platform/graphics/filters/FEBlend.h
+++ b/Source/WebCore/platform/graphics/filters/FEBlend.h
@@ -49,11 +49,6 @@ public:
unsigned colorArrayLength);
void platformApplyNEON(unsigned char* srcPixelArrayA, unsigned char* srcPixelArrayB, unsigned char* dstPixelArray,
unsigned colorArrayLength);
-#if USE(SKIA)
- virtual bool platformApplySkia();
- virtual SkImageFilter* createImageFilter(SkiaImageFilterBuilder*);
-#endif
-
virtual void platformApplySoftware();
virtual void dump();
diff --git a/Source/WebCore/platform/graphics/filters/FEColorMatrix.cpp b/Source/WebCore/platform/graphics/filters/FEColorMatrix.cpp
index 25b087e54..bdf5552ae 100644
--- a/Source/WebCore/platform/graphics/filters/FEColorMatrix.cpp
+++ b/Source/WebCore/platform/graphics/filters/FEColorMatrix.cpp
@@ -75,9 +75,9 @@ bool FEColorMatrix::setValues(const Vector<float> &values)
inline void matrix(float& red, float& green, float& blue, float& alpha, const Vector<float>& values)
{
- float r = values[0] * red + values[1] * green + values[2] * blue + values[3] * alpha + values[4] * 255;
- float g = values[5] * red + values[6] * green + values[7] * blue + values[8] * alpha + values[9] * 255;
- float b = values[10] * red + values[11] * green + values[12] * blue + values[13] * alpha + values[14] * 255;
+ float r = values[0] * red + values[1] * green + values[2] * blue + values[3] * alpha + values[4] * 255;
+ float g = values[5] * red + values[6] * green + values[7] * blue + values[8] * alpha + values[9] * 255;
+ float b = values[10] * red + values[11] * green + values[12] * blue + values[13] * alpha + values[14] * 255;
float a = values[15] * red + values[16] * green + values[17] * blue + values[18] * alpha + values[19] * 255;
red = r;
@@ -86,30 +86,11 @@ inline void matrix(float& red, float& green, float& blue, float& alpha, const Ve
alpha = a;
}
-inline void saturate(float& red, float& green, float& blue, const float& s)
+inline void saturateAndHueRotate(float& red, float& green, float& blue, const float* components)
{
- float r = (0.213 + 0.787 * s) * red + (0.715 - 0.715 * s) * green + (0.072 - 0.072 * s) * blue;
- float g = (0.213 - 0.213 * s) * red + (0.715 + 0.285 * s) * green + (0.072 - 0.072 * s) * blue;
- float b = (0.213 - 0.213 * s) * red + (0.715 - 0.715 * s) * green + (0.072 + 0.928 * s) * blue;
-
- red = r;
- green = g;
- blue = b;
-}
-
-inline void huerotate(float& red, float& green, float& blue, const float& hue)
-{
- float cosHue = cos(hue * piDouble / 180);
- float sinHue = sin(hue * piDouble / 180);
- float r = red * (0.213 + cosHue * 0.787 - sinHue * 0.213) +
- green * (0.715 - cosHue * 0.715 - sinHue * 0.715) +
- blue * (0.072 - cosHue * 0.072 + sinHue * 0.928);
- float g = red * (0.213 - cosHue * 0.213 + sinHue * 0.143) +
- green * (0.715 + cosHue * 0.285 + sinHue * 0.140) +
- blue * (0.072 - cosHue * 0.072 - sinHue * 0.283);
- float b = red * (0.213 - cosHue * 0.213 - sinHue * 0.787) +
- green * (0.715 - cosHue * 0.715 + sinHue * 0.715) +
- blue * (0.072 + cosHue * 0.928 + sinHue * 0.072);
+ float r = red * components[0] + green * components[1] + blue * components[2];
+ float g = red * components[3] + green * components[4] + blue * components[5];
+ float b = red * components[6] + green * components[7] + blue * components[8];
red = r;
green = g;
@@ -128,6 +109,13 @@ template<ColorMatrixType filterType>
void effectType(Uint8ClampedArray* pixelArray, const Vector<float>& values)
{
unsigned pixelArrayLength = pixelArray->length();
+ float components[9];
+
+ if (filterType == FECOLORMATRIX_TYPE_SATURATE)
+ FEColorMatrix::calculateSaturateComponents(components, values[0]);
+ else if (filterType == FECOLORMATRIX_TYPE_HUEROTATE)
+ FEColorMatrix::calculateHueRotateComponents(components, values[0]);
+
for (unsigned pixelByteOffset = 0; pixelByteOffset < pixelArrayLength; pixelByteOffset += 4) {
float red = pixelArray->item(pixelByteOffset);
float green = pixelArray->item(pixelByteOffset + 1);
@@ -138,11 +126,9 @@ void effectType(Uint8ClampedArray* pixelArray, const Vector<float>& values)
case FECOLORMATRIX_TYPE_MATRIX:
matrix(red, green, blue, alpha, values);
break;
- case FECOLORMATRIX_TYPE_SATURATE:
- saturate(red, green, blue, values[0]);
- break;
+ case FECOLORMATRIX_TYPE_SATURATE:
case FECOLORMATRIX_TYPE_HUEROTATE:
- huerotate(red, green, blue, values[0]);
+ saturateAndHueRotate(red, green, blue, components);
break;
case FECOLORMATRIX_TYPE_LUMINANCETOALPHA:
luminance(red, green, blue, alpha);
diff --git a/Source/WebCore/platform/graphics/filters/FEColorMatrix.h b/Source/WebCore/platform/graphics/filters/FEColorMatrix.h
index 99b650b9c..98905c58e 100644
--- a/Source/WebCore/platform/graphics/filters/FEColorMatrix.h
+++ b/Source/WebCore/platform/graphics/filters/FEColorMatrix.h
@@ -49,14 +49,16 @@ public:
bool setValues(const Vector<float>&);
virtual void platformApplySoftware();
-#if USE(SKIA)
- virtual bool platformApplySkia();
- virtual SkImageFilter* createImageFilter(SkiaImageFilterBuilder*);
+#if ENABLE(OPENCL)
+ virtual bool platformApplyOpenCL();
#endif
virtual void dump();
virtual TextStream& externalRepresentation(TextStream&, int indention) const;
+ static inline void calculateSaturateComponents(float* components, float value);
+ static inline void calculateHueRotateComponents(float* components, float value);
+
private:
FEColorMatrix(Filter*, ColorMatrixType, const Vector<float>&);
@@ -64,6 +66,35 @@ private:
Vector<float> m_values;
};
+inline void FEColorMatrix::calculateSaturateComponents(float* components, float value)
+{
+ components[0] = (0.213 + 0.787 * value);
+ components[1] = (0.715 - 0.715 * value);
+ components[2] = (0.072 - 0.072 * value);
+ components[3] = (0.213 - 0.213 * value);
+ components[4] = (0.715 + 0.285 * value);
+ components[5] = (0.072 - 0.072 * value);
+ components[6] = (0.213 - 0.213 * value);
+ components[7] = (0.715 - 0.715 * value);
+ components[8] = (0.072 + 0.928 * value);
+}
+
+inline void FEColorMatrix::calculateHueRotateComponents(float* components, float value)
+{
+ float cosHue = cos(value * piFloat / 180);
+ float sinHue = sin(value * piFloat / 180);
+ components[0] = 0.213 + cosHue * 0.787 - sinHue * 0.213;
+ components[1] = 0.715 - cosHue * 0.715 - sinHue * 0.715;
+ components[2] = 0.072 - cosHue * 0.072 + sinHue * 0.928;
+ components[3] = 0.213 - cosHue * 0.213 + sinHue * 0.143;
+ components[4] = 0.715 + cosHue * 0.285 + sinHue * 0.140;
+ components[5] = 0.072 - cosHue * 0.072 - sinHue * 0.283;
+ components[6] = 0.213 - cosHue * 0.213 - sinHue * 0.787;
+ components[7] = 0.715 - cosHue * 0.715 + sinHue * 0.715;
+ components[8] = 0.072 + cosHue * 0.928 + sinHue * 0.072;
+}
+
+
} // namespace WebCore
#endif // ENABLE(FILTERS)
diff --git a/Source/WebCore/platform/graphics/filters/FEComponentTransfer.cpp b/Source/WebCore/platform/graphics/filters/FEComponentTransfer.cpp
index a937148da..7caead2f8 100644
--- a/Source/WebCore/platform/graphics/filters/FEComponentTransfer.cpp
+++ b/Source/WebCore/platform/graphics/filters/FEComponentTransfer.cpp
@@ -166,10 +166,11 @@ void FEComponentTransfer::platformApplySoftware()
in->copyUnmultipliedImage(pixelArray, drawingRect);
unsigned pixelArrayLength = pixelArray->length();
+ unsigned char* data = pixelArray->data();
for (unsigned pixelOffset = 0; pixelOffset < pixelArrayLength; pixelOffset += 4) {
for (unsigned channel = 0; channel < 4; ++channel) {
- unsigned char c = pixelArray->item(pixelOffset + channel);
- pixelArray->set(pixelOffset + channel, tables[channel][c]);
+ unsigned char c = data[pixelOffset + channel];
+ data[pixelOffset + channel] = tables[channel][c];
}
}
}
@@ -183,7 +184,7 @@ void FEComponentTransfer::getValues(unsigned char rValues[256], unsigned char gV
TransferType callEffect[] = {identity, identity, table, discrete, linear, gamma};
for (unsigned channel = 0; channel < 4; channel++) {
- ASSERT(static_cast<size_t>(transferFunction[channel].type) < WTF_ARRAY_LENGTH(callEffect));
+ ASSERT_WITH_SECURITY_IMPLICATION(static_cast<size_t>(transferFunction[channel].type) < WTF_ARRAY_LENGTH(callEffect));
(*callEffect[transferFunction[channel].type])(tables[channel], transferFunction[channel]);
}
}
diff --git a/Source/WebCore/platform/graphics/filters/FEComponentTransfer.h b/Source/WebCore/platform/graphics/filters/FEComponentTransfer.h
index 68454fd35..cf6b7476d 100644
--- a/Source/WebCore/platform/graphics/filters/FEComponentTransfer.h
+++ b/Source/WebCore/platform/graphics/filters/FEComponentTransfer.h
@@ -79,10 +79,6 @@ public:
void setAlphaFunction(const ComponentTransferFunction&);
virtual void platformApplySoftware();
-#if USE(SKIA)
- virtual bool platformApplySkia();
- virtual SkImageFilter* createImageFilter(SkiaImageFilterBuilder*);
-#endif
virtual void dump();
virtual TextStream& externalRepresentation(TextStream&, int indention) const;
diff --git a/Source/WebCore/platform/graphics/filters/FEComposite.cpp b/Source/WebCore/platform/graphics/filters/FEComposite.cpp
index 9d566ed92..27e73aa9c 100644
--- a/Source/WebCore/platform/graphics/filters/FEComposite.cpp
+++ b/Source/WebCore/platform/graphics/filters/FEComposite.cpp
@@ -274,11 +274,15 @@ void FEComposite::platformApplySoftware()
return;
GraphicsContext* filterContext = resultImage->context();
- FloatRect srcRect = FloatRect(0, 0, -1, -1);
+ ImageBuffer* imageBuffer = in->asImageBuffer();
+ ImageBuffer* imageBuffer2 = in2->asImageBuffer();
+ ASSERT(imageBuffer);
+ ASSERT(imageBuffer2);
+
switch (m_type) {
case FECOMPOSITE_OPERATOR_OVER:
- filterContext->drawImageBuffer(in2->asImageBuffer(), ColorSpaceDeviceRGB, drawingRegionOfInputImage(in2->absolutePaintRect()));
- filterContext->drawImageBuffer(in->asImageBuffer(), ColorSpaceDeviceRGB, drawingRegionOfInputImage(in->absolutePaintRect()));
+ filterContext->drawImageBuffer(imageBuffer2, ColorSpaceDeviceRGB, drawingRegionOfInputImage(in2->absolutePaintRect()));
+ filterContext->drawImageBuffer(imageBuffer, ColorSpaceDeviceRGB, drawingRegionOfInputImage(in->absolutePaintRect()));
break;
case FECOMPOSITE_OPERATOR_IN: {
// Applies only to the intersected region.
@@ -292,21 +296,21 @@ void FEComposite::platformApplySoftware()
destinationRect.y() - in->absolutePaintRect().y()), destinationRect.size());
IntRect source2Rect(IntPoint(destinationRect.x() - in2->absolutePaintRect().x(),
destinationRect.y() - in2->absolutePaintRect().y()), destinationRect.size());
- filterContext->drawImageBuffer(in2->asImageBuffer(), ColorSpaceDeviceRGB, destinationPoint, source2Rect);
- filterContext->drawImageBuffer(in->asImageBuffer(), ColorSpaceDeviceRGB, destinationPoint, sourceRect, CompositeSourceIn);
+ filterContext->drawImageBuffer(imageBuffer2, ColorSpaceDeviceRGB, destinationPoint, source2Rect);
+ filterContext->drawImageBuffer(imageBuffer, ColorSpaceDeviceRGB, destinationPoint, sourceRect, CompositeSourceIn);
break;
}
case FECOMPOSITE_OPERATOR_OUT:
- filterContext->drawImageBuffer(in->asImageBuffer(), ColorSpaceDeviceRGB, drawingRegionOfInputImage(in->absolutePaintRect()));
- filterContext->drawImageBuffer(in2->asImageBuffer(), ColorSpaceDeviceRGB, drawingRegionOfInputImage(in2->absolutePaintRect()), srcRect, CompositeDestinationOut);
+ filterContext->drawImageBuffer(imageBuffer, ColorSpaceDeviceRGB, drawingRegionOfInputImage(in->absolutePaintRect()));
+ filterContext->drawImageBuffer(imageBuffer2, ColorSpaceDeviceRGB, drawingRegionOfInputImage(in2->absolutePaintRect()), IntRect(IntPoint(), imageBuffer2->logicalSize()), CompositeDestinationOut);
break;
case FECOMPOSITE_OPERATOR_ATOP:
- filterContext->drawImageBuffer(in2->asImageBuffer(), ColorSpaceDeviceRGB, drawingRegionOfInputImage(in2->absolutePaintRect()));
- filterContext->drawImageBuffer(in->asImageBuffer(), ColorSpaceDeviceRGB, drawingRegionOfInputImage(in->absolutePaintRect()), srcRect, CompositeSourceAtop);
+ filterContext->drawImageBuffer(imageBuffer2, ColorSpaceDeviceRGB, drawingRegionOfInputImage(in2->absolutePaintRect()));
+ filterContext->drawImageBuffer(imageBuffer, ColorSpaceDeviceRGB, drawingRegionOfInputImage(in->absolutePaintRect()), IntRect(IntPoint(), imageBuffer->logicalSize()), CompositeSourceAtop);
break;
case FECOMPOSITE_OPERATOR_XOR:
- filterContext->drawImageBuffer(in2->asImageBuffer(), ColorSpaceDeviceRGB, drawingRegionOfInputImage(in2->absolutePaintRect()));
- filterContext->drawImageBuffer(in->asImageBuffer(), ColorSpaceDeviceRGB, drawingRegionOfInputImage(in->absolutePaintRect()), srcRect, CompositeXOR);
+ filterContext->drawImageBuffer(imageBuffer2, ColorSpaceDeviceRGB, drawingRegionOfInputImage(in2->absolutePaintRect()));
+ filterContext->drawImageBuffer(imageBuffer, ColorSpaceDeviceRGB, drawingRegionOfInputImage(in->absolutePaintRect()), IntRect(IntPoint(), imageBuffer->logicalSize()), CompositeXOR);
break;
default:
break;
diff --git a/Source/WebCore/platform/graphics/filters/FEConvolveMatrix.h b/Source/WebCore/platform/graphics/filters/FEConvolveMatrix.h
index 81eba1d83..846e24497 100644
--- a/Source/WebCore/platform/graphics/filters/FEConvolveMatrix.h
+++ b/Source/WebCore/platform/graphics/filters/FEConvolveMatrix.h
@@ -28,7 +28,6 @@
#include "FloatPoint.h"
#include "FloatSize.h"
#include "Filter.h"
-#include <wtf/AlwaysInline.h>
#include <wtf/Vector.h>
namespace WebCore {
diff --git a/Source/WebCore/platform/graphics/filters/FECustomFilter.cpp b/Source/WebCore/platform/graphics/filters/FECustomFilter.cpp
index 15c50a1e5..c22f50ef9 100644
--- a/Source/WebCore/platform/graphics/filters/FECustomFilter.cpp
+++ b/Source/WebCore/platform/graphics/filters/FECustomFilter.cpp
@@ -33,6 +33,7 @@
#if ENABLE(CSS_SHADERS) && USE(3D_GRAPHICS)
#include "FECustomFilter.h"
+#include "CustomFilterCompiledProgram.h"
#include "CustomFilterRenderer.h"
#include "CustomFilterValidatedProgram.h"
#include "Extensions3D.h"
@@ -45,7 +46,7 @@
namespace WebCore {
FECustomFilter::FECustomFilter(Filter* filter, PassRefPtr<GraphicsContext3D> context, PassRefPtr<CustomFilterValidatedProgram> validatedProgram, const CustomFilterParameterList& parameters,
- unsigned meshRows, unsigned meshColumns, CustomFilterMeshBoxType meshBoxType, CustomFilterMeshType meshType)
+ unsigned meshRows, unsigned meshColumns, CustomFilterMeshType meshType)
: FilterEffect(filter)
, m_context(context)
, m_validatedProgram(validatedProgram)
@@ -59,13 +60,13 @@ FECustomFilter::FECustomFilter(Filter* filter, PassRefPtr<GraphicsContext3D> con
, m_multisampleDepthBuffer(0)
{
// We will not pass a CustomFilterCompiledProgram here, as we only want to compile it when we actually need it in the first paint.
- m_customFilterRenderer = CustomFilterRenderer::create(m_context, m_validatedProgram->programInfo().programType(), parameters, meshRows, meshColumns, meshBoxType, meshType);
+ m_customFilterRenderer = CustomFilterRenderer::create(m_context, m_validatedProgram->programInfo().programType(), parameters, meshRows, meshColumns, meshType);
}
PassRefPtr<FECustomFilter> FECustomFilter::create(Filter* filter, PassRefPtr<GraphicsContext3D> context, PassRefPtr<CustomFilterValidatedProgram> validatedProgram, const CustomFilterParameterList& parameters,
- unsigned meshRows, unsigned meshColumns, CustomFilterMeshBoxType meshBoxType, CustomFilterMeshType meshType)
+ unsigned meshRows, unsigned meshColumns, CustomFilterMeshType meshType)
{
- return adoptRef(new FECustomFilter(filter, context, validatedProgram, parameters, meshRows, meshColumns, meshBoxType, meshType));
+ return adoptRef(new FECustomFilter(filter, context, validatedProgram, parameters, meshRows, meshColumns, meshType));
}
FECustomFilter::~FECustomFilter()
@@ -156,9 +157,16 @@ bool FECustomFilter::prepareForDrawing()
{
m_context->makeContextCurrent();
- // Lazily inject the compiled program into the CustomFilterRenderer.
- if (!m_customFilterRenderer->compiledProgram())
- m_customFilterRenderer->setCompiledProgram(m_validatedProgram->compiledProgram());
+ if (!m_customFilterRenderer->compiledProgram()) {
+ RefPtr<CustomFilterCompiledProgram> compiledProgram = m_validatedProgram->compiledProgram();
+ if (!compiledProgram) {
+ // Lazily create a compiled program and let CustomFilterValidatedProgram hold on to it.
+ compiledProgram = CustomFilterCompiledProgram::create(m_context, m_validatedProgram->validatedVertexShader(), m_validatedProgram->validatedFragmentShader(), m_validatedProgram->programInfo().programType());
+ m_validatedProgram->setCompiledProgram(compiledProgram);
+ }
+ // Lazily inject the compiled program into the CustomFilterRenderer.
+ m_customFilterRenderer->setCompiledProgram(compiledProgram.release());
+ }
if (!m_customFilterRenderer->prepareForDrawing())
return false;
@@ -331,12 +339,7 @@ bool FECustomFilter::resizeContext(const IntSize& newContextSize)
m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_frameBuffer);
m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_destTexture);
// We are going to clear the output buffer anyway, so we can safely initialize the destination texture with garbage data.
-#if PLATFORM(CHROMIUM)
- // FIXME: GraphicsContext3D::texImage2DDirect is not implemented on Chromium.
- m_context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, newContextSize.width(), newContextSize.height(), 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, 0);
-#else
m_context->texImage2DDirect(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, newContextSize.width(), newContextSize.height(), 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, 0);
-#endif
m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_destTexture, 0);
// We don't need the depth buffer for the texture framebuffer, if we already
diff --git a/Source/WebCore/platform/graphics/filters/FECustomFilter.h b/Source/WebCore/platform/graphics/filters/FECustomFilter.h
index a19b48d63..fe29b5485 100644
--- a/Source/WebCore/platform/graphics/filters/FECustomFilter.h
+++ b/Source/WebCore/platform/graphics/filters/FECustomFilter.h
@@ -53,7 +53,7 @@ class IntSize;
class FECustomFilter : public FilterEffect {
public:
static PassRefPtr<FECustomFilter> create(Filter*, PassRefPtr<GraphicsContext3D>, PassRefPtr<CustomFilterValidatedProgram>, const CustomFilterParameterList&,
- unsigned meshRows, unsigned meshColumns, CustomFilterMeshBoxType, CustomFilterMeshType);
+ unsigned meshRows, unsigned meshColumns, CustomFilterMeshType);
virtual void platformApplySoftware();
virtual void dump();
@@ -62,7 +62,7 @@ public:
private:
FECustomFilter(Filter*, PassRefPtr<GraphicsContext3D>, PassRefPtr<CustomFilterValidatedProgram>, const CustomFilterParameterList&,
- unsigned meshRows, unsigned meshColumns, CustomFilterMeshBoxType, CustomFilterMeshType);
+ unsigned meshRows, unsigned meshColumns, CustomFilterMeshType);
~FECustomFilter();
bool applyShader();
diff --git a/Source/WebCore/platform/graphics/filters/FEDisplacementMap.cpp b/Source/WebCore/platform/graphics/filters/FEDisplacementMap.cpp
index 7f554aa84..025ff65ac 100644
--- a/Source/WebCore/platform/graphics/filters/FEDisplacementMap.cpp
+++ b/Source/WebCore/platform/graphics/filters/FEDisplacementMap.cpp
@@ -88,6 +88,22 @@ bool FEDisplacementMap::setScale(float scale)
return true;
}
+void FEDisplacementMap::setResultColorSpace(ColorSpace)
+{
+ // Spec: The 'color-interpolation-filters' property only applies to the 'in2' source image
+ // and does not apply to the 'in' source image. The 'in' source image must remain in its
+ // current color space.
+ // The result is in that smae color space because it is a displacement of the 'in' image.
+ FilterEffect::setResultColorSpace(inputEffect(0)->resultColorSpace());
+}
+
+void FEDisplacementMap::transformResultColorSpace(FilterEffect* in, const int index)
+{
+ // Do not transform the first primitive input, as per the spec.
+ if (index)
+ in->transformResultColorSpace(operatingColorSpace());
+}
+
void FEDisplacementMap::platformApplySoftware()
{
FilterEffect* in = inputEffect(0);
@@ -110,17 +126,19 @@ void FEDisplacementMap::platformApplySoftware()
Filter* filter = this->filter();
IntSize paintSize = absolutePaintRect().size();
- float scaleX = filter->applyHorizontalScale(m_scale / 255);
- float scaleY = filter->applyVerticalScale(m_scale / 255);
- float scaleAdjustmentX = filter->applyHorizontalScale(0.5f - 0.5f * m_scale);
- float scaleAdjustmentY = filter->applyVerticalScale(0.5f - 0.5f * m_scale);
+ float scaleX = filter->applyHorizontalScale(m_scale);
+ float scaleY = filter->applyVerticalScale(m_scale);
+ float scaleForColorX = scaleX / 255.0;
+ float scaleForColorY = scaleY / 255.0;
+ float scaledOffsetX = 0.5 - scaleX * 0.5;
+ float scaledOffsetY = 0.5 - scaleY * 0.5;
int stride = paintSize.width() * 4;
for (int y = 0; y < paintSize.height(); ++y) {
int line = y * stride;
for (int x = 0; x < paintSize.width(); ++x) {
int dstIndex = line + x * 4;
- int srcX = x + static_cast<int>(scaleX * srcPixelArrayB->item(dstIndex + m_xChannelSelector - 1) + scaleAdjustmentX);
- int srcY = y + static_cast<int>(scaleY * srcPixelArrayB->item(dstIndex + m_yChannelSelector - 1) + scaleAdjustmentY);
+ int srcX = x + static_cast<int>(scaleForColorX * srcPixelArrayB->item(dstIndex + m_xChannelSelector - 1) + scaledOffsetX);
+ int srcY = y + static_cast<int>(scaleForColorY * srcPixelArrayB->item(dstIndex + m_yChannelSelector - 1) + scaledOffsetY);
for (unsigned channel = 0; channel < 4; ++channel) {
if (srcX < 0 || srcX >= paintSize.width() || srcY < 0 || srcY >= paintSize.height())
dstPixelArray->set(dstIndex + channel, static_cast<unsigned char>(0));
diff --git a/Source/WebCore/platform/graphics/filters/FEDisplacementMap.h b/Source/WebCore/platform/graphics/filters/FEDisplacementMap.h
index 47b54d539..1b4170ef4 100644
--- a/Source/WebCore/platform/graphics/filters/FEDisplacementMap.h
+++ b/Source/WebCore/platform/graphics/filters/FEDisplacementMap.h
@@ -50,6 +50,9 @@ public:
float scale() const;
bool setScale(float);
+ void setResultColorSpace(ColorSpace) OVERRIDE;
+ virtual void transformResultColorSpace(FilterEffect*, const int) OVERRIDE;
+
virtual void platformApplySoftware();
virtual void dump();
diff --git a/Source/WebCore/platform/graphics/filters/FEFlood.h b/Source/WebCore/platform/graphics/filters/FEFlood.h
index e0484b449..8bd9e4d2b 100644
--- a/Source/WebCore/platform/graphics/filters/FEFlood.h
+++ b/Source/WebCore/platform/graphics/filters/FEFlood.h
@@ -39,7 +39,17 @@ public:
float floodOpacity() const;
bool setFloodOpacity(float);
+#if !USE(CG)
+ // feFlood does not perform color interpolation of any kind, so the result is always in the current
+ // color space regardless of the value of color-interpolation-filters.
+ void setOperatingColorSpace(ColorSpace) OVERRIDE { FilterEffect::setResultColorSpace(ColorSpaceDeviceRGB); }
+ void setResultColorSpace(ColorSpace) OVERRIDE { FilterEffect::setResultColorSpace(ColorSpaceDeviceRGB); }
+#endif
+
virtual void platformApplySoftware();
+#if ENABLE(OPENCL)
+ virtual bool platformApplyOpenCL();
+#endif
virtual void dump();
virtual void determineAbsolutePaintRect() { setAbsolutePaintRect(enclosingIntRect(maxEffectRect())); }
diff --git a/Source/WebCore/platform/graphics/filters/FEGaussianBlur.cpp b/Source/WebCore/platform/graphics/filters/FEGaussianBlur.cpp
index cb9562f69..446e25a10 100644
--- a/Source/WebCore/platform/graphics/filters/FEGaussianBlur.cpp
+++ b/Source/WebCore/platform/graphics/filters/FEGaussianBlur.cpp
@@ -230,6 +230,8 @@ inline void FEGaussianBlur::platformApply(Uint8ClampedArray* srcPixelArray, Uint
void FEGaussianBlur::calculateUnscaledKernelSize(unsigned& kernelSizeX, unsigned& kernelSizeY, float stdX, float stdY)
{
+ ASSERT(stdX >= 0 && stdY >= 0);
+
kernelSizeX = 0;
if (stdX)
kernelSizeX = max<unsigned>(2, static_cast<unsigned>(floorf(stdX * gaussianKernelFactor() + 0.5f)));
diff --git a/Source/WebCore/platform/graphics/filters/FEGaussianBlur.h b/Source/WebCore/platform/graphics/filters/FEGaussianBlur.h
index daf3ef17a..f554ef841 100644
--- a/Source/WebCore/platform/graphics/filters/FEGaussianBlur.h
+++ b/Source/WebCore/platform/graphics/filters/FEGaussianBlur.h
@@ -73,10 +73,6 @@ private:
inline void platformApply(Uint8ClampedArray* srcPixelArray, Uint8ClampedArray* tmpPixelArray, unsigned kernelSizeX, unsigned kernelSizeY, IntSize& paintSize);
inline void platformApplyGeneric(Uint8ClampedArray* srcPixelArray, Uint8ClampedArray* tmpPixelArray, unsigned kernelSizeX, unsigned kernelSizeY, IntSize& paintSize);
-#if USE(SKIA)
- virtual bool platformApplySkia();
- virtual SkImageFilter* createImageFilter(SkiaImageFilterBuilder*);
-#endif
float m_stdX;
float m_stdY;
diff --git a/Source/WebCore/platform/graphics/filters/FELighting.h b/Source/WebCore/platform/graphics/filters/FELighting.h
index 288985d42..b40bb1309 100644
--- a/Source/WebCore/platform/graphics/filters/FELighting.h
+++ b/Source/WebCore/platform/graphics/filters/FELighting.h
@@ -34,7 +34,6 @@
#include "LightSource.h"
#include "PointLightSource.h"
#include "SpotLightSource.h"
-#include <wtf/Platform.h>
#include <wtf/Uint8ClampedArray.h>
// Common base class for FEDiffuseLighting and FESpecularLighting
@@ -46,10 +45,6 @@ struct FELightingPaintingDataForNeon;
class FELighting : public FilterEffect {
public:
virtual void platformApplySoftware();
-#if USE(SKIA)
- virtual SkImageFilter* createImageFilter(SkiaImageFilterBuilder*);
- virtual bool platformApplySkia();
-#endif
virtual void determineAbsolutePaintRect() { setAbsolutePaintRect(enclosingIntRect(maxEffectRect())); }
diff --git a/Source/WebCore/platform/graphics/filters/FEMerge.h b/Source/WebCore/platform/graphics/filters/FEMerge.h
index 302336b63..fb4f4f6cf 100644
--- a/Source/WebCore/platform/graphics/filters/FEMerge.h
+++ b/Source/WebCore/platform/graphics/filters/FEMerge.h
@@ -34,6 +34,9 @@ public:
static PassRefPtr<FEMerge> create(Filter*);
virtual void platformApplySoftware();
+#if ENABLE(OPENCL)
+ virtual bool platformApplyOpenCL();
+#endif
virtual void dump();
virtual TextStream& externalRepresentation(TextStream&, int indention) const;
diff --git a/Source/WebCore/platform/graphics/filters/FEMorphology.h b/Source/WebCore/platform/graphics/filters/FEMorphology.h
index b38e673c3..04a77f546 100644
--- a/Source/WebCore/platform/graphics/filters/FEMorphology.h
+++ b/Source/WebCore/platform/graphics/filters/FEMorphology.h
@@ -47,11 +47,6 @@ public:
bool setRadiusY(float);
virtual void platformApplySoftware();
-#if USE(SKIA)
- virtual bool platformApplySkia();
- virtual SkImageFilter* createImageFilter(SkiaImageFilterBuilder*);
-
-#endif
virtual void dump();
virtual void determineAbsolutePaintRect();
diff --git a/Source/WebCore/platform/graphics/filters/FilterEffect.cpp b/Source/WebCore/platform/graphics/filters/FilterEffect.cpp
index 0a0f82278..5dd065d98 100644
--- a/Source/WebCore/platform/graphics/filters/FilterEffect.cpp
+++ b/Source/WebCore/platform/graphics/filters/FilterEffect.cpp
@@ -44,7 +44,7 @@ FilterEffect::FilterEffect(Filter* filter)
, m_hasWidth(false)
, m_hasHeight(false)
, m_clipsToBounds(true)
- , m_colorSpace(ColorSpaceLinearRGB)
+ , m_operatingColorSpace(ColorSpaceLinearRGB)
, m_resultColorSpace(ColorSpaceDeviceRGB)
{
ASSERT(m_filter);
@@ -93,10 +93,28 @@ IntRect FilterEffect::drawingRegionOfInputImage(const IntRect& srcRect) const
FilterEffect* FilterEffect::inputEffect(unsigned number) const
{
- ASSERT(number < m_inputEffects.size());
+ ASSERT_WITH_SECURITY_IMPLICATION(number < m_inputEffects.size());
return m_inputEffects.at(number).get();
}
+#if ENABLE(OPENCL)
+void FilterEffect::applyAll()
+{
+ if (hasResult())
+ return;
+ FilterContextOpenCL* context = FilterContextOpenCL::context();
+ if (context) {
+ apply();
+ if (!context->inError())
+ return;
+ clearResultsRecursive();
+ context->destroyContext();
+ }
+ // Software code path.
+ apply();
+}
+#endif
+
void FilterEffect::apply()
{
if (hasResult())
@@ -109,11 +127,11 @@ void FilterEffect::apply()
return;
// Convert input results to the current effect's color space.
- in->transformResultColorSpace(m_colorSpace);
+ transformResultColorSpace(in, i);
}
determineAbsolutePaintRect();
- m_resultColorSpace = m_colorSpace;
+ setResultColorSpace(m_operatingColorSpace);
if (!isFilterSizeValid(m_absolutePaintRect))
return;
@@ -128,10 +146,6 @@ void FilterEffect::apply()
if (platformApplyOpenCL())
return;
#endif
-#if USE(SKIA)
- if (platformApplySkia())
- return;
-#endif
platformApplySoftware();
}
@@ -223,6 +237,18 @@ void FilterEffect::clearResult()
#endif
}
+void FilterEffect::clearResultsRecursive()
+{
+ // Clear all results, regardless that the current effect has
+ // a result. Can be used if an effect is in an erroneous state.
+ if (hasResult())
+ clearResult();
+
+ unsigned size = m_inputEffects.size();
+ for (unsigned i = 0; i < size; ++i)
+ m_inputEffects.at(i).get()->clearResultsRecursive();
+}
+
ImageBuffer* FilterEffect::asImageBuffer()
{
if (!hasResult())
@@ -248,13 +274,19 @@ ImageBuffer* FilterEffect::openCLImageToImageBuffer()
FilterContextOpenCL* context = FilterContextOpenCL::context();
ASSERT(context);
+ if (context->inError())
+ return 0;
+
size_t origin[3] = { 0, 0, 0 };
size_t region[3] = { m_absolutePaintRect.width(), m_absolutePaintRect.height(), 1 };
RefPtr<Uint8ClampedArray> destinationPixelArray = Uint8ClampedArray::create(m_absolutePaintRect.width() * m_absolutePaintRect.height() * 4);
- clFinish(context->commandQueue());
- clEnqueueReadImage(context->commandQueue(), m_openCLImageResult, CL_TRUE, origin, region, 0, 0, destinationPixelArray->data(), 0, 0, 0);
+ if (context->isFailed(clFinish(context->commandQueue())))
+ return 0;
+
+ if (context->isFailed(clEnqueueReadImage(context->commandQueue(), m_openCLImageResult, CL_TRUE, origin, region, 0, 0, destinationPixelArray->data(), 0, 0, 0)))
+ return 0;
m_imageBufferResult = ImageBuffer::create(m_absolutePaintRect.size());
IntRect destinationRect(IntPoint(), m_absolutePaintRect.size());
@@ -392,7 +424,7 @@ ImageBuffer* FilterEffect::createImageBufferResult()
ASSERT(!hasResult());
if (m_absolutePaintRect.isEmpty())
return 0;
- m_imageBufferResult = ImageBuffer::create(m_absolutePaintRect.size(), 1, m_colorSpace, m_filter->renderingMode());
+ m_imageBufferResult = ImageBuffer::create(m_absolutePaintRect.size(), 1, m_resultColorSpace, m_filter->renderingMode());
if (!m_imageBufferResult)
return 0;
ASSERT(m_imageBufferResult->context());
@@ -426,15 +458,29 @@ Uint8ClampedArray* FilterEffect::createPremultipliedImageResult()
#if ENABLE(OPENCL)
OpenCLHandle FilterEffect::createOpenCLImageResult(uint8_t* source)
{
+ FilterContextOpenCL* context = FilterContextOpenCL::context();
+ ASSERT(context);
+
+ if (context->inError())
+ return 0;
+
ASSERT(!hasResult());
cl_image_format clImageFormat;
clImageFormat.image_channel_order = CL_RGBA;
clImageFormat.image_channel_data_type = CL_UNORM_INT8;
- FilterContextOpenCL* context = FilterContextOpenCL::context();
- ASSERT(context);
+ int errorCode = 0;
+#ifdef CL_API_SUFFIX__VERSION_1_2
+ cl_image_desc imageDescriptor = { CL_MEM_OBJECT_IMAGE2D, m_absolutePaintRect.width(), m_absolutePaintRect.height(), 0, 0, 0, 0, 0, 0, 0};
+ m_openCLImageResult = clCreateImage(context->deviceContext(), CL_MEM_READ_WRITE | (source ? CL_MEM_COPY_HOST_PTR : 0),
+ &clImageFormat, &imageDescriptor, source, &errorCode);
+#else
m_openCLImageResult = clCreateImage2D(context->deviceContext(), CL_MEM_READ_WRITE | (source ? CL_MEM_COPY_HOST_PTR : 0),
- &clImageFormat, m_absolutePaintRect.width(), m_absolutePaintRect.height(), 0, source, 0);
+ &clImageFormat, m_absolutePaintRect.width(), m_absolutePaintRect.height(), 0, source, &errorCode);
+#endif
+ if (context->isFailed(errorCode))
+ return 0;
+
return m_openCLImageResult;
}
#endif
@@ -448,27 +494,22 @@ void FilterEffect::transformResultColorSpace(ColorSpace dstColorSpace)
if (!hasResult() || dstColorSpace == m_resultColorSpace)
return;
- // FIXME: We can avoid this potentially unnecessary ImageBuffer conversion by adding
- // color space transform support for the {pre,un}multiplied arrays.
#if ENABLE(OPENCL)
if (openCLImage()) {
+ if (m_imageBufferResult)
+ m_imageBufferResult.clear();
FilterContextOpenCL* context = FilterContextOpenCL::context();
ASSERT(context);
context->openCLTransformColorSpace(m_openCLImageResult, absolutePaintRect(), m_resultColorSpace, dstColorSpace);
- if (m_imageBufferResult)
- m_imageBufferResult.clear();
- goto skipSoftwareCodePath;
- }
+ } else {
#endif
- if (!m_imageBufferResult) {
- asImageBuffer();
- ASSERT(m_imageBufferResult);
- }
- m_imageBufferResult->transformColorSpace(m_resultColorSpace, dstColorSpace);
+ // FIXME: We can avoid this potentially unnecessary ImageBuffer conversion by adding
+ // color space transform support for the {pre,un}multiplied arrays.
+ asImageBuffer()->transformColorSpace(m_resultColorSpace, dstColorSpace);
#if ENABLE(OPENCL)
-skipSoftwareCodePath:
+ }
#endif
m_resultColorSpace = dstColorSpace;
diff --git a/Source/WebCore/platform/graphics/filters/FilterEffect.h b/Source/WebCore/platform/graphics/filters/FilterEffect.h
index b9f219326..296461f9f 100644
--- a/Source/WebCore/platform/graphics/filters/FilterEffect.h
+++ b/Source/WebCore/platform/graphics/filters/FilterEffect.h
@@ -39,10 +39,6 @@
static const float kMaxFilterSize = 5000.0f;
-#if USE(SKIA)
-class SkImageFilter;
-#endif
-
namespace WebCore {
class Filter;
@@ -50,10 +46,6 @@ class FilterEffect;
class ImageBuffer;
class TextStream;
-#if USE(SKIA)
-class SkiaImageFilterBuilder;
-#endif
-
typedef Vector<RefPtr<FilterEffect> > FilterEffectVector;
enum FilterEffectType {
@@ -68,6 +60,8 @@ public:
virtual ~FilterEffect();
void clearResult();
+ void clearResultsRecursive();
+
ImageBuffer* asImageBuffer();
PassRefPtr<Uint8ClampedArray> asUnmultipliedImage(const IntRect&);
PassRefPtr<Uint8ClampedArray> asPremultipliedImage(const IntRect&);
@@ -109,7 +103,12 @@ public:
void setMaxEffectRect(const FloatRect& maxEffectRect) { m_maxEffectRect = maxEffectRect; }
void apply();
-
+#if ENABLE(OPENCL)
+ void applyAll();
+#else
+ inline void applyAll() { apply(); }
+#endif
+
// Correct any invalid pixels, if necessary, in the result of a filter operation.
// This method is used to ensure valid pixel values on filter inputs and the final result.
// Only the arithmetic composite filter ever needs to perform correction.
@@ -119,10 +118,6 @@ public:
#if ENABLE(OPENCL)
virtual bool platformApplyOpenCL();
#endif
-#if USE(SKIA)
- virtual bool platformApplySkia() { return false; }
- virtual SkImageFilter* createImageFilter(SkiaImageFilterBuilder*) { return 0; }
-#endif
virtual void dump() = 0;
virtual void determineAbsolutePaintRect();
@@ -157,8 +152,12 @@ public:
bool clipsToBounds() const { return m_clipsToBounds; }
void setClipsToBounds(bool value) { m_clipsToBounds = value; }
- ColorSpace colorSpace() const { return m_colorSpace; }
- void setColorSpace(ColorSpace colorSpace) { m_colorSpace = colorSpace; }
+ ColorSpace operatingColorSpace() const { return m_operatingColorSpace; }
+ virtual void setOperatingColorSpace(ColorSpace colorSpace) { m_operatingColorSpace = colorSpace; }
+ ColorSpace resultColorSpace() const { return m_resultColorSpace; }
+ virtual void setResultColorSpace(ColorSpace colorSpace) { m_resultColorSpace = colorSpace; }
+
+ virtual void transformResultColorSpace(FilterEffect* in, const int) { in->transformResultColorSpace(m_operatingColorSpace); }
void transformResultColorSpace(ColorSpace);
protected:
@@ -217,7 +216,7 @@ private:
// Should the effect clip to its primitive region, or expand to use the combined region of its inputs.
bool m_clipsToBounds;
- ColorSpace m_colorSpace;
+ ColorSpace m_operatingColorSpace;
ColorSpace m_resultColorSpace;
};
diff --git a/Source/WebCore/platform/graphics/filters/FilterOperation.cpp b/Source/WebCore/platform/graphics/filters/FilterOperation.cpp
index 656926e28..8bc79146d 100644
--- a/Source/WebCore/platform/graphics/filters/FilterOperation.cpp
+++ b/Source/WebCore/platform/graphics/filters/FilterOperation.cpp
@@ -30,8 +30,30 @@
#include "AnimationUtilities.h"
+#if ENABLE(SVG)
+#include "CachedSVGDocumentReference.h"
+#endif
+
namespace WebCore {
+ReferenceFilterOperation::ReferenceFilterOperation(const String& url, const String& fragment, OperationType type)
+ : FilterOperation(type)
+ , m_url(url)
+ , m_fragment(fragment)
+{
+}
+
+ReferenceFilterOperation::~ReferenceFilterOperation()
+{
+}
+
+#if ENABLE(SVG)
+void ReferenceFilterOperation::setCachedSVGDocumentReference(PassOwnPtr<CachedSVGDocumentReference> cachedSVGDocumentReference)
+{
+ m_cachedSVGDocumentReference = cachedSVGDocumentReference;
+}
+#endif
+
PassRefPtr<FilterOperation> BasicColorMatrixFilterOperation::blend(const FilterOperation* from, double progress, bool blendToPassthrough)
{
if (from && !from->isSameType(*this))
diff --git a/Source/WebCore/platform/graphics/filters/FilterOperation.h b/Source/WebCore/platform/graphics/filters/FilterOperation.h
index fb9b67619..5f61f8d65 100644
--- a/Source/WebCore/platform/graphics/filters/FilterOperation.h
+++ b/Source/WebCore/platform/graphics/filters/FilterOperation.h
@@ -41,10 +41,6 @@
#include <wtf/ThreadSafeRefCounted.h>
#endif
-#if ENABLE(SVG)
-#include "CachedSVGDocumentReference.h"
-#endif
-
// Annoyingly, wingdi.h #defines this.
#ifdef PASSTHROUGH
#undef PASSTHROUGH
@@ -54,6 +50,10 @@ namespace WebCore {
// CSS Filters
+#if ENABLE(SVG)
+class CachedSVGDocumentReference;
+#endif
+
#if PLATFORM(BLACKBERRY)
class FilterOperation : public ThreadSafeRefCounted<FilterOperation> {
#else
@@ -166,6 +166,7 @@ public:
{
return adoptRef(new ReferenceFilterOperation(url, fragment, type));
}
+ ~ReferenceFilterOperation();
virtual bool affectsOpacity() const { return true; }
virtual bool movesPixels() const { return true; }
@@ -175,13 +176,14 @@ public:
#if ENABLE(SVG)
CachedSVGDocumentReference* cachedSVGDocumentReference() const { return m_cachedSVGDocumentReference.get(); }
- void setCachedSVGDocumentReference(PassOwnPtr<CachedSVGDocumentReference> cachedSVGDocumentReference) { m_cachedSVGDocumentReference = cachedSVGDocumentReference; }
+ void setCachedSVGDocumentReference(PassOwnPtr<CachedSVGDocumentReference>);
#endif
FilterEffect* filterEffect() const { return m_filterEffect.get(); }
void setFilterEffect(PassRefPtr<FilterEffect> filterEffect) { m_filterEffect = filterEffect; }
private:
+ ReferenceFilterOperation(const String& url, const String& fragment, OperationType);
virtual bool operator==(const FilterOperation& o) const
{
@@ -191,13 +193,6 @@ private:
return m_url == other->m_url;
}
- ReferenceFilterOperation(const String& url, const String& fragment, OperationType type)
- : FilterOperation(type)
- , m_url(url)
- , m_fragment(fragment)
- {
- }
-
String m_url;
String m_fragment;
#if ENABLE(SVG)
diff --git a/Source/WebCore/platform/graphics/filters/FilterOperations.cpp b/Source/WebCore/platform/graphics/filters/FilterOperations.cpp
index fcb74fc32..db6594394 100644
--- a/Source/WebCore/platform/graphics/filters/FilterOperations.cpp
+++ b/Source/WebCore/platform/graphics/filters/FilterOperations.cpp
@@ -118,32 +118,30 @@ bool FilterOperations::hasOutsets() const
return false;
}
-void FilterOperations::getOutsets(int& top, int& right, int& bottom, int& left) const
+FilterOutsets FilterOperations::outsets() const
{
- top = 0;
- right = 0;
- bottom = 0;
- left = 0;
+ FilterOutsets totalOutsets;
for (size_t i = 0; i < m_operations.size(); ++i) {
FilterOperation* filterOperation = m_operations.at(i).get();
switch (filterOperation->getOperationType()) {
case FilterOperation::BLUR: {
BlurFilterOperation* blurOperation = static_cast<BlurFilterOperation*>(filterOperation);
float stdDeviation = floatValueForLength(blurOperation->stdDeviation(), 0);
- IntSize outset = outsetSizeForBlur(stdDeviation);
- top += outset.height();
- right += outset.width();
- bottom += outset.height();
- left += outset.width();
+ IntSize outsetSize = outsetSizeForBlur(stdDeviation);
+ FilterOutsets outsets(outsetSize.height(), outsetSize.width(), outsetSize.height(), outsetSize.width());
+ totalOutsets += outsets;
break;
}
case FilterOperation::DROP_SHADOW: {
DropShadowFilterOperation* dropShadowOperation = static_cast<DropShadowFilterOperation*>(filterOperation);
- IntSize outset = outsetSizeForBlur(dropShadowOperation->stdDeviation());
- top += std::max(0, outset.height() - dropShadowOperation->y());
- right += std::max(0, outset.width() + dropShadowOperation->x());
- bottom += std::max(0, outset.height() + dropShadowOperation->y());
- left += std::max(0, outset.width() - dropShadowOperation->x());
+ IntSize outsetSize = outsetSizeForBlur(dropShadowOperation->stdDeviation());
+ FilterOutsets outsets(
+ std::max(0, outsetSize.height() - dropShadowOperation->y()),
+ std::max(0, outsetSize.width() + dropShadowOperation->x()),
+ std::max(0, outsetSize.height() + dropShadowOperation->y()),
+ std::max(0, outsetSize.width() - dropShadowOperation->x())
+ );
+ totalOutsets += outsets;
break;
}
#if ENABLE(CSS_SHADERS)
@@ -158,6 +156,7 @@ void FilterOperations::getOutsets(int& top, int& right, int& bottom, int& left)
break;
}
}
+ return totalOutsets;
}
bool FilterOperations::hasFilterThatAffectsOpacity() const
diff --git a/Source/WebCore/platform/graphics/filters/FilterOperations.h b/Source/WebCore/platform/graphics/filters/FilterOperations.h
index c1da85b01..09a2d8ff1 100644
--- a/Source/WebCore/platform/graphics/filters/FilterOperations.h
+++ b/Source/WebCore/platform/graphics/filters/FilterOperations.h
@@ -29,11 +29,14 @@
#if ENABLE(CSS_FILTERS)
#include "FilterOperation.h"
+#include "IntRectExtent.h"
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
namespace WebCore {
+typedef IntRectExtent FilterOutsets;
+
class FilterOperations {
WTF_MAKE_FAST_ALLOCATED;
public:
@@ -63,7 +66,7 @@ public:
bool operationsMatch(const FilterOperations&) const;
bool hasOutsets() const;
- void getOutsets(int& top, int& right, int& bottom, int& left) const;
+ FilterOutsets outsets() const;
bool hasFilterThatAffectsOpacity() const;
bool hasFilterThatMovesPixels() const;
diff --git a/Source/WebCore/platform/graphics/filters/LightSource.cpp b/Source/WebCore/platform/graphics/filters/LightSource.cpp
deleted file mode 100644
index cf262e852..000000000
--- a/Source/WebCore/platform/graphics/filters/LightSource.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
- * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
- * Copyright (C) 2005 Eric Seidel <eric@webkit.org>
- * Copyright (C) 2010 Zoltan Herczeg <zherczeg@webkit.org>
- * Copyright (C) 2011 Renata Hodovan <reni@webkit.org>, University of Szeged.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-
-#if ENABLE(FILTERS)
-#include "LightSource.h"
-
-#include "DistantLightSource.h"
-#include "PointLightSource.h"
-#include "RenderTreeAsText.h"
-#include "SpotLightSource.h"
-#include <wtf/MathExtras.h>
-
-namespace WebCore {
-
-bool LightSource::setAzimuth(float azimuth)
-{
- if (m_type == LS_DISTANT)
- return static_cast<DistantLightSource*>(this)->setAzimuth(azimuth);
- return false;
-}
-
-bool LightSource::setElevation(float elevation)
-{
- if (m_type == LS_DISTANT)
- return static_cast<DistantLightSource*>(this)->setElevation(elevation);
- return false;
-}
-
-bool LightSource::setX(float x)
-{
- if (m_type == LS_SPOT)
- return static_cast<SpotLightSource*>(this)->setX(x);
- if (m_type == LS_POINT)
- return static_cast<PointLightSource*>(this)->setX(x);
- return false;
-}
-
-bool LightSource::setY(float y)
-{
- if (m_type == LS_SPOT)
- return static_cast<SpotLightSource*>(this)->setY(y);
- if (m_type == LS_POINT)
- return static_cast<PointLightSource*>(this)->setY(y);
- return false;
-}
-
-bool LightSource::setZ(float z)
-{
- if (m_type == LS_SPOT)
- return static_cast<SpotLightSource*>(this)->setZ(z);
- if (m_type == LS_POINT)
- return static_cast<PointLightSource*>(this)->setZ(z);
- return false;
-}
-
-bool LightSource::setPointsAtX(float pointsAtX)
-{
- if (m_type == LS_SPOT)
- return static_cast<SpotLightSource*>(this)->setPointsAtX(pointsAtX);
- return false;
-}
-
-bool LightSource::setPointsAtY(float pointsAtY)
-{
- if (m_type == LS_SPOT)
- return static_cast<SpotLightSource*>(this)->setPointsAtY(pointsAtY);
- return false;
-}
-
-bool LightSource::setPointsAtZ(float pointsAtZ)
-{
- if (m_type == LS_SPOT)
- return static_cast<SpotLightSource*>(this)->setPointsAtZ(pointsAtZ);
- return false;
-}
-
-bool LightSource::setSpecularExponent(float specularExponent)
-{
- if (m_type == LS_SPOT)
- return static_cast<SpotLightSource*>(this)->setSpecularExponent(specularExponent);
- return false;
-}
-
-bool LightSource::setLimitingConeAngle(float limitingConeAngle)
-{
- if (m_type == LS_SPOT)
- return static_cast<SpotLightSource*>(this)->setLimitingConeAngle(limitingConeAngle);
- return false;
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(FILTERS)
diff --git a/Source/WebCore/platform/graphics/filters/LightSource.h b/Source/WebCore/platform/graphics/filters/LightSource.h
index 24c319a61..7aa270e5f 100644
--- a/Source/WebCore/platform/graphics/filters/LightSource.h
+++ b/Source/WebCore/platform/graphics/filters/LightSource.h
@@ -74,16 +74,16 @@ public:
// specified "surfaceScale" constant, which type is <number> in the SVG standard
virtual void updatePaintingData(PaintingData&, int x, int y, float z) = 0;
- bool setAzimuth(float);
- bool setElevation(float);
- bool setX(float);
- bool setY(float);
- bool setZ(float);
- bool setPointsAtX(float);
- bool setPointsAtY(float);
- bool setPointsAtZ(float);
- bool setSpecularExponent(float);
- bool setLimitingConeAngle(float);
+ virtual bool setAzimuth(float) { return false; }
+ virtual bool setElevation(float) { return false; }
+ virtual bool setX(float) { return false; }
+ virtual bool setY(float) { return false; }
+ virtual bool setZ(float) { return false; }
+ virtual bool setPointsAtX(float) { return false; }
+ virtual bool setPointsAtY(float) { return false; }
+ virtual bool setPointsAtZ(float) { return false; }
+ virtual bool setSpecularExponent(float) { return false; }
+ virtual bool setLimitingConeAngle(float) { return false; }
private:
LightType m_type;
diff --git a/Source/WebCore/platform/graphics/filters/PointLightSource.h b/Source/WebCore/platform/graphics/filters/PointLightSource.h
index a93bf2cf7..80eef10fc 100644
--- a/Source/WebCore/platform/graphics/filters/PointLightSource.h
+++ b/Source/WebCore/platform/graphics/filters/PointLightSource.h
@@ -36,9 +36,9 @@ public:
}
const FloatPoint3D& position() const { return m_position; }
- bool setX(float);
- bool setY(float);
- bool setZ(float);
+ virtual bool setX(float) OVERRIDE;
+ virtual bool setY(float) OVERRIDE;
+ virtual bool setZ(float) OVERRIDE;
virtual void initPaintingData(PaintingData&);
virtual void updatePaintingData(PaintingData&, int x, int y, float z);
diff --git a/Source/WebCore/platform/graphics/filters/SourceGraphic.h b/Source/WebCore/platform/graphics/filters/SourceGraphic.h
index 185e564bf..4200595fb 100644
--- a/Source/WebCore/platform/graphics/filters/SourceGraphic.h
+++ b/Source/WebCore/platform/graphics/filters/SourceGraphic.h
@@ -49,7 +49,7 @@ private:
SourceGraphic(Filter* filter)
: FilterEffect(filter)
{
- setColorSpace(ColorSpaceDeviceRGB);
+ setOperatingColorSpace(ColorSpaceDeviceRGB);
}
};
diff --git a/Source/WebCore/platform/graphics/filters/SpotLightSource.h b/Source/WebCore/platform/graphics/filters/SpotLightSource.h
index b4f1b6182..a54ddc08e 100644
--- a/Source/WebCore/platform/graphics/filters/SpotLightSource.h
+++ b/Source/WebCore/platform/graphics/filters/SpotLightSource.h
@@ -37,18 +37,19 @@ public:
}
const FloatPoint3D& position() const { return m_position; }
- bool setX(float);
- bool setY(float);
- bool setZ(float);
const FloatPoint3D& direction() const { return m_direction; }
- bool setPointsAtX(float);
- bool setPointsAtY(float);
- bool setPointsAtZ(float);
-
float specularExponent() const { return m_specularExponent; }
- bool setSpecularExponent(float);
float limitingConeAngle() const { return m_limitingConeAngle; }
- bool setLimitingConeAngle(float);
+
+ virtual bool setX(float) OVERRIDE;
+ virtual bool setY(float) OVERRIDE;
+ virtual bool setZ(float) OVERRIDE;
+ virtual bool setPointsAtX(float) OVERRIDE;
+ virtual bool setPointsAtY(float) OVERRIDE;
+ virtual bool setPointsAtZ(float) OVERRIDE;
+
+ virtual bool setSpecularExponent(float) OVERRIDE;
+ virtual bool setLimitingConeAngle(float) OVERRIDE;
virtual void initPaintingData(PaintingData&);
virtual void updatePaintingData(PaintingData&, int x, int y, float z);
diff --git a/Source/WebCore/platform/graphics/filters/ValidatedCustomFilterOperation.cpp b/Source/WebCore/platform/graphics/filters/ValidatedCustomFilterOperation.cpp
index 3103c01da..1f64d5743 100644
--- a/Source/WebCore/platform/graphics/filters/ValidatedCustomFilterOperation.cpp
+++ b/Source/WebCore/platform/graphics/filters/ValidatedCustomFilterOperation.cpp
@@ -35,18 +35,16 @@
#include "CustomFilterParameter.h"
#include "CustomFilterValidatedProgram.h"
#include "LayoutSize.h"
-#include <wtf/UnusedParam.h>
namespace WebCore {
ValidatedCustomFilterOperation::ValidatedCustomFilterOperation(PassRefPtr<CustomFilterValidatedProgram> validatedProgram,
- const CustomFilterParameterList& sortedParameters, unsigned meshRows, unsigned meshColumns, CustomFilterMeshBoxType meshBoxType, CustomFilterMeshType meshType)
+ const CustomFilterParameterList& sortedParameters, unsigned meshRows, unsigned meshColumns, CustomFilterMeshType meshType)
: FilterOperation(VALIDATED_CUSTOM)
, m_validatedProgram(validatedProgram)
, m_parameters(sortedParameters)
, m_meshRows(meshRows)
, m_meshColumns(meshColumns)
- , m_meshBoxType(meshBoxType)
, m_meshType(meshType)
{
}
diff --git a/Source/WebCore/platform/graphics/filters/ValidatedCustomFilterOperation.h b/Source/WebCore/platform/graphics/filters/ValidatedCustomFilterOperation.h
index ad2f93a2f..eabb0d559 100644
--- a/Source/WebCore/platform/graphics/filters/ValidatedCustomFilterOperation.h
+++ b/Source/WebCore/platform/graphics/filters/ValidatedCustomFilterOperation.h
@@ -43,9 +43,9 @@ class CustomFilterValidatedProgram;
class ValidatedCustomFilterOperation : public FilterOperation {
public:
static PassRefPtr<ValidatedCustomFilterOperation> create(PassRefPtr<CustomFilterValidatedProgram> validatedProgram,
- const CustomFilterParameterList& sortedParameters, unsigned meshRows, unsigned meshColumns, CustomFilterMeshBoxType meshBoxType, CustomFilterMeshType meshType)
+ const CustomFilterParameterList& sortedParameters, unsigned meshRows, unsigned meshColumns, CustomFilterMeshType meshType)
{
- return adoptRef(new ValidatedCustomFilterOperation(validatedProgram, sortedParameters, meshRows, meshColumns, meshBoxType, meshType));
+ return adoptRef(new ValidatedCustomFilterOperation(validatedProgram, sortedParameters, meshRows, meshColumns, meshType));
}
virtual ~ValidatedCustomFilterOperation();
@@ -62,7 +62,6 @@ public:
unsigned meshRows() const { return m_meshRows; }
unsigned meshColumns() const { return m_meshColumns; }
- CustomFilterMeshBoxType meshBoxType() const { return m_meshBoxType; }
CustomFilterMeshType meshType() const { return m_meshType; }
private:
@@ -75,19 +74,17 @@ private:
return m_validatedProgram.get() == other->m_validatedProgram.get()
&& m_meshRows == other->m_meshRows
&& m_meshColumns == other->m_meshColumns
- && m_meshBoxType == other->m_meshBoxType
&& m_meshType == other->m_meshType
&& m_parameters == other->m_parameters;
}
- ValidatedCustomFilterOperation(PassRefPtr<CustomFilterValidatedProgram>, const CustomFilterParameterList&, unsigned meshRows, unsigned meshColumns, CustomFilterMeshBoxType, CustomFilterMeshType);
+ ValidatedCustomFilterOperation(PassRefPtr<CustomFilterValidatedProgram>, const CustomFilterParameterList&, unsigned meshRows, unsigned meshColumns, CustomFilterMeshType);
RefPtr<CustomFilterValidatedProgram> m_validatedProgram;
CustomFilterParameterList m_parameters;
unsigned m_meshRows;
unsigned m_meshColumns;
- CustomFilterMeshBoxType m_meshBoxType;
CustomFilterMeshType m_meshType;
};
diff --git a/Source/WebCore/platform/graphics/filters/skia/DropShadowImageFilter.cpp b/Source/WebCore/platform/graphics/filters/skia/DropShadowImageFilter.cpp
deleted file mode 100644
index 4ad90f7ed..000000000
--- a/Source/WebCore/platform/graphics/filters/skia/DropShadowImageFilter.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "config.h"
-
-#include "DropShadowImageFilter.h"
-
-#include "SkBitmap.h"
-#include "SkBlurImageFilter.h"
-#include "SkCanvas.h"
-#include "SkColorMatrixFilter.h"
-#include "SkDevice.h"
-#include "SkFlattenableBuffers.h"
-
-namespace WebCore {
-
-DropShadowImageFilter::DropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigma, SkColor color, SkImageFilter* input)
- : SkSingleInputImageFilter(input)
- , m_dx(dx)
- , m_dy(dy)
- , m_sigma(sigma)
- , m_color(color)
-{
-}
-
-DropShadowImageFilter::DropShadowImageFilter(SkFlattenableReadBuffer& buffer) : SkSingleInputImageFilter(buffer)
-{
- m_dx = buffer.readScalar();
- m_dy = buffer.readScalar();
- m_sigma = buffer.readScalar();
- m_color = buffer.readColor();
-}
-
-void DropShadowImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const
-{
- buffer.writeScalar(m_dx);
- buffer.writeScalar(m_dy);
- buffer.writeScalar(m_sigma);
- buffer.writeColor(m_color);
-}
-
-bool DropShadowImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source, const SkMatrix& matrix, SkBitmap* result, SkIPoint* loc)
-{
- SkBitmap src = this->getInputResult(proxy, source, matrix, loc);
- SkAutoTUnref<SkDevice> device(proxy->createDevice(src.width(), src.height()));
- SkCanvas canvas(device.get());
-
- SkAutoTUnref<SkImageFilter> blurFilter(new SkBlurImageFilter(m_sigma, m_sigma));
- SkAutoTUnref<SkColorFilter> colorFilter(SkColorFilter::CreateModeFilter(m_color, SkXfermode::kSrcIn_Mode));
- SkPaint paint;
- paint.setImageFilter(blurFilter.get());
- paint.setColorFilter(colorFilter.get());
- paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
- canvas.saveLayer(0, &paint);
- canvas.drawBitmap(src, m_dx, -m_dy);
- canvas.restore();
- canvas.drawBitmap(src, 0, 0);
- *result = device.get()->accessBitmap(false);
- return true;
-}
-
-};
diff --git a/Source/WebCore/platform/graphics/filters/skia/DropShadowImageFilter.h b/Source/WebCore/platform/graphics/filters/skia/DropShadowImageFilter.h
deleted file mode 100644
index 4fa5b5d02..000000000
--- a/Source/WebCore/platform/graphics/filters/skia/DropShadowImageFilter.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "SkColor.h"
-#include "SkScalar.h"
-#include "SkSingleInputImageFilter.h"
-
-namespace WebCore {
-
-class DropShadowImageFilter : public SkSingleInputImageFilter {
-public:
- DropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigma, SkColor, SkImageFilter* input = 0);
- SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(DropShadowImageFilter)
-
-protected:
- explicit DropShadowImageFilter(SkFlattenableReadBuffer&);
- virtual void flatten(SkFlattenableWriteBuffer&) const OVERRIDE;
- virtual bool onFilterImage(Proxy*, const SkBitmap& source, const SkMatrix&, SkBitmap* result, SkIPoint* loc) OVERRIDE;
-
-private:
- SkScalar m_dx, m_dy, m_sigma;
- SkColor m_color;
-};
-
-};
diff --git a/Source/WebCore/platform/graphics/filters/skia/FEBlendSkia.cpp b/Source/WebCore/platform/graphics/filters/skia/FEBlendSkia.cpp
deleted file mode 100644
index cdda2cb5e..000000000
--- a/Source/WebCore/platform/graphics/filters/skia/FEBlendSkia.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(FILTERS)
-#include "FEBlend.h"
-
-#include "NativeImageSkia.h"
-#include "SkBitmapSource.h"
-#include "SkBlendImageFilter.h"
-#include "SkiaImageFilterBuilder.h"
-
-namespace WebCore {
-
-static SkBlendImageFilter::Mode toSkiaMode(BlendModeType mode)
-{
- switch (mode) {
- case FEBLEND_MODE_NORMAL:
- return SkBlendImageFilter::kNormal_Mode;
- case FEBLEND_MODE_MULTIPLY:
- return SkBlendImageFilter::kMultiply_Mode;
- case FEBLEND_MODE_SCREEN:
- return SkBlendImageFilter::kScreen_Mode;
- case FEBLEND_MODE_DARKEN:
- return SkBlendImageFilter::kDarken_Mode;
- case FEBLEND_MODE_LIGHTEN:
- return SkBlendImageFilter::kLighten_Mode;
- default:
- return SkBlendImageFilter::kNormal_Mode;
- }
-}
-
-bool FEBlend::platformApplySkia()
-{
- // For now, only use the skia implementation for accelerated rendering.
- if (filter()->renderingMode() != Accelerated)
- return false;
-
- FilterEffect* in = inputEffect(0);
- FilterEffect* in2 = inputEffect(1);
-
- if (!in || !in2)
- return false;
-
- ImageBuffer* resultImage = createImageBufferResult();
- if (!resultImage)
- return false;
-
- RefPtr<Image> foreground = in->asImageBuffer()->copyImage(DontCopyBackingStore);
- RefPtr<Image> background = in2->asImageBuffer()->copyImage(DontCopyBackingStore);
-
- NativeImageSkia* foregroundNativeImage = foreground->nativeImageForCurrentFrame();
- NativeImageSkia* backgroundNativeImage = background->nativeImageForCurrentFrame();
-
- if (!foregroundNativeImage || !backgroundNativeImage)
- return false;
-
- SkBitmap foregroundBitmap = foregroundNativeImage->bitmap();
- SkBitmap backgroundBitmap = backgroundNativeImage->bitmap();
-
- SkAutoTUnref<SkImageFilter> backgroundSource(new SkBitmapSource(backgroundBitmap));
- SkBlendImageFilter::Mode mode = toSkiaMode(m_mode);
- SkAutoTUnref<SkImageFilter> blend(new SkBlendImageFilter(mode, backgroundSource));
- SkPaint paint;
- paint.setImageFilter(blend);
- resultImage->context()->platformContext()->drawBitmap(foregroundBitmap, 0, 0, &paint);
- return true;
-}
-
-SkImageFilter* FEBlend::createImageFilter(SkiaImageFilterBuilder* builder)
-{
- SkImageFilter* foreground = builder->build(inputEffect(0));
- SkImageFilter* background = builder->build(inputEffect(1));
- SkBlendImageFilter::Mode mode = toSkiaMode(m_mode);
- return new SkBlendImageFilter(mode, background, foreground);
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(FILTERS)
diff --git a/Source/WebCore/platform/graphics/filters/skia/FEColorMatrixSkia.cpp b/Source/WebCore/platform/graphics/filters/skia/FEColorMatrixSkia.cpp
deleted file mode 100644
index 3228cd8a3..000000000
--- a/Source/WebCore/platform/graphics/filters/skia/FEColorMatrixSkia.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#if ENABLE(FILTERS) && USE(SKIA)
-#include "FEColorMatrix.h"
-
-#include "NativeImageSkia.h"
-#include "SkColorFilterImageFilter.h"
-#include "SkColorMatrixFilter.h"
-#include "SkiaImageFilterBuilder.h"
-
-namespace WebCore {
-
-static void saturateMatrix(float s, SkScalar matrix[20])
-{
- matrix[0] = 0.213f + 0.787f * s;
- matrix[1] = 0.715f - 0.715f * s;
- matrix[2] = 0.072f - 0.072f * s;
- matrix[3] = matrix[4] = 0;
- matrix[5] = 0.213f - 0.213f * s;
- matrix[6] = 0.715f + 0.285f * s;
- matrix[7] = 0.072f - 0.072f * s;
- matrix[8] = matrix[9] = 0;
- matrix[10] = 0.213f - 0.213f * s;
- matrix[11] = 0.715f - 0.715f * s;
- matrix[12] = 0.072f + 0.928f * s;
- matrix[13] = matrix[14] = 0;
- matrix[15] = matrix[16] = matrix[17] = 0;
- matrix[18] = 1;
- matrix[19] = 0;
-}
-
-static void hueRotateMatrix(float hue, SkScalar matrix[20])
-{
- float cosHue = cosf(hue * piFloat / 180);
- float sinHue = sinf(hue * piFloat / 180);
- matrix[0] = 0.213f + cosHue * 0.787f - sinHue * 0.213f;
- matrix[1] = 0.715f - cosHue * 0.715f - sinHue * 0.715f;
- matrix[2] = 0.072f - cosHue * 0.072f + sinHue * 0.928f;
- matrix[3] = matrix[4] = 0;
- matrix[5] = 0.213f - cosHue * 0.213f + sinHue * 0.143f;
- matrix[6] = 0.715f + cosHue * 0.285f + sinHue * 0.140f;
- matrix[7] = 0.072f - cosHue * 0.072f - sinHue * 0.283f;
- matrix[8] = matrix[9] = 0;
- matrix[10] = 0.213f - cosHue * 0.213f - sinHue * 0.787f;
- matrix[11] = 0.715f - cosHue * 0.715f + sinHue * 0.715f;
- matrix[12] = 0.072f + cosHue * 0.928f + sinHue * 0.072f;
- matrix[13] = matrix[14] = 0;
- matrix[15] = matrix[16] = matrix[17] = 0;
- matrix[18] = 1;
- matrix[19] = 0;
-}
-
-static void luminanceToAlphaMatrix(SkScalar matrix[20])
-{
- memset(matrix, 0, 20 * sizeof(SkScalar));
- matrix[15] = 0.2125f;
- matrix[16] = 0.7154f;
- matrix[17] = 0.0721f;
-}
-
-static SkColorFilter* createColorFilter(ColorMatrixType type, const float* values)
-{
- SkScalar matrix[20];
- switch (type) {
- case FECOLORMATRIX_TYPE_UNKNOWN:
- break;
- case FECOLORMATRIX_TYPE_MATRIX:
- for (int i = 0; i < 20; ++i)
- matrix[i] = values[i];
-
- matrix[4] *= SkScalar(255);
- matrix[9] *= SkScalar(255);
- matrix[14] *= SkScalar(255);
- matrix[19] *= SkScalar(255);
- break;
- case FECOLORMATRIX_TYPE_SATURATE:
- saturateMatrix(values[0], matrix);
- break;
- case FECOLORMATRIX_TYPE_HUEROTATE:
- hueRotateMatrix(values[0], matrix);
- break;
- case FECOLORMATRIX_TYPE_LUMINANCETOALPHA:
- luminanceToAlphaMatrix(matrix);
- break;
- }
- return new SkColorMatrixFilter(matrix);
-}
-
-bool FEColorMatrix::platformApplySkia()
-{
- ImageBuffer* resultImage = createImageBufferResult();
- if (!resultImage)
- return false;
-
- FilterEffect* in = inputEffect(0);
-
- IntRect imageRect(IntPoint(), absolutePaintRect().size());
-
- SkAutoTUnref<SkColorFilter> filter(createColorFilter(m_type, m_values.data()));
-
- RefPtr<Image> image = in->asImageBuffer()->copyImage(DontCopyBackingStore);
- NativeImageSkia* nativeImage = image->nativeImageForCurrentFrame();
- if (!nativeImage)
- return false;
-
- SkPaint paint;
- paint.setColorFilter(filter);
- paint.setXfermodeMode(SkXfermode::kSrc_Mode);
- resultImage->context()->platformContext()->drawBitmap(nativeImage->bitmap(), 0, 0, &paint);
- return true;
-}
-
-SkImageFilter* FEColorMatrix::createImageFilter(SkiaImageFilterBuilder* builder)
-{
- SkAutoTUnref<SkImageFilter> input(builder->build(inputEffect(0)));
- SkAutoTUnref<SkColorFilter> filter(createColorFilter(m_type, m_values.data()));
- return SkColorFilterImageFilter::Create(filter, input);
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(FILTERS) && USE(SKIA)
diff --git a/Source/WebCore/platform/graphics/filters/skia/FEComponentTransferSkia.cpp b/Source/WebCore/platform/graphics/filters/skia/FEComponentTransferSkia.cpp
deleted file mode 100644
index 260954c41..000000000
--- a/Source/WebCore/platform/graphics/filters/skia/FEComponentTransferSkia.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(FILTERS)
-#include "FEComponentTransfer.h"
-
-#include "NativeImageSkia.h"
-#include "SkColorFilterImageFilter.h"
-#include "SkTableColorFilter.h"
-#include "SkiaImageFilterBuilder.h"
-
-namespace WebCore {
-
-bool FEComponentTransfer::platformApplySkia()
-{
- FilterEffect* in = inputEffect(0);
- ImageBuffer* resultImage = createImageBufferResult();
- if (!resultImage)
- return false;
-
- RefPtr<Image> image = in->asImageBuffer()->copyImage(DontCopyBackingStore);
- NativeImageSkia* nativeImage = image->nativeImageForCurrentFrame();
- if (!nativeImage)
- return false;
-
- unsigned char rValues[256], gValues[256], bValues[256], aValues[256];
- getValues(rValues, gValues, bValues, aValues);
-
- SkPaint paint;
- paint.setColorFilter(SkTableColorFilter::CreateARGB(aValues, rValues, gValues, bValues))->unref();
- paint.setXfermodeMode(SkXfermode::kSrc_Mode);
- resultImage->context()->platformContext()->drawBitmap(nativeImage->bitmap(), 0, 0, &paint);
-
- return true;
-}
-
-SkImageFilter* FEComponentTransfer::createImageFilter(SkiaImageFilterBuilder* builder)
-{
- SkImageFilter* input = builder->build(inputEffect(0));
-
- unsigned char rValues[256], gValues[256], bValues[256], aValues[256];
- getValues(rValues, gValues, bValues, aValues);
-
- SkAutoTUnref<SkColorFilter> colorFilter(SkTableColorFilter::CreateARGB(aValues, rValues, gValues, bValues));
-
- return SkColorFilterImageFilter::Create(colorFilter, input);
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(FILTERS)
diff --git a/Source/WebCore/platform/graphics/filters/skia/FEGaussianBlurSkia.cpp b/Source/WebCore/platform/graphics/filters/skia/FEGaussianBlurSkia.cpp
deleted file mode 100644
index f5f46daed..000000000
--- a/Source/WebCore/platform/graphics/filters/skia/FEGaussianBlurSkia.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#if USE(SKIA)
-#include "FEGaussianBlur.h"
-
-#include "BitmapImageSingleFrameSkia.h"
-#include "SkBlurImageFilter.h"
-#include "SkiaImageFilterBuilder.h"
-
-namespace WebCore {
-
-bool FEGaussianBlur::platformApplySkia()
-{
- ImageBuffer* resultImage = createImageBufferResult();
- if (!resultImage)
- return false;
-
- FilterEffect* in = inputEffect(0);
-
- IntRect drawingRegion = drawingRegionOfInputImage(in->absolutePaintRect());
-
- setIsAlphaImage(in->isAlphaImage());
-
- float stdX = filter()->applyHorizontalScale(m_stdX);
- float stdY = filter()->applyVerticalScale(m_stdY);
-
- RefPtr<Image> image = in->asImageBuffer()->copyImage(DontCopyBackingStore);
-
- SkPaint paint;
- GraphicsContext* dstContext = resultImage->context();
- PlatformContextSkia* platformContext = dstContext->platformContext();
- paint.setImageFilter(new SkBlurImageFilter(stdX, stdY))->unref();
-
- platformContext->saveLayer(0, &paint);
- paint.setColor(0xFFFFFFFF);
- dstContext->drawImage(image.get(), ColorSpaceDeviceRGB, drawingRegion.location(), CompositeCopy);
- platformContext->restoreLayer();
- return true;
-}
-
-SkImageFilter* FEGaussianBlur::createImageFilter(SkiaImageFilterBuilder* builder)
-{
- SkAutoTUnref<SkImageFilter> input(builder->build(inputEffect(0)));
- return new SkBlurImageFilter(SkFloatToScalar(m_stdX), SkFloatToScalar(m_stdY), input);
-}
-
-};
-#endif
diff --git a/Source/WebCore/platform/graphics/filters/skia/FELightingSkia.cpp b/Source/WebCore/platform/graphics/filters/skia/FELightingSkia.cpp
deleted file mode 100644
index 9f4c6b91e..000000000
--- a/Source/WebCore/platform/graphics/filters/skia/FELightingSkia.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#if USE(SKIA)
-#include "FELighting.h"
-
-#include "DistantLightSource.h"
-#include "NativeImageSkia.h"
-#include "PointLightSource.h"
-#include "SkLightingImageFilter.h"
-#include "SkiaImageFilterBuilder.h"
-#include "SpotLightSource.h"
-
-namespace WebCore {
-
-SkImageFilter* FELighting::createImageFilter(SkiaImageFilterBuilder* builder)
-{
- SkImageFilter* input = builder ? builder->build(inputEffect(0)) : 0;
- switch (m_lightSource->type()) {
- case LS_DISTANT: {
- DistantLightSource* distantLightSource = static_cast<DistantLightSource*>(m_lightSource.get());
- float azimuthRad = deg2rad(distantLightSource->azimuth());
- float elevationRad = deg2rad(distantLightSource->elevation());
- SkPoint3 direction(cosf(azimuthRad) * cosf(elevationRad),
- sinf(azimuthRad) * cosf(elevationRad),
- sinf(elevationRad));
- if (m_specularConstant > 0)
- return SkLightingImageFilter::CreateDistantLitSpecular(direction, m_lightingColor.rgb(), m_surfaceScale, m_specularConstant, m_specularExponent, input);
- else
- return SkLightingImageFilter::CreateDistantLitDiffuse(direction, m_lightingColor.rgb(), m_surfaceScale, m_diffuseConstant, input);
- }
- case LS_POINT: {
- PointLightSource* pointLightSource = static_cast<PointLightSource*>(m_lightSource.get());
- FloatPoint3D position = pointLightSource->position();
- SkPoint3 skPosition(position.x(), position.y(), position.z());
- if (m_specularConstant > 0)
- return SkLightingImageFilter::CreatePointLitSpecular(skPosition, m_lightingColor.rgb(), m_surfaceScale, m_specularConstant, m_specularExponent, input);
- else
- return SkLightingImageFilter::CreatePointLitDiffuse(skPosition, m_lightingColor.rgb(), m_surfaceScale, m_diffuseConstant, input);
- }
- case LS_SPOT: {
- SpotLightSource* spotLightSource = static_cast<SpotLightSource*>(m_lightSource.get());
- SkPoint3 location(spotLightSource->position().x(), spotLightSource->position().y(), spotLightSource->position().z());
- SkPoint3 target(spotLightSource->direction().x(), spotLightSource->direction().y(), spotLightSource->direction().z());
- float specularExponent = spotLightSource->specularExponent();
- float limitingConeAngle = spotLightSource->limitingConeAngle();
- if (!limitingConeAngle || limitingConeAngle > 90 || limitingConeAngle < -90)
- limitingConeAngle = 90;
- if (m_specularConstant > 0)
- return SkLightingImageFilter::CreateSpotLitSpecular(location, target, specularExponent, limitingConeAngle, m_lightingColor.rgb(), m_surfaceScale, m_specularConstant, m_specularExponent, input);
- else
- return SkLightingImageFilter::CreateSpotLitDiffuse(location, target, specularExponent, limitingConeAngle, m_lightingColor.rgb(), m_surfaceScale, m_diffuseConstant, input);
- }
- default:
- ASSERT_NOT_REACHED();
- return 0;
- }
-}
-
-bool FELighting::platformApplySkia()
-{
- // For now, only use the skia implementation for accelerated rendering.
- if (filter()->renderingMode() != Accelerated)
- return false;
-
- ImageBuffer* resultImage = createImageBufferResult();
- if (!resultImage)
- return false;
-
- FilterEffect* in = inputEffect(0);
-
- IntRect drawingRegion = drawingRegionOfInputImage(in->absolutePaintRect());
-
- setIsAlphaImage(in->isAlphaImage());
-
- RefPtr<Image> image = in->asImageBuffer()->copyImage(DontCopyBackingStore);
- NativeImageSkia* nativeImage = image->nativeImageForCurrentFrame();
- if (!nativeImage)
- return false;
-
- GraphicsContext* dstContext = resultImage->context();
-
- SkPaint paint;
- paint.setImageFilter(createImageFilter(0))->unref();
- dstContext->platformContext()->drawBitmap(nativeImage->bitmap(), drawingRegion.location().x(), drawingRegion.location().y(), &paint);
- return true;
-}
-
-};
-#endif
diff --git a/Source/WebCore/platform/graphics/filters/skia/FEMorphologySkia.cpp b/Source/WebCore/platform/graphics/filters/skia/FEMorphologySkia.cpp
deleted file mode 100644
index b2e9f4fcf..000000000
--- a/Source/WebCore/platform/graphics/filters/skia/FEMorphologySkia.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#if USE(SKIA)
-#include "FEMorphology.h"
-
-#include "SkMorphologyImageFilter.h"
-#include "SkiaImageFilterBuilder.h"
-
-namespace WebCore {
-
-bool FEMorphology::platformApplySkia()
-{
- ImageBuffer* resultImage = createImageBufferResult();
- if (!resultImage)
- return false;
-
- FilterEffect* in = inputEffect(0);
-
- IntRect drawingRegion = drawingRegionOfInputImage(in->absolutePaintRect());
-
- setIsAlphaImage(in->isAlphaImage());
-
- float radiusX = filter()->applyHorizontalScale(m_radiusX);
- float radiusY = filter()->applyVerticalScale(m_radiusY);
-
- RefPtr<Image> image = in->asImageBuffer()->copyImage(DontCopyBackingStore);
-
- SkPaint paint;
- GraphicsContext* dstContext = resultImage->context();
- PlatformContextSkia* platformContext = dstContext->platformContext();
- if (m_type == FEMORPHOLOGY_OPERATOR_DILATE)
- paint.setImageFilter(new SkDilateImageFilter(radiusX, radiusY))->unref();
- else if (m_type == FEMORPHOLOGY_OPERATOR_ERODE)
- paint.setImageFilter(new SkErodeImageFilter(radiusX, radiusY))->unref();
-
- platformContext->saveLayer(0, &paint);
- dstContext->drawImage(image.get(), ColorSpaceDeviceRGB, drawingRegion.location(), CompositeCopy);
- platformContext->restoreLayer();
- return true;
-}
-
-SkImageFilter* FEMorphology::createImageFilter(SkiaImageFilterBuilder* builder)
-{
- SkAutoTUnref<SkImageFilter> input(builder->build(inputEffect(0)));
- SkScalar radiusX = SkFloatToScalar(m_radiusX);
- SkScalar radiusY = SkFloatToScalar(m_radiusY);
- if (m_type == FEMORPHOLOGY_OPERATOR_DILATE)
- return new SkDilateImageFilter(radiusX, radiusY, input);
- return new SkErodeImageFilter(radiusX, radiusY, input);
-}
-
-};
-#endif
diff --git a/Source/WebCore/platform/graphics/filters/skia/SkiaImageFilterBuilder.cpp b/Source/WebCore/platform/graphics/filters/skia/SkiaImageFilterBuilder.cpp
deleted file mode 100644
index 8b86668f0..000000000
--- a/Source/WebCore/platform/graphics/filters/skia/SkiaImageFilterBuilder.cpp
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "config.h"
-
-#include "SkiaImageFilterBuilder.h"
-
-#include "DropShadowImageFilter.h"
-#include "FilterEffect.h"
-#include "FilterOperations.h"
-#include "SkBlurImageFilter.h"
-#include "SkColorFilterImageFilter.h"
-#include "SkColorMatrixFilter.h"
-#include "SkMatrix.h"
-
-namespace {
-
-void getBrightnessMatrix(float amount, SkScalar matrix[20])
-{
- memset(matrix, 0, 20 * sizeof(SkScalar));
- matrix[0] = matrix[6] = matrix[12] = matrix[18] = 1;
- matrix[4] = matrix[9] = matrix[14] = amount * 255;
-}
-
-void getContrastMatrix(float amount, SkScalar matrix[20])
-{
- memset(matrix, 0, 20 * sizeof(SkScalar));
- matrix[0] = matrix[6] = matrix[12] = amount;
- matrix[4] = matrix[9] = matrix[14] = (-0.5f * amount + 0.5f) * 255;
- matrix[18] = 1;
-}
-
-void getSaturateMatrix(float amount, SkScalar matrix[20])
-{
- // Note, these values are computed to ensure matrixNeedsClamping is false
- // for amount in [0..1]
- matrix[0] = 0.213f + 0.787f * amount;
- matrix[1] = 0.715f - 0.715f * amount;
- matrix[2] = 1.f - (matrix[0] + matrix[1]);
- matrix[3] = matrix[4] = 0;
- matrix[5] = 0.213f - 0.213f * amount;
- matrix[6] = 0.715f + 0.285f * amount;
- matrix[7] = 1.f - (matrix[5] + matrix[6]);
- matrix[8] = matrix[9] = 0;
- matrix[10] = 0.213f - 0.213f * amount;
- matrix[11] = 0.715f - 0.715f * amount;
- matrix[12] = 1.f - (matrix[10] + matrix[11]);
- matrix[13] = matrix[14] = 0;
- matrix[15] = matrix[16] = matrix[17] = matrix[19] = 0;
- matrix[18] = 1;
-}
-
-void getHueRotateMatrix(float hue, SkScalar matrix[20])
-{
- float cosHue = cosf(hue * piFloat / 180);
- float sinHue = sinf(hue * piFloat / 180);
- matrix[0] = 0.213f + cosHue * 0.787f - sinHue * 0.213f;
- matrix[1] = 0.715f - cosHue * 0.715f - sinHue * 0.715f;
- matrix[2] = 0.072f - cosHue * 0.072f + sinHue * 0.928f;
- matrix[3] = matrix[4] = 0;
- matrix[5] = 0.213f - cosHue * 0.213f + sinHue * 0.143f;
- matrix[6] = 0.715f + cosHue * 0.285f + sinHue * 0.140f;
- matrix[7] = 0.072f - cosHue * 0.072f - sinHue * 0.283f;
- matrix[8] = matrix[9] = 0;
- matrix[10] = 0.213f - cosHue * 0.213f - sinHue * 0.787f;
- matrix[11] = 0.715f - cosHue * 0.715f + sinHue * 0.715f;
- matrix[12] = 0.072f + cosHue * 0.928f + sinHue * 0.072f;
- matrix[13] = matrix[14] = 0;
- matrix[15] = matrix[16] = matrix[17] = 0;
- matrix[18] = 1;
- matrix[19] = 0;
-}
-
-void getInvertMatrix(float amount, SkScalar matrix[20])
-{
- memset(matrix, 0, 20 * sizeof(SkScalar));
- matrix[0] = matrix[6] = matrix[12] = 1 - 2 * amount;
- matrix[4] = matrix[9] = matrix[14] = amount * 255;
- matrix[18] = 1;
-}
-
-void getOpacityMatrix(float amount, SkScalar matrix[20])
-{
- memset(matrix, 0, 20 * sizeof(SkScalar));
- matrix[0] = matrix[6] = matrix[12] = 1;
- matrix[18] = amount;
-}
-
-void getGrayscaleMatrix(float amount, SkScalar matrix[20])
-{
- // Note, these values are computed to ensure matrixNeedsClamping is false
- // for amount in [0..1]
- matrix[0] = 0.2126f + 0.7874f * amount;
- matrix[1] = 0.7152f - 0.7152f * amount;
- matrix[2] = 1.f - (matrix[0] + matrix[1]);
- matrix[3] = matrix[4] = 0;
-
- matrix[5] = 0.2126f - 0.2126f * amount;
- matrix[6] = 0.7152f + 0.2848f * amount;
- matrix[7] = 1.f - (matrix[5] + matrix[6]);
- matrix[8] = matrix[9] = 0;
-
- matrix[10] = 0.2126f - 0.2126f * amount;
- matrix[11] = 0.7152f - 0.7152f * amount;
- matrix[12] = 1.f - (matrix[10] + matrix[11]);
- matrix[13] = matrix[14] = 0;
-
- matrix[15] = matrix[16] = matrix[17] = matrix[19] = 0;
- matrix[18] = 1;
-}
-
-void getSepiaMatrix(float amount, SkScalar matrix[20])
-{
- matrix[0] = 0.393f + 0.607f * amount;
- matrix[1] = 0.769f - 0.769f * amount;
- matrix[2] = 0.189f - 0.189f * amount;
- matrix[3] = matrix[4] = 0;
-
- matrix[5] = 0.349f - 0.349f * amount;
- matrix[6] = 0.686f + 0.314f * amount;
- matrix[7] = 0.168f - 0.168f * amount;
- matrix[8] = matrix[9] = 0;
-
- matrix[10] = 0.272f - 0.272f * amount;
- matrix[11] = 0.534f - 0.534f * amount;
- matrix[12] = 0.131f + 0.869f * amount;
- matrix[13] = matrix[14] = 0;
-
- matrix[15] = matrix[16] = matrix[17] = matrix[19] = 0;
- matrix[18] = 1;
-}
-
-SkImageFilter* createMatrixImageFilter(SkScalar matrix[20], SkImageFilter* input)
-{
- SkAutoTUnref<SkColorFilter> colorFilter(new SkColorMatrixFilter(matrix));
- return SkColorFilterImageFilter::Create(colorFilter, input);
-}
-
-};
-
-namespace WebCore {
-
-SkiaImageFilterBuilder::SkiaImageFilterBuilder()
-{
-}
-
-SkImageFilter* SkiaImageFilterBuilder::build(FilterEffect* effect)
-{
- if (!effect)
- return 0;
-
- FilterBuilderHashMap::iterator it = m_map.find(effect);
- if (it != m_map.end())
- return it->value;
-
- SkImageFilter* filter = effect->createImageFilter(this);
- m_map.set(effect, filter);
- return filter;
-}
-
-SkImageFilter* SkiaImageFilterBuilder::build(const FilterOperations& operations)
-{
- SkImageFilter* filter = 0;
- SkScalar matrix[20];
- for (size_t i = 0; i < operations.size(); ++i) {
- const FilterOperation& op = *operations.at(i);
- switch (op.getOperationType()) {
- case FilterOperation::REFERENCE: {
- FilterEffect* filterEffect = static_cast<const ReferenceFilterOperation*>(&op)->filterEffect();
- // FIXME: hook up parent filter to image source
- filter = SkiaImageFilterBuilder::build(filterEffect);
- break;
- }
- case FilterOperation::GRAYSCALE: {
- float amount = static_cast<const BasicColorMatrixFilterOperation*>(&op)->amount();
- getGrayscaleMatrix(1 - amount, matrix);
- filter = createMatrixImageFilter(matrix, filter);
- break;
- }
- case FilterOperation::SEPIA: {
- float amount = static_cast<const BasicColorMatrixFilterOperation*>(&op)->amount();
- getSepiaMatrix(1 - amount, matrix);
- filter = createMatrixImageFilter(matrix, filter);
- break;
- }
- case FilterOperation::SATURATE: {
- float amount = static_cast<const BasicColorMatrixFilterOperation*>(&op)->amount();
- getSaturateMatrix(amount, matrix);
- filter = createMatrixImageFilter(matrix, filter);
- break;
- }
- case FilterOperation::HUE_ROTATE: {
- float amount = static_cast<const BasicColorMatrixFilterOperation*>(&op)->amount();
- getHueRotateMatrix(amount, matrix);
- filter = createMatrixImageFilter(matrix, filter);
- break;
- }
- case FilterOperation::INVERT: {
- float amount = static_cast<const BasicComponentTransferFilterOperation*>(&op)->amount();
- getInvertMatrix(amount, matrix);
- filter = createMatrixImageFilter(matrix, filter);
- break;
- }
- case FilterOperation::OPACITY: {
- float amount = static_cast<const BasicComponentTransferFilterOperation*>(&op)->amount();
- getOpacityMatrix(amount, matrix);
- filter = createMatrixImageFilter(matrix, filter);
- break;
- }
- case FilterOperation::BRIGHTNESS: {
- float amount = static_cast<const BasicComponentTransferFilterOperation*>(&op)->amount();
- getBrightnessMatrix(amount, matrix);
- filter = createMatrixImageFilter(matrix, filter);
- break;
- }
- case FilterOperation::CONTRAST: {
- float amount = static_cast<const BasicComponentTransferFilterOperation*>(&op)->amount();
- getContrastMatrix(amount, matrix);
- filter = createMatrixImageFilter(matrix, filter);
- break;
- }
- case FilterOperation::BLUR: {
- float pixelRadius = static_cast<const BlurFilterOperation*>(&op)->stdDeviation().getFloatValue();
- filter = new SkBlurImageFilter(pixelRadius, pixelRadius, filter);
- break;
- }
- case FilterOperation::DROP_SHADOW: {
- const DropShadowFilterOperation* drop = static_cast<const DropShadowFilterOperation*>(&op);
- filter = new DropShadowImageFilter(SkIntToScalar(drop->x()), SkIntToScalar(drop->y()), SkIntToScalar(drop->stdDeviation()), drop->color().rgb(), filter);
- break;
- }
-#if ENABLE(CSS_SHADERS)
- case FilterOperation::VALIDATED_CUSTOM:
- case FilterOperation::CUSTOM:
- // Not supported.
-#endif
- case FilterOperation::PASSTHROUGH:
- case FilterOperation::NONE:
- break;
- }
- }
- return filter;
-}
-
-};
diff --git a/Source/WebCore/platform/graphics/filters/skia/SkiaImageFilterBuilder.h b/Source/WebCore/platform/graphics/filters/skia/SkiaImageFilterBuilder.h
deleted file mode 100644
index 27bd68320..000000000
--- a/Source/WebCore/platform/graphics/filters/skia/SkiaImageFilterBuilder.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SkiaImageFilterBuilder_h
-#define SkiaImageFilterBuilder_h
-
-#include <wtf/HashMap.h>
-
-class SkImageFilter;
-
-namespace WebCore {
-class FilterEffect;
-class FilterOperations;
-
-class SkiaImageFilterBuilder {
-public:
- SkiaImageFilterBuilder();
-
- SkImageFilter* build(FilterEffect*);
- SkImageFilter* build(const FilterOperations&);
-private:
- typedef HashMap<FilterEffect*, SkImageFilter*> FilterBuilderHashMap;
- FilterBuilderHashMap m_map;
-};
-
-};
-
-#endif
diff --git a/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp b/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp
index 3e6bcfa9a..cd25f7d73 100644
--- a/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp
+++ b/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp
@@ -26,6 +26,7 @@
#include "OwnPtrCairo.h"
#include "RefPtrCairo.h"
#include "SimpleFontData.h"
+#include "UTF16UChar32Iterator.h"
#include <cairo-ft.h>
#include <cairo.h>
#include <fontconfig/fcfreetype.h>
@@ -41,19 +42,18 @@ void FontCache::platformInit()
ASSERT_NOT_REACHED();
}
-FcPattern* createFontConfigPatternForCharacters(const UChar* characters, int length)
+FcPattern* createFontConfigPatternForCharacters(const UChar* characters, int bufferLength)
{
FcPattern* pattern = FcPatternCreate();
-
FcCharSet* fontConfigCharSet = FcCharSetCreate();
- for (int i = 0; i < length; ++i) {
- if (U16_IS_SURROGATE(characters[i]) && U16_IS_SURROGATE_LEAD(characters[i])
- && i != length - 1 && U16_IS_TRAIL(characters[i + 1])) {
- FcCharSetAddChar(fontConfigCharSet, U16_GET_SUPPLEMENTARY(characters[i], characters[i+1]));
- i++;
- } else
- FcCharSetAddChar(fontConfigCharSet, characters[i]);
+
+ UTF16UChar32Iterator iterator(characters, bufferLength);
+ UChar32 character = iterator.next();
+ while (character != iterator.end()) {
+ FcCharSetAddChar(fontConfigCharSet, character);
+ character = iterator.next();
}
+
FcPatternAddCharSet(pattern, FC_CHARSET, fontConfigCharSet);
FcCharSetDestroy(fontConfigCharSet);
@@ -81,14 +81,14 @@ FcPattern* findBestFontGivenFallbacks(const FontPlatformData& fontData, FcPatter
return FcFontSetMatch(0, sets, 1, pattern, &fontConfigResult);
}
-PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
+PassRefPtr<SimpleFontData> FontCache::systemFallbackForCharacters(const FontDescription& description, const SimpleFontData* originalFontData, bool, const UChar* characters, int length)
{
RefPtr<FcPattern> pattern = adoptRef(createFontConfigPatternForCharacters(characters, length));
- const FontPlatformData& fontData = font.primaryFont()->platformData();
+ const FontPlatformData& fontData = originalFontData->platformData();
RefPtr<FcPattern> fallbackPattern = adoptRef(findBestFontGivenFallbacks(fontData, pattern.get()));
if (fallbackPattern) {
- FontPlatformData alternateFontData(fallbackPattern.get(), font.fontDescription());
+ FontPlatformData alternateFontData(fallbackPattern.get(), description);
return getCachedFontData(&alternateFontData, DoNotRetain);
}
@@ -96,15 +96,10 @@ PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font,
RefPtr<FcPattern> resultPattern = adoptRef(FcFontMatch(0, pattern.get(), &fontConfigResult));
if (!resultPattern)
return 0;
- FontPlatformData alternateFontData(resultPattern.get(), font.fontDescription());
+ FontPlatformData alternateFontData(resultPattern.get(), description);
return getCachedFontData(&alternateFontData, DoNotRetain);
}
-PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font&)
-{
- return 0;
-}
-
PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)
{
// We want to return a fallback font here, otherwise the logic preventing FontConfig
@@ -169,7 +164,7 @@ int fontWeightToFontconfigWeight(FontWeight weight)
}
}
-FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
+PassOwnPtr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
{
// The CSS font matching algorithm (http://www.w3.org/TR/css3-fonts/#font-matching-algorithm)
// says that we must find an exact match for font family, slant (italic or oblique can be used)
@@ -177,15 +172,15 @@ FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD
RefPtr<FcPattern> pattern = adoptRef(FcPatternCreate());
String familyNameString(getFamilyNameStringFromFontDescriptionAndFamily(fontDescription, family));
if (!FcPatternAddString(pattern.get(), FC_FAMILY, reinterpret_cast<const FcChar8*>(familyNameString.utf8().data())))
- return 0;
+ return nullptr;
bool italic = fontDescription.italic();
if (!FcPatternAddInteger(pattern.get(), FC_SLANT, italic ? FC_SLANT_ITALIC : FC_SLANT_ROMAN))
- return 0;
+ return nullptr;
if (!FcPatternAddInteger(pattern.get(), FC_WEIGHT, fontWeightToFontconfigWeight(fontDescription.weight())))
- return 0;
+ return nullptr;
if (!FcPatternAddDouble(pattern.get(), FC_PIXEL_SIZE, fontDescription.computedPixelSize()))
- return 0;
+ return nullptr;
// The strategy is originally from Skia (src/ports/SkFontHost_fontconfig.cpp):
@@ -202,7 +197,7 @@ FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD
FcResult fontConfigResult;
RefPtr<FcPattern> resultPattern = adoptRef(FcFontMatch(0, pattern.get(), &fontConfigResult));
if (!resultPattern) // No match.
- return 0;
+ return nullptr;
FcChar8* fontConfigFamilyNameAfterMatching;
FcPatternGetString(resultPattern.get(), FC_FAMILY, 0, &fontConfigFamilyNameAfterMatching);
@@ -215,18 +210,16 @@ FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD
&& !(equalIgnoringCase(familyNameString, "sans") || equalIgnoringCase(familyNameString, "sans-serif")
|| equalIgnoringCase(familyNameString, "serif") || equalIgnoringCase(familyNameString, "monospace")
|| equalIgnoringCase(familyNameString, "fantasy") || equalIgnoringCase(familyNameString, "cursive")))
- return 0;
+ return nullptr;
// Verify that this font has an encoding compatible with Fontconfig. Fontconfig currently
// supports three encodings in FcFreeTypeCharIndex: Unicode, Symbol and AppleRoman.
// If this font doesn't have one of these three encodings, don't select it.
- FontPlatformData* platformData = new FontPlatformData(resultPattern.get(), fontDescription);
- if (!platformData->hasCompatibleCharmap()) {
- delete platformData;
- return 0;
- }
+ OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(resultPattern.get(), fontDescription));
+ if (!platformData->hasCompatibleCharmap())
+ return nullptr;
- return platformData;
+ return platformData.release();
}
}
diff --git a/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp b/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp
index b1cf96bd9..841c8a3ad 100644
--- a/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp
+++ b/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp
@@ -59,7 +59,7 @@ FontCustomPlatformData::~FontCustomPlatformData()
cairo_font_face_destroy(m_fontFace);
}
-FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation, TextOrientation, FontWidthVariant, FontRenderingMode)
+FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation, FontWidthVariant, FontRenderingMode)
{
return FontPlatformData(m_fontFace, size, bold, italic);
}
diff --git a/Source/WebCore/platform/graphics/freetype/FontPlatformData.h b/Source/WebCore/platform/graphics/freetype/FontPlatformData.h
index 6a62c6c7c..d8ecf0a43 100644
--- a/Source/WebCore/platform/graphics/freetype/FontPlatformData.h
+++ b/Source/WebCore/platform/graphics/freetype/FontPlatformData.h
@@ -29,15 +29,13 @@
#include "FontDescription.h"
#include "FontOrientation.h"
#include "GlyphBuffer.h"
-#if USE(HARFBUZZ_NG)
-#include "HarfBuzzNGFace.h"
-#endif
+#include "HarfBuzzFace.h"
#include "RefPtrCairo.h"
#include <wtf/Forward.h>
#include <wtf/HashFunctions.h>
typedef struct _FcFontSet FcFontSet;
-class HarfBuzzNGFace;
+class HarfBuzzFace;
namespace WebCore {
@@ -67,9 +65,7 @@ public:
~FontPlatformData();
-#if USE(HARFBUZZ_NG)
- HarfBuzzNGFace* harfbuzzFace() const;
-#endif
+ HarfBuzzFace* harfBuzzFace() const;
bool isFixedPitch();
float size() const { return m_size; }
@@ -106,9 +102,7 @@ public:
bool m_syntheticOblique;
bool m_fixedWidth;
cairo_scaled_font_t* m_scaledFont;
-#if USE(HARFBUZZ_NG)
- mutable RefPtr<HarfBuzzNGFace> m_harfbuzzFace;
-#endif
+ mutable RefPtr<HarfBuzzFace> m_harfBuzzFace;
private:
void initializeWithFontFace(cairo_font_face_t*, const FontDescription& = FontDescription());
diff --git a/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp b/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp
index c95d1b3b9..a2d591ba7 100644
--- a/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp
+++ b/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp
@@ -130,9 +130,14 @@ FontPlatformData::FontPlatformData(FcPattern* pattern, const FontDescription& fo
if (fontDescription.weight() >= FontWeightBold) {
// The FC_EMBOLDEN property instructs us to fake the boldness of the font.
- FcBool fontConfigEmbolden;
+ FcBool fontConfigEmbolden = FcFalse;
if (FcPatternGetBool(pattern, FC_EMBOLDEN, 0, &fontConfigEmbolden) == FcResultMatch)
m_syntheticBold = fontConfigEmbolden;
+
+ // Fallback fonts may not have FC_EMBOLDEN activated even though it's necessary.
+ int weight = 0;
+ if (!m_syntheticBold && FcPatternGetInteger(pattern, FC_WEIGHT, 0, &weight) == FcResultMatch)
+ m_syntheticBold = m_syntheticBold || weight < FC_WEIGHT_DEMIBOLD;
}
}
@@ -186,9 +191,7 @@ FontPlatformData& FontPlatformData::operator=(const FontPlatformData& other)
cairo_scaled_font_destroy(m_scaledFont);
m_scaledFont = cairo_scaled_font_reference(other.m_scaledFont);
-#if USE(HARFBUZZ_NG)
- m_harfbuzzFace = other.m_harfbuzzFace;
-#endif
+ m_harfBuzzFace = other.m_harfBuzzFace;
return *this;
}
@@ -196,17 +199,13 @@ FontPlatformData& FontPlatformData::operator=(const FontPlatformData& other)
FontPlatformData::FontPlatformData(const FontPlatformData& other)
: m_fallbacks(0)
, m_scaledFont(0)
-#if USE(HARFBUZZ_NG)
- , m_harfbuzzFace(other.m_harfbuzzFace)
-#endif
+ , m_harfBuzzFace(other.m_harfBuzzFace)
{
*this = other;
}
FontPlatformData::FontPlatformData(const FontPlatformData& other, float size)
-#if USE(HARFBUZZ_NG)
- : m_harfbuzzFace(other.m_harfbuzzFace)
-#endif
+ : m_harfBuzzFace(other.m_harfBuzzFace)
{
*this = other;
@@ -227,15 +226,13 @@ FontPlatformData::~FontPlatformData()
cairo_scaled_font_destroy(m_scaledFont);
}
-#if USE(HARFBUZZ_NG)
-HarfBuzzNGFace* FontPlatformData::harfbuzzFace() const
+HarfBuzzFace* FontPlatformData::harfBuzzFace() const
{
- if (!m_harfbuzzFace)
- m_harfbuzzFace = HarfBuzzNGFace::create(const_cast<FontPlatformData*>(this), hash());
+ if (!m_harfBuzzFace)
+ m_harfBuzzFace = HarfBuzzFace::create(const_cast<FontPlatformData*>(this), hash());
- return m_harfbuzzFace.get();
+ return m_harfBuzzFace.get();
}
-#endif
bool FontPlatformData::isFixedPitch()
{
@@ -244,8 +241,13 @@ bool FontPlatformData::isFixedPitch()
bool FontPlatformData::operator==(const FontPlatformData& other) const
{
- return m_pattern == other.m_pattern
- && m_scaledFont == other.m_scaledFont
+ // FcPatternEqual does not support null pointers as arguments.
+ if ((m_pattern && !other.m_pattern)
+ || (!m_pattern && other.m_pattern)
+ || (m_pattern != other.m_pattern && !FcPatternEqual(m_pattern.get(), other.m_pattern.get())))
+ return false;
+
+ return m_scaledFont == other.m_scaledFont
&& m_size == other.m_size
&& m_syntheticOblique == other.m_syntheticOblique
&& m_syntheticBold == other.m_syntheticBold;
diff --git a/Source/WebCore/platform/graphics/freetype/GlyphPageTreeNodeFreeType.cpp b/Source/WebCore/platform/graphics/freetype/GlyphPageTreeNodeFreeType.cpp
index 170e70a22..d156d8c83 100644
--- a/Source/WebCore/platform/graphics/freetype/GlyphPageTreeNodeFreeType.cpp
+++ b/Source/WebCore/platform/graphics/freetype/GlyphPageTreeNodeFreeType.cpp
@@ -32,6 +32,7 @@
#include "GlyphPageTreeNode.h"
#include "SimpleFontData.h"
+#include "UTF16UChar32Iterator.h"
#include <cairo-ft.h>
#include <cairo.h>
#include <fontconfig/fcfreetype.h>
@@ -40,11 +41,6 @@ namespace WebCore {
bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData)
{
- // The bufferLength will be greater than the glyph page size if the buffer has Unicode supplementary characters.
- // We won't support this for now.
- if (bufferLength > GlyphPage::size)
- return false;
-
cairo_scaled_font_t* scaledFont = fontData->platformData().scaledFont();
ASSERT(scaledFont);
@@ -53,8 +49,13 @@ bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned b
return false;
bool haveGlyphs = false;
+ UTF16UChar32Iterator iterator(buffer, bufferLength);
for (unsigned i = 0; i < length; i++) {
- Glyph glyph = FcFreeTypeCharIndex(face, buffer[i]);
+ UChar32 character = iterator.next();
+ if (character == iterator.end())
+ break;
+
+ Glyph glyph = FcFreeTypeCharIndex(face, character);
if (!glyph)
setGlyphDataForIndex(offset + i, 0, 0);
else {
diff --git a/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp b/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp
index a16ad17df..dbaa2c393 100644
--- a/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp
+++ b/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp
@@ -39,6 +39,7 @@
#include "FontCache.h"
#include "FontDescription.h"
#include "GlyphBuffer.h"
+#include "UTF16UChar32Iterator.h"
#include <cairo-ft.h>
#include <cairo.h>
#include <fontconfig/fcfreetype.h>
@@ -65,8 +66,12 @@ void SimpleFontData::platformInit()
m_fontMetrics.setAscent(ascent);
m_fontMetrics.setDescent(descent);
+#if PLATFORM(EFL)
+ m_fontMetrics.setLineSpacing(ascent + descent + lineGap);
+#else
// Match CoreGraphics metrics.
m_fontMetrics.setLineSpacing(lroundf(ascent) + lroundf(descent) + lroundf(lineGap));
+#endif
m_fontMetrics.setLineGap(lineGap);
cairo_scaled_font_text_extents(m_platformData.scaledFont(), "x", &text_extents);
@@ -74,7 +79,7 @@ void SimpleFontData::platformInit()
cairo_scaled_font_text_extents(m_platformData.scaledFont(), " ", &text_extents);
m_spaceWidth = narrowPrecisionToFloat(text_extents.x_advance);
-
+
m_syntheticBoldOffset = m_platformData.syntheticBold() ? 1.0f : 0.f;
}
@@ -89,7 +94,7 @@ void SimpleFontData::platformDestroy()
{
}
-PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
+PassRefPtr<SimpleFontData> SimpleFontData::platformCreateScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
{
ASSERT(m_platformData.scaledFont());
return SimpleFontData::create(FontPlatformData(cairo_scaled_font_get_font_face(m_platformData.scaledFont()),
@@ -98,18 +103,21 @@ PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescri
m_platformData.syntheticOblique()), isCustomFont(), false);
}
-bool SimpleFontData::containsCharacters(const UChar* characters, int length) const
+bool SimpleFontData::containsCharacters(const UChar* characters, int bufferLength) const
{
ASSERT(m_platformData.scaledFont());
FT_Face face = cairo_ft_scaled_font_lock_face(m_platformData.scaledFont());
if (!face)
return false;
- for (int i = 0; i < length; i++) {
- if (FcFreeTypeCharIndex(face, characters[i]) == 0) {
+ UTF16UChar32Iterator iterator(characters, bufferLength);
+ UChar32 character = iterator.next();
+ while (character != iterator.end()) {
+ if (!FcFreeTypeCharIndex(face, character)) {
cairo_ft_scaled_font_unlock_face(m_platformData.scaledFont());
return false;
}
+ character = iterator.next();
}
cairo_ft_scaled_font_unlock_face(m_platformData.scaledFont());
@@ -152,7 +160,7 @@ float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
return w;
}
-#if USE(HARFBUZZ_NG)
+#if USE(HARFBUZZ)
bool SimpleFontData::canRenderCombiningCharacterSequence(const UChar* characters, size_t length) const
{
if (!m_combiningCharacterSequenceSupport)
diff --git a/Source/WebCore/platform/graphics/chromium/LayerPainterChromium.h b/Source/WebCore/platform/graphics/freetype/UTF16UChar32Iterator.h
index bc0352e7c..2f8145e96 100644
--- a/Source/WebCore/platform/graphics/chromium/LayerPainterChromium.h
+++ b/Source/WebCore/platform/graphics/freetype/UTF16UChar32Iterator.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
+ * Copyright (C) 2013 Igalia S.L.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -11,7 +11,7 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * THIS SOFTWARE IS PROVIDED BY IGALIA AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
@@ -23,26 +23,48 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef UTF16UChar32Iterator_h
+#define UTF16UChar32Iterator_h
-#ifndef LayerPainterChromium_h
-#define LayerPainterChromium_h
+namespace WebCore {
-#if USE(ACCELERATED_COMPOSITING)
+class UTF16UChar32Iterator {
+ WTF_MAKE_NONCOPYABLE(UTF16UChar32Iterator);
+public:
+ UTF16UChar32Iterator(const UChar* buffer, unsigned bufferLength)
+ : m_buffer(buffer)
+ , m_bufferLength(bufferLength)
+ , m_currentOffset(0)
+ {
+ }
-class SkCanvas;
+ static UChar32 end()
+ {
+ return static_cast<UChar32>(-1);
+ }
-namespace WebCore {
+ UChar32 next()
+ {
+ if (m_currentOffset >= m_bufferLength)
+ return end();
-class FloatRect;
-class IntRect;
+ const UChar32 character = m_buffer[m_currentOffset++];
+ if (U16_IS_SURROGATE_LEAD(character)
+ && m_currentOffset != m_bufferLength
+ && U16_IS_TRAIL(m_buffer[m_currentOffset])) {
+ return U16_GET_SUPPLEMENTARY(character, m_buffer[m_currentOffset++]);
+ }
-class LayerPainterChromium {
-public:
- virtual ~LayerPainterChromium() { }
- virtual void paint(SkCanvas*, const IntRect& contentRect, FloatRect& opaque) = 0;
+ return character;
+ }
+
+private:
+ const UChar* m_buffer;
+ unsigned m_bufferLength;
+ unsigned m_currentOffset;
};
} // namespace WebCore
-#endif // USE(ACCELERATED_COMPOSITING)
-#endif // LayerPainterChromium_h
+
+#endif // UTF16UChar32Iterator_h
diff --git a/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp b/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp
index 31f32cf0b..176f7722d 100644
--- a/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp
+++ b/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp
@@ -23,8 +23,13 @@
#include "GraphicsContext3D.h"
#include "OpenGLShims.h"
#include <GL/glx.h>
+#include <cairo.h>
#include <wtf/OwnPtr.h>
+#if ENABLE(ACCELERATED_2D_CANVAS)
+#include <cairo-gl.h>
+#endif
+
namespace WebCore {
PassOwnPtr<GLContextGLX> GLContextGLX::createWindowContext(XID window, GLContext* sharingContext)
@@ -168,6 +173,7 @@ GLContextGLX::GLContextGLX(GLXContext context)
, m_pbuffer(0)
, m_pixmap(0)
, m_glxPixmap(0)
+ , m_cairoDevice(0)
{
}
@@ -177,11 +183,15 @@ GLContextGLX::GLContextGLX(GLXContext context, Pixmap pixmap, GLXPixmap glxPixma
, m_pbuffer(0)
, m_pixmap(pixmap)
, m_glxPixmap(glxPixmap)
+ , m_cairoDevice(0)
{
}
GLContextGLX::~GLContextGLX()
{
+ if (m_cairoDevice)
+ cairo_device_destroy(m_cairoDevice);
+
if (m_context) {
// This may be necessary to prevent crashes with NVidia's closed source drivers. Originally
// from Mozilla's 3D canvas implementation at: http://bitbucket.org/ilmari/canvas3d/
@@ -251,6 +261,18 @@ void GLContextGLX::waitNative()
glXWaitX();
}
+cairo_device_t* GLContextGLX::cairoDevice()
+{
+ if (m_cairoDevice)
+ return m_cairoDevice;
+
+#if ENABLE(ACCELERATED_2D_CANVAS)
+ m_cairoDevice = cairo_glx_device_create(sharedX11Display(), m_context);
+#endif
+
+ return m_cairoDevice;
+}
+
#if USE(3D_GRAPHICS)
PlatformGraphicsContext3D GLContextGLX::platformContext()
{
diff --git a/Source/WebCore/platform/graphics/glx/GLContextGLX.h b/Source/WebCore/platform/graphics/glx/GLContextGLX.h
index 888146b11..edefc04c2 100644
--- a/Source/WebCore/platform/graphics/glx/GLContextGLX.h
+++ b/Source/WebCore/platform/graphics/glx/GLContextGLX.h
@@ -46,6 +46,7 @@ public:
virtual void waitNative();
virtual bool canRenderToDefaultFramebuffer();
virtual IntSize defaultFrameBufferSize();
+ virtual cairo_device_t* cairoDevice();
#if USE(3D_GRAPHICS)
virtual PlatformGraphicsContext3D platformContext();
@@ -63,6 +64,7 @@ private:
GLXPbuffer m_pbuffer;
Pixmap m_pixmap;
GLXPixmap m_glxPixmap;
+ cairo_device_t* m_cairoDevice;
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp b/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp
index 282bde03f..19bdc7138 100644
--- a/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp
+++ b/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp
@@ -36,16 +36,60 @@
#include "Extensions3D.h"
#include "GraphicsContext3D.h"
-#include "ImageData.h"
namespace WebCore {
+#if PLATFORM(WIN) || PLATFORM(QT) || USE(CAIRO)
+DrawingBuffer::DrawingBuffer(GraphicsContext3D* context, const IntSize& size, bool multisampleExtensionSupported, bool packedDepthStencilExtensionSupported, PreserveDrawingBuffer preserveDrawingBuffer, AlphaRequirement alpha)
+ : m_preserveDrawingBuffer(preserveDrawingBuffer)
+ , m_alpha(alpha)
+ , m_scissorEnabled(false)
+ , m_texture2DBinding(0)
+ , m_framebufferBinding(0)
+ , m_activeTextureUnit(GraphicsContext3D::TEXTURE0)
+ , m_context(context)
+ , m_size(-1, -1)
+ , m_multisampleExtensionSupported(multisampleExtensionSupported)
+ , m_packedDepthStencilExtensionSupported(packedDepthStencilExtensionSupported)
+ , m_fbo(context->createFramebuffer())
+ , m_colorBuffer(0)
+ , m_frontColorBuffer(0)
+ , m_separateFrontTexture(false)
+ , m_depthStencilBuffer(0)
+ , m_depthBuffer(0)
+ , m_stencilBuffer(0)
+ , m_multisampleFBO(0)
+ , m_multisampleColorBuffer(0)
+{
+ ASSERT(m_fbo);
+ if (!m_fbo) {
+ clear();
+ return;
+ }
+
+ // create a texture to render into
+ m_colorBuffer = context->createTexture();
+ context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_colorBuffer);
+ context->texParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR);
+ context->texParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR);
+ context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE);
+ context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE);
+ context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0);
+
+ createSecondaryBuffers();
+ reset(size);
+}
+
+DrawingBuffer::~DrawingBuffer()
+{
+ clear();
+}
+#endif
+
// Global resource ceiling (expressed in terms of pixels) for DrawingBuffer creation and resize.
// When this limit is set, DrawingBuffer::create() and DrawingBuffer::reset() calls that would
// exceed the global cap will instead clear the buffer.
-#if PLATFORM(CHROMIUM) // Currently, this cap only exists for chromium.
-static int s_maximumResourceUsePixels = 16 * 1024 * 1024;
-#elif !PLATFORM(BLACKBERRY)
+#if !PLATFORM(BLACKBERRY)
static int s_maximumResourceUsePixels = 0;
#endif
static int s_currentResourceUsePixels = 0;
@@ -76,6 +120,7 @@ void DrawingBuffer::clear()
return;
m_context->makeContextCurrent();
+
if (!m_size.isEmpty()) {
s_currentResourceUsePixels -= m_size.width() * m_size.height();
m_size = IntSize();
@@ -184,6 +229,33 @@ void DrawingBuffer::clearFramebuffers(GC3Dbitfield clearMask)
}
}
+// Only way to ensure that we're not getting a bad framebuffer on some AMD/OSX devices.
+// FIXME: This can be removed once renderbufferStorageMultisample starts reporting GL_OUT_OF_MEMORY properly.
+bool DrawingBuffer::checkBufferIntegrity()
+{
+ if (!m_multisampleFBO)
+ return true;
+
+ if (m_scissorEnabled)
+ m_context->disable(GraphicsContext3D::SCISSOR_TEST);
+
+ m_context->colorMask(true, true, true, true);
+
+ m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO);
+ m_context->clearColor(1.0f, 0.0f, 1.0f, 1.0f);
+ m_context->clear(GraphicsContext3D::COLOR_BUFFER_BIT);
+
+ commit(0, 0, 1, 1);
+
+ unsigned char pixel[4] = {0, 0, 0, 0};
+ m_context->readPixels(0, 0, 1, 1, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, &pixel);
+
+ if (m_scissorEnabled)
+ m_context->enable(GraphicsContext3D::SCISSOR_TEST);
+
+ return (pixel[0] == 0xFF && pixel[1] == 0x00 && pixel[2] == 0xFF && pixel[3] == 0xFF);
+}
+
bool DrawingBuffer::reset(const IntSize& newSize)
{
if (!m_context)
@@ -233,7 +305,6 @@ bool DrawingBuffer::reset(const IntSize& newSize)
internalRenderbufferFormat = Extensions3D::RGB8_OES;
}
-
do {
m_size = adjustedSize;
// resize multisample FBO
@@ -247,6 +318,12 @@ bool DrawingBuffer::reset(const IntSize& newSize)
m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_multisampleColorBuffer);
m_context->getExtensions()->renderbufferStorageMultisample(GraphicsContext3D::RENDERBUFFER, sampleCount, internalRenderbufferFormat, m_size.width(), m_size.height());
+
+ if (m_context->getError() == GraphicsContext3D::OUT_OF_MEMORY) {
+ adjustedSize.scale(s_resourceAdjustedRatio);
+ continue;
+ }
+
m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::RENDERBUFFER, m_multisampleColorBuffer);
resizeDepthStencil(sampleCount);
if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) {
@@ -273,9 +350,20 @@ bool DrawingBuffer::reset(const IntSize& newSize)
if (!multisample())
resizeDepthStencil(0);
- if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) == GraphicsContext3D::FRAMEBUFFER_COMPLETE)
- break;
- adjustedSize.scale(s_resourceAdjustedRatio);
+ if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) {
+ adjustedSize.scale(s_resourceAdjustedRatio);
+ continue;
+ }
+
+#if OS(DARWIN)
+ // FIXME: This can be removed once renderbufferStorageMultisample starts reporting GL_OUT_OF_MEMORY properly on OSX.
+ if (!checkBufferIntegrity()) {
+ adjustedSize.scale(s_resourceAdjustedRatio);
+ continue;
+ }
+#endif
+
+ break;
} while (!adjustedSize.isEmpty());
@@ -352,11 +440,6 @@ bool DrawingBuffer::multisample() const
return m_context && m_context->getContextAttributes().antialias && m_multisampleExtensionSupported;
}
-PassRefPtr<ImageData> DrawingBuffer::paintRenderingResultsToImageData()
-{
- return m_context->paintRenderingResultsToImageData(this);
-}
-
void DrawingBuffer::discardResources()
{
m_colorBuffer = 0;
diff --git a/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h b/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h
index b2c59aae6..e234e420c 100644
--- a/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h
+++ b/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h
@@ -45,10 +45,6 @@
namespace WebCore {
class GraphicsContext3D;
-class ImageData;
-#if PLATFORM(CHROMIUM)
-class DrawingBufferPrivate;
-#endif
// Manages a rendering target (framebuffer + attachment) for a canvas. Can publish its rendering
// results to a PlatformLayer for compositing.
@@ -115,8 +111,6 @@ public:
Platform3DObject framebuffer() const;
- PassRefPtr<ImageData> paintRenderingResultsToImageData();
-
// Immediately releases ownership of all resources. Call upon loss of the
// graphics context to prevent freeing invalid resources.
void discardResources();
@@ -125,8 +119,6 @@ public:
#if USE(ACCELERATED_COMPOSITING)
PlatformLayer* platformLayer();
- void prepareBackBuffer();
- bool requiresCopyFromBackToFrontBuffer() const;
unsigned frontColorBuffer() const;
void paintCompositedResultsToCanvas(ImageBuffer*);
#endif
@@ -139,6 +131,8 @@ private:
void initialize(const IntSize&);
+ bool checkBufferIntegrity();
+
PreserveDrawingBuffer m_preserveDrawingBuffer;
AlphaRequirement m_alpha;
bool m_scissorEnabled;
@@ -169,10 +163,6 @@ private:
// True if our contents have been modified since the last presentation of this buffer.
bool m_contentsChanged;
-#if PLATFORM(CHROMIUM)
- OwnPtr<DrawingBufferPrivate> m_private;
-#endif
-
#if PLATFORM(MAC)
RetainPtr<WebGLLayer> m_platformLayer;
#endif
diff --git a/Source/WebCore/platform/graphics/gpu/LoopBlinnMathUtils.cpp b/Source/WebCore/platform/graphics/gpu/LoopBlinnMathUtils.cpp
index baf1c9685..32a54fb90 100644
--- a/Source/WebCore/platform/graphics/gpu/LoopBlinnMathUtils.cpp
+++ b/Source/WebCore/platform/graphics/gpu/LoopBlinnMathUtils.cpp
@@ -336,7 +336,7 @@ bool safeUnitDivide(float numerator, float denominator, float& ratio)
if (!numerator || !denominator || numerator >= denominator)
return false;
float r = numerator / denominator;
- if (isnan(r))
+ if (std::isnan(r))
return false;
ASSERT(r >= 0 && r < 1);
if (!r) // catch underflow if numerator <<<< denominator
@@ -359,7 +359,7 @@ int findUnitQuadRoots(float a, float b, float c, float roots[2])
return safeUnitDivide(-c, b, roots[0]) ? 1 : 0;
float discriminant = b*b - 4*a*c;
- if (discriminant < 0 || isnan(discriminant)) // complex roots
+ if (discriminant < 0 || std::isnan(discriminant)) // complex roots
return 0;
discriminant = sqrtf(discriminant);
diff --git a/Source/WebCore/platform/graphics/gpu/LoopBlinnPathProcessor.cpp b/Source/WebCore/platform/graphics/gpu/LoopBlinnPathProcessor.cpp
deleted file mode 100644
index a1d667975..000000000
--- a/Source/WebCore/platform/graphics/gpu/LoopBlinnPathProcessor.cpp
+++ /dev/null
@@ -1,1236 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "LoopBlinnPathProcessor.h"
-
-#include "FloatPoint.h"
-#include "FloatRect.h"
-#include "LoopBlinnClassifier.h"
-#include "LoopBlinnConstants.h"
-#include "LoopBlinnLocalTriangulator.h"
-#include "LoopBlinnMathUtils.h"
-#include "LoopBlinnPathCache.h"
-#include "LoopBlinnTextureCoords.h"
-#include "PODArena.h"
-#include "PODIntervalTree.h"
-#include "Path.h"
-#include "internal_glu.h"
-#include <algorithm>
-#include <wtf/Assertions.h>
-#include <wtf/FastMalloc.h>
-#include <wtf/UnusedParam.h>
-
-
-#if USE(SKIA)
-#include "SkGeometry.h"
-#include "SkPath.h"
-#include "SkScalar.h"
-#else
-// Must port to your platform.
-#endif
-
-namespace WebCore {
-
-using LoopBlinnMathUtils::XRay;
-using LoopBlinnMathUtils::chopCubicAt;
-using LoopBlinnMathUtils::numXRayCrossingsForCubic;
-using LoopBlinnMathUtils::trianglesOverlap;
-using LoopBlinnMathUtils::xRayCrossesLine;
-using LoopBlinnPathProcessorImplementation::Contour;
-using LoopBlinnPathProcessorImplementation::Segment;
-
-namespace {
-
-#ifndef NDEBUG
-String valueToString(const FloatRect& arg)
-{
- StringBuilder builder;
- builder.appendLiteral("[FloatRect x=");
- builder.append(String::number(arg.x()));
- builder.appendLiteral(" y=");
- builder.append(String::number(arg.y()));
- builder.appendLiteral(" maxX=");
- builder.append(String::number(arg.maxX()));
- builder.appendLiteral(" maxY=");
- builder.append(String::number(arg.maxY()));
- builder.append(']');
- return builder.toString();
-}
-#endif
-
-struct SweepData;
-
-} // anonymous namespace
-
-namespace LoopBlinnPathProcessorImplementation {
-class Segment;
-}
-
-#ifndef NDEBUG
-// Routines needed to print the types of IntervalNodes we instantiate
-// in this file.
-template <>
-struct ValueToString<float> {
- static String string(const float& value)
- {
- return String::number(value);
- }
-};
-
-template <>
-struct ValueToString<SweepData*> {
- static String string(SweepData* const& value)
- {
- return String::format("0x%p", value);
- }
-};
-
-template <>
-struct ValueToString<LoopBlinnPathProcessorImplementation::Segment*> {
- static String string(LoopBlinnPathProcessorImplementation::Segment* const& value)
- {
- return String::format("0x%p", value);
- }
-};
-#endif
-
-namespace LoopBlinnPathProcessorImplementation {
-
-//----------------------------------------------------------------------
-// Segment
-//
-
-// Describes a segment of the path: either a cubic or a line segment.
-// These are stored in a doubly linked list to speed up curve
-// subdivision, which occurs due to either rendering artifacts in the
-// loop case or due to overlapping triangles.
-class Segment {
- WTF_MAKE_NONCOPYABLE(Segment);
-public:
- enum Kind {
- Cubic,
- Line
- };
-
- // No-argument constructor allows construction by the PODArena class.
- Segment()
- : m_arena(0)
- , m_kind(Cubic)
- , m_prev(0)
- , m_next(0)
- , m_contour(0)
- , m_triangulator(0)
- , m_markedForSubdivision(false)
- {
- }
-
- // Initializer for cubic curve segments.
- void setup(PODArena* arena,
- Contour* contour,
- FloatPoint cp0,
- FloatPoint cp1,
- FloatPoint cp2,
- FloatPoint cp3)
- {
- m_arena = arena;
- m_contour = contour;
- m_kind = Cubic;
- m_points[0] = cp0;
- m_points[1] = cp1;
- m_points[2] = cp2;
- m_points[3] = cp3;
- computeBoundingBox();
- }
-
- // Initializer for line segments.
- void setup(PODArena* arena,
- Contour* contour,
- FloatPoint p0,
- FloatPoint p1)
- {
- m_arena = arena;
- m_contour = contour;
- m_kind = Line;
- m_points[0] = p0;
- m_points[1] = p1;
- computeBoundingBox();
- }
-
- Kind kind() const { return m_kind; }
-
- // Returns the i'th control point, 0 <= i < 4.
- const FloatPoint& getPoint(int i)
- {
- ASSERT(i >= 0 && i < 4);
- return m_points[i];
- }
-
- Segment* next() const { return m_next; }
- Segment* prev() const { return m_prev; }
-
- void setNext(Segment* next) { m_next = next; }
- void setPrev(Segment* prev) { m_prev = prev; }
-
- // The contour this segment belongs to.
- Contour* contour() const { return m_contour; }
-
- // Subdivides the current segment at the given parameter value (0 <=
- // t <= 1) and replaces it with the two newly created Segments in
- // the linked list, if possible. Returns a pointer to the leftmost
- // Segment.
- Segment* subdivide(float param)
- {
- FloatPoint dst[7];
- chopCubicAt(m_points, dst, param);
- Segment* left = m_arena->allocateObject<Segment>();
- Segment* right = m_arena->allocateObject<Segment>();
- left->setup(m_arena, m_contour, dst[0], dst[1], dst[2], dst[3]);
- right->setup(m_arena, m_contour, dst[3], dst[4], dst[5], dst[6]);
- left->setNext(right);
- right->setPrev(left);
- // Try to set up a link between "this->prev()" and "left".
- if (prev()) {
- left->setPrev(prev());
- prev()->setNext(left);
- }
- // Try to set up a link between "this->next()" and "right".
- Segment* n = next();
- if (n) {
- right->setNext(n);
- n->setPrev(right);
- }
- // Set up a link between "this" and "left"; this is only to
- // provide a certain amount of continuity during forward iteration.
- setNext(left);
- return left;
- }
-
- // Subdivides the current segment at the halfway point and replaces
- // it with the two newly created Segments in the linked list, if
- // possible. Returns a pointer to the leftmost Segment.
- Segment* subdivide() { return subdivide(0.5f); }
-
- const FloatRect& boundingBox() const { return m_boundingBox; }
-
- // Computes the number of times a query line starting at the given
- // point and extending to x=+infinity crosses this segment. Outgoing
- // "ambiguous" argument indicates whether the query intersected an
- // endpoint or tangent point of the segment, indicating that another
- // query point is preferred.
- int numCrossingsForXRay(const XRay& xRay, bool& ambiguous) const
- {
- if (m_kind == Cubic)
- // Should consider caching the monotonic cubics.
- return numXRayCrossingsForCubic(xRay, m_points, ambiguous);
-
- return xRayCrossesLine(xRay, m_points, ambiguous) ? 1 : 0;
- }
-
- // Performs a local triangulation of the control points in this
- // segment. This operation only makes sense for cubic type segments.
- // texCoords may be null when the klm coordinates have not been
- // computed yet.
- void triangulate(LoopBlinnLocalTriangulator::InsideEdgeComputation computeInsideEdges,
- const LoopBlinnTextureCoords::Result* texCoords);
-
- // Returns the number of control point triangles associated with
- // this segment.
- int numberOfTriangles() const
- {
- if (!m_triangulator)
- return 0;
- return m_triangulator->numberOfTriangles();
- }
-
- // Fetches the given control point triangle for this segment.
- LoopBlinnLocalTriangulator::Triangle* getTriangle(int index)
- {
- ASSERT(m_triangulator);
- return m_triangulator->getTriangle(index);
- }
-
- // Number of vertices along the inside edge of this segment. This
- // can be called either for line or cubic type segments.
- int numberOfInteriorVertices() const
- {
- if (m_kind == Cubic) {
- if (m_triangulator)
- return m_triangulator->numberOfInteriorVertices();
-
- return 0;
- }
-
- return 2;
- }
-
- // Returns the given interior vertex, 0 <= index < numberOfInteriorVertices().
- FloatPoint getInteriorVertex(int index) const
- {
- ASSERT(index >= 0 && index < numberOfInteriorVertices());
- if (m_kind == Cubic) {
- FloatPoint res;
- if (m_triangulator) {
- LoopBlinnLocalTriangulator::Vertex* vertex = m_triangulator->getInteriorVertex(index);
- if (vertex)
- res.set(vertex->xyCoordinates().x(), vertex->xyCoordinates().y());
- }
- return res;
- }
-
- return m_points[index];
- }
-
- // State to assist with curve subdivision.
- bool markedForSubdivision() const { return m_markedForSubdivision; }
- void setMarkedForSubdivision(bool markedForSubdivision) { m_markedForSubdivision = markedForSubdivision; }
-
-#ifndef NDEBUG
- // Suppport for printing Segments.
- String toString() const
- {
- StringBuilder builder;
- builder.append("[Segment kind=");
- builder.append(kind() == Line ? "line" : "cubic");
- builder.append(" boundingBox=");
- builder.append(valueToString(boundingBox()));
- builder.append(" contour=0x");
- builder.append(String::format("%p", contour()));
- builder.append(" markedForSubdivision=");
- builder.append(markedForSubdivision() ? "true" : "false");
- builder.append("]");
- return builder.toString();
- }
-#endif
-
- private:
- // Computes the bounding box of this Segment.
- void computeBoundingBox()
- {
- switch (m_kind) {
- case Cubic:
- m_boundingBox.fitToPoints(m_points[0], m_points[1], m_points[2], m_points[3]);
- break;
-
- case Line:
- m_boundingBox.fitToPoints(m_points[0], m_points[1]);
- break;
- }
- }
-
- PODArena* m_arena;
- Kind m_kind;
- FloatPoint m_points[4];
- Segment* m_prev;
- Segment* m_next;
- Contour* m_contour;
- FloatRect m_boundingBox;
- LoopBlinnLocalTriangulator* m_triangulator;
- bool m_markedForSubdivision;
-};
-
-//----------------------------------------------------------------------
-// Contour
-//
-
-// Describes a closed contour of the path.
-class Contour {
- WTF_MAKE_NONCOPYABLE(Contour);
-public:
- Contour()
- {
- m_first = &m_sentinel;
- m_first->setNext(m_first);
- m_first->setPrev(m_first);
- m_isOrientedCounterClockwise = true;
- m_boundingBoxDirty = false;
- m_fillSide = LoopBlinnConstants::RightSide;
- }
-
- void add(Segment* segment)
- {
- if (m_first == &m_sentinel) {
- // First element is the sentinel. Replace it with the incoming
- // segment.
- segment->setNext(m_first);
- segment->setPrev(m_first);
- m_first->setNext(segment);
- m_first->setPrev(segment);
- m_first = segment;
- } else {
- // m_first->prev() is the sentinel.
- ASSERT(m_first->prev() == &m_sentinel);
- Segment* last = m_sentinel.prev();
- last->setNext(segment);
- segment->setPrev(last);
- segment->setNext(&m_sentinel);
- m_sentinel.setPrev(segment);
- }
- m_boundingBoxDirty = true;
- }
-
- // Subdivides the given segment at the given parametric value.
- // Returns a pointer to the first of the two portions of the
- // subdivided segment.
- Segment* subdivide(Segment* segment, float param)
- {
- Segment* left = segment->subdivide(param);
- if (m_first == segment)
- m_first = left;
- return left;
- }
-
- // Subdivides the given segment at the halfway point. Returns a
- // pointer to the first of the two portions of the subdivided
- // segment.
- Segment* subdivide(Segment* segment)
- {
- Segment* left = segment->subdivide();
- if (m_first == segment)
- m_first = left;
- return left;
- }
-
- // Returns the first segment in the contour for iteration.
- Segment* begin() const { return m_first; }
-
- // Returns the last segment in the contour for iteration. Callers
- // should not iterate over this segment. In other words:
- // for (Segment* cur = contour->begin();
- // cur != contour->end();
- // cur = cur->next()) {
- // // .. process cur ...
- // }
- Segment* end()
- {
- ASSERT(m_first->prev() == &m_sentinel);
- return &m_sentinel;
- }
-
- bool isOrientedCounterClockwise() const { return m_isOrientedCounterClockwise; }
- void setIsOrientedCounterClockwise(bool isOrientedCounterClockwise) { m_isOrientedCounterClockwise = isOrientedCounterClockwise; }
-
- const FloatRect& boundingBox()
- {
- if (m_boundingBoxDirty) {
- bool first = true;
- for (Segment* cur = begin(); cur != end(); cur = cur->next()) {
- if (first)
- m_boundingBox = cur->boundingBox();
- else
- m_boundingBox.unite(cur->boundingBox());
- first = false;
- }
-
- m_boundingBoxDirty = false;
- }
- return m_boundingBox;
- }
-
- // Returns which side of this contour is filled.
- LoopBlinnConstants::FillSide fillSide() const
- {
- return m_fillSide;
- }
-
- void setFillSide(LoopBlinnConstants::FillSide fillSide)
- {
- m_fillSide = fillSide;
- }
-
-private:
- // The start of the segment chain. The segments are kept in a
- // circular doubly linked list for rapid access to the beginning and
- // end.
- Segment* m_first;
-
- // The sentinel element at the end of the chain, needed for
- // reasonable iteration semantics.
- Segment m_sentinel;
-
- bool m_isOrientedCounterClockwise;
-
- FloatRect m_boundingBox;
- bool m_boundingBoxDirty;
-
- // Which side of this contour should be filled.
- LoopBlinnConstants::FillSide m_fillSide;
-};
-
-//----------------------------------------------------------------------
-// Segment
-//
-
-// Definition of Segment::triangulate(), which must come after
-// declaration of Contour.
-void Segment::triangulate(LoopBlinnLocalTriangulator::InsideEdgeComputation computeInsideEdges,
- const LoopBlinnTextureCoords::Result* texCoords)
-{
- ASSERT(m_kind == Cubic);
- if (!m_triangulator)
- m_triangulator = m_arena->allocateObject<LoopBlinnLocalTriangulator>();
- m_triangulator->reset();
- for (int i = 0; i < 4; i++) {
- LoopBlinnLocalTriangulator::Vertex* vertex = m_triangulator->getVertex(i);
- if (texCoords) {
- vertex->set(getPoint(i).x(),
- getPoint(i).y(),
- texCoords->klmCoordinates[i].x(),
- texCoords->klmCoordinates[i].y(),
- texCoords->klmCoordinates[i].z());
- } else {
- vertex->set(getPoint(i).x(),
- getPoint(i).y(),
- // No texture coordinates yet
- 0, 0, 0);
- }
- }
- m_triangulator->triangulate(computeInsideEdges, contour()->fillSide());
-}
-
-} // namespace LoopBlinnPathProcessorImplementation
-
-//----------------------------------------------------------------------
-// LoopBlinnPathProcessor
-//
-
-LoopBlinnPathProcessor::LoopBlinnPathProcessor()
- : m_arena(PODArena::create())
-#ifndef NDEBUG
- , m_verboseLogging(false)
-#endif
-{
-}
-
-LoopBlinnPathProcessor::LoopBlinnPathProcessor(PassRefPtr<PODArena> arena)
- : m_arena(arena)
-#ifndef NDEBUG
- , m_verboseLogging(false)
-#endif
-{
-}
-
-LoopBlinnPathProcessor::~LoopBlinnPathProcessor()
-{
-}
-
-void LoopBlinnPathProcessor::process(const Path& path, LoopBlinnPathCache& cache)
-{
- buildContours(path);
-
- // Run plane-sweep algorithm to determine overlaps of control point
- // curves and subdivide curves appropriately.
- subdivideCurves();
-
- // Determine orientations of countours. Based on orientation and the
- // number of curve crossings at a random point on the contour,
- // determine whether to fill the left or right side of the contour.
- determineSidesToFill();
-
- // Classify curves, compute texture coordinates and subdivide as
- // necessary to eliminate rendering artifacts. Do the final
- // triangulation of the curve segments, determining the path along
- // the interior of the shape.
- for (Vector<Contour*>::iterator iter = m_contours.begin(); iter != m_contours.end(); ++iter) {
- Contour* cur = *iter;
- for (Segment* seg = cur->begin(); seg != cur->end(); seg = seg->next()) {
- if (seg->kind() == Segment::Cubic) {
- LoopBlinnClassifier::Result classification = LoopBlinnClassifier::classify(seg->getPoint(0),
- seg->getPoint(1),
- seg->getPoint(2),
- seg->getPoint(3));
-#ifndef NDEBUG
- if (m_verboseLogging)
- LOG_ERROR("Classification: %d", (int) classification.curveType);
-#endif
- LoopBlinnTextureCoords::Result texCoords =
- LoopBlinnTextureCoords::compute(classification, cur->fillSide());
- if (texCoords.hasRenderingArtifact) {
- // FIXME: there is a problem where the algorithm
- // sometimes fails to converge when splitting at the
- // subdivision parameter value. For the time being,
- // split halfway.
- cur->subdivide(seg);
- // Next iteration will handle the newly subdivided curves
- } else {
- if (!texCoords.isLineOrPoint) {
- seg->triangulate(LoopBlinnLocalTriangulator::ComputeInsideEdges, &texCoords);
- for (int i = 0; i < seg->numberOfTriangles(); i++) {
- LoopBlinnLocalTriangulator::Triangle* triangle = seg->getTriangle(i);
- for (int j = 0; j < 3; j++) {
- LoopBlinnLocalTriangulator::Vertex* vert = triangle->getVertex(j);
- cache.addVertex(vert->xyCoordinates().x(),
- vert->xyCoordinates().y(),
- vert->klmCoordinates().x(),
- vert->klmCoordinates().y(),
- vert->klmCoordinates().z());
- }
- }
-#ifdef LOOP_BLINN_PATH_CACHE_DEBUG_INTERIOR_EDGES
- // Show the end user the interior edges as well
- for (int i = 1; i < seg->numberOfInteriorVertices(); i++) {
- FloatPoint vert = seg->getInteriorVertex(i);
- // Duplicate previous vertex to be able to draw GL_LINES
- FloatPoint prev = seg->getInteriorVertex(i - 1);
- cache.addInteriorEdgeVertex(prev.x(), prev.y());
- cache.addInteriorEdgeVertex(vert.x(), vert.y());
- }
-#endif // LOOP_BLINN_PATH_CACHE_DEBUG_INTERIOR_EDGES
- }
- }
- }
- }
- }
-
- // Run the interior paths through a tessellation algorithm
- // supporting multiple contours.
- tessellateInterior(cache);
-}
-
-void LoopBlinnPathProcessor::buildContours(const Path& path)
-{
- // Clear out the contours
- m_contours.clear();
- if (path.isNull())
- return;
-
-#if USE(SKIA)
- SkPath::Iter iter(*path.platformPath(), false);
- SkPoint points[4];
- SkPath::Verb verb;
- Contour* contour = 0;
- SkPoint curPoint = { 0 };
- SkPoint moveToPoint = { 0 };
- do {
- verb = iter.next(points);
- if (verb != SkPath::kMove_Verb) {
- if (!contour) {
- contour = m_arena->allocateObject<Contour>();
- m_contours.append(contour);
- }
- }
- switch (verb) {
- case SkPath::kMove_Verb: {
- contour = m_arena->allocateObject<Contour>();
- m_contours.append(contour);
- curPoint = points[0];
- moveToPoint = points[0];
-#ifndef NDEBUG
- if (m_verboseLogging)
- LOG_ERROR("MoveTo (%f, %f)", points[0].fX, points[0].fY);
-#endif
- break;
- }
- case SkPath::kLine_Verb: {
- Segment* segment = m_arena->allocateObject<Segment>();
- if (iter.isCloseLine()) {
- segment->setup(m_arena.get(), contour, curPoint, points[1]);
-#ifndef NDEBUG
- if (m_verboseLogging)
- LOG_ERROR("CloseLineTo (%f, %f), (%f, %f)", curPoint.fX, curPoint.fY, points[1].fX, points[1].fY);
-#endif
- contour->add(segment);
- contour = 0;
- } else {
- segment->setup(m_arena.get(), contour, points[0], points[1]);
-#ifndef NDEBUG
- if (m_verboseLogging)
- LOG_ERROR("LineTo (%f, %f), (%f, %f)", points[0].fX, points[0].fY, points[1].fX, points[1].fY);
-#endif
- contour->add(segment);
- curPoint = points[1];
- }
- break;
- }
- case SkPath::kQuad_Verb: {
- // Need to degree elevate the quadratic into a cubic
- SkPoint cubic[4];
- SkConvertQuadToCubic(points, cubic);
- Segment* segment = m_arena->allocateObject<Segment>();
- segment->setup(m_arena.get(), contour,
- cubic[0], cubic[1], cubic[2], cubic[3]);
-#ifndef NDEBUG
- if (m_verboseLogging)
- LOG_ERROR("Quad->CubicTo (%f, %f), (%f, %f), (%f, %f), (%f, %f)", cubic[0].fX, cubic[0].fY, cubic[1].fX, cubic[1].fY, cubic[2].fX, cubic[2].fY, cubic[3].fX, cubic[3].fY);
-#endif
- contour->add(segment);
- curPoint = cubic[3];
- break;
- }
- case SkPath::kCubic_Verb: {
- Segment* segment = m_arena->allocateObject<Segment>();
- segment->setup(m_arena.get(), contour, points[0], points[1], points[2], points[3]);
-#ifndef NDEBUG
- if (m_verboseLogging)
- LOG_ERROR("CubicTo (%f, %f), (%f, %f), (%f, %f), (%f, %f)", points[0].fX, points[0].fY, points[1].fX, points[1].fY, points[2].fX, points[2].fY, points[3].fX, points[3].fY);
-#endif
- contour->add(segment);
- curPoint = points[3];
- break;
- }
- case SkPath::kClose_Verb: {
- Segment* segment = m_arena->allocateObject<Segment>();
- segment->setup(m_arena.get(), contour, curPoint, moveToPoint);
-#ifndef NDEBUG
- if (m_verboseLogging)
- LOG_ERROR("Close (%f, %f) -> (%f, %f)", curPoint.fX, curPoint.fY, moveToPoint.fX, moveToPoint.fY);
-#endif
- contour->add(segment);
- contour = 0;
- }
- case SkPath::kDone_Verb:
- break;
- }
- } while (verb != SkPath::kDone_Verb);
-#else // !USE(SKIA)
- UNUSED_PARAM(path);
- // Must port to your platform.
- ASSERT_NOT_REACHED();
-#endif
-}
-
-#ifndef NDEBUG
-Vector<Segment*> LoopBlinnPathProcessor::allSegmentsOverlappingY(Contour* queryContour, float x, float y)
-{
- Vector<Segment*> res;
- for (Vector<Contour*>::iterator iter = m_contours.begin(); iter != m_contours.end(); ++iter) {
- Contour* cur = *iter;
- for (Segment* seg = cur->begin(); seg != cur->end(); seg = seg->next()) {
- const FloatRect& boundingBox = seg->boundingBox();
- if (boundingBox.y() <= y && y <= boundingBox.maxY())
- res.append(seg);
- }
- }
- return res;
-}
-#endif
-
-// Uncomment this to debug the orientation computation.
-// #define GPU_PATH_PROCESSOR_DEBUG_ORIENTATION
-
-void LoopBlinnPathProcessor::determineSidesToFill()
-{
- // Loop and Blinn's algorithm can only easily emulate the even/odd
- // fill rule, and only for non-intersecting curves. We can determine
- // which side of each curve segment to fill based on its
- // clockwise/counterclockwise orientation and how many other
- // contours surround it.
-
- // To optimize the query of all curve segments intersecting a
- // horizontal line going to x=+infinity, we build up an interval
- // tree whose keys are the y extents of the segments.
- PODIntervalTree<float, Segment*> tree(m_arena);
- typedef PODIntervalTree<float, Segment*>::IntervalType IntervalType;
-
- for (Vector<Contour*>::iterator iter = m_contours.begin(); iter != m_contours.end(); ++iter) {
- Contour* cur = *iter;
- determineOrientation(cur);
- for (Segment* seg = cur->begin(); seg != cur->end(); seg = seg->next()) {
- const FloatRect& boundingBox = seg->boundingBox();
- tree.add(tree.createInterval(boundingBox.y(), boundingBox.maxY(), seg));
- }
- }
-
- // Now iterate through the contours and pick a random segment (in
- // this case we use the first) and a random point on that segment.
- // Find all segments from other contours which intersect this one
- // and count the number of crossings a horizontal line to
- // x=+infinity makes with those contours. This combined with the
- // orientation of the curve tells us which side to fill -- again,
- // assuming an even/odd fill rule, which is all we can easily
- // handle.
- for (Vector<Contour*>::iterator iter = m_contours.begin(); iter != m_contours.end(); ++iter) {
- Contour* cur = *iter;
-
- bool ambiguous = true;
- int numCrossings = 0;
-
- // For each contour, attempt to find a point on the contour which,
- // when we cast an XRay, does not intersect the other contours at
- // an ambiguous point (the junction between two curves or at a
- // tangent point). Ambiguous points make the determination of
- // whether this contour is contained within another fragile. Note
- // that this loop is only an approximation to the selection of a
- // good casting point. We could as well evaluate a segment to
- // determine a point upon it.
- for (Segment* seg = cur->begin();
- ambiguous && seg != cur->end();
- seg = seg->next()) {
- numCrossings = 0;
- // We use a zero-sized vertical interval for the query.
- Vector<IntervalType> overlaps = tree.allOverlaps(tree.createInterval(seg->getPoint(0).y(),
- seg->getPoint(0).y(),
- 0));
-#if defined(GPU_PATH_PROCESSOR_DEBUG_ORIENTATION) && !defined(NDEBUG)
- Vector<Segment*> slowOverlaps = allSegmentsOverlappingY(cur, seg->getPoint(0).x(), seg->getPoint(0).y());
- if (overlaps.size() != slowOverlaps.size()) {
- LOG_ERROR("For query point (%f, %f) on contour 0x%p:", seg->getPoint(0).x(), seg->getPoint(0).y(), cur);
- LOG_ERROR(" overlaps:");
- for (size_t i = 0; i < overlaps.size(); i++)
- LOG_ERROR(" %d: %s", i+1, overlaps[i].data()->toString().ascii().data());
- LOG_ERROR(" slowOverlaps:");
- for (size_t i = 0; i < slowOverlaps.size(); i++)
- LOG_ERROR(" %d: %s", (i+1) slowOverlaps[i]->toString());
- LOG_ERROR("Interval tree:");
- tree.dump();
- }
- ASSERT(overlaps.size() == slowOverlaps.size());
-#endif // defined(GPU_PATH_PROCESSOR_DEBUG_ORIENTATION) && !defined(NDEBUG)
- for (Vector<IntervalType>::iterator iter = overlaps.begin(); iter != overlaps.end(); ++iter) {
- const IntervalType& interval = *iter;
- Segment* querySegment = interval.data();
- // Ignore segments coming from the same contour.
- if (querySegment->contour() != cur) {
- // Only perform queries that can affect the computation.
- const FloatRect& boundingBox = querySegment->contour()->boundingBox();
- if (seg->getPoint(0).x() >= boundingBox.x()
- && seg->getPoint(0).x() <= boundingBox.maxX()) {
- numCrossings += querySegment->numCrossingsForXRay(seg->getPoint(0),
- ambiguous);
- if (ambiguous) {
-#ifndef NDEBUG
- if (m_verboseLogging) {
- LOG_ERROR("Ambiguous intersection query at point (%f, %f)", seg->getPoint(0).x(), seg->getPoint(0).y());
- LOG_ERROR("Query segment: %s", querySegment->toString().ascii().data());
- }
-#endif
- break; // Abort iteration over overlaps.
- }
- }
- }
- }
- } // for (Segment* seg = cur->begin(); ...
-
- cur->setFillSide((cur->isOrientedCounterClockwise() ^ (numCrossings & 1)) ? LoopBlinnConstants::LeftSide : LoopBlinnConstants::RightSide);
- }
-}
-
-void LoopBlinnPathProcessor::determineOrientation(Contour* contour)
-{
- // Determine signed area of the polygon represented by the points
- // along the segments. Consider this an approximation to the true
- // orientation of the polygon; it probably won't handle
- // self-intersecting curves correctly.
- //
- // There is also a pretty basic assumption here that the contour is
- // closed.
- float signedArea = 0;
- for (Segment* seg = contour->begin();
- seg != contour->end();
- seg = seg->next()) {
- int limit = (seg->kind() == Segment::Cubic) ? 4 : 2;
- for (int i = 1; i < limit; i++) {
- const FloatPoint& prevPoint = seg->getPoint(i - 1);
- const FloatPoint& point = seg->getPoint(i);
- float curArea = prevPoint.x() * point.y() - prevPoint.y() * point.x();
-#ifndef NDEBUG
- if (m_verboseLogging)
- LOG_ERROR("Adding to signed area (%f, %f) -> (%f, %f) = %f", prevPoint.x(), prevPoint.y(), point.x(), point.y(), curArea);
-#endif
- signedArea += curArea;
- }
- }
-
- if (signedArea > 0)
- contour->setIsOrientedCounterClockwise(true);
- else
- contour->setIsOrientedCounterClockwise(false);
-}
-
-namespace {
-
-//----------------------------------------------------------------------
-// Classes and typedefs needed for curve subdivision. These can't be scoped
-// within the subdivideCurves() method itself, because templates then fail
-// to instantiate.
-
-// The user data which is placed in the PODIntervalTree.
-struct SweepData {
- SweepData()
- : triangle(0)
- , segment(0)
- {
- }
-
- // The triangle this interval is associated with
- LoopBlinnLocalTriangulator::Triangle* triangle;
- // The segment the triangle is associated with
- Segment* segment;
-};
-
-typedef PODIntervalTree<float, SweepData*> SweepTree;
-typedef SweepTree::IntervalType SweepInterval;
-
-// The entry / exit events which occur at the minimum and maximum x
-// coordinates of the control point triangles' bounding boxes.
-//
-// Note that this class requires its copy constructor and assignment
-// operator since it needs to be stored in a Vector.
-class SweepEvent {
-public:
- SweepEvent()
- : m_x(0)
- , m_entry(false)
- , m_interval(0, 0, 0)
- {
- }
-
- // Initializes the SweepEvent.
- void setup(float x, bool entry, SweepInterval interval)
- {
- m_x = x;
- m_entry = entry;
- m_interval = interval;
- }
-
- float x() const { return m_x; }
- bool entry() const { return m_entry; }
- const SweepInterval& interval() const { return m_interval; }
-
- bool operator<(const SweepEvent& other) const
- {
- return m_x < other.m_x;
- }
-
-private:
- float m_x;
- bool m_entry;
- SweepInterval m_interval;
-};
-
-bool trianglesOverlap(LoopBlinnLocalTriangulator::Triangle* t0,
- LoopBlinnLocalTriangulator::Triangle* t1)
-{
- return trianglesOverlap(t0->getVertex(0)->xyCoordinates(),
- t0->getVertex(1)->xyCoordinates(),
- t0->getVertex(2)->xyCoordinates(),
- t1->getVertex(0)->xyCoordinates(),
- t1->getVertex(1)->xyCoordinates(),
- t1->getVertex(2)->xyCoordinates());
-}
-
-} // anonymous namespace
-
-void LoopBlinnPathProcessor::subdivideCurves()
-{
- // We need to determine all overlaps of all control point triangles
- // (from different segments, not the same segment) and, if any
- // exist, subdivide the associated curves.
- //
- // The plane-sweep algorithm determines all overlaps of a set of
- // rectangles in the 2D plane. Our problem maps very well to this
- // algorithm and significantly reduces the complexity compared to a
- // naive implementation.
- //
- // Each bounding box of a control point triangle is converted into
- // an "entry" event at its smallest X coordinate and an "exit" event
- // at its largest X coordinate. Each event has an associated
- // one-dimensional interval representing the Y span of the bounding
- // box. We sort these events by increasing X coordinate. We then
- // iterate through them. For each entry event we add the interval to
- // a side interval tree, and query this tree for overlapping
- // intervals. Any overlapping interval corresponds to an overlapping
- // bounding box. For each exit event we remove the associated
- // interval from the interval tree.
-
- Vector<Segment*> curSegments;
- Vector<Segment*> nextSegments;
-
- // Start things off by considering all of the segments
- for (Vector<Contour*>::iterator iter = m_contours.begin(); iter != m_contours.end(); ++iter) {
- Contour* cur = *iter;
- for (Segment* seg = cur->begin(); seg != cur->end(); seg = seg->next()) {
- if (seg->kind() == Segment::Cubic) {
- seg->triangulate(LoopBlinnLocalTriangulator::DontComputeInsideEdges, 0);
- curSegments.append(seg);
- }
- }
- }
-
- // Subdivide curves at most this many times
- const int MaxIterations = 5;
- Vector<SweepInterval> overlaps;
-
- for (int currentIteration = 0; currentIteration < MaxIterations; ++currentIteration) {
- if (!curSegments.size())
- // Done
- break;
-
- Vector<SweepEvent> events;
- SweepTree tree(m_arena);
- for (Vector<Segment*>::iterator iter = curSegments.begin(); iter != curSegments.end(); ++iter) {
- Segment* seg = *iter;
- ASSERT(seg->kind() == Segment::Cubic);
- for (int i = 0; i < seg->numberOfTriangles(); i++) {
- LoopBlinnLocalTriangulator::Triangle* triangle = seg->getTriangle(i);
- FloatRect boundingBox;
- boundingBox.fitToPoints(triangle->getVertex(0)->xyCoordinates(),
- triangle->getVertex(1)->xyCoordinates(),
- triangle->getVertex(2)->xyCoordinates());
- // Ignore zero-width triangles to avoid issues with
- // coincident entry and exit events for the same triangle
- if (boundingBox.maxX() > boundingBox.x()) {
- SweepData* data = m_arena->allocateObject<SweepData>();
- data->triangle = triangle;
- data->segment = seg;
- SweepInterval interval = tree.createInterval(boundingBox.y(), boundingBox.maxY(), data);
- // Add entry and exit events
- SweepEvent event;
- event.setup(boundingBox.x(), true, interval);
- events.append(event);
- event.setup(boundingBox.maxX(), false, interval);
- events.append(event);
- }
- }
- }
-
- // Sort events by increasing X coordinate
- std::sort(events.begin(), events.end());
-#ifndef NDEBUG
- for (size_t ii = 1; ii < events.size(); ++ii)
- ASSERT(events[ii - 1].x() <= events[ii].x());
-#endif
-
- // Now iterate through the events
- for (Vector<SweepEvent>::iterator iter = events.begin(); iter != events.end(); ++iter) {
- SweepEvent event = *iter;
- if (event.entry()) {
- // See whether the associated segment has been subdivided yet
- if (!event.interval().data()->segment->markedForSubdivision()) {
- // Query the tree
- overlaps.clear();
- tree.allOverlaps(event.interval(), overlaps);
- // Now see exactly which triangles overlap this one
- for (Vector<SweepInterval>::iterator iter = overlaps.begin(); iter != overlaps.end(); ++iter) {
- SweepInterval overlap = *iter;
- // Only pay attention to overlaps from a different Segment
- if (event.interval().data()->segment != overlap.data()->segment) {
- // See whether the triangles actually overlap
- if (trianglesOverlap(event.interval().data()->triangle,
- overlap.data()->triangle)) {
- // Actually subdivide the segments.
- // Each one might already have been subdivided.
- Segment* seg = event.interval().data()->segment;
- conditionallySubdivide(seg, nextSegments);
- seg = overlap.data()->segment;
- conditionallySubdivide(seg, nextSegments);
- }
- }
- }
- }
- // Add this interval into the tree
- tree.add(event.interval());
- } else {
- // Remove this interval from the tree
- tree.remove(event.interval());
- }
- }
-
- curSegments.swap(nextSegments);
- nextSegments.clear();
- }
-}
-
-void LoopBlinnPathProcessor::conditionallySubdivide(Segment* seg, Vector<Segment*>& nextSegments)
-{
- if (!seg->markedForSubdivision()) {
- seg->setMarkedForSubdivision(true);
- Segment* next = seg->contour()->subdivide(seg);
- // Triangulate the newly subdivided segments.
- next->triangulate(LoopBlinnLocalTriangulator::DontComputeInsideEdges, 0);
- next->next()->triangulate(LoopBlinnLocalTriangulator::DontComputeInsideEdges, 0);
- // Add them for the next iteration.
- nextSegments.append(next);
- nextSegments.append(next->next());
- }
-}
-
-#ifndef NDEBUG
-void LoopBlinnPathProcessor::subdivideCurvesSlow()
-{
- // Alternate, significantly slower algorithm for curve subdivision
- // for use in debugging.
- Vector<Segment*> curSegments;
- Vector<Segment*> nextSegments;
-
- // Start things off by considering all of the segments
- for (Vector<Contour*>::iterator iter = m_contours.begin(); iter != m_contours.end(); ++iter) {
- Contour* cur = *iter;
- for (Segment* seg = cur->begin(); seg != cur->end(); seg = seg->next()) {
- if (seg->kind() == Segment::Cubic) {
- seg->triangulate(LoopBlinnLocalTriangulator::DontComputeInsideEdges, 0);
- curSegments.append(seg);
- }
- }
- }
-
- // Subdivide curves at most this many times
- const int MaxIterations = 5;
-
- for (int currentIteration = 0; currentIteration < MaxIterations; ++currentIteration) {
- if (!curSegments.size())
- // Done
- break;
-
- for (Vector<Segment*>::iterator iter = curSegments.begin(); iter != curSegments.end(); ++iter) {
- Segment* seg = *iter;
- ASSERT(seg->kind() == Segment::Cubic);
- for (Vector<Segment*>::iterator iter2 = curSegments.begin();
- iter2 != curSegments.end();
- iter2++) {
- Segment* seg2 = *iter2;
- ASSERT(seg2->kind() == Segment::Cubic);
- if (seg != seg2) {
- for (int i = 0; i < seg->numberOfTriangles(); i++) {
- LoopBlinnLocalTriangulator::Triangle* triangle = seg->getTriangle(i);
- for (int j = 0; j < seg2->numberOfTriangles(); j++) {
- LoopBlinnLocalTriangulator::Triangle* triangle2 = seg2->getTriangle(j);
- if (trianglesOverlap(triangle, triangle2)) {
- conditionallySubdivide(seg, nextSegments);
- conditionallySubdivide(seg2, nextSegments);
- }
- }
- }
- }
- }
- }
-
- curSegments.swap(nextSegments);
- nextSegments.clear();
- }
-}
-#endif
-
-namespace {
-
-//----------------------------------------------------------------------
-// Structures and callbacks for tessellation of the interior region of
-// the contours.
-
-// The user data for the GLU tessellator.
-struct TessellationState {
- TessellationState(LoopBlinnPathCache& inputCache)
- : cache(inputCache) { }
-
- LoopBlinnPathCache& cache;
- Vector<void*> allocatedPointers;
-};
-
-static void vertexCallback(void* vertexData, void* data)
-{
- TessellationState* state = static_cast<TessellationState*>(data);
- GLdouble* location = static_cast<GLdouble*>(vertexData);
- state->cache.addInteriorVertex(static_cast<float>(location[0]),
- static_cast<float>(location[1]));
-}
-
-static void combineCallback(GLdouble coords[3], void* vertexData[4],
- GLfloat weight[4], void** outData,
- void* polygonData)
-{
- UNUSED_PARAM(vertexData);
- UNUSED_PARAM(weight);
- TessellationState* state = static_cast<TessellationState*>(polygonData);
- GLdouble* outVertex = static_cast<GLdouble*>(fastMalloc(3 * sizeof(GLdouble)));
- state->allocatedPointers.append(outVertex);
- outVertex[0] = coords[0];
- outVertex[1] = coords[1];
- outVertex[2] = coords[2];
- *outData = outVertex;
-}
-
-static void edgeFlagCallback(GLboolean)
-{
- // No-op just to prevent triangle strips and fans from being passed to us.
- // See the OpenGL Programming Guide, Chapter 11, "Tessellators and Quadrics".
-}
-
-} // anonymous namespace
-
-void LoopBlinnPathProcessor::tessellateInterior(LoopBlinnPathCache& cache)
-{
- // Because the GLU tessellator requires its input in
- // double-precision format, we need to make a separate copy of the
- // data.
- Vector<GLdouble> vertexData;
- Vector<size_t> contourEndings;
- // For avoiding adding coincident vertices.
- float curX = 0, curY = 0;
- for (Vector<Contour*>::iterator iter = m_contours.begin(); iter != m_contours.end(); ++iter) {
- Contour* cur = *iter;
- bool first = true;
- for (Segment* seg = cur->begin(); seg != cur->end(); seg = seg->next()) {
- int numberOfInteriorVertices = seg->numberOfInteriorVertices();
- for (int i = 0; i < numberOfInteriorVertices - 1; i++) {
- FloatPoint point = seg->getInteriorVertex(i);
- if (first) {
- first = false;
- vertexData.append(point.x());
- vertexData.append(point.y());
- vertexData.append(0);
- curX = point.x();
- curY = point.y();
- } else if (point.x() != curX || point.y() != curY) {
- vertexData.append(point.x());
- vertexData.append(point.y());
- vertexData.append(0);
- curX = point.x();
- curY = point.y();
- }
- }
- }
- contourEndings.append(vertexData.size());
- }
- // Now that we have all of the vertex data in a stable location in
- // memory, call the tessellator.
- GLUtesselator* tess = internal_gluNewTess();
- TessellationState state(cache);
- internal_gluTessCallback(tess, GLU_TESS_VERTEX_DATA,
- reinterpret_cast<GLvoid (*)()>(vertexCallback));
- internal_gluTessCallback(tess, GLU_TESS_COMBINE_DATA,
- reinterpret_cast<GLvoid (*)()>(combineCallback));
- internal_gluTessCallback(tess, GLU_TESS_EDGE_FLAG,
- reinterpret_cast<GLvoid (*)()>(edgeFlagCallback));
- internal_gluTessBeginPolygon(tess, &state);
- internal_gluTessBeginContour(tess);
- GLdouble* base = vertexData.data();
- int contourIndex = 0;
- for (size_t i = 0; i < vertexData.size(); i += 3) {
- if (i == contourEndings[contourIndex]) {
- internal_gluTessEndContour(tess);
- internal_gluTessBeginContour(tess);
- ++contourIndex;
- }
- internal_gluTessVertex(tess, &base[i], &base[i]);
- }
- internal_gluTessEndContour(tess);
- internal_gluTessEndPolygon(tess);
- for (size_t i = 0; i < state.allocatedPointers.size(); i++)
- fastFree(state.allocatedPointers[i]);
- internal_gluDeleteTess(tess);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/gpu/LoopBlinnShader.cpp b/Source/WebCore/platform/graphics/gpu/LoopBlinnShader.cpp
index 364e6c805..5d9fdc883 100644
--- a/Source/WebCore/platform/graphics/gpu/LoopBlinnShader.cpp
+++ b/Source/WebCore/platform/graphics/gpu/LoopBlinnShader.cpp
@@ -45,7 +45,7 @@ void LoopBlinnShader::use(unsigned vertexOffset, unsigned klmOffset, const Affin
float matrix[16];
affineTo4x4(transform, matrix);
- m_context->uniformMatrix4fv(m_worldViewProjectionLocation, false /*transpose*/, matrix, 1 /*count*/);
+ m_context->uniformMatrix4fv(m_worldViewProjectionLocation, 1 /*count*/, false /*transpose*/, matrix);
m_context->vertexAttribPointer(m_positionLocation, 2, GraphicsContext3D::FLOAT, false, 0, vertexOffset);
m_context->enableVertexAttribArray(m_positionLocation);
diff --git a/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp b/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp
index 58a16b4ac..8b98e7805 100644
--- a/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp
+++ b/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp
@@ -38,12 +38,12 @@ public:
SharedGraphicsContext3DImpl() : m_context(0) { }
PassRefPtr<GraphicsContext3D> getOrCreateContext()
{
+ bool wasCreated = false;
+
// If we lost the context, or can't make it current, create a new one.
if (m_context && (!m_context->makeContextCurrent() || (m_context->getExtensions()->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERROR)))
m_context.clear();
- bool wasCreated = false;
-
if (!m_context) {
createContext();
wasCreated = true;
@@ -54,7 +54,6 @@ public:
if (m_context && wasCreated)
m_context->getExtensions()->pushGroupMarkerEXT("SharedGraphicsContext");
-
return m_context;
}
@@ -70,7 +69,6 @@ public:
attributes.stencil = true;
attributes.antialias = false;
attributes.shareResources = true;
- attributes.preferDiscreteGPU = true;
m_context = GraphicsContext3D::create(attributes, 0);
return m_context;
}
@@ -96,7 +94,6 @@ static PassRefPtr<GraphicsContext3D> getOrCreateContextForImplThread(ContextOper
PassRefPtr<GraphicsContext3D> SharedGraphicsContext3D::getForImplThread()
{
- ASSERT(!isMainThread());
return getOrCreateContextForImplThread(Get);
}
diff --git a/Source/WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm b/Source/WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm
index 40dc2a51e..51c2657f1 100644
--- a/Source/WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm
+++ b/Source/WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm
@@ -70,7 +70,7 @@ DrawingBuffer::DrawingBuffer(GraphicsContext3D* context,
// Create the WebGLLayer
BEGIN_BLOCK_OBJC_EXCEPTIONS
- m_platformLayer.adoptNS([[WebGLLayer alloc] initWithGraphicsContext3D:m_context.get()]);
+ m_platformLayer = adoptNS([[WebGLLayer alloc] initWithGraphicsContext3D:m_context.get()]);
#ifndef NDEBUG
[m_platformLayer.get() setName:@"DrawingBuffer Layer"];
#endif
@@ -100,15 +100,6 @@ PlatformLayer* DrawingBuffer::platformLayer()
return m_platformLayer.get();
}
-void DrawingBuffer::prepareBackBuffer()
-{
-}
-
-bool DrawingBuffer::requiresCopyFromBackToFrontBuffer() const
-{
- return false;
-}
-
unsigned DrawingBuffer::frontColorBuffer() const
{
return colorBuffer();
diff --git a/Source/WebCore/platform/graphics/gpu/opencl/FilterContextOpenCL.cpp b/Source/WebCore/platform/graphics/gpu/opencl/FilterContextOpenCL.cpp
index 9dcafe762..cba666985 100644
--- a/Source/WebCore/platform/graphics/gpu/opencl/FilterContextOpenCL.cpp
+++ b/Source/WebCore/platform/graphics/gpu/opencl/FilterContextOpenCL.cpp
@@ -88,6 +88,46 @@ FilterContextOpenCL* FilterContextOpenCL::context()
return m_context;
}
+void FilterContextOpenCL::freeResources()
+{
+ clFinish(m_commandQueue);
+
+ if (m_colorMatrixWasCompiled) {
+ freeResource(m_matrixOperation);
+ freeResource(m_saturateAndHueRotateOperation);
+ freeResource(m_luminanceOperation);
+ freeResource(m_colorMatrixProgram);
+ }
+ m_colorMatrixWasCompiled = false;
+
+ if (m_turbulenceWasCompiled) {
+ freeResource(m_turbulenceOperation);
+ freeResource(m_turbulenceProgram);
+ }
+ m_turbulenceWasCompiled = false;
+
+ if (m_transformColorSpaceWasCompiled) {
+ freeResource(m_transformColorSpaceKernel);
+ freeResource(m_transformColorSpaceProgram);
+ }
+ m_transformColorSpaceWasCompiled = false;
+}
+
+void FilterContextOpenCL::destroyContext()
+{
+ freeResources();
+
+ if (m_commandQueue)
+ clReleaseCommandQueue(m_commandQueue);
+ m_commandQueue = 0;
+
+ if (m_deviceContext)
+ clReleaseContext(m_deviceContext);
+ m_deviceContext = 0;
+
+ m_context = 0;
+}
+
OpenCLHandle FilterContextOpenCL::createOpenCLImage(IntSize paintSize)
{
FilterContextOpenCL* context = FilterContextOpenCL::context();
@@ -96,13 +136,18 @@ OpenCLHandle FilterContextOpenCL::createOpenCLImage(IntSize paintSize)
clImageFormat.image_channel_order = CL_RGBA;
clImageFormat.image_channel_data_type = CL_UNORM_INT8;
+#ifdef CL_API_SUFFIX__VERSION_1_2
+ cl_image_desc imageDescriptor = { CL_MEM_OBJECT_IMAGE2D, paintSize.width(), paintSize.height(), 0, 0, 0, 0, 0, 0, 0};
+ OpenCLHandle image = clCreateImage(context->deviceContext(), CL_MEM_READ_WRITE, &clImageFormat, &imageDescriptor, 0, 0);
+#else
OpenCLHandle image = clCreateImage2D(context->deviceContext(), CL_MEM_READ_WRITE, &clImageFormat,
paintSize.width(), paintSize.height(), 0, 0, 0);
+#endif
return image;
}
static const char* transformColorSpaceKernelProgram =
-PROGRAM_STR(
+PROGRAM(
const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;
__kernel void transformColorSpace(__read_only image2d_t source, __write_only image2d_t destination, __constant float *clLookUpTable)
@@ -110,38 +155,45 @@ __kernel void transformColorSpace(__read_only image2d_t source, __write_only ima
int2 sourceCoord = (int2) (get_global_id(0), get_global_id(1));
float4 pixel = read_imagef(source, sampler, sourceCoord);
- pixel = (float4)(clLookUpTable[(int)(round(pixel.x * 255))], clLookUpTable[(int)(round(pixel.y * 255))],
- clLookUpTable[(int)(round(pixel.z * 255))], pixel.w);
+ pixel = (float4) (clLookUpTable[(int)(round(pixel.x * 255))], clLookUpTable[(int)(round(pixel.y * 255))],
+ clLookUpTable[(int) (round(pixel.z * 255))], pixel.w);
write_imagef(destination, sourceCoord, pixel);
}
-);
+); // End of OpenCL kernels
+
+inline bool FilterContextOpenCL::compileTransformColorSpaceProgram()
+{
+ if (m_transformColorSpaceWasCompiled || inError())
+ return !inError();
+
+ m_transformColorSpaceWasCompiled = true;
+
+ if (isResourceAllocationFailed((m_transformColorSpaceProgram = compileProgram(transformColorSpaceKernelProgram))))
+ return false;
+ if (isResourceAllocationFailed((m_transformColorSpaceKernel = kernelByName(m_transformColorSpaceProgram, "transformColorSpace"))))
+ return false;
+ return true;
+}
void FilterContextOpenCL::openCLTransformColorSpace(OpenCLHandle& source, IntRect sourceSize, ColorSpace srcColorSpace, ColorSpace dstColorSpace)
{
DEFINE_STATIC_LOCAL(OpenCLHandle, deviceRgbLUT, ());
DEFINE_STATIC_LOCAL(OpenCLHandle, linearRgbLUT, ());
- if (srcColorSpace == dstColorSpace)
+ if (srcColorSpace == dstColorSpace || inError())
return;
if ((srcColorSpace != ColorSpaceLinearRGB && srcColorSpace != ColorSpaceDeviceRGB)
|| (dstColorSpace != ColorSpaceLinearRGB && dstColorSpace != ColorSpaceDeviceRGB))
return;
- FilterContextOpenCL* context = FilterContextOpenCL::context();
- ASSERT(context);
+ if (!compileTransformColorSpaceProgram())
+ return;
- OpenCLHandle destination = context->createOpenCLImage(sourceSize.size());
+ OpenCLHandle destination = createOpenCLImage(sourceSize.size());
- if (!m_transformColorSpaceProgram) {
- m_transformColorSpaceProgram = compileProgram(transformColorSpaceKernelProgram);
- ASSERT(m_transformColorSpaceProgram);
- m_transformColorSpaceKernel = kernelByName(m_transformColorSpaceProgram, "transformColorSpace");
- ASSERT(m_transformColorSpaceKernel);
- }
-
- RunKernel kernel(context, m_transformColorSpaceKernel, sourceSize.width(), sourceSize.height());
+ RunKernel kernel(this, m_transformColorSpaceKernel, sourceSize.width(), sourceSize.height());
kernel.addArgument(source);
kernel.addArgument(destination);
@@ -178,21 +230,79 @@ void FilterContextOpenCL::openCLTransformColorSpace(OpenCLHandle& source, IntRec
source = destination;
}
+static const char* fillKernelProgram =
+PROGRAM_STR(
+__kernel void fill(__write_only image2d_t destination, float r, float g, float b, float a)
+{
+ float4 sourcePixel = (float4)(r, g, b, a);
+ write_imagef(destination, (int2)(get_global_id(0), get_global_id(1)), sourcePixel);
+}
+);
+
+inline bool FilterContextOpenCL::compileFill()
+{
+ if (m_fillWasCompiled || inError())
+ return !inError();
+
+ m_fillWasCompiled = true;
+
+ if (isResourceAllocationFailed((m_fillProgram = compileProgram(fillKernelProgram))))
+ return false;
+ if (isResourceAllocationFailed((m_fill = kernelByName(m_fillProgram, "fill"))))
+ return false;
+ return true;
+}
+
+void FilterContextOpenCL::fill(cl_mem image, IntSize imageSize, Color color)
+{
+ if (!m_context || inError())
+ return;
+
+ compileFill();
+
+ float r, g, b, a;
+
+ color.getRGBA(r, g, b, a);
+
+ RunKernel kernel(this, m_fill, imageSize.width(), imageSize.height());
+ kernel.addArgument(image);
+ kernel.addArgument(r);
+ kernel.addArgument(g);
+ kernel.addArgument(b);
+ kernel.addArgument(a);
+ kernel.run();
+}
+
cl_program FilterContextOpenCL::compileProgram(const char* source)
{
cl_program program;
- cl_int errorNumber;
+ cl_int errorNumber = 0;
- FilterContextOpenCL* context = FilterContextOpenCL::context();
- ASSERT(context);
+ program = clCreateProgramWithSource(m_deviceContext, 1, (const char**) &source, 0, &errorNumber);
+ if (isFailed(errorNumber))
+ return 0;
- program = clCreateProgramWithSource(context->m_deviceContext, 1, (const char**) &source, 0, 0);
- errorNumber = clBuildProgram(program, 0, 0, 0, 0, 0);
- if (errorNumber)
+ if (isFailed(clBuildProgram(program, 0, 0, 0, 0, 0)))
return 0;
return program;
}
+
+void FilterContextOpenCL::freeResource(cl_kernel& handle)
+{
+ if (handle) {
+ clReleaseKernel(handle);
+ handle = 0;
+ }
+}
+
+void FilterContextOpenCL::freeResource(cl_program& handle)
+{
+ if (handle) {
+ clReleaseProgram(handle);
+ handle = 0;
+ }
+}
} // namespace WebCore
#endif
diff --git a/Source/WebCore/platform/graphics/gpu/opencl/FilterContextOpenCL.h b/Source/WebCore/platform/graphics/gpu/opencl/FilterContextOpenCL.h
index d4fbf3a47..38de75805 100644
--- a/Source/WebCore/platform/graphics/gpu/opencl/FilterContextOpenCL.h
+++ b/Source/WebCore/platform/graphics/gpu/opencl/FilterContextOpenCL.h
@@ -44,12 +44,26 @@ namespace WebCore {
class FilterContextOpenCL {
public:
FilterContextOpenCL()
- : m_deviceId(0)
+ : m_inError(false)
+ , m_deviceId(0)
, m_deviceContext(0)
, m_commandQueue(0)
+ , m_transformColorSpaceWasCompiled(false)
, m_transformColorSpaceProgram(0)
, m_transformColorSpaceKernel(0)
- , m_turbulenceCompileStatus(openclNotCompiledYet)
+ , m_fillWasCompiled(false)
+ , m_fillProgram(0)
+ , m_fill(0)
+ , m_mergeWasCompiled(false)
+ , m_mergeProgram(0)
+ , m_mergeCopyOperation(0)
+ , m_mergeOperation(0)
+ , m_colorMatrixWasCompiled(false)
+ , m_colorMatrixProgram(0)
+ , m_matrixOperation(0)
+ , m_saturateAndHueRotateOperation(0)
+ , m_luminanceOperation(0)
+ , m_turbulenceWasCompiled(false)
, m_turbulenceProgram(0)
, m_turbulenceOperation(0)
{
@@ -62,13 +76,31 @@ public:
cl_context deviceContext() { return m_deviceContext; }
cl_command_queue commandQueue() { return m_commandQueue; }
+ inline void setInError(bool errorCode = true) { m_inError = errorCode; }
+ inline bool inError() { return m_inError; }
+ inline bool isFailed(bool);
+ inline bool isResourceAllocationFailed(bool);
+
+ void freeResources();
+ void destroyContext();
+
OpenCLHandle createOpenCLImage(IntSize);
+
+ inline bool compileFill();
+ void fill(cl_mem, IntSize, Color);
+
+ inline bool compileTransformColorSpaceProgram();
void openCLTransformColorSpace(OpenCLHandle&, IntRect, ColorSpace, ColorSpace);
+ inline bool compileFEColorMatrix();
inline bool compileFETurbulence();
+ inline bool compileFEMerge();
+ inline void applyFEMergeCopy(OpenCLHandle, IntSize, OpenCLHandle, IntPoint&);
+ inline void applyFEMerge(OpenCLHandle, OpenCLHandle, OpenCLHandle, OpenCLHandle, IntSize, IntPoint&, IntPoint&);
+ inline void applyFEColorMatrix(OpenCLHandle, IntSize, OpenCLHandle, IntPoint, float*, int);
inline void applyFETurbulence(OpenCLHandle, IntSize, int, void*, void*, void*, void*, void*,
- void*, int, int, int, int, float, float, bool, int, int);
+ int*, int, int, int, int, float, float, bool, int, int);
private:
@@ -77,7 +109,8 @@ private:
RunKernel(FilterContextOpenCL* context, cl_kernel kernel, size_t width, size_t height)
: m_context(context)
, m_kernel(kernel)
- , index(0)
+ , m_index(0)
+ , m_error(context->inError())
{
m_globalSize[0] = width;
m_globalSize[1] = height;
@@ -85,68 +118,112 @@ private:
void addArgument(OpenCLHandle handle)
{
- clSetKernelArg(m_kernel, index++, sizeof(OpenCLHandle), handle.handleAddress());
+ if (!m_error)
+ m_error = clSetKernelArg(m_kernel, m_index++, sizeof(OpenCLHandle), handle.handleAddress());
}
void addArgument(cl_int value)
{
- clSetKernelArg(m_kernel, index++, sizeof(cl_int), reinterpret_cast<void*>(&value));
+ if (!m_error)
+ m_error = clSetKernelArg(m_kernel, m_index++, sizeof(cl_int), reinterpret_cast<void*>(&value));
}
void addArgument(cl_float value)
{
- clSetKernelArg(m_kernel, index++, sizeof(cl_float), reinterpret_cast<void*>(&value));
+ if (!m_error)
+ m_error = clSetKernelArg(m_kernel, m_index++, sizeof(cl_float), reinterpret_cast<void*>(&value));
}
void addArgument(cl_sampler handle)
{
- clSetKernelArg(m_kernel, index++, sizeof(cl_sampler), reinterpret_cast<void*>(&handle));
+ if (!m_error)
+ m_error = clSetKernelArg(m_kernel, m_index++, sizeof(cl_sampler), reinterpret_cast<void*>(&handle));
}
OpenCLHandle addArgument(void* buffer, int size)
{
- OpenCLHandle handle(clCreateBuffer(m_context->deviceContext(), CL_MEM_READ_ONLY, size, 0, 0));
- clEnqueueWriteBuffer(m_context->commandQueue(), handle, CL_TRUE, 0, size, buffer, 0, 0, 0);
- clSetKernelArg(m_kernel, index++, sizeof(OpenCLHandle), handle.handleAddress());
- return handle;
+ if (m_error)
+ return 0;
+ OpenCLHandle handle(clCreateBuffer(m_context->deviceContext(), CL_MEM_READ_ONLY, size, 0, &m_error));
+ if (m_error)
+ return 0;
+ m_error = clEnqueueWriteBuffer(m_context->commandQueue(), handle, CL_TRUE, 0, size, buffer, 0, 0, 0);
+ if (m_error)
+ return 0;
+ m_error = clSetKernelArg(m_kernel, m_index++, sizeof(OpenCLHandle), handle.handleAddress());
+ return !m_error ? handle : 0;
}
void run()
{
- clFinish(m_context->m_commandQueue);
- clEnqueueNDRangeKernel(m_context->m_commandQueue, m_kernel, 2, 0, m_globalSize, 0, 0, 0, 0);
+ if (m_context->isFailed(m_error))
+ return;
+
+ m_error = clFinish(m_context->m_commandQueue);
+ if (!m_error)
+ m_error = clEnqueueNDRangeKernel(m_context->m_commandQueue, m_kernel, 2, 0, m_globalSize, 0, 0, 0, 0);
+ m_context->isFailed(m_error);
}
FilterContextOpenCL* m_context;
cl_kernel m_kernel;
size_t m_globalSize[2];
- int index;
+ int m_index;
+ int m_error;
};
- enum OpenCLCompileStatus {
- openclNotCompiledYet,
- openclCompileFailed,
- openclCompileSuccessful
- };
-
- static cl_program compileProgram(const char*);
+ cl_program compileProgram(const char*);
static inline cl_kernel kernelByName(cl_program program, const char* name) { return clCreateKernel(program, name, 0); }
+ static inline void freeResource(cl_kernel&);
+ static inline void freeResource(cl_program&);
+
static FilterContextOpenCL* m_context;
static int m_alreadyInitialized;
+ bool m_inError;
cl_device_id m_deviceId;
cl_context m_deviceContext;
cl_command_queue m_commandQueue;
+ bool m_transformColorSpaceWasCompiled;
cl_program m_transformColorSpaceProgram;
cl_kernel m_transformColorSpaceKernel;
- OpenCLCompileStatus m_turbulenceCompileStatus;
+ bool m_fillWasCompiled;
+ cl_program m_fillProgram;
+ cl_kernel m_fill;
+
+ bool m_mergeWasCompiled;
+ cl_program m_mergeProgram;
+ cl_kernel m_mergeCopyOperation;
+ cl_kernel m_mergeOperation;
+
+ bool m_colorMatrixWasCompiled;
+ cl_program m_colorMatrixProgram;
+ cl_kernel m_matrixOperation;
+ cl_kernel m_saturateAndHueRotateOperation;
+ cl_kernel m_luminanceOperation;
+
+ bool m_turbulenceWasCompiled;
cl_program m_turbulenceProgram;
cl_kernel m_turbulenceOperation;
};
+inline bool FilterContextOpenCL::isFailed(bool value)
+{
+ if (value)
+ setInError();
+ return value;
+}
+
+inline bool FilterContextOpenCL::isResourceAllocationFailed(bool value)
+{
+ if (!value)
+ setInError();
+ return !value;
+}
+
} // namespace WebCore
#endif // ENABLE(OPENCL)
diff --git a/Source/WebCore/platform/graphics/gpu/opencl/OpenCLFEColorMatrix.cpp b/Source/WebCore/platform/graphics/gpu/opencl/OpenCLFEColorMatrix.cpp
new file mode 100644
index 000000000..c6c34bdb5
--- /dev/null
+++ b/Source/WebCore/platform/graphics/gpu/opencl/OpenCLFEColorMatrix.cpp
@@ -0,0 +1,156 @@
+/*
+ * Copyright (C) 2012 University of Szeged
+ * Copyright (C) 2012 Tamas Czene <tczene@inf.u-szeged.hu>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UNIVERSITY OF SZEGED OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(FILTERS) && ENABLE(OPENCL)
+#include "FEColorMatrix.h"
+
+#include "FilterContextOpenCL.h"
+
+namespace WebCore {
+
+#define COLOR_MATRIX_KERNEL(...) \
+ int2 sourceCoord = (int2) (get_global_id(0) + x, get_global_id(1) + y); \
+ float4 sourcePixel = read_imagef(source, sampler, sourceCoord); \
+ float4 destinationPixel = (float4) (__VA_ARGS__); \
+ write_imagef(destination, (int2) (get_global_id(0), get_global_id(1)), destinationPixel);
+
+static const char* colorMatrixKernelProgram =
+PROGRAM(
+const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;
+
+__kernel void matrix(__write_only image2d_t destination, __read_only image2d_t source, float x, float y, __constant float *values)
+{
+ COLOR_MATRIX_KERNEL(values[0] * sourcePixel.x + values[1] * sourcePixel.y + values[2] * sourcePixel.z + values[3] * sourcePixel.w + values[4],
+ values[5] * sourcePixel.x + values[6] * sourcePixel.y + values[7] * sourcePixel.z + values[8] * sourcePixel.w + values[9],
+ values[10] * sourcePixel.x + values[11] * sourcePixel.y + values[12] * sourcePixel.z + values[13] * sourcePixel.w + values[14],
+ values[15] * sourcePixel.x + values[16] * sourcePixel.y + values[17] * sourcePixel.z + values[18] * sourcePixel.w + values[19])
+}
+
+__kernel void saturateAndHueRotate(__write_only image2d_t destination, __read_only image2d_t source, float x, float y, __constant float *components)
+{
+ COLOR_MATRIX_KERNEL(sourcePixel.x * components[0] + sourcePixel.y * components[1] + sourcePixel.z * components[2],
+ sourcePixel.x * components[3] + sourcePixel.y * components[4] + sourcePixel.z * components[5],
+ sourcePixel.x * components[6] + sourcePixel.y * components[7] + sourcePixel.z * components[8],
+ sourcePixel.w)
+}
+
+__kernel void luminance(__write_only image2d_t destination, __read_only image2d_t source, float x, float y)
+{
+ COLOR_MATRIX_KERNEL(0, 0, 0, 0.2125 * sourcePixel.x + 0.7154 * sourcePixel.y + 0.0721 * sourcePixel.z)
+}
+); // End of OpenCL kernels
+
+inline bool FilterContextOpenCL::compileFEColorMatrix()
+{
+ if (m_colorMatrixWasCompiled || inError())
+ return !inError();
+
+ m_colorMatrixWasCompiled = true;
+
+ if (isResourceAllocationFailed((m_colorMatrixProgram = compileProgram(colorMatrixKernelProgram))))
+ return false;
+ if (isResourceAllocationFailed((m_matrixOperation = kernelByName(m_colorMatrixProgram, "matrix"))))
+ return false;
+ if (isResourceAllocationFailed((m_saturateAndHueRotateOperation = kernelByName(m_colorMatrixProgram, "saturateAndHueRotate"))))
+ return false;
+ if (isResourceAllocationFailed((m_saturateAndHueRotateOperation = kernelByName(m_colorMatrixProgram, "saturateAndHueRotate"))))
+ return false;
+ if (isResourceAllocationFailed((m_luminanceOperation = kernelByName(m_colorMatrixProgram, "luminance"))))
+ return false;
+ return true;
+}
+
+inline void FilterContextOpenCL::applyFEColorMatrix(OpenCLHandle destination, IntSize destinationSize, OpenCLHandle source, IntPoint relativeSourceLocation, float* values, int type)
+{
+ cl_kernel colorMatrix;
+ OpenCLHandle clValues;
+
+ switch (type) {
+ case FECOLORMATRIX_TYPE_MATRIX:
+ colorMatrix = m_matrixOperation;
+ break;
+ case FECOLORMATRIX_TYPE_SATURATE:
+ colorMatrix = m_saturateAndHueRotateOperation;
+ break;
+ case FECOLORMATRIX_TYPE_HUEROTATE:
+ colorMatrix = m_saturateAndHueRotateOperation;
+ break;
+ case FECOLORMATRIX_TYPE_LUMINANCETOALPHA:
+ colorMatrix = m_luminanceOperation;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ return;
+ }
+
+ RunKernel kernel(this, colorMatrix, destinationSize.width(), destinationSize.height());
+ kernel.addArgument(destination);
+ kernel.addArgument(source);
+ kernel.addArgument(relativeSourceLocation.x());
+ kernel.addArgument(relativeSourceLocation.y());
+ if (type == FECOLORMATRIX_TYPE_MATRIX)
+ clValues = kernel.addArgument(values, sizeof(float) * 20);
+ else if (type == FECOLORMATRIX_TYPE_SATURATE || type == FECOLORMATRIX_TYPE_HUEROTATE)
+ clValues = kernel.addArgument(values, sizeof(float) * 9);
+ kernel.run();
+
+ clValues.clear();
+}
+
+bool FEColorMatrix::platformApplyOpenCL()
+{
+ FilterContextOpenCL* context = FilterContextOpenCL::context();
+ if (!context)
+ return false;
+
+ if (!context->compileFEColorMatrix())
+ return true;
+
+ FilterEffect* in = inputEffect(0);
+ OpenCLHandle source = in->openCLImage();
+ OpenCLHandle destination = createOpenCLImageResult();
+
+ IntPoint relativeSourceLocation(
+ absolutePaintRect().x() - in->absolutePaintRect().location().x(),
+ absolutePaintRect().y() - in->absolutePaintRect().location().y());
+
+ float components[9];
+ if (FECOLORMATRIX_TYPE_SATURATE == m_type)
+ calculateSaturateComponents(components, m_values[0]);
+ else if (FECOLORMATRIX_TYPE_HUEROTATE == m_type)
+ calculateHueRotateComponents(components, m_values[0]);
+
+ context->applyFEColorMatrix(destination, absolutePaintRect().size(), source, relativeSourceLocation, (FECOLORMATRIX_TYPE_MATRIX == m_type) ? m_values.data() : components, m_type);
+
+ return true;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(FILTERS) && ENABLE(OPENCL)
diff --git a/Source/WebCore/platform/graphics/FontFamily.cpp b/Source/WebCore/platform/graphics/gpu/opencl/OpenCLFEFlood.cpp
index b2c1e9d66..6ef1f666d 100644
--- a/Source/WebCore/platform/graphics/FontFamily.cpp
+++ b/Source/WebCore/platform/graphics/gpu/opencl/OpenCLFEFlood.cpp
@@ -1,5 +1,7 @@
/*
- * Copyright (C) 2004, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2013 University of Szeged
+ * Copyright (C) 2013 Tamas Czene <tczene@inf.u-szeged.hu>
+ * All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -10,37 +12,46 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UNIVERSITY OF SZEGED OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
-#include "FontFamily.h"
+#if ENABLE(FILTERS) && ENABLE(OPENCL)
+#include "FEFlood.h"
+
+#include "FilterContextOpenCL.h"
namespace WebCore {
-bool operator==(const FontFamily& a, const FontFamily& b)
+bool FEFlood::platformApplyOpenCL()
{
- if (a.family() != b.family())
+ FilterContextOpenCL* context = FilterContextOpenCL::context();
+
+ if (!context)
return false;
- const FontFamily* ap;
- const FontFamily* bp;
- for (ap = a.next(), bp = b.next(); ap != bp; ap = ap->next(), bp = bp->next()) {
- if (!ap || !bp)
- return false;
- if (ap->family() != bp->family())
- return false;
- }
+
+ if (context->inError())
+ return true;
+
+ cl_mem destination = createOpenCLImageResult();
+
+ Color color = colorWithOverrideAlpha(floodColor().rgb(), floodOpacity());
+
+ context->fill(destination, absolutePaintRect().size(), color);
+
return true;
}
-}
+} // namespace WebCore
+
+#endif // ENABLE(FILTERS) && ENABLE(OPENCL)
diff --git a/Source/WebCore/platform/graphics/chromium/ScaledImageFragment.cpp b/Source/WebCore/platform/graphics/gpu/opencl/OpenCLFEImage.cpp
index 71bb620ae..736a8627d 100644
--- a/Source/WebCore/platform/graphics/chromium/ScaledImageFragment.cpp
+++ b/Source/WebCore/platform/graphics/gpu/opencl/OpenCLFEImage.cpp
@@ -1,5 +1,7 @@
/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
+ * Copyright (C) 2013 University of Szeged
+ * Copyright (C) 2013 Tamas Czene <tczene@inf.u-szeged.hu>
+ * All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -10,10 +12,10 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UNIVERSITY OF SZEGED OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
@@ -24,20 +26,26 @@
*/
#include "config.h"
+#if ENABLE(FILTERS) && ENABLE(OPENCL)
-#include "ScaledImageFragment.h"
+#include "FilterContextOpenCL.h"
+#include "SVGFEImage.h"
+#include "SVGFilter.h"
+#include "SharedBuffer.h"
namespace WebCore {
-ScaledImageFragment::~ScaledImageFragment()
-{
-}
-
-ScaledImageFragment::ScaledImageFragment(const SkISize& scaledSize, const SkBitmap& bitmap, const bool isComplete)
- : m_scaledSize(scaledSize)
- , m_bitmap(bitmap)
- , m_isComplete(isComplete)
+bool FEImage::platformApplyOpenCL()
{
+ platformApplySoftware();
+ ImageBuffer* sourceImage = asImageBuffer();
+ if (sourceImage) {
+ RefPtr<Uint8ClampedArray> sourceImageData = sourceImage->getUnmultipliedImageData(IntRect(IntPoint(), sourceImage->internalSize()));
+ createOpenCLImageResult(sourceImageData->data());
+ }
+ return true;
}
} // namespace WebCore
+
+#endif // ENABLE(FILTERS) && ENABLE(OPENCL)
diff --git a/Source/WebCore/platform/graphics/gpu/opencl/OpenCLFEMerge.cpp b/Source/WebCore/platform/graphics/gpu/opencl/OpenCLFEMerge.cpp
new file mode 100644
index 000000000..b2b80c2a0
--- /dev/null
+++ b/Source/WebCore/platform/graphics/gpu/opencl/OpenCLFEMerge.cpp
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2013 University of Szeged
+ * Copyright (C) 2013 Tamas Czene <tczene@inf.u-szeged.hu>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UNIVERSITY OF SZEGED OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#if ENABLE(FILTERS) && ENABLE(OPENCL)
+#include "FEMerge.h"
+
+#include "FilterContextOpenCL.h"
+
+namespace WebCore {
+
+static const char* mergeKernelProgram =
+PROGRAM(
+const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP | CLK_FILTER_NEAREST;
+
+__kernel void copy(__write_only image2d_t destination, __read_only image2d_t source, int x, int y)
+{
+ float4 destinationPixel = read_imagef(source, sampler, (int2) (get_global_id(0) + x, get_global_id(1) + y));
+ write_imagef(destination, (int2) (get_global_id(0), get_global_id(1)), destinationPixel);
+}
+
+__kernel void merge(__write_only image2d_t destination, __read_only image2d_t previousDestination, __read_only image2d_t sourceA, __read_only image2d_t sourceB, int xA, int yA, int xB, int yB)
+{
+ int2 destinationCoord = (int2) (get_global_id(0), get_global_id(1));
+ int2 sourceCoordA = (int2) (destinationCoord.x + xA, destinationCoord.y + yA);
+ int2 sourceCoordB = (int2) (destinationCoord.x + xB, destinationCoord.y + yB);
+ float4 destinationPixel = read_imagef(previousDestination, sampler, destinationCoord);
+ float4 sourcePixelA = read_imagef(sourceA, sampler, sourceCoordA);
+ float4 sourcePixelB = read_imagef(sourceB, sampler, sourceCoordB);
+
+ destinationPixel = sourcePixelA + destinationPixel * (1 - sourcePixelA.w);
+ destinationPixel = sourcePixelB + destinationPixel * (1 - sourcePixelB.w);
+
+ write_imagef(destination, destinationCoord, destinationPixel);
+}
+); // End of OpenCL kernels
+
+inline bool FilterContextOpenCL::compileFEMerge()
+{
+ if (m_mergeWasCompiled || inError())
+ return !inError();
+
+ m_mergeWasCompiled = true;
+
+ if (isResourceAllocationFailed((m_mergeProgram = compileProgram(mergeKernelProgram))))
+ return false;
+ if (isResourceAllocationFailed((m_mergeCopyOperation = kernelByName(m_mergeProgram, "copy"))))
+ return false;
+ if (isResourceAllocationFailed((m_mergeOperation = kernelByName(m_mergeProgram, "merge"))))
+ return false;
+ return true;
+}
+
+inline void FilterContextOpenCL::applyFEMergeCopy(OpenCLHandle destination, IntSize destinationSize, OpenCLHandle source, IntPoint& relativeSourcePoint)
+{
+ RunKernel kernel(this, m_mergeCopyOperation, destinationSize.width(), destinationSize.height());
+ kernel.addArgument(destination);
+ kernel.addArgument(source);
+ kernel.addArgument(relativeSourcePoint.x());
+ kernel.addArgument(relativeSourcePoint.y());
+ kernel.run();
+}
+
+inline void FilterContextOpenCL::applyFEMerge(OpenCLHandle destination, OpenCLHandle previousDestination, OpenCLHandle sourceA, OpenCLHandle sourceB, IntSize destinationSize, IntPoint& relativeSourcePointA, IntPoint& relativeSourcePointB)
+{
+ RunKernel kernel(this, m_mergeOperation, destinationSize.width(), destinationSize.height());
+ kernel.addArgument(destination);
+ kernel.addArgument(previousDestination);
+ kernel.addArgument(sourceA);
+ kernel.addArgument(sourceB);
+ kernel.addArgument(relativeSourcePointA.x());
+ kernel.addArgument(relativeSourcePointA.y());
+ kernel.addArgument(relativeSourcePointB.x());
+ kernel.addArgument(relativeSourcePointB.y());
+ kernel.run();
+}
+
+bool FEMerge::platformApplyOpenCL()
+{
+ FilterContextOpenCL* context = FilterContextOpenCL::context();
+ if (!context)
+ return false;
+
+ context->compileFEMerge();
+
+ unsigned size = numberOfEffectInputs();
+ ASSERT(size > 0);
+
+ OpenCLHandle destination = createOpenCLImageResult();
+ OpenCLHandle sourceA = 0;
+ OpenCLHandle sourceB = 0;
+ FilterEffect* in;
+
+ int i = 0;
+
+ if (size & 1) {
+ in = inputEffect(i++);
+ sourceA = in->openCLImage();
+ IntPoint relativeSourcePoint(in->absolutePaintRect().location());
+ relativeSourcePoint.setX(absolutePaintRect().x() - relativeSourcePoint.x());
+ relativeSourcePoint.setY(absolutePaintRect().y() - relativeSourcePoint.y());
+
+ context->applyFEMergeCopy(destination, absolutePaintRect().size(), sourceA, relativeSourcePoint);
+ if (size == 1)
+ return true;
+ } else
+ context->fill(destination, absolutePaintRect().size(), Color(0.0f, 0.0f, 0.0f, 0.0f));
+
+ OpenCLHandle previousDestination = context->createOpenCLImage(absolutePaintRect().size());
+
+ while (i < size) {
+ OpenCLHandle temp = previousDestination;
+ previousDestination = destination;
+ destination = temp;
+
+ in = inputEffect(i++);
+ sourceA = in->openCLImage();
+ IntPoint relativeSourcePointA(in->absolutePaintRect().location());
+ relativeSourcePointA.setX(absolutePaintRect().x() - relativeSourcePointA.x());
+ relativeSourcePointA.setY(absolutePaintRect().y() - relativeSourcePointA.y());
+
+ in = inputEffect(i++);
+ sourceB = in->openCLImage();
+ IntPoint relativeSourcePointB(in->absolutePaintRect().location());
+ relativeSourcePointB.setX(absolutePaintRect().x() - relativeSourcePointB.x());
+ relativeSourcePointB.setY(absolutePaintRect().y() - relativeSourcePointB.y());
+
+ context->applyFEMerge(destination, previousDestination, sourceA, sourceB, absolutePaintRect().size(), relativeSourcePointA, relativeSourcePointB);
+ }
+ setOpenCLImage(destination);
+ previousDestination.clear();
+ return true;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(FILTERS) && ENABLE(OPENCL)
diff --git a/Source/WebCore/platform/graphics/gpu/opencl/OpenCLFETurbulence.cpp b/Source/WebCore/platform/graphics/gpu/opencl/OpenCLFETurbulence.cpp
index 7ebc6074d..d8284ebc1 100644
--- a/Source/WebCore/platform/graphics/gpu/opencl/OpenCLFETurbulence.cpp
+++ b/Source/WebCore/platform/graphics/gpu/opencl/OpenCLFETurbulence.cpp
@@ -36,7 +36,7 @@
namespace WebCore {
static const char* turbulenceKernelProgram =
-PROGRAM_STR(
+PROGRAM(
__constant int s_perlinNoise = 4096;
__constant int s_blockSize = 256;
__constant int s_blockMask = 255;
@@ -165,41 +165,38 @@ __kernel void Turbulence(__write_only image2d_t destination, __constant float *t
write_imagef(destination, (int2)(get_global_id(0), get_global_id(1)), turbulenceFunctionResult);
}
-);
+); // End of OpenCL kernels
inline bool FilterContextOpenCL::compileFETurbulence()
{
- if (m_turbulenceCompileStatus != openclNotCompiledYet)
- return m_turbulenceCompileStatus == openclCompileSuccessful;
+ if (m_turbulenceWasCompiled || inError())
+ return !inError();
- m_turbulenceCompileStatus = openclCompileFailed;
- m_turbulenceProgram = compileProgram(turbulenceKernelProgram);
- if (!m_turbulenceProgram)
+ m_turbulenceWasCompiled = true;
+
+ if (isResourceAllocationFailed((m_turbulenceProgram = compileProgram(turbulenceKernelProgram))))
return false;
- m_turbulenceOperation = kernelByName(m_turbulenceProgram, "Turbulence");
- if (!m_turbulenceOperation)
+ if (isResourceAllocationFailed((m_turbulenceOperation = kernelByName(m_turbulenceProgram, "Turbulence"))))
return false;
-
- m_turbulenceCompileStatus = openclCompileSuccessful;
- return openclCompileFailed;
+ return true;
}
inline void FilterContextOpenCL::applyFETurbulence(OpenCLHandle destination,
- IntSize destinationSize, int blockSize,
+ IntSize destinationSize, int totalBlockSize,
void* transform, void* redComponent, void* greenComponent,
void* blueComponent, void* alphaComponent,
- void* latticeSelector, int offsetX, int offsetY, int tileWidth, int tileHeight,
+ int* latticeSelector, int offsetX, int offsetY, int tileWidth, int tileHeight,
float baseFrequencyX, float baseFrequencyY, bool stitchTiles, int numOctaves, int type)
{
RunKernel kernel(this, m_turbulenceOperation, destinationSize.width(), destinationSize.height());
kernel.addArgument(destination);
OpenCLHandle transformHandle(kernel.addArgument(transform, sizeof(float) * 6));
- OpenCLHandle redComponentHandle(kernel.addArgument(redComponent, sizeof(float) * (2 * blockSize + 2) * 2));
- OpenCLHandle greenComponentHandle(kernel.addArgument(greenComponent, sizeof(float) * (2 * blockSize + 2) * 2));
- OpenCLHandle blueComponentHandle(kernel.addArgument(blueComponent, sizeof(float) * (2 * blockSize + 2) * 2));
- OpenCLHandle alphaComponentHandle(kernel.addArgument(alphaComponent, sizeof(float) * (2 * blockSize + 2) * 2));
- OpenCLHandle latticeSelectorHandle(kernel.addArgument(latticeSelector, sizeof(int) * (2 * blockSize + 2)));
+ OpenCLHandle redComponentHandle(kernel.addArgument(redComponent, sizeof(float) * totalBlockSize * 2));
+ OpenCLHandle greenComponentHandle(kernel.addArgument(greenComponent, sizeof(float) * totalBlockSize * 2));
+ OpenCLHandle blueComponentHandle(kernel.addArgument(blueComponent, sizeof(float) * totalBlockSize * 2));
+ OpenCLHandle alphaComponentHandle(kernel.addArgument(alphaComponent, sizeof(float) * totalBlockSize * 2));
+ OpenCLHandle latticeSelectorHandle(kernel.addArgument(latticeSelector, sizeof(int) * totalBlockSize));
kernel.addArgument(offsetX);
kernel.addArgument(offsetY);
kernel.addArgument(tileWidth);
@@ -224,9 +221,12 @@ inline void FilterContextOpenCL::applyFETurbulence(OpenCLHandle destination,
bool FETurbulence::platformApplyOpenCL()
{
FilterContextOpenCL* context = FilterContextOpenCL::context();
- if (!context || !context->compileFETurbulence())
+ if (!context)
return false;
+ if (!context->compileFETurbulence())
+ return true;
+
OpenCLHandle destination = createOpenCLImageResult();
PaintingData paintingData(m_seed, roundedIntSize(filterPrimitiveSubregion().size()));
@@ -235,7 +235,7 @@ bool FETurbulence::platformApplyOpenCL()
AffineTransform invertedTransform = reinterpret_cast<SVGFilter*>(filter())->absoluteTransform().inverse();
float transformComponents[6] = { invertedTransform.a(), invertedTransform.b(), invertedTransform.c(), invertedTransform.d(), invertedTransform.e(), invertedTransform.f() };
- context->applyFETurbulence(destination, absolutePaintRect().size(), s_blockSize, transformComponents, paintingData.gradient,
+ context->applyFETurbulence(destination, absolutePaintRect().size(), 2 * s_blockSize + 2, transformComponents, paintingData.gradient,
paintingData.gradient + 1, paintingData.gradient + 2, paintingData.gradient + 3, paintingData.latticeSelector,
absolutePaintRect().x(), absolutePaintRect().y(), paintingData.filterSize.width(), paintingData.filterSize.height(),
m_baseFrequencyX, m_baseFrequencyY, m_stitchTiles, m_numOctaves, m_type);
diff --git a/Source/WebCore/platform/graphics/gpu/opencl/OpenCLHandle.h b/Source/WebCore/platform/graphics/gpu/opencl/OpenCLHandle.h
index 9f585dcf9..fa75b94e3 100644
--- a/Source/WebCore/platform/graphics/gpu/opencl/OpenCLHandle.h
+++ b/Source/WebCore/platform/graphics/gpu/opencl/OpenCLHandle.h
@@ -1,20 +1,28 @@
/*
+ * Copyright (C) 2012 University of Szeged
* Copyright (C) 2012 Tamas Czene <tczene@inf.u-szeged.hu>
+ * All rights reserved.
*
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
*
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
+ * THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UNIVERSITY OF SZEGED OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if ENABLE(OPENCL)
diff --git a/Source/WebCore/platform/graphics/gpu/qt/DrawingBufferQt.cpp b/Source/WebCore/platform/graphics/gpu/qt/DrawingBufferQt.cpp
index 17a59a418..47cb4b95b 100644
--- a/Source/WebCore/platform/graphics/gpu/qt/DrawingBufferQt.cpp
+++ b/Source/WebCore/platform/graphics/gpu/qt/DrawingBufferQt.cpp
@@ -31,71 +31,12 @@
namespace WebCore {
-DrawingBuffer::DrawingBuffer(GraphicsContext3D* context,
- const IntSize& size,
- bool multisampleExtensionSupported,
- bool packedDepthStencilExtensionSupported,
- PreserveDrawingBuffer preserveDrawingBuffer,
- AlphaRequirement alpha)
- : m_preserveDrawingBuffer(preserveDrawingBuffer)
- , m_alpha(alpha)
- , m_scissorEnabled(false)
- , m_texture2DBinding(0)
- , m_framebufferBinding(0)
- , m_activeTextureUnit(GraphicsContext3D::TEXTURE0)
- , m_context(context)
- , m_size(-1, -1)
- , m_multisampleExtensionSupported(multisampleExtensionSupported)
- , m_packedDepthStencilExtensionSupported(packedDepthStencilExtensionSupported)
- , m_fbo(context->createFramebuffer())
- , m_colorBuffer(0)
- , m_frontColorBuffer(0)
- , m_separateFrontTexture(false)
- , m_depthStencilBuffer(0)
- , m_depthBuffer(0)
- , m_stencilBuffer(0)
- , m_multisampleFBO(0)
- , m_multisampleColorBuffer(0)
-{
- ASSERT(m_fbo);
- if (!m_fbo) {
- clear();
- return;
- }
-
- // create a texture to render into
- m_colorBuffer = context->createTexture();
- context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_colorBuffer);
- context->texParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR);
- context->texParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR);
- context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE);
- context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE);
- context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0);
-
- createSecondaryBuffers();
- reset(size);
-}
-
-DrawingBuffer::~DrawingBuffer()
-{
- clear();
-}
-
#if USE(ACCELERATED_COMPOSITING)
PlatformLayer* DrawingBuffer::platformLayer()
{
return 0;
}
-void DrawingBuffer::prepareBackBuffer()
-{
-}
-
-bool DrawingBuffer::requiresCopyFromBackToFrontBuffer() const
-{
- return false;
-}
-
unsigned DrawingBuffer::frontColorBuffer() const
{
return colorBuffer();
diff --git a/Source/WebCore/platform/graphics/gstreamer/FullscreenVideoControllerGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/FullscreenVideoControllerGStreamer.cpp
new file mode 100644
index 000000000..47a6afca0
--- /dev/null
+++ b/Source/WebCore/platform/graphics/gstreamer/FullscreenVideoControllerGStreamer.cpp
@@ -0,0 +1,156 @@
+/*
+ * Copyright (C) 2013 Igalia S.L
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#if ENABLE(VIDEO) && USE(GSTREAMER) && USE(NATIVE_FULLSCREEN_VIDEO)
+
+#include "FullscreenVideoControllerGStreamer.h"
+
+#if PLATFORM(GTK)
+#include "FullscreenVideoControllerGtk.h"
+#endif
+
+#include "GStreamerGWorld.h"
+#include "MediaPlayer.h"
+#include "MediaPlayerPrivateGStreamerBase.h"
+#include <gst/gst.h>
+#include <wtf/text/CString.h>
+
+#define VOLUME_UP_OFFSET 0.05 // 5%
+#define VOLUME_DOWN_OFFSET 0.05 // 5%
+
+namespace WebCore {
+
+void playerVolumeChangedCallback(GObject *element, GParamSpec *pspec, FullscreenVideoControllerGStreamer* controller)
+{
+ controller->volumeChanged();
+}
+
+void playerMuteChangedCallback(GObject *element, GParamSpec *pspec, FullscreenVideoControllerGStreamer* controller)
+{
+ controller->muteChanged();
+}
+
+PassOwnPtr<FullscreenVideoControllerGStreamer> FullscreenVideoControllerGStreamer::create(MediaPlayerPrivateGStreamerBase* player)
+{
+#if PLATFORM(GTK)
+ return adoptPtr(new FullscreenVideoControllerGtk(player));
+#else
+ return nullptr;
+#endif
+}
+
+FullscreenVideoControllerGStreamer::FullscreenVideoControllerGStreamer(MediaPlayerPrivateGStreamerBase* player)
+ : m_player(player)
+ , m_client(player->mediaPlayer()->mediaPlayerClient())
+ , m_gstreamerGWorld(player->platformMedia().media.gstreamerGWorld)
+ , m_playerVolumeSignalHandler(0)
+ , m_playerMuteSignalHandler(0)
+{
+}
+
+FullscreenVideoControllerGStreamer::~FullscreenVideoControllerGStreamer()
+{
+ exitFullscreen();
+}
+
+void FullscreenVideoControllerGStreamer::enterFullscreen()
+{
+ if (!m_gstreamerGWorld)
+ return;
+
+ if (!m_gstreamerGWorld->enterFullscreen())
+ return;
+
+ initializeWindow();
+
+ GstElement* pipeline = m_gstreamerGWorld->pipeline();
+ m_playerVolumeSignalHandler = g_signal_connect(pipeline, "notify::volume", G_CALLBACK(playerVolumeChangedCallback), this);
+ m_playerMuteSignalHandler = g_signal_connect(pipeline, "notify::mute", G_CALLBACK(playerMuteChangedCallback), this);
+}
+
+void FullscreenVideoControllerGStreamer::exitFullscreen()
+{
+ destroyWindow();
+
+ GstElement* pipeline = m_gstreamerGWorld->pipeline();
+ if (m_playerVolumeSignalHandler) {
+ g_signal_handler_disconnect(pipeline, m_playerVolumeSignalHandler);
+ m_playerVolumeSignalHandler = 0;
+ }
+
+ if (m_playerMuteSignalHandler) {
+ g_signal_handler_disconnect(pipeline, m_playerMuteSignalHandler);
+ m_playerMuteSignalHandler = 0;
+ }
+
+ m_gstreamerGWorld->exitFullscreen();
+}
+
+void FullscreenVideoControllerGStreamer::exitOnUserRequest()
+{
+ m_client->mediaPlayerExitFullscreen();
+}
+
+void FullscreenVideoControllerGStreamer::togglePlay()
+{
+ if (m_client->mediaPlayerIsPaused())
+ m_client->mediaPlayerPlay();
+ else
+ m_client->mediaPlayerPause();
+ playStateChanged();
+}
+
+void FullscreenVideoControllerGStreamer::increaseVolume()
+{
+ setVolume(m_player->volume() + VOLUME_UP_OFFSET);
+}
+
+void FullscreenVideoControllerGStreamer::decreaseVolume()
+{
+ setVolume(m_player->volume() - VOLUME_DOWN_OFFSET);
+}
+
+void FullscreenVideoControllerGStreamer::setVolume(float volume)
+{
+ volume = CLAMP(volume, 0.0, 1.0);
+ m_player->setVolume(volume);
+}
+
+String FullscreenVideoControllerGStreamer::timeToString(float time)
+{
+ if (!std::isfinite(time))
+ time = 0;
+ int seconds = fabsf(time);
+ int hours = seconds / (60 * 60);
+ int minutes = (seconds / 60) % 60;
+ seconds %= 60;
+
+ if (hours) {
+ if (hours > 9)
+ return String::format("%s%02d:%02d:%02d", (time < 0 ? "-" : ""), hours, minutes, seconds);
+ return String::format("%s%01d:%02d:%02d", (time < 0 ? "-" : ""), hours, minutes, seconds);
+ }
+
+ return String::format("%s%02d:%02d", (time < 0 ? "-" : ""), minutes, seconds);
+}
+
+} // namespace WebCore
+#endif
diff --git a/Source/WebCore/platform/graphics/gstreamer/FullscreenVideoControllerGStreamer.h b/Source/WebCore/platform/graphics/gstreamer/FullscreenVideoControllerGStreamer.h
new file mode 100644
index 000000000..9e197990c
--- /dev/null
+++ b/Source/WebCore/platform/graphics/gstreamer/FullscreenVideoControllerGStreamer.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2013 Igalia S.L
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef FullscreenVideoControllerGStreamer_h
+#define FullscreenVideoControllerGStreamer_h
+
+#if ENABLE(VIDEO) && USE(GSTREAMER) && USE(NATIVE_FULLSCREEN_VIDEO)
+
+#include <wtf/Forward.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/PassOwnPtr.h>
+
+namespace WebCore {
+
+class GStreamerGWorld;
+class MediaPlayerPrivateGStreamerBase;
+class MediaPlayerClient;
+
+class FullscreenVideoControllerGStreamer {
+ WTF_MAKE_NONCOPYABLE(FullscreenVideoControllerGStreamer);
+public:
+ static PassOwnPtr<FullscreenVideoControllerGStreamer> create(MediaPlayerPrivateGStreamerBase*);
+ FullscreenVideoControllerGStreamer(MediaPlayerPrivateGStreamerBase*);
+ virtual ~FullscreenVideoControllerGStreamer();
+
+ void enterFullscreen();
+ void exitFullscreen();
+ void exitOnUserRequest();
+
+ void togglePlay();
+ virtual void playStateChanged() { }
+
+ void increaseVolume();
+ void decreaseVolume();
+ void setVolume(float);
+
+ virtual void volumeChanged() { }
+ virtual void muteChanged() { }
+
+protected:
+ String timeToString(float time);
+
+ MediaPlayerPrivateGStreamerBase* m_player;
+ MediaPlayerClient* m_client;
+ GStreamerGWorld* m_gstreamerGWorld;
+
+private:
+ virtual void initializeWindow() { }
+ virtual void destroyWindow() { }
+
+ unsigned long m_playerVolumeSignalHandler;
+ unsigned long m_playerMuteSignalHandler;
+};
+
+}
+#endif
+
+#endif // FullscreenVideoControllerGStreamer_h
diff --git a/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp
index ffb0e1673..e9f2b294d 100644
--- a/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp
+++ b/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp
@@ -165,5 +165,23 @@ template <> void derefGPtr<GstElementFactory>(GstElementFactory* ptr)
gst_object_unref(ptr);
}
+template<> GRefPtr<GstBuffer> adoptGRef(GstBuffer* ptr)
+{
+ return GRefPtr<GstBuffer>(ptr, GRefPtrAdopt);
+}
+
+template<> GstBuffer* refGPtr<GstBuffer>(GstBuffer* ptr)
+{
+ if (ptr)
+ gst_buffer_ref(ptr);
+
+ return ptr;
+}
+
+template<> void derefGPtr<GstBuffer>(GstBuffer* ptr)
+{
+ if (ptr)
+ gst_buffer_unref(ptr);
+}
}
#endif // USE(GSTREAMER)
diff --git a/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h b/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h
index 5b0ed0db2..002879f4f 100644
--- a/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h
+++ b/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h
@@ -30,6 +30,7 @@ typedef struct _GstCaps GstCaps;
typedef struct _GstTask GstTask;
typedef struct _GstBus GstBus;
typedef struct _GstElementFactory GstElementFactory;
+typedef struct _GstBuffer GstBuffer;
namespace WTF {
@@ -61,6 +62,9 @@ template<> GRefPtr<GstElementFactory> adoptGRef(GstElementFactory* ptr);
template<> GstElementFactory* refGPtr<GstElementFactory>(GstElementFactory* ptr);
template<> void derefGPtr<GstElementFactory>(GstElementFactory* ptr);
+template<> GRefPtr<GstBuffer> adoptGRef(GstBuffer* ptr);
+template<> GstBuffer* refGPtr<GstBuffer>(GstBuffer* ptr);
+template<> void derefGPtr<GstBuffer>(GstBuffer* ptr);
}
#endif // USE(GSTREAMER)
diff --git a/Source/WebCore/platform/graphics/gstreamer/GStreamerGWorld.cpp b/Source/WebCore/platform/graphics/gstreamer/GStreamerGWorld.cpp
index 212defb29..1d2e7b9cd 100644
--- a/Source/WebCore/platform/graphics/gstreamer/GStreamerGWorld.cpp
+++ b/Source/WebCore/platform/graphics/gstreamer/GStreamerGWorld.cpp
@@ -18,14 +18,23 @@
*/
#include "config.h"
+
#include "GStreamerGWorld.h"
-#if ENABLE(VIDEO) && USE(GSTREAMER) && !defined(GST_API_VERSION_1)
+
+#if ENABLE(VIDEO) && USE(GSTREAMER) && USE(NATIVE_FULLSCREEN_VIDEO)
#include "GRefPtrGStreamer.h"
+#include "GStreamerVersioning.h"
#include <gst/gst.h>
-#include <gst/interfaces/xoverlay.h>
#include <gst/pbutils/pbutils.h>
+#ifdef GST_API_VERSION_1
+#include <gst/video/videooverlay.h>
+#else
+#include <gst/interfaces/xoverlay.h>
+#endif
+
+
#if PLATFORM(GTK)
#include <gtk/gtk.h>
#ifdef GDK_WINDOWING_X11
@@ -33,6 +42,12 @@
#endif
#endif
+#ifndef GST_API_VERSION_1
+static const char* gVideoConvertName = "ffmpegcolorspace";
+#else
+static const char* gVideoConvertName = "videoconvert";
+#endif
+
using namespace std;
namespace WebCore {
@@ -42,11 +57,16 @@ gboolean gstGWorldSyncMessageCallback(GstBus*, GstMessage* message, gpointer dat
ASSERT(GST_MESSAGE_TYPE(message) == GST_MESSAGE_ELEMENT);
GStreamerGWorld* gstGWorld = static_cast<GStreamerGWorld*>(data);
+#ifndef GST_API_VERSION_1
const GstStructure* structure = gst_message_get_structure(message);
if (gst_structure_has_name(structure, "prepare-xwindow-id")
|| gst_structure_has_name(structure, "have-ns-view"))
gstGWorld->setWindowOverlay(message);
+#else
+ if (gst_is_video_overlay_prepare_window_handle_message(message))
+ gstGWorld->setWindowOverlay(message);
+#endif
return TRUE;
}
@@ -59,16 +79,27 @@ GStreamerGWorld::GStreamerGWorld(GstElement* pipeline)
: m_pipeline(pipeline)
{
// XOverlay messages need to be handled synchronously.
- GstBus* bus = gst_pipeline_get_bus(GST_PIPELINE(m_pipeline));
- gst_bus_set_sync_handler(bus, gst_bus_sync_signal_handler, this);
- g_signal_connect(bus, "sync-message::element", G_CALLBACK(gstGWorldSyncMessageCallback), this);
- gst_object_unref(bus);
+ GRefPtr<GstBus> bus = webkitGstPipelineGetBus(GST_PIPELINE(m_pipeline));
+#ifndef GST_API_VERSION_1
+ gst_bus_set_sync_handler(bus.get(), gst_bus_sync_signal_handler, this);
+#else
+ gst_bus_set_sync_handler(bus.get(), gst_bus_sync_signal_handler, this, 0);
+#endif
+ g_signal_connect(bus.get(), "sync-message::element", G_CALLBACK(gstGWorldSyncMessageCallback), this);
}
GStreamerGWorld::~GStreamerGWorld()
{
exitFullscreen();
+ GRefPtr<GstBus> bus = webkitGstPipelineGetBus(GST_PIPELINE(m_pipeline));
+ g_signal_handlers_disconnect_by_func(bus.get(), reinterpret_cast<gpointer>(gstGWorldSyncMessageCallback), this);
+#ifndef GST_API_VERSION_1
+ gst_bus_set_sync_handler(bus.get(), 0, this);
+#else
+ gst_bus_set_sync_handler(bus.get(), 0, this, 0);
+#endif
+
m_pipeline = 0;
}
@@ -81,7 +112,7 @@ bool GStreamerGWorld::enterFullscreen()
m_videoWindow = PlatformVideoWindow::createWindow();
GstElement* platformVideoSink = gst_element_factory_make("autovideosink", "platformVideoSink");
- GstElement* colorspace = gst_element_factory_make("ffmpegcolorspace", "colorspace");
+ GstElement* colorspace = gst_element_factory_make(gVideoConvertName, "colorspace");
GstElement* queue = gst_element_factory_make("queue", "queue");
GstElement* videoScale = gst_element_factory_make("videoscale", "videoScale");
@@ -94,7 +125,6 @@ bool GStreamerGWorld::enterFullscreen()
GRefPtr<GstElement> tee = adoptGRef(gst_bin_get_by_name(GST_BIN(videoSink.get()), "videoTee"));
- // Add and link a queue, ffmpegcolorspace, videoscale and sink in the bin.
gst_bin_add_many(GST_BIN(videoSink.get()), platformVideoSink, videoScale, colorspace, queue, NULL);
// Faster elements linking.
@@ -103,7 +133,11 @@ bool GStreamerGWorld::enterFullscreen()
gst_element_link_pads_full(videoScale, "src", platformVideoSink, "sink", GST_PAD_LINK_CHECK_NOTHING);
// Link a new src pad from tee to queue.
+#ifndef GST_API_VERSION_1
GRefPtr<GstPad> srcPad = adoptGRef(gst_element_get_request_pad(tee.get(), "src%d"));
+#else
+ GRefPtr<GstPad> srcPad = adoptGRef(gst_element_get_request_pad(tee.get(), "src_%u"));
+#endif
GRefPtr<GstPad> sinkPad = adoptGRef(gst_element_get_static_pad(queue, "sink"));
gst_pad_link(srcPad.get(), sinkPad.get());
@@ -121,9 +155,9 @@ bool GStreamerGWorld::enterFullscreen()
gst_element_set_state(colorspace, state);
gst_element_set_state(queue, state);
+#ifndef GST_API_VERSION_1
// Query the current media segment informations and send them towards
// the new tee branch downstream.
-
GstQuery* query = gst_query_new_segment(GST_FORMAT_TIME);
gboolean queryResult = gst_element_query(m_pipeline, query);
@@ -132,8 +166,8 @@ bool GStreamerGWorld::enterFullscreen()
return true;
}
- GstFormat format;
gint64 position;
+ GstFormat format;
if (!gst_element_query_position(m_pipeline, &format, &position))
position = 0;
@@ -145,20 +179,55 @@ bool GStreamerGWorld::enterFullscreen()
gst_pad_push_event(srcPad.get(), event);
gst_query_unref(query);
+#endif
return true;
}
+#ifdef GST_API_VERSION_1
+static GstPadProbeReturn gstGWorldPadProbeCallback(GstPad* pad, GstPadProbeInfo* info, GStreamerGWorld* gstGWorld)
+{
+ gstGWorld->removePlatformVideoSink();
+ return GST_PAD_PROBE_REMOVE;
+}
+#endif
+
void GStreamerGWorld::exitFullscreen()
{
if (!m_dynamicPadName)
return;
- // Get video sink bin and the elements to remove.
- GRefPtr<GstElement> videoSink;
GstElement* sinkPtr = 0;
+ g_object_get(m_pipeline, "video-sink", &sinkPtr, NULL);
+ GRefPtr<GstElement> videoSink = adoptGRef(sinkPtr);
+
+ GRefPtr<GstElement> tee = adoptGRef(gst_bin_get_by_name(GST_BIN(videoSink.get()), "videoTee"));
+ GRefPtr<GstPad> srcPad = adoptGRef(gst_element_get_static_pad(tee.get(), m_dynamicPadName.get()));
+
+ // Block data flow towards the pipeline branch to remove. No need
+ // for pad blocking if the pipeline is paused.
+ GstState state;
+ gst_element_get_state(m_pipeline, &state, 0, 0);
+#ifdef GST_API_VERSION_1
+ if (state >= GST_STATE_PLAYING)
+ gst_pad_add_probe(srcPad.get(), GST_PAD_PROBE_TYPE_IDLE, reinterpret_cast<GstPadProbeCallback>(gstGWorldPadProbeCallback), this, 0);
+ else
+#else
+ if (state < GST_STATE_PLAYING || gst_pad_set_blocked(srcPad.get(), true))
+#endif
+ removePlatformVideoSink();
+
+ m_videoWindow = 0;
+}
+
+void GStreamerGWorld::removePlatformVideoSink()
+{
+ if (!m_dynamicPadName)
+ return;
+ // Get video sink bin and the elements to remove.
+ GstElement* sinkPtr = 0;
g_object_get(m_pipeline, "video-sink", &sinkPtr, NULL);
- videoSink = adoptGRef(sinkPtr);
+ GRefPtr<GstElement> videoSink = adoptGRef(sinkPtr);
GRefPtr<GstElement> tee = adoptGRef(gst_bin_get_by_name(GST_BIN(videoSink.get()), "videoTee"));
GRefPtr<GstElement> platformVideoSink = adoptGRef(gst_bin_get_by_name(GST_BIN(videoSink.get()), "platformVideoSink"));
@@ -166,28 +235,17 @@ void GStreamerGWorld::exitFullscreen()
GRefPtr<GstElement> colorspace = adoptGRef(gst_bin_get_by_name(GST_BIN(videoSink.get()), "colorspace"));
GRefPtr<GstElement> videoScale = adoptGRef(gst_bin_get_by_name(GST_BIN(videoSink.get()), "videoScale"));
- // Get pads to unlink and remove.
GRefPtr<GstPad> srcPad = adoptGRef(gst_element_get_static_pad(tee.get(), m_dynamicPadName.get()));
GRefPtr<GstPad> sinkPad = adoptGRef(gst_element_get_static_pad(queue.get(), "sink"));
+ gst_pad_unlink(srcPad.get(), sinkPad.get());
+ gst_element_release_request_pad(tee.get(), srcPad.get());
- // Block data flow towards the pipeline branch to remove. No need
- // for pad blocking if the pipeline is paused.
- GstState state;
- gst_element_get_state(m_pipeline, &state, 0, 0);
- if (state < GST_STATE_PLAYING || gst_pad_set_blocked(srcPad.get(), true)) {
-
- // Unlink and release request pad.
- gst_pad_unlink(srcPad.get(), sinkPad.get());
- gst_element_release_request_pad(tee.get(), srcPad.get());
-
- // Unlink, remove and cleanup queue, ffmpegcolorspace, videoScale and sink.
- gst_element_unlink_many(queue.get(), colorspace.get(), videoScale.get(), platformVideoSink.get(), NULL);
- gst_bin_remove_many(GST_BIN(videoSink.get()), queue.get(), colorspace.get(), videoScale.get(), platformVideoSink.get(), NULL);
- gst_element_set_state(platformVideoSink.get(), GST_STATE_NULL);
- gst_element_set_state(videoScale.get(), GST_STATE_NULL);
- gst_element_set_state(colorspace.get(), GST_STATE_NULL);
- gst_element_set_state(queue.get(), GST_STATE_NULL);
- }
+ gst_element_unlink_many(queue.get(), colorspace.get(), videoScale.get(), platformVideoSink.get(), NULL);
+ gst_bin_remove_many(GST_BIN(videoSink.get()), queue.get(), colorspace.get(), videoScale.get(), platformVideoSink.get(), NULL);
+ gst_element_set_state(platformVideoSink.get(), GST_STATE_NULL);
+ gst_element_set_state(videoScale.get(), GST_STATE_NULL);
+ gst_element_set_state(colorspace.get(), GST_STATE_NULL);
+ gst_element_set_state(queue.get(), GST_STATE_NULL);
m_dynamicPadName.clear();
}
@@ -196,7 +254,11 @@ void GStreamerGWorld::setWindowOverlay(GstMessage* message)
{
GstObject* sink = GST_MESSAGE_SRC(message);
+#ifndef GST_API_VERSION_1
if (!GST_IS_X_OVERLAY(sink))
+#else
+ if (!GST_IS_VIDEO_OVERLAY(sink))
+#endif
return;
if (g_object_class_find_property(G_OBJECT_GET_CLASS(sink), "force-aspect-ratio"))
@@ -205,6 +267,7 @@ void GStreamerGWorld::setWindowOverlay(GstMessage* message)
if (m_videoWindow) {
m_videoWindow->prepareForOverlay(message);
+#ifndef GST_API_VERSION_1
// gst_x_overlay_set_window_handle was introduced in -plugins-base
// 0.10.31, just like the macro for checking the version.
#ifdef GST_CHECK_PLUGINS_BASE_VERSION
@@ -212,8 +275,11 @@ void GStreamerGWorld::setWindowOverlay(GstMessage* message)
#else
gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(sink), m_videoWindow->videoWindowId());
#endif
+#else
+ gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(sink), m_videoWindow->videoWindowId());
+#endif
}
}
}
-#endif // ENABLE(VIDEO) && USE(GSTREAMER) && !defined(GST_API_VERSION_1)
+#endif // ENABLE(VIDEO) && USE(GSTREAMER) && USE(NATIVE_FULLSCREEN_VIDEO)
diff --git a/Source/WebCore/platform/graphics/gstreamer/GStreamerGWorld.h b/Source/WebCore/platform/graphics/gstreamer/GStreamerGWorld.h
index dff47b008..22806b408 100644
--- a/Source/WebCore/platform/graphics/gstreamer/GStreamerGWorld.h
+++ b/Source/WebCore/platform/graphics/gstreamer/GStreamerGWorld.h
@@ -20,7 +20,7 @@
#ifndef GStreamerGWorld_h
#define GStreamerGWorld_h
-#if ENABLE(VIDEO) && USE(GSTREAMER) && !defined(GST_API_VERSION_1)
+#if ENABLE(VIDEO) && USE(GSTREAMER) && USE(NATIVE_FULLSCREEN_VIDEO)
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
@@ -49,6 +49,7 @@ public:
~GStreamerGWorld();
GstElement* pipeline() const { return m_pipeline; }
+ void removePlatformVideoSink();
// Returns the full-screen window created
bool enterFullscreen();
@@ -67,5 +68,5 @@ private:
};
}
-#endif // ENABLE(VIDEO) && USE(GSTREAMER) && !defined(GST_API_VERSION_1)
+#endif // ENABLE(VIDEO) && USE(GSTREAMER) && USE(NATIVE_FULLSCREEN_VIDEO)
#endif
diff --git a/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.cpp b/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.cpp
index 1b5741e55..fc3862da8 100644
--- a/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.cpp
+++ b/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.cpp
@@ -20,11 +20,10 @@
#include "config.h"
#include "GStreamerUtilities.h"
+#if USE(GSTREAMER)
#include <gst/gst.h>
#include <wtf/gobject/GOwnPtr.h>
-#if USE(GSTREAMER)
-
namespace WebCore {
bool initializeGStreamer()
@@ -43,4 +42,4 @@ bool initializeGStreamer()
}
-#endif // ENABLE(WEB_AUDIO) && USE(GSTREAMER)
+#endif // USE(GSTREAMER)
diff --git a/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.h b/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.h
index 87bcf6787..a2bb1fdeb 100644
--- a/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.h
+++ b/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.h
@@ -20,6 +20,14 @@
GST_DEBUG(__VA_ARGS__); \
LOG_VERBOSE(Media, __VA_ARGS__); } while (0)
+#define ERROR_MEDIA_MESSAGE(...) do { \
+ GST_ERROR(__VA_ARGS__); \
+ LOG_VERBOSE(Media, __VA_ARGS__); } while (0)
+
+#define INFO_MEDIA_MESSAGE(...) do { \
+ GST_INFO(__VA_ARGS__); \
+ LOG_VERBOSE(Media, __VA_ARGS__); } while (0)
+
namespace WebCore {
bool initializeGStreamer();
}
diff --git a/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.cpp b/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.cpp
index 30f5d99ca..b070ffb39 100644
--- a/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.cpp
+++ b/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012 Igalia, S.L.
+ * Copyright (C) 2013 Collabora Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -21,8 +22,18 @@
#include "GStreamerVersioning.h"
+#if USE(GSTREAMER)
#include "IntSize.h"
-#include <wtf/UnusedParam.h>
+
+#ifdef GST_API_VERSION_1
+#include <gst/audio/audio.h>
+#else
+#include <gst/audio/multichannel.h>
+#endif
+
+#ifdef GST_API_VERSION_1
+const char* webkitGstMapInfoQuarkString = "webkit-gst-map-info";
+#endif
void webkitGstObjectRefSink(GstObject* gstObject)
{
@@ -63,11 +74,24 @@ GRefPtr<GstCaps> webkitGstGetPadCaps(GstPad* pad)
#endif
}
+GRefPtr<GstBus> webkitGstPipelineGetBus(GstPipeline* pipeline)
+{
+#ifdef GST_API_VERSION_1
+ return adoptGRef(gst_pipeline_get_bus(pipeline));
+#else
+ // gst_pipeline_get_bus returns a floating reference in
+ // gstreamer 0.10 so we should not adopt.
+ return gst_pipeline_get_bus(pipeline);
+#endif
+}
+
+#if ENABLE(VIDEO)
bool getVideoSizeAndFormatFromCaps(GstCaps* caps, WebCore::IntSize& size, GstVideoFormat& format, int& pixelAspectRatioNumerator, int& pixelAspectRatioDenominator, int& stride)
{
#ifdef GST_API_VERSION_1
GstVideoInfo info;
- if (!gst_video_info_from_caps(&info, caps))
+
+ if (!gst_caps_is_fixed(caps) || !gst_video_info_from_caps(&info, caps))
return false;
format = GST_VIDEO_INFO_FORMAT(&info);
@@ -90,6 +114,7 @@ bool getVideoSizeAndFormatFromCaps(GstCaps* caps, WebCore::IntSize& size, GstVid
return true;
}
+#endif
GstBuffer* createGstBuffer(GstBuffer* buffer)
{
@@ -111,6 +136,75 @@ GstBuffer* createGstBuffer(GstBuffer* buffer)
return newBuffer;
}
+GstBuffer* createGstBufferForData(const char* data, int length)
+{
+ GstBuffer* buffer = gst_buffer_new_and_alloc(length);
+
+#ifdef GST_API_VERSION_1
+ gst_buffer_fill(buffer, 0, data, length);
+#else
+ memcpy(GST_BUFFER_DATA(buffer), data, length);
+#endif
+
+ return buffer;
+}
+
+int getGstBufferSize(GstBuffer* buffer)
+{
+#ifdef GST_API_VERSION_1
+ return gst_buffer_get_size(buffer);
+#else
+ return GST_BUFFER_SIZE(buffer);
+#endif
+}
+
+void setGstBufferSize(GstBuffer* buffer, int newSize)
+{
+#ifdef GST_API_VERSION_1
+ gst_buffer_set_size(buffer, static_cast<gssize>(newSize));
+#else
+ GST_BUFFER_SIZE(buffer) = static_cast<gsize>(newSize);
+#endif
+}
+
+char* getGstBufferDataPointer(GstBuffer* buffer)
+{
+#ifdef GST_API_VERSION_1
+ GstMiniObject* miniObject = reinterpret_cast<GstMiniObject*>(buffer);
+ GstMapInfo* mapInfo = static_cast<GstMapInfo*>(gst_mini_object_get_qdata(miniObject, g_quark_from_static_string(webkitGstMapInfoQuarkString)));
+ return reinterpret_cast<char*>(mapInfo->data);
+#else
+ return reinterpret_cast<char*>(GST_BUFFER_DATA(buffer));
+#endif
+}
+
+#ifdef GST_API_VERSION_1
+void mapGstBuffer(GstBuffer* buffer)
+{
+ GstMapInfo* mapInfo = g_slice_new(GstMapInfo);
+ if (!gst_buffer_map(buffer, mapInfo, GST_MAP_WRITE)) {
+ g_slice_free(GstMapInfo, mapInfo);
+ gst_buffer_unref(buffer);
+ return;
+ }
+
+ GstMiniObject* miniObject = reinterpret_cast<GstMiniObject*>(buffer);
+ gst_mini_object_set_qdata(miniObject, g_quark_from_static_string(webkitGstMapInfoQuarkString), mapInfo, 0);
+}
+
+void unmapGstBuffer(GstBuffer* buffer)
+{
+ GstMiniObject* miniObject = reinterpret_cast<GstMiniObject*>(buffer);
+ GstMapInfo* mapInfo = static_cast<GstMapInfo*>(gst_mini_object_steal_qdata(miniObject, g_quark_from_static_string(webkitGstMapInfoQuarkString)));
+
+ if (!mapInfo)
+ return;
+
+ gst_buffer_unmap(buffer, mapInfo);
+ g_slice_free(GstMapInfo, mapInfo);
+}
+#endif
+
void setGstElementClassMetadata(GstElementClass* elementClass, const char* name, const char* longName, const char* description, const char* author)
{
#ifdef GST_API_VERSION_1
@@ -138,3 +232,22 @@ void notifyGstTagsOnPad(GstElement* element, GstPad* pad, GstTagList* tags)
gst_element_found_tags_for_pad(element, pad, tags);
#endif
}
+
+#if ENABLE(WEB_AUDIO)
+GstCaps* getGstAudioCaps(int channels, float sampleRate)
+{
+#ifdef GST_API_VERSION_1
+ return gst_caps_new_simple("audio/x-raw", "rate", G_TYPE_INT, static_cast<int>(sampleRate),
+ "channels", G_TYPE_INT, channels,
+ "format", G_TYPE_STRING, gst_audio_format_to_string(GST_AUDIO_FORMAT_F32),
+ "layout", G_TYPE_STRING, "interleaved", NULL);
+#else
+ return gst_caps_new_simple("audio/x-raw-float", "rate", G_TYPE_INT, static_cast<int>(sampleRate),
+ "channels", G_TYPE_INT, channels,
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "width", G_TYPE_INT, 32, NULL);
+#endif
+}
+#endif
+
+#endif // USE(GSTREAMER)
diff --git a/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.h b/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.h
index e5d8065ce..3ee325e6f 100644
--- a/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.h
+++ b/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.h
@@ -19,6 +19,7 @@
#ifndef GStreamerVersioning_h
#define GStreamerVersioning_h
+#if USE(GSTREAMER)
#include "GRefPtrGStreamer.h"
#include <gst/gst.h>
@@ -31,9 +32,24 @@ class IntSize;
void webkitGstObjectRefSink(GstObject*);
GstPad* webkitGstGhostPadFromStaticTemplate(GstStaticPadTemplate*, const gchar* name, GstPad* target);
GRefPtr<GstCaps> webkitGstGetPadCaps(GstPad*);
+GRefPtr<GstBus> webkitGstPipelineGetBus(GstPipeline*);
+#if ENABLE(VIDEO)
bool getVideoSizeAndFormatFromCaps(GstCaps*, WebCore::IntSize&, GstVideoFormat&, int& pixelAspectRatioNumerator, int& pixelAspectRatioDenominator, int& stride);
+#endif
GstBuffer* createGstBuffer(GstBuffer*);
+GstBuffer* createGstBufferForData(const char* data, int length);
+int getGstBufferSize(GstBuffer*);
+void setGstBufferSize(GstBuffer*, int newSize);
+char* getGstBufferDataPointer(GstBuffer*);
+#ifdef GST_API_VERSION_1
+void mapGstBuffer(GstBuffer*);
+void unmapGstBuffer(GstBuffer*);
+#endif
void setGstElementClassMetadata(GstElementClass*, const char* name, const char* longName, const char* description, const char* author);
bool gstObjectIsFloating(GstObject*);
void notifyGstTagsOnPad(GstElement*, GstPad*, GstTagList*);
+#if ENABLE(WEB_AUDIO)
+GstCaps* getGstAudioCaps(int channels, float sampleRate);
+#endif
+#endif // USE(GSTREAMER)
#endif // GStreamerVersioning_h
diff --git a/Source/WebCore/platform/graphics/gstreamer/ImageGStreamer.h b/Source/WebCore/platform/graphics/gstreamer/ImageGStreamer.h
index 83bdfe2b7..8b46cd688 100644
--- a/Source/WebCore/platform/graphics/gstreamer/ImageGStreamer.h
+++ b/Source/WebCore/platform/graphics/gstreamer/ImageGStreamer.h
@@ -51,15 +51,19 @@ class ImageGStreamer : public RefCounted<ImageGStreamer> {
{
if (!m_cropRect.isEmpty())
return FloatRect(m_cropRect);
-
- // Default rectangle used by GraphicsContext::drawImage().
- return FloatRect(0, 0, -1, -1);
+ ASSERT(m_image);
+ return FloatRect(0, 0, m_image->size().width(), m_image->size().height());
}
private:
ImageGStreamer(GstBuffer*, GstCaps*);
RefPtr<BitmapImage> m_image;
FloatRect m_cropRect;
+
+#if USE(CAIRO) && defined(GST_API_VERSION_1)
+ GRefPtr<GstBuffer> m_buffer;
+ GstMapInfo m_mapInfo;
+#endif
};
}
diff --git a/Source/WebCore/platform/graphics/gstreamer/ImageGStreamerCairo.cpp b/Source/WebCore/platform/graphics/gstreamer/ImageGStreamerCairo.cpp
index d3f7fa73b..328c53e4e 100644
--- a/Source/WebCore/platform/graphics/gstreamer/ImageGStreamerCairo.cpp
+++ b/Source/WebCore/platform/graphics/gstreamer/ImageGStreamerCairo.cpp
@@ -36,6 +36,9 @@ using namespace std;
using namespace WebCore;
ImageGStreamer::ImageGStreamer(GstBuffer* buffer, GstCaps* caps)
+#ifdef GST_API_VERSION_1
+ : m_buffer(buffer)
+#endif
{
GstVideoFormat format;
IntSize size;
@@ -43,9 +46,8 @@ ImageGStreamer::ImageGStreamer(GstBuffer* buffer, GstCaps* caps)
getVideoSizeAndFormatFromCaps(caps, size, format, pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride);
#ifdef GST_API_VERSION_1
- GstMapInfo mapInfo;
- gst_buffer_map(buffer, &mapInfo, GST_MAP_READ);
- unsigned char* bufferData = reinterpret_cast<unsigned char*>(mapInfo.data);
+ gst_buffer_map(buffer, &m_mapInfo, GST_MAP_READ);
+ unsigned char* bufferData = reinterpret_cast<unsigned char*>(m_mapInfo.data);
#else
unsigned char* bufferData = reinterpret_cast<unsigned char*>(GST_BUFFER_DATA(buffer));
#endif
@@ -57,15 +59,13 @@ ImageGStreamer::ImageGStreamer(GstBuffer* buffer, GstCaps* caps)
cairoFormat = (format == GST_VIDEO_FORMAT_ARGB) ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24;
#endif
- cairo_surface_t* surface = cairo_image_surface_create_for_data(bufferData, cairoFormat, size.width(), size.height(), stride);
- ASSERT(cairo_surface_status(surface) == CAIRO_STATUS_SUCCESS);
- m_image = BitmapImage::create(surface);
+ RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create_for_data(bufferData, cairoFormat, size.width(), size.height(), stride));
+ ASSERT(cairo_surface_status(surface.get()) == CAIRO_STATUS_SUCCESS);
+ m_image = BitmapImage::create(surface.release());
#ifdef GST_API_VERSION_1
if (GstVideoCropMeta* cropMeta = gst_buffer_get_video_crop_meta(buffer))
setCropRect(FloatRect(cropMeta->x, cropMeta->y, cropMeta->width, cropMeta->height));
-
- gst_buffer_unmap(buffer, &mapInfo);
#endif
}
@@ -75,5 +75,11 @@ ImageGStreamer::~ImageGStreamer()
m_image.clear();
m_image = 0;
+
+#ifdef GST_API_VERSION_1
+ // We keep the buffer memory mapped until the image is destroyed because the internal
+ // cairo_surface_t was created using cairo_image_surface_create_for_data().
+ gst_buffer_unmap(m_buffer.get(), &m_mapInfo);
+#endif
}
#endif // USE(GSTREAMER)
diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
index 6b69cb006..de27ee07d 100644
--- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
+++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
@@ -3,7 +3,7 @@
* Copyright (C) 2007 Collabora Ltd. All rights reserved.
* Copyright (C) 2007 Alp Toker <alp@atoker.com>
* Copyright (C) 2009 Gustavo Noronha Silva <gns@gnome.org>
- * Copyright (C) 2009, 2010 Igalia S.L
+ * Copyright (C) 2009, 2010, 2011, 2012, 2013 Igalia S.L
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -26,30 +26,19 @@
#if ENABLE(VIDEO) && USE(GSTREAMER)
-#include "ColorSpace.h"
-#include "Document.h"
-#include "Frame.h"
-#include "FrameView.h"
-#include "GStreamerGWorld.h"
#include "GStreamerUtilities.h"
#include "GStreamerVersioning.h"
-#include "GraphicsContext.h"
-#include "GraphicsTypes.h"
-#include "ImageGStreamer.h"
-#include "ImageOrientation.h"
-#include "IntRect.h"
#include "KURL.h"
+#include "Logging.h"
#include "MIMETypeRegistry.h"
#include "MediaPlayer.h"
#include "NotImplemented.h"
#include "SecurityOrigin.h"
#include "TimeRanges.h"
-#include "VideoSinkGStreamer.h"
#include "WebKitWebSourceGStreamer.h"
#include <gst/gst.h>
-#include <gst/video/video.h>
+#include <gst/pbutils/missing-plugins.h>
#include <limits>
-#include <math.h>
#include <wtf/gobject/GOwnPtr.h>
#include <wtf/text/CString.h>
@@ -87,24 +76,13 @@ static const char* gPlaybinName = "playbin2";
static const gint64 gPercentMax = 100;
#endif
-GST_DEBUG_CATEGORY_STATIC(webkit_media_player_debug);
+GST_DEBUG_CATEGORY_EXTERN(webkit_media_player_debug);
#define GST_CAT_DEFAULT webkit_media_player_debug
using namespace std;
namespace WebCore {
-static int greatestCommonDivisor(int a, int b)
-{
- while (b) {
- int temp = a;
- a = b;
- b = temp % b;
- }
-
- return ABS(a);
-}
-
static gboolean mediaPlayerPrivateMessageCallback(GstBus*, GstMessage* message, MediaPlayerPrivateGStreamer* player)
{
return player->handleMessage(message);
@@ -115,32 +93,6 @@ static void mediaPlayerPrivateSourceChangedCallback(GObject*, GParamSpec*, Media
player->sourceChanged();
}
-static void mediaPlayerPrivateVolumeChangedCallback(GObject*, GParamSpec*, MediaPlayerPrivateGStreamer* player)
-{
- // This is called when playbin receives the notify::volume signal.
- player->volumeChanged();
-}
-
-static gboolean mediaPlayerPrivateVolumeChangeTimeoutCallback(MediaPlayerPrivateGStreamer* player)
-{
- // This is the callback of the timeout source created in ::volumeChanged.
- player->notifyPlayerOfVolumeChange();
- return FALSE;
-}
-
-static void mediaPlayerPrivateMuteChangedCallback(GObject*, GParamSpec*, MediaPlayerPrivateGStreamer* player)
-{
- // This is called when playbin receives the notify::mute signal.
- player->muteChanged();
-}
-
-static gboolean mediaPlayerPrivateMuteChangeTimeoutCallback(MediaPlayerPrivateGStreamer* player)
-{
- // This is the callback of the timeout source created in ::muteChanged.
- player->notifyPlayerOfMute();
- return FALSE;
-}
-
static void mediaPlayerPrivateVideoSinkCapsChangedCallback(GObject*, GParamSpec*, MediaPlayerPrivateGStreamer* player)
{
player->videoChanged();
@@ -163,6 +115,16 @@ static gboolean mediaPlayerPrivateAudioChangeTimeoutCallback(MediaPlayerPrivateG
return FALSE;
}
+#ifdef GST_API_VERSION_1
+static void setAudioStreamPropertiesCallback(GstChildProxy*, GObject* object, gchar*,
+ MediaPlayerPrivateGStreamer* player)
+#else
+static void setAudioStreamPropertiesCallback(GstChildProxy*, GObject* object, MediaPlayerPrivateGStreamer* player)
+#endif
+{
+ player->setAudioStreamProperties(object);
+}
+
static gboolean mediaPlayerPrivateVideoChangeTimeoutCallback(MediaPlayerPrivateGStreamer* player)
{
// This is the callback of the timeout source created in ::videoChanged.
@@ -170,9 +132,36 @@ static gboolean mediaPlayerPrivateVideoChangeTimeoutCallback(MediaPlayerPrivateG
return FALSE;
}
-static void mediaPlayerPrivateRepaintCallback(WebKitVideoSink*, GstBuffer *buffer, MediaPlayerPrivateGStreamer* playerPrivate)
+static void mediaPlayerPrivatePluginInstallerResultFunction(GstInstallPluginsReturn result, gpointer userData)
{
- playerPrivate->triggerRepaint(buffer);
+ MediaPlayerPrivateGStreamer* player = reinterpret_cast<MediaPlayerPrivateGStreamer*>(userData);
+ player->handlePluginInstallerResult(result);
+}
+
+static GstClockTime toGstClockTime(float time)
+{
+ // Extract the integer part of the time (seconds) and the fractional part (microseconds). Attempt to
+ // round the microseconds so no floating point precision is lost and we can perform an accurate seek.
+ float seconds;
+ float microSeconds = modf(time, &seconds) * 1000000;
+ GTimeVal timeValue;
+ timeValue.tv_sec = static_cast<glong>(seconds);
+ timeValue.tv_usec = static_cast<glong>(roundf(microSeconds / 10000) * 10000);
+ return GST_TIMEVAL_TO_TIME(timeValue);
+}
+
+void MediaPlayerPrivateGStreamer::setAudioStreamProperties(GObject* object)
+{
+ if (g_strcmp0(G_OBJECT_TYPE_NAME(object), "GstPulseSink"))
+ return;
+
+ const char* role = m_player->mediaPlayerClient() && m_player->mediaPlayerClient()->mediaPlayerIsVideo()
+ ? "video" : "music";
+ GstStructure* structure = gst_structure_new("stream-properties", "media.role", G_TYPE_STRING, role, NULL);
+ g_object_set(object, "stream-properties", structure, NULL);
+ gst_structure_free(structure);
+ GOwnPtr<gchar> elementName(gst_element_get_name(GST_ELEMENT(object)));
+ LOG_MEDIA_MESSAGE("Set media.role as %s at %s", role, elementName.get());
}
PassOwnPtr<MediaPlayerPrivateInterface> MediaPlayerPrivateGStreamer::create(MediaPlayer* player)
@@ -210,48 +199,43 @@ bool MediaPlayerPrivateGStreamer::isAvailable()
}
MediaPlayerPrivateGStreamer::MediaPlayerPrivateGStreamer(MediaPlayer* player)
- : m_player(player)
- , m_webkitVideoSink(0)
- , m_fpsSink(0)
+ : MediaPlayerPrivateGStreamerBase(player)
, m_source(0)
, m_seekTime(0)
, m_changingRate(false)
, m_endTime(numeric_limits<float>::infinity())
, m_isEndReached(false)
- , m_networkState(MediaPlayer::Empty)
- , m_readyState(MediaPlayer::HaveNothing)
, m_isStreaming(false)
- , m_size(IntSize())
- , m_buffer(0)
, m_mediaLocations(0)
, m_mediaLocationCurrentIndex(0)
, m_resetPipeline(false)
, m_paused(true)
, m_seeking(false)
+ , m_seekIsPending(false)
+ , m_timeOfOverlappingSeek(-1)
, m_buffering(false)
, m_playbackRate(1)
, m_errorOccured(false)
, m_mediaDuration(0)
- , m_startedBuffering(false)
+ , m_downloadFinished(false)
, m_fillTimer(this, &MediaPlayerPrivateGStreamer::fillTimerFired)
, m_maxTimeLoaded(0)
, m_bufferingPercentage(0)
- , m_preload(MediaPlayer::Auto)
+ , m_preload(player->preload())
, m_delayingLoad(false)
, m_mediaDurationKnown(true)
, m_maxTimeLoadedAtLastDidLoadingProgress(0)
- , m_volumeTimerHandler(0)
- , m_muteTimerHandler(0)
+ , m_volumeAndMuteInitialized(false)
, m_hasVideo(false)
, m_hasAudio(false)
, m_audioTimerHandler(0)
, m_videoTimerHandler(0)
, m_webkitAudioSink(0)
, m_totalBytes(-1)
- , m_originalPreloadWasAutoAndWasOverridden(false)
+ , m_preservesPitch(false)
+ , m_requestedState(GST_STATE_VOID_PENDING)
+ , m_missingPlugins(false)
{
- if (initializeGStreamerAndRegisterWebKitElements())
- createGSTPlayBin();
}
MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer()
@@ -259,34 +243,31 @@ MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer()
if (m_fillTimer.isActive())
m_fillTimer.stop();
- if (m_buffer)
- gst_buffer_unref(m_buffer);
- m_buffer = 0;
-
if (m_mediaLocations) {
gst_structure_free(m_mediaLocations);
m_mediaLocations = 0;
}
-#ifndef GST_API_VERSION_1
- if (m_videoSinkBin) {
- gst_object_unref(m_videoSinkBin);
- m_videoSinkBin = 0;
- }
-#endif
+ if (m_autoAudioSink)
+ g_signal_handlers_disconnect_by_func(G_OBJECT(m_autoAudioSink.get()),
+ reinterpret_cast<gpointer>(setAudioStreamPropertiesCallback), this);
if (m_playBin) {
- gst_element_set_state(m_playBin.get(), GST_STATE_NULL);
- m_playBin = 0;
- }
+ GRefPtr<GstBus> bus = webkitGstPipelineGetBus(GST_PIPELINE(m_playBin.get()));
+ ASSERT(bus);
+ g_signal_handlers_disconnect_by_func(bus.get(), reinterpret_cast<gpointer>(mediaPlayerPrivateMessageCallback), this);
+ gst_bus_remove_signal_watch(bus.get());
- m_player = 0;
+ g_signal_handlers_disconnect_by_func(m_playBin.get(), reinterpret_cast<gpointer>(mediaPlayerPrivateSourceChangedCallback), this);
+ g_signal_handlers_disconnect_by_func(m_playBin.get(), reinterpret_cast<gpointer>(mediaPlayerPrivateVideoChangedCallback), this);
+ g_signal_handlers_disconnect_by_func(m_playBin.get(), reinterpret_cast<gpointer>(mediaPlayerPrivateAudioChangedCallback), this);
- if (m_muteTimerHandler)
- g_source_remove(m_muteTimerHandler);
+ gst_element_set_state(m_playBin.get(), GST_STATE_NULL);
+ m_playBin.clear();
+ }
- if (m_volumeTimerHandler)
- g_source_remove(m_volumeTimerHandler);
+ GRefPtr<GstPad> videoSinkPad = adoptGRef(gst_element_get_static_pad(m_webkitVideoSink.get(), "sink"));
+ g_signal_handlers_disconnect_by_func(videoSinkPad.get(), reinterpret_cast<gpointer>(mediaPlayerPrivateVideoSinkCapsChangedCallback), this);
if (m_videoTimerHandler)
g_source_remove(m_videoTimerHandler);
@@ -297,6 +278,8 @@ MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer()
void MediaPlayerPrivateGStreamer::load(const String& url)
{
+ if (!initializeGStreamerAndRegisterWebKitElements())
+ return;
KURL kurl(KURL(), url);
String cleanUrl(url);
@@ -305,10 +288,15 @@ void MediaPlayerPrivateGStreamer::load(const String& url)
if (kurl.isLocalFile())
cleanUrl = cleanUrl.substring(0, kurl.pathEnd());
+ if (!m_playBin)
+ createGSTPlayBin();
+
+ ASSERT(m_playBin);
+
m_url = KURL(KURL(), cleanUrl);
g_object_set(m_playBin.get(), "uri", cleanUrl.utf8().data(), NULL);
- LOG_MEDIA_MESSAGE("Load %s", cleanUrl.utf8().data());
+ INFO_MEDIA_MESSAGE("Load %s", cleanUrl.utf8().data());
if (m_preload == MediaPlayer::None) {
LOG_MEDIA_MESSAGE("Delaying load.");
@@ -321,19 +309,29 @@ void MediaPlayerPrivateGStreamer::load(const String& url)
m_player->networkStateChanged();
m_readyState = MediaPlayer::HaveNothing;
m_player->readyStateChanged();
-
- // GStreamer needs to have the pipeline set to a paused state to
- // start providing anything useful.
- gst_element_set_state(m_playBin.get(), GST_STATE_PAUSED);
+ m_volumeAndMuteInitialized = false;
if (!m_delayingLoad)
commitLoad();
}
+#if ENABLE(MEDIA_SOURCE)
+void MediaPlayerPrivateGStreamer::load(const String& url, PassRefPtr<MediaSource>)
+{
+ notImplemented();
+}
+#endif
+
void MediaPlayerPrivateGStreamer::commitLoad()
{
ASSERT(!m_delayingLoad);
LOG_MEDIA_MESSAGE("Committing load.");
+
+ // GStreamer needs to have the pipeline set to a paused state to
+ // start providing anything useful.
+ gst_element_set_state(m_playBin.get(), GST_STATE_PAUSED);
+
+ setDownloadBuffering();
updateStates();
}
@@ -348,30 +346,26 @@ float MediaPlayerPrivateGStreamer::playbackPosition() const
return m_seekTime;
if (m_mediaDuration)
return m_mediaDuration;
+ return 0;
}
- float ret = 0.0f;
-
- GstQuery* query = gst_query_new_position(GST_FORMAT_TIME);
- if (!gst_element_query(m_playBin.get(), query)) {
- LOG_MEDIA_MESSAGE("Position query failed...");
- gst_query_unref(query);
- return ret;
- }
-
- gint64 position;
- gst_query_parse_position(query, 0, &position);
+ // Position is only available if no async state change is going on and the state is either paused or playing.
+ gint64 position = GST_CLOCK_TIME_NONE;
+ GstQuery* query= gst_query_new_position(GST_FORMAT_TIME);
+ if (gst_element_query(m_playBin.get(), query))
+ gst_query_parse_position(query, 0, &position);
- // Position is available only if the pipeline is not in GST_STATE_NULL or
- // GST_STATE_READY state.
- if (position != static_cast<gint64>(GST_CLOCK_TIME_NONE))
- ret = static_cast<double>(position) / GST_SECOND;
+ float result = 0.0f;
+ if (static_cast<GstClockTime>(position) != GST_CLOCK_TIME_NONE)
+ result = static_cast<double>(position) / GST_SECOND;
+ else if (m_canFallBackToLastFinishedSeekPositon)
+ result = m_seekTime;
LOG_MEDIA_MESSAGE("Position %" GST_TIME_FORMAT, GST_TIME_ARGS(position));
gst_query_unref(query);
- return ret;
+ return result;
}
bool MediaPlayerPrivateGStreamer::changePipelineState(GstState newState)
@@ -382,9 +376,14 @@ bool MediaPlayerPrivateGStreamer::changePipelineState(GstState newState)
GstState pending;
gst_element_get_state(m_playBin.get(), &currentState, &pending, 0);
- LOG_MEDIA_MESSAGE("Current state: %s, pending: %s", gst_element_state_get_name(currentState), gst_element_state_get_name(pending));
- if (currentState == newState || pending == newState)
+ if (currentState == newState || pending == newState) {
+ LOG_MEDIA_MESSAGE("Rejected state change to %s from %s with %s pending", gst_element_state_get_name(newState),
+ gst_element_state_get_name(currentState), gst_element_state_get_name(pending));
return true;
+ }
+
+ LOG_MEDIA_MESSAGE("Changing state change to %s from %s with %s pending", gst_element_state_get_name(newState),
+ gst_element_state_get_name(currentState), gst_element_state_get_name(pending));
GstStateChangeReturn setStateResult = gst_element_set_state(m_playBin.get(), newState);
GstState pausedOrPlaying = newState == GST_STATE_PLAYING ? GST_STATE_PAUSED : GST_STATE_PLAYING;
@@ -397,9 +396,7 @@ bool MediaPlayerPrivateGStreamer::changePipelineState(GstState newState)
void MediaPlayerPrivateGStreamer::prepareToPlay()
{
- m_isEndReached = false;
- m_seeking = false;
-
+ m_preload = MediaPlayer::Auto;
if (m_delayingLoad) {
m_delayingLoad = false;
commitLoad();
@@ -410,17 +407,22 @@ void MediaPlayerPrivateGStreamer::play()
{
if (changePipelineState(GST_STATE_PLAYING)) {
m_isEndReached = false;
+ m_delayingLoad = false;
+ m_preload = MediaPlayer::Auto;
+ setDownloadBuffering();
LOG_MEDIA_MESSAGE("Play");
}
}
void MediaPlayerPrivateGStreamer::pause()
{
- if (m_isEndReached)
+ GstState currentState, pendingState;
+ gst_element_get_state(m_playBin.get(), &currentState, &pendingState, 0);
+ if (currentState < GST_STATE_PAUSED && pendingState <= GST_STATE_PAUSED)
return;
if (changePipelineState(GST_STATE_PAUSED))
- LOG_MEDIA_MESSAGE("Pause");
+ INFO_MEDIA_MESSAGE("Pause");
}
float MediaPlayerPrivateGStreamer::duration() const
@@ -453,7 +455,8 @@ float MediaPlayerPrivateGStreamer::duration() const
LOG_MEDIA_MESSAGE("Duration: %" GST_TIME_FORMAT, GST_TIME_ARGS(timeLength));
- return static_cast<double>(timeLength) / GST_SECOND;
+ m_mediaDuration = static_cast<double>(timeLength) / GST_SECOND;
+ return m_mediaDuration;
// FIXME: handle 3.14.9.5 properly
}
@@ -477,7 +480,6 @@ float MediaPlayerPrivateGStreamer::currentTime() const
return 0.0f;
return playbackPosition();
-
}
void MediaPlayerPrivateGStreamer::seek(float time)
@@ -488,35 +490,51 @@ void MediaPlayerPrivateGStreamer::seek(float time)
if (m_errorOccured)
return;
- LOG_MEDIA_MESSAGE("Seek attempt to %f secs", time);
+ INFO_MEDIA_MESSAGE("[Seek] seek attempt to %f secs", time);
// Avoid useless seeking.
if (time == currentTime())
return;
- // Extract the integer part of the time (seconds) and the
- // fractional part (microseconds). Attempt to round the
- // microseconds so no floating point precision is lost and we can
- // perform an accurate seek.
- float seconds;
- float microSeconds = modf(time, &seconds) * 1000000;
- GTimeVal timeValue;
- timeValue.tv_sec = static_cast<glong>(seconds);
- timeValue.tv_usec = static_cast<glong>(roundf(microSeconds / 10000) * 10000);
+ if (isLiveStream())
+ return;
- GstClockTime clockTime = GST_TIMEVAL_TO_TIME(timeValue);
- LOG_MEDIA_MESSAGE("Seek: %" GST_TIME_FORMAT, GST_TIME_ARGS(clockTime));
-
- if (!gst_element_seek(m_playBin.get(), m_player->rate(),
- GST_FORMAT_TIME,
- (GstSeekFlags)(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE),
- GST_SEEK_TYPE_SET, clockTime,
- GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE))
- LOG_MEDIA_MESSAGE("Seek to %f failed", time);
- else {
- m_seeking = true;
- m_seekTime = time;
+ GstClockTime clockTime = toGstClockTime(time);
+ INFO_MEDIA_MESSAGE("[Seek] seeking to %" GST_TIME_FORMAT " (%f)", GST_TIME_ARGS(clockTime), time);
+
+ if (m_seeking) {
+ m_timeOfOverlappingSeek = time;
+ if (m_seekIsPending) {
+ m_seekTime = time;
+ return;
+ }
+ }
+
+ GstState state;
+ GstStateChangeReturn getStateResult = gst_element_get_state(m_playBin.get(), &state, 0, 0);
+ if (getStateResult == GST_STATE_CHANGE_FAILURE || getStateResult == GST_STATE_CHANGE_NO_PREROLL) {
+ LOG_MEDIA_MESSAGE("[Seek] cannot seek, current state change is %s", gst_element_state_change_return_get_name(getStateResult));
+ return;
}
+ if (getStateResult == GST_STATE_CHANGE_ASYNC || state < GST_STATE_PAUSED || m_isEndReached) {
+ m_seekIsPending = true;
+ if (m_isEndReached) {
+ LOG_MEDIA_MESSAGE("[Seek] reset pipeline");
+ m_resetPipeline = true;
+ changePipelineState(GST_STATE_PAUSED);
+ }
+ } else {
+ // We can seek now.
+ if (!gst_element_seek(m_playBin.get(), m_player->rate(), GST_FORMAT_TIME, static_cast<GstSeekFlags>(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE),
+ GST_SEEK_TYPE_SET, clockTime, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE)) {
+ LOG_MEDIA_MESSAGE("[Seek] seeking to %f failed", time);
+ return;
+ }
+ }
+
+ m_seeking = true;
+ m_seekTime = time;
+ m_isEndReached = false;
}
bool MediaPlayerPrivateGStreamer::paused() const
@@ -536,66 +554,6 @@ bool MediaPlayerPrivateGStreamer::seeking() const
return m_seeking;
}
-// Returns the size of the video
-IntSize MediaPlayerPrivateGStreamer::naturalSize() const
-{
- if (!hasVideo())
- return IntSize();
-
- if (!m_videoSize.isEmpty())
- return m_videoSize;
-
- GRefPtr<GstCaps> caps = webkitGstGetPadCaps(m_videoSinkPad.get());
- if (!caps)
- return IntSize();
-
-
- // TODO: handle possible clean aperture data. See
- // https://bugzilla.gnome.org/show_bug.cgi?id=596571
- // TODO: handle possible transformation matrix. See
- // https://bugzilla.gnome.org/show_bug.cgi?id=596326
-
- // Get the video PAR and original size, if this fails the
- // video-sink has likely not yet negotiated its caps.
- int pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride;
- IntSize originalSize;
- GstVideoFormat format;
- if (!getVideoSizeAndFormatFromCaps(caps.get(), originalSize, format, pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride))
- return IntSize();
-
- LOG_MEDIA_MESSAGE("Original video size: %dx%d", originalSize.width(), originalSize.height());
- LOG_MEDIA_MESSAGE("Pixel aspect ratio: %d/%d", pixelAspectRatioNumerator, pixelAspectRatioDenominator);
-
- // Calculate DAR based on PAR and video size.
- int displayWidth = originalSize.width() * pixelAspectRatioNumerator;
- int displayHeight = originalSize.height() * pixelAspectRatioDenominator;
-
- // Divide display width and height by their GCD to avoid possible overflows.
- int displayAspectRatioGCD = greatestCommonDivisor(displayWidth, displayHeight);
- displayWidth /= displayAspectRatioGCD;
- displayHeight /= displayAspectRatioGCD;
-
- // Apply DAR to original video size. This is the same behavior as in xvimagesink's setcaps function.
- guint64 width = 0, height = 0;
- if (!(originalSize.height() % displayHeight)) {
- LOG_MEDIA_MESSAGE("Keeping video original height");
- width = gst_util_uint64_scale_int(originalSize.height(), displayWidth, displayHeight);
- height = static_cast<guint64>(originalSize.height());
- } else if (!(originalSize.width() % displayWidth)) {
- LOG_MEDIA_MESSAGE("Keeping video original width");
- height = gst_util_uint64_scale_int(originalSize.width(), displayHeight, displayWidth);
- width = static_cast<guint64>(originalSize.width());
- } else {
- LOG_MEDIA_MESSAGE("Approximating while keeping original video height");
- width = gst_util_uint64_scale_int(originalSize.height(), displayWidth, displayHeight);
- height = static_cast<guint64>(originalSize.height());
- }
-
- LOG_MEDIA_MESSAGE("Natural size: %" G_GUINT64_FORMAT "x%" G_GUINT64_FORMAT, width, height);
- m_videoSize = IntSize(static_cast<int>(width), static_cast<int>(height));
- return m_videoSize;
-}
-
void MediaPlayerPrivateGStreamer::videoChanged()
{
if (m_videoTimerHandler)
@@ -636,37 +594,6 @@ void MediaPlayerPrivateGStreamer::notifyPlayerOfAudio()
m_player->mediaPlayerClient()->mediaPlayerEngineUpdated(m_player);
}
-void MediaPlayerPrivateGStreamer::setVolume(float volume)
-{
- if (!m_playBin)
- return;
-
- gst_stream_volume_set_volume(GST_STREAM_VOLUME(m_playBin.get()), GST_STREAM_VOLUME_FORMAT_CUBIC,
- static_cast<double>(volume));
-}
-
-void MediaPlayerPrivateGStreamer::notifyPlayerOfVolumeChange()
-{
- m_volumeTimerHandler = 0;
-
- if (!m_player || !m_playBin)
- return;
- double volume;
- volume = gst_stream_volume_get_volume(GST_STREAM_VOLUME(m_playBin.get()), GST_STREAM_VOLUME_FORMAT_CUBIC);
- // get_volume() can return values superior to 1.0 if the user
- // applies software user gain via third party application (GNOME
- // volume control for instance).
- volume = CLAMP(volume, 0.0, 1.0);
- m_player->volumeChanged(static_cast<float>(volume));
-}
-
-void MediaPlayerPrivateGStreamer::volumeChanged()
-{
- if (m_volumeTimerHandler)
- g_source_remove(m_volumeTimerHandler);
- m_volumeTimerHandler = g_timeout_add(0, reinterpret_cast<GSourceFunc>(mediaPlayerPrivateVolumeChangeTimeoutCallback), this);
-}
-
void MediaPlayerPrivateGStreamer::setRate(float rate)
{
// Avoid useless playback rate update.
@@ -697,11 +624,11 @@ void MediaPlayerPrivateGStreamer::setRate(float rate)
gint64 start, end;
bool mute = false;
- LOG_MEDIA_MESSAGE("Set Rate to %f", rate);
+ INFO_MEDIA_MESSAGE("Set Rate to %f", rate);
if (rate > 0) {
- // Mute the sound if the playback rate is too extreme.
- // TODO: in other cases we should perform pitch adjustments.
- mute = (bool) (rate < 0.8 || rate > 2);
+ // Mute the sound if the playback rate is too extreme and
+ // audio pitch is not adjusted.
+ mute = (!m_preservesPitch && (rate < 0.8 || rate > 2));
start = currentPosition;
end = GST_CLOCK_TIME_NONE;
} else {
@@ -716,24 +643,19 @@ void MediaPlayerPrivateGStreamer::setRate(float rate)
end = currentPosition;
}
- LOG_MEDIA_MESSAGE("Need to mute audio: %d", (int) mute);
+ INFO_MEDIA_MESSAGE("Need to mute audio?: %d", (int) mute);
if (!gst_element_seek(m_playBin.get(), rate, GST_FORMAT_TIME, flags,
GST_SEEK_TYPE_SET, start,
GST_SEEK_TYPE_SET, end))
- LOG_MEDIA_MESSAGE("Set rate to %f failed", rate);
+ ERROR_MEDIA_MESSAGE("Set rate to %f failed", rate);
else
g_object_set(m_playBin.get(), "mute", mute, NULL);
}
-MediaPlayer::NetworkState MediaPlayerPrivateGStreamer::networkState() const
-{
- return m_networkState;
-}
-
-MediaPlayer::ReadyState MediaPlayerPrivateGStreamer::readyState() const
+void MediaPlayerPrivateGStreamer::setPreservesPitch(bool preservesPitch)
{
- return m_readyState;
+ m_preservesPitch = preservesPitch;
}
PassRefPtr<TimeRanges> MediaPlayerPrivateGStreamer::buffered() const
@@ -744,7 +666,7 @@ PassRefPtr<TimeRanges> MediaPlayerPrivateGStreamer::buffered() const
#if GST_CHECK_VERSION(0, 10, 31)
float mediaDuration(duration());
- if (!mediaDuration || isinf(mediaDuration))
+ if (!mediaDuration || std::isinf(mediaDuration))
return timeRanges.release();
GstQuery* query = gst_query_new_buffering(GST_FORMAT_PERCENT);
@@ -784,6 +706,9 @@ gboolean MediaPlayerPrivateGStreamer::handleMessage(GstMessage* message)
bool issueError = true;
bool attemptNextLocation = false;
const GstStructure* structure = gst_message_get_structure(message);
+ GstState requestedState, currentState;
+
+ m_canFallBackToLastFinishedSeekPositon = false;
if (structure) {
const gchar* messageTypeName = gst_structure_get_name(structure);
@@ -796,13 +721,18 @@ gboolean MediaPlayerPrivateGStreamer::handleMessage(GstMessage* message)
}
}
- LOG_MEDIA_MESSAGE("Message received from element %s", GST_MESSAGE_SRC_NAME(message));
+ // We ignore state changes from internal elements. They are forwarded to playbin2 anyway.
+ bool messageSourceIsPlaybin = GST_MESSAGE_SRC(message) == reinterpret_cast<GstObject*>(m_playBin.get());
+
+ LOG_MEDIA_MESSAGE("Message %s received from element %s", GST_MESSAGE_TYPE_NAME(message), GST_MESSAGE_SRC_NAME(message));
switch (GST_MESSAGE_TYPE(message)) {
case GST_MESSAGE_ERROR:
if (m_resetPipeline)
break;
+ if (m_missingPlugins)
+ break;
gst_message_parse_error(message, &err.outPtr(), &debug.outPtr());
- LOG_MEDIA_MESSAGE("Error %d: %s (url=%s)", err->code, err->message, m_url.string().utf8().data());
+ ERROR_MEDIA_MESSAGE("Error %d: %s (url=%s)", err->code, err->message, m_url.string().utf8().data());
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(m_playBin.get()), GST_DEBUG_GRAPH_SHOW_ALL, "webkit-video.error");
@@ -818,7 +748,7 @@ gboolean MediaPlayerPrivateGStreamer::handleMessage(GstMessage* message)
// this case the HTMLMediaElement will emit a stalled
// event.
if (err->code == GST_STREAM_ERROR_TYPE_NOT_FOUND) {
- LOG_MEDIA_MESSAGE("Decode error, let the Media element emit a stalled event.");
+ ERROR_MEDIA_MESSAGE("Decode error, let the Media element emit a stalled event.");
break;
}
error = MediaPlayer::DecodeError;
@@ -832,33 +762,26 @@ gboolean MediaPlayerPrivateGStreamer::handleMessage(GstMessage* message)
loadingFailed(error);
break;
case GST_MESSAGE_EOS:
- LOG_MEDIA_MESSAGE("End of Stream");
didEnd();
break;
- case GST_MESSAGE_STATE_CHANGED:
- // Ignore state changes if load is delayed (preload=none). The
- // player state will be updated once commitLoad() is called.
- if (m_delayingLoad) {
- LOG_MEDIA_MESSAGE("Media load has been delayed. Ignoring state changes for now");
+ case GST_MESSAGE_ASYNC_DONE:
+ if (!messageSourceIsPlaybin || m_delayingLoad)
break;
- }
-
- // Ignore state changes from internal elements. They are
- // forwarded to playbin2 anyway.
- if (GST_MESSAGE_SRC(message) == reinterpret_cast<GstObject*>(m_playBin.get())) {
- updateStates();
-
- // Construct a filename for the graphviz dot file output.
- GstState oldState, newState;
- gst_message_parse_state_changed(message, &oldState, &newState, 0);
+ asyncStateChangeDone();
+ break;
+ case GST_MESSAGE_STATE_CHANGED: {
+ if (!messageSourceIsPlaybin || m_delayingLoad)
+ break;
+ updateStates();
- CString dotFileName = String::format("webkit-video.%s_%s",
- gst_element_state_get_name(oldState),
- gst_element_state_get_name(newState)).utf8();
+ // Construct a filename for the graphviz dot file output.
+ GstState newState;
+ gst_message_parse_state_changed(message, &currentState, &newState, 0);
+ CString dotFileName = String::format("webkit-video.%s_%s", gst_element_state_get_name(currentState), gst_element_state_get_name(newState)).utf8();
+ GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(m_playBin.get()), GST_DEBUG_GRAPH_SHOW_ALL, dotFileName.data());
- GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(m_playBin.get()), GST_DEBUG_GRAPH_SHOW_ALL, dotFileName.data());
- }
break;
+ }
case GST_MESSAGE_BUFFERING:
processBufferingStats(message);
break;
@@ -867,8 +790,28 @@ gboolean MediaPlayerPrivateGStreamer::handleMessage(GstMessage* message)
#else
case GST_MESSAGE_DURATION:
#endif
- LOG_MEDIA_MESSAGE("Duration changed");
- durationChanged();
+ if (messageSourceIsPlaybin)
+ durationChanged();
+ break;
+ case GST_MESSAGE_REQUEST_STATE:
+ gst_message_parse_request_state(message, &requestedState);
+ gst_element_get_state(m_playBin.get(), &currentState, NULL, 250);
+ if (requestedState < currentState) {
+ GOwnPtr<gchar> elementName(gst_element_get_name(GST_ELEMENT(message)));
+ INFO_MEDIA_MESSAGE("Element %s requested state change to %s", elementName.get(),
+ gst_element_state_get_name(requestedState));
+ m_requestedState = requestedState;
+ changePipelineState(requestedState);
+ }
+ break;
+ case GST_MESSAGE_ELEMENT:
+ if (gst_is_missing_plugin_message(message)) {
+ gchar* detail = gst_missing_plugin_message_get_installer_detail(message);
+ gchar* detailArray[2] = {detail, 0};
+ GstInstallPluginsReturn result = gst_install_plugins_async(detailArray, 0, mediaPlayerPrivatePluginInstallerResultFunction, this);
+ m_missingPlugins = result == GST_INSTALL_PLUGINS_STARTED_OK;
+ g_free(detail);
+ }
break;
default:
LOG_MEDIA_MESSAGE("Unhandled GStreamer message type: %s",
@@ -878,35 +821,24 @@ gboolean MediaPlayerPrivateGStreamer::handleMessage(GstMessage* message)
return TRUE;
}
+void MediaPlayerPrivateGStreamer::handlePluginInstallerResult(GstInstallPluginsReturn result)
+{
+ m_missingPlugins = false;
+ if (result == GST_INSTALL_PLUGINS_SUCCESS) {
+ gst_element_set_state(m_playBin.get(), GST_STATE_READY);
+ gst_element_set_state(m_playBin.get(), GST_STATE_PAUSED);
+ }
+}
+
void MediaPlayerPrivateGStreamer::processBufferingStats(GstMessage* message)
{
- // This is the immediate buffering that needs to happen so we have
- // enough to play right now.
m_buffering = true;
const GstStructure *structure = gst_message_get_structure(message);
gst_structure_get_int(structure, "buffer-percent", &m_bufferingPercentage);
LOG_MEDIA_MESSAGE("[Buffering] Buffering: %d%%.", m_bufferingPercentage);
- GstBufferingMode mode;
- gst_message_parse_buffering_stats(message, &mode, 0, 0, 0);
- if (mode != GST_BUFFERING_DOWNLOAD) {
- updateStates();
- return;
- }
-
- // This is on-disk buffering, that allows us to download much more
- // than needed for right now.
- if (!m_startedBuffering) {
- LOG_MEDIA_MESSAGE("[Buffering] Starting on-disk buffering.");
-
- m_startedBuffering = true;
-
- if (m_fillTimer.isActive())
- m_fillTimer.stop();
-
- m_fillTimer.startRepeating(0.2);
- }
+ updateStates();
}
void MediaPlayerPrivateGStreamer::fillTimerFired(Timer<MediaPlayerPrivateGStreamer>*)
@@ -942,7 +874,8 @@ void MediaPlayerPrivateGStreamer::fillTimerFired(Timer<MediaPlayerPrivateGStream
LOG_MEDIA_MESSAGE("[Buffering] Updated maxTimeLoaded: %f", m_maxTimeLoaded);
}
- if (fillStatus != 100.0) {
+ m_downloadFinished = fillStatus == 100.0;
+ if (!m_downloadFinished) {
updateStates();
return;
}
@@ -951,7 +884,6 @@ void MediaPlayerPrivateGStreamer::fillTimerFired(Timer<MediaPlayerPrivateGStream
// connection is cut. Buffering is done, remove the fill source
// from the main loop.
m_fillTimer.stop();
- m_startedBuffering = false;
updateStates();
}
@@ -962,7 +894,7 @@ float MediaPlayerPrivateGStreamer::maxTimeSeekable() const
LOG_MEDIA_MESSAGE("maxTimeSeekable");
// infinite duration means live stream
- if (isinf(duration()))
+ if (std::isinf(duration()))
return 0.0f;
return duration();
@@ -974,8 +906,8 @@ float MediaPlayerPrivateGStreamer::maxTimeLoaded() const
return 0.0f;
float loaded = m_maxTimeLoaded;
- if (!loaded && !m_fillTimer.isActive())
- loaded = duration();
+ if (m_isEndReached && m_mediaDuration)
+ loaded = m_mediaDuration;
LOG_MEDIA_MESSAGE("maxTimeLoaded: %f", loaded);
return loaded;
}
@@ -1009,7 +941,7 @@ unsigned MediaPlayerPrivateGStreamer::totalBytes() const
#else
if (gst_element_query_duration(m_source.get(), &fmt, &length)) {
#endif
- LOG_MEDIA_MESSAGE("totalBytes %" G_GINT64_FORMAT, length);
+ INFO_MEDIA_MESSAGE("totalBytes %" G_GINT64_FORMAT, length);
m_totalBytes = static_cast<unsigned>(length);
m_isStreaming = !length;
return m_totalBytes;
@@ -1059,52 +991,12 @@ unsigned MediaPlayerPrivateGStreamer::totalBytes() const
gst_iterator_free(iter);
- LOG_MEDIA_MESSAGE("totalBytes %" G_GINT64_FORMAT, length);
+ INFO_MEDIA_MESSAGE("totalBytes %" G_GINT64_FORMAT, length);
m_totalBytes = static_cast<unsigned>(length);
m_isStreaming = !length;
return m_totalBytes;
}
-unsigned MediaPlayerPrivateGStreamer::decodedFrameCount() const
-{
- guint64 decodedFrames = 0;
- if (m_fpsSink)
- g_object_get(m_fpsSink, "frames-rendered", &decodedFrames, NULL);
- return static_cast<unsigned>(decodedFrames);
-}
-
-unsigned MediaPlayerPrivateGStreamer::droppedFrameCount() const
-{
- guint64 framesDropped = 0;
- if (m_fpsSink)
- g_object_get(m_fpsSink, "frames-dropped", &framesDropped, NULL);
- return static_cast<unsigned>(framesDropped);
-}
-
-unsigned MediaPlayerPrivateGStreamer::audioDecodedByteCount() const
-{
- GstQuery* query = gst_query_new_position(GST_FORMAT_BYTES);
- gint64 position = 0;
-
- if (m_webkitAudioSink && gst_element_query(m_webkitAudioSink.get(), query))
- gst_query_parse_position(query, 0, &position);
-
- gst_query_unref(query);
- return static_cast<unsigned>(position);
-}
-
-unsigned MediaPlayerPrivateGStreamer::videoDecodedByteCount() const
-{
- GstQuery* query = gst_query_new_position(GST_FORMAT_BYTES);
- gint64 position = 0;
-
- if (gst_element_query(m_webkitVideoSink, query))
- gst_query_parse_position(query, 0, &position);
-
- gst_query_unref(query);
- return static_cast<unsigned>(position);
-}
-
void MediaPlayerPrivateGStreamer::updateAudioSink()
{
if (!m_playBin)
@@ -1117,6 +1009,10 @@ void MediaPlayerPrivateGStreamer::updateAudioSink()
}
+GstElement* MediaPlayerPrivateGStreamer::audioSink() const
+{
+ return m_webkitAudioSink.get();
+}
void MediaPlayerPrivateGStreamer::sourceChanged()
{
@@ -1138,6 +1034,33 @@ void MediaPlayerPrivateGStreamer::cancelLoad()
gst_element_set_state(m_playBin.get(), GST_STATE_NULL);
}
+void MediaPlayerPrivateGStreamer::asyncStateChangeDone()
+{
+ if (!m_playBin || m_errorOccured)
+ return;
+
+ if (m_seeking) {
+ if (m_seekIsPending)
+ updateStates();
+ else {
+ LOG_MEDIA_MESSAGE("[Seek] seeked to %f", m_seekTime);
+ m_seeking = false;
+ if (m_timeOfOverlappingSeek != m_seekTime && m_timeOfOverlappingSeek != -1) {
+ seek(m_timeOfOverlappingSeek);
+ m_timeOfOverlappingSeek = -1;
+ return;
+ }
+ m_timeOfOverlappingSeek = -1;
+
+ // The pipeline can still have a pending state. In this case a position query will fail.
+ // Right now we can use m_seekTime as a fallback.
+ m_canFallBackToLastFinishedSeekPositon = true;
+ timeChanged();
+ }
+ } else
+ updateStates();
+}
+
void MediaPlayerPrivateGStreamer::updateStates()
{
if (!m_playBin)
@@ -1151,104 +1074,99 @@ void MediaPlayerPrivateGStreamer::updateStates()
GstState state;
GstState pending;
- GstStateChangeReturn ret = gst_element_get_state(m_playBin.get(),
- &state, &pending, 250 * GST_NSECOND);
+ GstStateChangeReturn getStateResult = gst_element_get_state(m_playBin.get(), &state, &pending, 250 * GST_NSECOND);
- bool shouldUpdateAfterSeek = false;
- switch (ret) {
- case GST_STATE_CHANGE_SUCCESS:
- LOG_MEDIA_MESSAGE("State: %s, pending: %s",
- gst_element_state_get_name(state),
- gst_element_state_get_name(pending));
+ bool shouldUpdatePlaybackState = false;
+ switch (getStateResult) {
+ case GST_STATE_CHANGE_SUCCESS: {
+ LOG_MEDIA_MESSAGE("State: %s, pending: %s", gst_element_state_get_name(state), gst_element_state_get_name(pending));
- m_resetPipeline = state <= GST_STATE_READY;
+ if (state <= GST_STATE_READY) {
+ m_resetPipeline = true;
+ m_mediaDuration = 0;
+ } else {
+ m_resetPipeline = false;
+ cacheDuration();
+ }
+
+ bool didBuffering = m_buffering;
- // Try to figure out ready and network states.
- if (state == GST_STATE_READY) {
+ // Update ready and network states.
+ switch (state) {
+ case GST_STATE_NULL:
+ m_readyState = MediaPlayer::HaveNothing;
+ m_networkState = MediaPlayer::Empty;
+ break;
+ case GST_STATE_READY:
m_readyState = MediaPlayer::HaveMetadata;
m_networkState = MediaPlayer::Empty;
- // Cache the duration without emiting the durationchange
- // event because it's taken care of by the media element
- // in this precise case.
- if (!m_isEndReached)
- cacheDuration();
- } else if ((state == GST_STATE_NULL) || (maxTimeLoaded() == duration())) {
- m_networkState = MediaPlayer::Loaded;
- m_readyState = MediaPlayer::HaveEnoughData;
- } else {
- m_readyState = currentTime() < maxTimeLoaded() ? MediaPlayer::HaveFutureData : MediaPlayer::HaveCurrentData;
- m_networkState = MediaPlayer::Loading;
- }
+ break;
+ case GST_STATE_PAUSED:
+ case GST_STATE_PLAYING:
+ if (m_buffering) {
+ if (m_bufferingPercentage == 100) {
+ LOG_MEDIA_MESSAGE("[Buffering] Complete.");
+ m_buffering = false;
+ m_readyState = MediaPlayer::HaveEnoughData;
+ m_networkState = m_downloadFinished ? MediaPlayer::Idle : MediaPlayer::Loading;
+ } else {
+ m_readyState = MediaPlayer::HaveCurrentData;
+ m_networkState = MediaPlayer::Loading;
+ }
+ } else if (m_downloadFinished) {
+ m_readyState = MediaPlayer::HaveEnoughData;
+ m_networkState = MediaPlayer::Loaded;
+ } else {
+ m_readyState = MediaPlayer::HaveFutureData;
+ m_networkState = MediaPlayer::Loading;
+ }
- if (m_buffering && state != GST_STATE_READY) {
- m_readyState = MediaPlayer::HaveCurrentData;
- m_networkState = MediaPlayer::Loading;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ break;
}
- // Now let's try to get the states in more detail using
- // information from GStreamer, while we sync states where
- // needed.
+ // Sync states where needed.
if (state == GST_STATE_PAUSED) {
if (!m_webkitAudioSink)
updateAudioSink();
- if (m_buffering && m_bufferingPercentage == 100) {
- m_buffering = false;
- m_bufferingPercentage = 0;
- m_readyState = MediaPlayer::HaveEnoughData;
- LOG_MEDIA_MESSAGE("[Buffering] Complete.");
+ if (!m_volumeAndMuteInitialized) {
+ notifyPlayerOfVolumeChange();
+ notifyPlayerOfMute();
+ m_volumeAndMuteInitialized = true;
+ }
- if (!m_paused) {
- LOG_MEDIA_MESSAGE("[Buffering] Restarting playback.");
- gst_element_set_state(m_playBin.get(), GST_STATE_PLAYING);
- }
- } else if (!m_buffering && (currentTime() < duration())) {
- m_paused = true;
+ if (didBuffering && !m_buffering && !m_paused) {
+ LOG_MEDIA_MESSAGE("[Buffering] Restarting playback.");
+ gst_element_set_state(m_playBin.get(), GST_STATE_PLAYING);
}
} else if (state == GST_STATE_PLAYING) {
- m_readyState = MediaPlayer::HaveEnoughData;
m_paused = false;
if (m_buffering && !isLiveStream()) {
- m_readyState = MediaPlayer::HaveCurrentData;
- m_networkState = MediaPlayer::Loading;
-
LOG_MEDIA_MESSAGE("[Buffering] Pausing stream for buffering.");
-
gst_element_set_state(m_playBin.get(), GST_STATE_PAUSED);
}
} else
m_paused = true;
- // Is on-disk buffering in progress?
- if (m_fillTimer.isActive())
- m_networkState = MediaPlayer::Loading;
-
if (m_changingRate) {
m_player->rateChanged();
m_changingRate = false;
}
- if (m_seeking) {
- shouldUpdateAfterSeek = true;
- m_seeking = false;
+ if (m_requestedState == GST_STATE_PAUSED && state == GST_STATE_PAUSED) {
+ shouldUpdatePlaybackState = true;
+ LOG_MEDIA_MESSAGE("Requested state change to %s was completed", gst_element_state_get_name(state));
}
break;
+ }
case GST_STATE_CHANGE_ASYNC:
- LOG_MEDIA_MESSAGE("Async: State: %s, pending: %s",
- gst_element_state_get_name(state),
- gst_element_state_get_name(pending));
- // Change in progress
-
- // On-disk buffering was attempted but the media is live. This
- // can't work so disable on-disk buffering and reset the
- // pipeline.
- if (state == GST_STATE_READY && isLiveStream() && m_preload == MediaPlayer::Auto) {
- setPreload(MediaPlayer::None);
- gst_element_set_state(m_playBin.get(), GST_STATE_NULL);
- gst_element_set_state(m_playBin.get(), GST_STATE_PAUSED);
- }
+ LOG_MEDIA_MESSAGE("Async: State: %s, pending: %s", gst_element_state_get_name(state), gst_element_state_get_name(pending));
+ // Change in progress.
// A live stream was paused, reset the pipeline.
if (state == GST_STATE_PAUSED && pending == GST_STATE_PLAYING && isLiveStream()) {
@@ -1256,66 +1174,58 @@ void MediaPlayerPrivateGStreamer::updateStates()
gst_element_set_state(m_playBin.get(), GST_STATE_PLAYING);
}
- if (!isLiveStream() && !m_buffering)
- return;
-
- if (m_seeking) {
- shouldUpdateAfterSeek = true;
- m_seeking = false;
- }
break;
case GST_STATE_CHANGE_FAILURE:
- LOG_MEDIA_MESSAGE("Failure: State: %s, pending: %s",
- gst_element_state_get_name(state),
- gst_element_state_get_name(pending));
+ LOG_MEDIA_MESSAGE("Failure: State: %s, pending: %s", gst_element_state_get_name(state), gst_element_state_get_name(pending));
// Change failed
return;
case GST_STATE_CHANGE_NO_PREROLL:
- LOG_MEDIA_MESSAGE("No preroll: State: %s, pending: %s",
- gst_element_state_get_name(state),
- gst_element_state_get_name(pending));
+ LOG_MEDIA_MESSAGE("No preroll: State: %s, pending: %s", gst_element_state_get_name(state), gst_element_state_get_name(pending));
+
+ // Live pipelines go in PAUSED without prerolling.
+ m_isStreaming = true;
+ setDownloadBuffering();
if (state == GST_STATE_READY)
m_readyState = MediaPlayer::HaveNothing;
else if (state == GST_STATE_PAUSED) {
m_readyState = MediaPlayer::HaveEnoughData;
m_paused = true;
- // Live pipelines go in PAUSED without prerolling.
- m_isStreaming = true;
} else if (state == GST_STATE_PLAYING)
m_paused = false;
- if (m_seeking) {
- shouldUpdateAfterSeek = true;
- m_seeking = false;
- if (!m_paused)
- gst_element_set_state(m_playBin.get(), GST_STATE_PLAYING);
- } else if (!m_paused)
+ if (!m_paused)
gst_element_set_state(m_playBin.get(), GST_STATE_PLAYING);
m_networkState = MediaPlayer::Loading;
break;
default:
- LOG_MEDIA_MESSAGE("Else : %d", ret);
+ LOG_MEDIA_MESSAGE("Else : %d", getStateResult);
break;
}
- if (seeking())
- m_readyState = MediaPlayer::HaveNothing;
+ m_requestedState = GST_STATE_VOID_PENDING;
- if (shouldUpdateAfterSeek)
- timeChanged();
+ if (shouldUpdatePlaybackState)
+ m_player->playbackStateChanged();
if (m_networkState != oldNetworkState) {
- LOG_MEDIA_MESSAGE("Network State Changed from %u to %u",
- oldNetworkState, m_networkState);
+ LOG_MEDIA_MESSAGE("Network State Changed from %u to %u", oldNetworkState, m_networkState);
m_player->networkStateChanged();
}
if (m_readyState != oldReadyState) {
- LOG_MEDIA_MESSAGE("Ready State Changed from %u to %u",
- oldReadyState, m_readyState);
+ LOG_MEDIA_MESSAGE("Ready State Changed from %u to %u", oldReadyState, m_readyState);
m_player->readyStateChanged();
}
+
+ if (m_seekIsPending && getStateResult == GST_STATE_CHANGE_SUCCESS && (state == GST_STATE_PAUSED || state == GST_STATE_PLAYING)) {
+ LOG_MEDIA_MESSAGE("[Seek] committing pending seek to %f", m_seekTime);
+ m_seekIsPending = false;
+ m_seeking = gst_element_seek(m_playBin.get(), m_player->rate(), GST_FORMAT_TIME, static_cast<GstSeekFlags>(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE),
+ GST_SEEK_TYPE_SET, toGstClockTime(m_seekTime), GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
+ if (!m_seeking)
+ LOG_MEDIA_MESSAGE("[Seek] seeking to %f failed", m_seekTime);
+ }
}
void MediaPlayerPrivateGStreamer::mediaLocationChanged(GstMessage* message)
@@ -1375,23 +1285,12 @@ bool MediaPlayerPrivateGStreamer::loadNextLocation()
// Found a candidate. new-location is not always an absolute url
// though. We need to take the base of the current url and
// append the value of new-location to it.
+ KURL baseUrl = gst_uri_is_valid(newLocation) ? KURL() : m_url;
+ KURL newUrl = KURL(baseUrl, newLocation);
- gchar* currentLocation = 0;
- g_object_get(m_playBin.get(), "uri", &currentLocation, NULL);
-
- KURL currentUrl(KURL(), currentLocation);
- g_free(currentLocation);
-
- KURL newUrl;
-
- if (gst_uri_is_valid(newLocation))
- newUrl = KURL(KURL(), newLocation);
- else
- newUrl = KURL(KURL(), currentUrl.baseAsString() + newLocation);
-
- RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::create(currentUrl);
+ RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::create(m_url);
if (securityOrigin->canRequest(newUrl)) {
- LOG_MEDIA_MESSAGE("New media url: %s", newUrl.string().utf8().data());
+ INFO_MEDIA_MESSAGE("New media url: %s", newUrl.string().utf8().data());
// Reset player states.
m_networkState = MediaPlayer::Loading;
@@ -1408,14 +1307,15 @@ bool MediaPlayerPrivateGStreamer::loadNextLocation()
if (state <= GST_STATE_READY) {
// Set the new uri and start playing.
g_object_set(m_playBin.get(), "uri", newUrl.string().utf8().data(), NULL);
+ m_url = newUrl;
gst_element_set_state(m_playBin.get(), GST_STATE_PLAYING);
return true;
}
- }
+ } else
+ INFO_MEDIA_MESSAGE("Not allowed to load new media location: %s", newUrl.string().utf8().data());
}
m_mediaLocationCurrentIndex--;
return false;
-
}
void MediaPlayerPrivateGStreamer::loadStateChanged()
@@ -1423,11 +1323,6 @@ void MediaPlayerPrivateGStreamer::loadStateChanged()
updateStates();
}
-void MediaPlayerPrivateGStreamer::sizeChanged()
-{
- notImplemented();
-}
-
void MediaPlayerPrivateGStreamer::timeChanged()
{
updateStates();
@@ -1452,33 +1347,25 @@ void MediaPlayerPrivateGStreamer::didEnd()
if (!m_player->mediaPlayerClient()->mediaPlayerIsLooping()) {
m_paused = true;
gst_element_set_state(m_playBin.get(), GST_STATE_NULL);
+ m_downloadFinished = false;
}
}
void MediaPlayerPrivateGStreamer::cacheDuration()
{
- // Reset cached media duration
- m_mediaDuration = 0;
+ if (m_mediaDuration || !m_mediaDurationKnown)
+ return;
- // And re-cache it if possible.
- GstState state;
- gst_element_get_state(m_playBin.get(), &state, 0, 0);
float newDuration = duration();
-
- if (state <= GST_STATE_READY) {
- // Don't set m_mediaDurationKnown yet if the pipeline is not
- // paused. This allows duration() query to fail at least once
- // before playback starts and duration becomes known.
- if (!isinf(newDuration))
- m_mediaDuration = newDuration;
- } else {
- m_mediaDurationKnown = !isinf(newDuration);
- if (m_mediaDurationKnown)
- m_mediaDuration = newDuration;
+ if (std::isinf(newDuration)) {
+ // Only pretend that duration is not available if the the query failed in a stable pipeline state.
+ GstState state;
+ if (gst_element_get_state(m_playBin.get(), &state, 0, 0) == GST_STATE_CHANGE_SUCCESS && state > GST_STATE_READY)
+ m_mediaDurationKnown = false;
+ return;
}
- if (!isinf(newDuration))
- m_mediaDuration = newDuration;
+ m_mediaDuration = newDuration;
}
void MediaPlayerPrivateGStreamer::durationChanged()
@@ -1491,47 +1378,6 @@ void MediaPlayerPrivateGStreamer::durationChanged()
// HTMLMediaElement.
if (previousDuration && m_mediaDuration != previousDuration)
m_player->durationChanged();
-
- if (m_preload == MediaPlayer::None && m_originalPreloadWasAutoAndWasOverridden) {
- m_totalBytes = -1;
- if (totalBytes() && !isLiveStream()) {
- setPreload(MediaPlayer::Auto);
- gst_element_set_state(m_playBin.get(), GST_STATE_NULL);
- gst_element_set_state(m_playBin.get(), GST_STATE_PAUSED);
- }
- }
-}
-
-bool MediaPlayerPrivateGStreamer::supportsMuting() const
-{
- return true;
-}
-
-void MediaPlayerPrivateGStreamer::setMuted(bool muted)
-{
- if (!m_playBin)
- return;
-
- g_object_set(m_playBin.get(), "mute", muted, NULL);
-}
-
-void MediaPlayerPrivateGStreamer::notifyPlayerOfMute()
-{
- m_muteTimerHandler = 0;
-
- if (!m_player || !m_playBin)
- return;
-
- gboolean muted;
- g_object_get(m_playBin.get(), "mute", &muted, NULL);
- m_player->muteChanged(static_cast<bool>(muted));
-}
-
-void MediaPlayerPrivateGStreamer::muteChanged()
-{
- if (m_muteTimerHandler)
- g_source_remove(m_muteTimerHandler);
- m_muteTimerHandler = g_timeout_add(0, reinterpret_cast<GSourceFunc>(mediaPlayerPrivateMuteChangeTimeoutCallback), this);
}
void MediaPlayerPrivateGStreamer::loadingFailed(MediaPlayer::NetworkState error)
@@ -1547,46 +1393,6 @@ void MediaPlayerPrivateGStreamer::loadingFailed(MediaPlayer::NetworkState error)
}
}
-void MediaPlayerPrivateGStreamer::setSize(const IntSize& size)
-{
- m_size = size;
-}
-
-void MediaPlayerPrivateGStreamer::setVisible(bool)
-{
-}
-
-
-void MediaPlayerPrivateGStreamer::triggerRepaint(GstBuffer* buffer)
-{
- g_return_if_fail(GST_IS_BUFFER(buffer));
- gst_buffer_replace(&m_buffer, buffer);
- m_player->repaint();
-}
-
-void MediaPlayerPrivateGStreamer::paint(GraphicsContext* context, const IntRect& rect)
-{
- if (context->paintingDisabled())
- return;
-
- if (!m_player->visible())
- return;
-
- if (!m_buffer)
- return;
-
- GRefPtr<GstCaps> caps = webkitGstGetPadCaps(m_videoSinkPad.get());
- if (!caps)
- return;
-
- RefPtr<ImageGStreamer> gstImage = ImageGStreamer::createImage(m_buffer, caps.get());
- if (!gstImage)
- return;
-
- context->drawImage(reinterpret_cast<Image*>(gstImage->image().get()), ColorSpaceSRGB,
- rect, gstImage->rect(), CompositeCopy, DoNotRespectImageOrientation, false);
-}
-
static HashSet<String> mimeTypeCache()
{
initializeGStreamerAndRegisterWebKitElements();
@@ -1596,90 +1402,95 @@ static HashSet<String> mimeTypeCache()
if (typeListInitialized)
return cache;
- const char* mimeTypes[] = {"application/ogg",
- "application/vnd.apple.mpegurl",
- "application/vnd.rn-realmedia",
- "application/x-3gp",
- "application/x-pn-realaudio",
- "audio/3gpp",
- "audio/aac",
- "audio/flac",
- "audio/iLBC-sh",
- "audio/midi",
- "audio/mobile-xmf",
- "audio/mp1",
- "audio/mp2",
- "audio/mp3",
- "audio/mp4",
- "audio/mpeg",
- "audio/ogg",
- "audio/qcelp",
- "audio/riff-midi",
- "audio/wav",
- "audio/webm",
- "audio/x-ac3",
- "audio/x-aiff",
- "audio/x-amr-nb-sh",
- "audio/x-amr-wb-sh",
- "audio/x-au",
- "audio/x-ay",
- "audio/x-celt",
- "audio/x-dts",
- "audio/x-flac",
- "audio/x-gbs",
- "audio/x-gsm",
- "audio/x-gym",
- "audio/x-imelody",
- "audio/x-ircam",
- "audio/x-kss",
- "audio/x-m4a",
- "audio/x-mod",
- "audio/x-mp3",
- "audio/x-mpeg",
- "audio/x-musepack",
- "audio/x-nist",
- "audio/x-nsf",
- "audio/x-paris",
- "audio/x-sap",
- "audio/x-sbc",
- "audio/x-sds",
- "audio/x-shorten",
- "audio/x-sid",
- "audio/x-spc",
- "audio/x-speex",
- "audio/x-svx",
- "audio/x-ttafile",
- "audio/x-vgm",
- "audio/x-voc",
- "audio/x-vorbis+ogg",
- "audio/x-w64",
- "audio/x-wav",
- "audio/x-wavpack",
- "audio/x-wavpack-correction",
- "video/3gpp",
- "video/mj2",
- "video/mp4",
- "video/mpeg",
- "video/mpegts",
- "video/ogg",
- "video/quicktime",
- "video/vivo",
- "video/webm",
- "video/x-cdxa",
- "video/x-dirac",
- "video/x-dv",
- "video/x-fli",
- "video/x-flv",
- "video/x-h263",
- "video/x-ivf",
- "video/x-m4v",
- "video/x-matroska",
- "video/x-mng",
- "video/x-ms-asf",
- "video/x-msvideo",
- "video/x-mve",
- "video/x-nuv",
- "video/x-vcd"};
+
+ const char* mimeTypes[] = {
+ "application/ogg",
+ "application/vnd.apple.mpegurl",
+ "application/vnd.rn-realmedia",
+ "application/x-3gp",
+ "application/x-pn-realaudio",
+ "audio/3gpp",
+ "audio/aac",
+ "audio/flac",
+ "audio/iLBC-sh",
+ "audio/midi",
+ "audio/mobile-xmf",
+ "audio/mp1",
+ "audio/mp2",
+ "audio/mp3",
+ "audio/mp4",
+ "audio/mpeg",
+ "audio/ogg",
+ "audio/opus",
+ "audio/qcelp",
+ "audio/riff-midi",
+ "audio/speex",
+ "audio/wav",
+ "audio/webm",
+ "audio/x-ac3",
+ "audio/x-aiff",
+ "audio/x-amr-nb-sh",
+ "audio/x-amr-wb-sh",
+ "audio/x-au",
+ "audio/x-ay",
+ "audio/x-celt",
+ "audio/x-dts",
+ "audio/x-flac",
+ "audio/x-gbs",
+ "audio/x-gsm",
+ "audio/x-gym",
+ "audio/x-imelody",
+ "audio/x-ircam",
+ "audio/x-kss",
+ "audio/x-m4a",
+ "audio/x-mod",
+ "audio/x-mp3",
+ "audio/x-mpeg",
+ "audio/x-musepack",
+ "audio/x-nist",
+ "audio/x-nsf",
+ "audio/x-paris",
+ "audio/x-sap",
+ "audio/x-sbc",
+ "audio/x-sds",
+ "audio/x-shorten",
+ "audio/x-sid",
+ "audio/x-spc",
+ "audio/x-speex",
+ "audio/x-svx",
+ "audio/x-ttafile",
+ "audio/x-vgm",
+ "audio/x-voc",
+ "audio/x-vorbis+ogg",
+ "audio/x-w64",
+ "audio/x-wav",
+ "audio/x-wavpack",
+ "audio/x-wavpack-correction",
+ "video/3gpp",
+ "video/mj2",
+ "video/mp4",
+ "video/mpeg",
+ "video/mpegts",
+ "video/ogg",
+ "video/quicktime",
+ "video/vivo",
+ "video/webm",
+ "video/x-cdxa",
+ "video/x-dirac",
+ "video/x-dv",
+ "video/x-fli",
+ "video/x-flv",
+ "video/x-h263",
+ "video/x-ivf",
+ "video/x-m4v",
+ "video/x-matroska",
+ "video/x-mng",
+ "video/x-ms-asf",
+ "video/x-msvideo",
+ "video/x-mve",
+ "video/x-nuv",
+ "video/x-vcd"
+ };
for (unsigned i = 0; i < (sizeof(mimeTypes) / sizeof(*mimeTypes)); ++i)
cache.add(String(mimeTypes[i]));
@@ -1704,59 +1515,37 @@ MediaPlayer::SupportsType MediaPlayerPrivateGStreamer::supportsType(const String
return MediaPlayer::IsNotSupported;
}
-bool MediaPlayerPrivateGStreamer::hasSingleSecurityOrigin() const
+void MediaPlayerPrivateGStreamer::setDownloadBuffering()
{
- return true;
-}
-
-bool MediaPlayerPrivateGStreamer::supportsFullscreen() const
-{
-#if PLATFORM(MAC) && !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1050
- // See <rdar://problem/7389945>
- return false;
-#else
- return true;
-#endif
-}
-
-PlatformMedia MediaPlayerPrivateGStreamer::platformMedia() const
-{
- PlatformMedia p;
-#ifndef GST_API_VERSION_1
- p.type = PlatformMedia::GStreamerGWorldType;
- p.media.gstreamerGWorld = m_gstGWorld.get();
-#endif
- return p;
-}
-
-MediaPlayer::MovieLoadType MediaPlayerPrivateGStreamer::movieLoadType() const
-{
- if (m_readyState == MediaPlayer::HaveNothing)
- return MediaPlayer::Unknown;
-
- if (isLiveStream())
- return MediaPlayer::LiveStream;
-
- return MediaPlayer::Download;
-}
-
-void MediaPlayerPrivateGStreamer::setPreload(MediaPlayer::Preload preload)
-{
- m_originalPreloadWasAutoAndWasOverridden = m_preload != preload && m_preload == MediaPlayer::Auto;
-
- m_preload = preload;
-
- ASSERT(m_playBin);
+ if (!m_playBin)
+ return;
GstPlayFlags flags;
g_object_get(m_playBin.get(), "flags", &flags, NULL);
- if (m_preload == MediaPlayer::Auto) {
+
+ // We don't want to stop downloading if we already started it.
+ if (flags & GST_PLAY_FLAG_DOWNLOAD && m_readyState > MediaPlayer::HaveNothing && !m_resetPipeline)
+ return;
+
+ bool shouldDownload = !isLiveStream() && m_preload == MediaPlayer::Auto;
+ if (shouldDownload) {
LOG_MEDIA_MESSAGE("Enabling on-disk buffering");
g_object_set(m_playBin.get(), "flags", flags | GST_PLAY_FLAG_DOWNLOAD, NULL);
+ m_fillTimer.startRepeating(0.2);
} else {
LOG_MEDIA_MESSAGE("Disabling on-disk buffering");
g_object_set(m_playBin.get(), "flags", flags & ~GST_PLAY_FLAG_DOWNLOAD, NULL);
+ m_fillTimer.stop();
}
+}
+
+void MediaPlayerPrivateGStreamer::setPreload(MediaPlayer::Preload preload)
+{
+ if (preload == MediaPlayer::Auto && isLiveStream())
+ return;
+
+ m_preload = preload;
+ setDownloadBuffering();
if (m_delayingLoad && m_preload != MediaPlayer::None) {
m_delayingLoad = false;
@@ -1764,121 +1553,78 @@ void MediaPlayerPrivateGStreamer::setPreload(MediaPlayer::Preload preload)
}
}
-void MediaPlayerPrivateGStreamer::createGSTPlayBin()
+void MediaPlayerPrivateGStreamer::createAudioSink()
{
- ASSERT(!m_playBin);
-
- // gst_element_factory_make() returns a floating reference so
- // we should not adopt.
- m_playBin = gst_element_factory_make(gPlaybinName, "play");
-
-#ifndef GST_API_VERSION_1
- m_gstGWorld = GStreamerGWorld::createGWorld(m_playBin.get());
-#endif
-
- GstBus* bus = gst_pipeline_get_bus(GST_PIPELINE(m_playBin.get()));
- gst_bus_add_signal_watch(bus);
- g_signal_connect(bus, "message", G_CALLBACK(mediaPlayerPrivateMessageCallback), this);
- gst_object_unref(bus);
-
- g_object_set(m_playBin.get(), "mute", m_player->muted(), NULL);
+ // Construct audio sink if pitch preserving is enabled.
+ if (!m_preservesPitch)
+ return;
- g_signal_connect(m_playBin.get(), "notify::volume", G_CALLBACK(mediaPlayerPrivateVolumeChangedCallback), this);
- g_signal_connect(m_playBin.get(), "notify::source", G_CALLBACK(mediaPlayerPrivateSourceChangedCallback), this);
- g_signal_connect(m_playBin.get(), "notify::mute", G_CALLBACK(mediaPlayerPrivateMuteChangedCallback), this);
- g_signal_connect(m_playBin.get(), "video-changed", G_CALLBACK(mediaPlayerPrivateVideoChangedCallback), this);
- g_signal_connect(m_playBin.get(), "audio-changed", G_CALLBACK(mediaPlayerPrivateAudioChangedCallback), this);
+ if (!m_playBin)
+ return;
-#ifndef GST_API_VERSION_1
- m_webkitVideoSink = webkitVideoSinkNew(m_gstGWorld.get());
-#else
- m_webkitVideoSink = webkitVideoSinkNew();
-#endif
- m_videoSinkPad = adoptGRef(gst_element_get_static_pad(m_webkitVideoSink, "sink"));
+ GstElement* scale = gst_element_factory_make("scaletempo", 0);
+ if (!scale) {
+ GST_WARNING("Failed to create scaletempo");
+ return;
+ }
- g_signal_connect(m_webkitVideoSink, "repaint-requested", G_CALLBACK(mediaPlayerPrivateRepaintCallback), this);
+ GstElement* convert = gst_element_factory_make("audioconvert", 0);
+ GstElement* resample = gst_element_factory_make("audioresample", 0);
+ GstElement* sink = gst_element_factory_make("autoaudiosink", 0);
+ m_autoAudioSink = sink;
-#ifndef GST_API_VERSION_1
- m_videoSinkBin = gst_bin_new("sink");
+ g_signal_connect(sink, "child-added", G_CALLBACK(setAudioStreamPropertiesCallback), this);
- GstElement* videoTee = gst_element_factory_make("tee", "videoTee");
- GstElement* queue = gst_element_factory_make("queue", 0);
+ GstElement* audioSink = gst_bin_new("audio-sink");
+ gst_bin_add_many(GST_BIN(audioSink), scale, convert, resample, sink, NULL);
- // Take ownership.
- gst_object_ref_sink(m_videoSinkBin);
+ if (!gst_element_link_many(scale, convert, resample, sink, NULL)) {
+ GST_WARNING("Failed to link audio sink elements");
+ gst_object_unref(audioSink);
+ return;
+ }
- // Build a new video sink consisting of a bin containing a tee
- // (meant to distribute data to multiple video sinks) and our
- // internal video sink. For fullscreen we create an autovideosink
- // and initially block the data flow towards it and configure it
+ GRefPtr<GstPad> pad = adoptGRef(gst_element_get_static_pad(scale, "sink"));
+ gst_element_add_pad(audioSink, gst_ghost_pad_new("sink", pad.get()));
- gst_bin_add_many(GST_BIN(m_videoSinkBin), videoTee, queue, NULL);
+ g_object_set(m_playBin.get(), "audio-sink", audioSink, NULL);
+}
- // Link a new src pad from tee to queue1.
- GRefPtr<GstPad> srcPad = adoptGRef(gst_element_get_request_pad(videoTee, "src%d"));
- GRefPtr<GstPad> sinkPad = adoptGRef(gst_element_get_static_pad(queue, "sink"));
- gst_pad_link(srcPad.get(), sinkPad.get());
-#endif
+void MediaPlayerPrivateGStreamer::createGSTPlayBin()
+{
+ ASSERT(!m_playBin);
- GstElement* actualVideoSink = 0;
- m_fpsSink = gst_element_factory_make("fpsdisplaysink", "sink");
- if (m_fpsSink) {
- // The verbose property has been added in -bad 0.10.22. Making
- // this whole code depend on it because we don't want
- // fpsdiplaysink to spit data on stdout.
- GstElementFactory* factory = GST_ELEMENT_FACTORY(GST_ELEMENT_GET_CLASS(m_fpsSink)->elementfactory);
- if (gst_plugin_feature_check_version(GST_PLUGIN_FEATURE(factory), 0, 10, 22)) {
- g_object_set(m_fpsSink, "silent", TRUE , NULL);
-
- // Turn off text overlay unless logging is enabled.
-#if LOG_DISABLED
- g_object_set(m_fpsSink, "text-overlay", FALSE , NULL);
-#else
- WTFLogChannel* channel = getChannelFromName("Media");
- if (channel->state != WTFLogChannelOn)
- g_object_set(m_fpsSink, "text-overlay", FALSE , NULL);
-#endif // LOG_DISABLED
-
- if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_fpsSink), "video-sink")) {
- g_object_set(m_fpsSink, "video-sink", m_webkitVideoSink, NULL);
-#ifndef GST_API_VERSION_1
- gst_bin_add(GST_BIN(m_videoSinkBin), m_fpsSink);
-#endif
- actualVideoSink = m_fpsSink;
- } else
- m_fpsSink = 0;
- } else
- m_fpsSink = 0;
- }
+ // gst_element_factory_make() returns a floating reference so
+ // we should not adopt.
+ m_playBin = gst_element_factory_make(gPlaybinName, "play");
+ setStreamVolumeElement(GST_STREAM_VOLUME(m_playBin.get()));
- if (!m_fpsSink) {
-#ifndef GST_API_VERSION_1
- gst_bin_add(GST_BIN(m_videoSinkBin), m_webkitVideoSink);
-#endif
- actualVideoSink = m_webkitVideoSink;
- }
+ GRefPtr<GstBus> bus = webkitGstPipelineGetBus(GST_PIPELINE(m_playBin.get()));
+ gst_bus_add_signal_watch(bus.get());
+ g_signal_connect(bus.get(), "message", G_CALLBACK(mediaPlayerPrivateMessageCallback), this);
- ASSERT(actualVideoSink);
+ g_object_set(m_playBin.get(), "mute", m_player->muted(), NULL);
-#ifndef GST_API_VERSION_1
- // Faster elements linking.
- gst_element_link_pads_full(queue, "src", actualVideoSink, "sink", GST_PAD_LINK_CHECK_NOTHING);
+ g_signal_connect(m_playBin.get(), "notify::source", G_CALLBACK(mediaPlayerPrivateSourceChangedCallback), this);
+ g_signal_connect(m_playBin.get(), "video-changed", G_CALLBACK(mediaPlayerPrivateVideoChangedCallback), this);
+ g_signal_connect(m_playBin.get(), "audio-changed", G_CALLBACK(mediaPlayerPrivateAudioChangedCallback), this);
- // Add a ghostpad to the bin so it can proxy to tee.
- GRefPtr<GstPad> pad = adoptGRef(gst_element_get_static_pad(videoTee, "sink"));
- gst_element_add_pad(m_videoSinkBin, gst_ghost_pad_new("sink", pad.get()));
+ GstElement* videoElement = createVideoSink(m_playBin.get());
- // Set the bin as video sink of playbin.
- g_object_set(m_playBin.get(), "video-sink", m_videoSinkBin, NULL);
-#else
- g_object_set(m_playBin.get(), "video-sink", actualVideoSink, NULL);
-#endif
+ g_object_set(m_playBin.get(), "video-sink", videoElement, NULL);
- GRefPtr<GstPad> videoSinkPad = adoptGRef(gst_element_get_static_pad(m_webkitVideoSink, "sink"));
+ GRefPtr<GstPad> videoSinkPad = adoptGRef(gst_element_get_static_pad(m_webkitVideoSink.get(), "sink"));
if (videoSinkPad)
g_signal_connect(videoSinkPad.get(), "notify::caps", G_CALLBACK(mediaPlayerPrivateVideoSinkCapsChangedCallback), this);
+ createAudioSink();
+}
+
+void MediaPlayerPrivateGStreamer::simulateAudioInterruption()
+{
+ GstMessage* message = gst_message_new_request_state(GST_OBJECT(m_playBin.get()), GST_STATE_PAUSED);
+ gst_element_post_message(m_playBin.get(), message);
}
}
diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h
index 1f7b3f3c8..48284d34f 100644
--- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h
+++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h
@@ -25,185 +25,150 @@
#if ENABLE(VIDEO) && USE(GSTREAMER)
#include "GRefPtrGStreamer.h"
-#include "MediaPlayerPrivate.h"
+#include "MediaPlayerPrivateGStreamerBase.h"
#include "Timer.h"
#include <glib.h>
#include <gst/gst.h>
+#include <gst/pbutils/install-plugins.h>
#include <wtf/Forward.h>
-typedef struct _WebKitVideoSink WebKitVideoSink;
typedef struct _GstBuffer GstBuffer;
typedef struct _GstMessage GstMessage;
typedef struct _GstElement GstElement;
namespace WebCore {
-class GraphicsContext;
-class IntSize;
-class IntRect;
-class GStreamerGWorld;
-class MediaPlayerPrivateGStreamer;
+class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateGStreamerBase {
+public:
+ ~MediaPlayerPrivateGStreamer();
+ static void registerMediaEngine(MediaEngineRegistrar);
+ gboolean handleMessage(GstMessage*);
+ void handlePluginInstallerResult(GstInstallPluginsReturn);
-class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateInterface {
+ bool hasVideo() const { return m_hasVideo; }
+ bool hasAudio() const { return m_hasAudio; }
- public:
- ~MediaPlayerPrivateGStreamer();
- static void registerMediaEngine(MediaEngineRegistrar);
- gboolean handleMessage(GstMessage*);
-
- IntSize naturalSize() const;
- bool hasVideo() const { return m_hasVideo; }
- bool hasAudio() const { return m_hasAudio; }
-
- void load(const String &url);
- void commitLoad();
- void cancelLoad();
-
- void prepareToPlay();
- void play();
- void pause();
-
- bool paused() const;
- bool seeking() const;
-
- float duration() const;
- float currentTime() const;
- void seek(float);
-
- void setRate(float);
-
- void setVolume(float);
- void volumeChanged();
- void notifyPlayerOfVolumeChange();
-
- bool supportsMuting() const;
- void setMuted(bool);
- void muteChanged();
- void notifyPlayerOfMute();
-
- void setPreload(MediaPlayer::Preload);
- void fillTimerFired(Timer<MediaPlayerPrivateGStreamer>*);
-
- MediaPlayer::NetworkState networkState() const;
- MediaPlayer::ReadyState readyState() const;
-
- PassRefPtr<TimeRanges> buffered() const;
- float maxTimeSeekable() const;
- bool didLoadingProgress() const;
- unsigned totalBytes() const;
-
- void setVisible(bool);
- void setSize(const IntSize&);
-
- void loadStateChanged();
- void sizeChanged();
- void timeChanged();
- void didEnd();
- void durationChanged();
- void loadingFailed(MediaPlayer::NetworkState);
-
- void triggerRepaint(GstBuffer*);
- void repaint();
- void paint(GraphicsContext*, const IntRect&);
-
- bool hasSingleSecurityOrigin() const;
-
- bool supportsFullscreen() const;
- PlatformMedia platformMedia() const;
-
- void videoChanged();
- void audioChanged();
- void notifyPlayerOfVideo();
- void notifyPlayerOfAudio();
-
- void sourceChanged();
-
- unsigned decodedFrameCount() const;
- unsigned droppedFrameCount() const;
- unsigned audioDecodedByteCount() const;
- unsigned videoDecodedByteCount() const;
-
- MediaPlayer::MovieLoadType movieLoadType() const;
-
- private:
- MediaPlayerPrivateGStreamer(MediaPlayer*);
-
- static PassOwnPtr<MediaPlayerPrivateInterface> create(MediaPlayer*);
-
- static void getSupportedTypes(HashSet<String>&);
- static MediaPlayer::SupportsType supportsType(const String& type, const String& codecs, const KURL&);
-
- static bool isAvailable();
-
- void updateAudioSink();
-
- float playbackPosition() const;
-
- void cacheDuration();
- void updateStates();
- float maxTimeLoaded() const;
-
- void createGSTPlayBin();
- bool changePipelineState(GstState state);
-
- bool loadNextLocation();
- void mediaLocationChanged(GstMessage*);
-
- void processBufferingStats(GstMessage*);
-
- virtual String engineDescription() const { return "GStreamer"; }
- bool isLiveStream() const { return m_isStreaming; }
-
- private:
- MediaPlayer* m_player;
- GRefPtr<GstElement> m_playBin;
- GstElement* m_webkitVideoSink;
- GstElement* m_videoSinkBin;
- GstElement* m_fpsSink;
- GRefPtr<GstElement> m_source;
- float m_seekTime;
- bool m_changingRate;
- float m_endTime;
- bool m_isEndReached;
- MediaPlayer::NetworkState m_networkState;
- MediaPlayer::ReadyState m_readyState;
- mutable bool m_isStreaming;
- IntSize m_size;
- GstBuffer* m_buffer;
- GstStructure* m_mediaLocations;
- int m_mediaLocationCurrentIndex;
- bool m_resetPipeline;
- bool m_paused;
- bool m_seeking;
- bool m_buffering;
- float m_playbackRate;
- bool m_errorOccured;
- gfloat m_mediaDuration;
- bool m_startedBuffering;
- Timer<MediaPlayerPrivateGStreamer> m_fillTimer;
- float m_maxTimeLoaded;
- int m_bufferingPercentage;
- MediaPlayer::Preload m_preload;
- bool m_delayingLoad;
- bool m_mediaDurationKnown;
- mutable float m_maxTimeLoadedAtLastDidLoadingProgress;
-#ifndef GST_API_VERSION_1
- RefPtr<GStreamerGWorld> m_gstGWorld;
+ void load(const String &url);
+#if ENABLE(MEDIA_SOURCE)
+ void load(const String& url, PassRefPtr<MediaSource>);
#endif
- guint m_volumeTimerHandler;
- guint m_muteTimerHandler;
- bool m_hasVideo;
- bool m_hasAudio;
- guint m_audioTimerHandler;
- guint m_videoTimerHandler;
- GRefPtr<GstElement> m_webkitAudioSink;
- mutable long m_totalBytes;
- GRefPtr<GstPad> m_videoSinkPad;
- mutable IntSize m_videoSize;
- KURL m_url;
- bool m_originalPreloadWasAutoAndWasOverridden;
- };
+ void commitLoad();
+ void cancelLoad();
+
+ void prepareToPlay();
+ void play();
+ void pause();
+
+ bool paused() const;
+ bool seeking() const;
+
+ float duration() const;
+ float currentTime() const;
+ void seek(float);
+
+ void setRate(float);
+ void setPreservesPitch(bool);
+
+ void setPreload(MediaPlayer::Preload);
+ void fillTimerFired(Timer<MediaPlayerPrivateGStreamer>*);
+
+ PassRefPtr<TimeRanges> buffered() const;
+ float maxTimeSeekable() const;
+ bool didLoadingProgress() const;
+ unsigned totalBytes() const;
+ float maxTimeLoaded() const;
+
+ void loadStateChanged();
+ void timeChanged();
+ void didEnd();
+ void durationChanged();
+ void loadingFailed(MediaPlayer::NetworkState);
+
+ void videoChanged();
+ void audioChanged();
+ void notifyPlayerOfVideo();
+ void notifyPlayerOfAudio();
+
+ void sourceChanged();
+ GstElement* audioSink() const;
+
+ void setAudioStreamProperties(GObject*);
+
+ void simulateAudioInterruption();
+
+private:
+ MediaPlayerPrivateGStreamer(MediaPlayer*);
+
+ static PassOwnPtr<MediaPlayerPrivateInterface> create(MediaPlayer*);
+
+ static void getSupportedTypes(HashSet<String>&);
+ static MediaPlayer::SupportsType supportsType(const String& type, const String& codecs, const KURL&);
+
+ static bool isAvailable();
+
+ void updateAudioSink();
+ void createAudioSink();
+
+ float playbackPosition() const;
+
+ void cacheDuration();
+ void updateStates();
+ void asyncStateChangeDone();
+
+ void createGSTPlayBin();
+ bool changePipelineState(GstState);
+
+ bool loadNextLocation();
+ void mediaLocationChanged(GstMessage*);
+
+ void setDownloadBuffering();
+ void processBufferingStats(GstMessage*);
+
+ virtual String engineDescription() const { return "GStreamer"; }
+ virtual bool isLiveStream() const { return m_isStreaming; }
+
+private:
+ GRefPtr<GstElement> m_playBin;
+ GRefPtr<GstElement> m_source;
+ float m_seekTime;
+ bool m_changingRate;
+ float m_endTime;
+ bool m_isEndReached;
+ mutable bool m_isStreaming;
+ GstStructure* m_mediaLocations;
+ int m_mediaLocationCurrentIndex;
+ bool m_resetPipeline;
+ bool m_paused;
+ bool m_seeking;
+ bool m_seekIsPending;
+ float m_timeOfOverlappingSeek;
+ bool m_canFallBackToLastFinishedSeekPositon;
+ bool m_buffering;
+ float m_playbackRate;
+ bool m_errorOccured;
+ mutable gfloat m_mediaDuration;
+ bool m_downloadFinished;
+ Timer<MediaPlayerPrivateGStreamer> m_fillTimer;
+ float m_maxTimeLoaded;
+ int m_bufferingPercentage;
+ MediaPlayer::Preload m_preload;
+ bool m_delayingLoad;
+ bool m_mediaDurationKnown;
+ mutable float m_maxTimeLoadedAtLastDidLoadingProgress;
+ bool m_volumeAndMuteInitialized;
+ bool m_hasVideo;
+ bool m_hasAudio;
+ guint m_audioTimerHandler;
+ guint m_videoTimerHandler;
+ GRefPtr<GstElement> m_webkitAudioSink;
+ mutable long m_totalBytes;
+ KURL m_url;
+ bool m_preservesPitch;
+ GstState m_requestedState;
+ GRefPtr<GstElement> m_autoAudioSink;
+ bool m_missingPlugins;
+};
}
#endif // USE(GSTREAMER)
diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp
new file mode 100644
index 000000000..2a02afbab
--- /dev/null
+++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp
@@ -0,0 +1,669 @@
+/*
+ * Copyright (C) 2007, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2007 Collabora Ltd. All rights reserved.
+ * Copyright (C) 2007 Alp Toker <alp@atoker.com>
+ * Copyright (C) 2009 Gustavo Noronha Silva <gns@gnome.org>
+ * Copyright (C) 2009, 2010 Igalia S.L
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * aint with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "MediaPlayerPrivateGStreamerBase.h"
+
+#if ENABLE(VIDEO) && USE(GSTREAMER)
+
+#include "ColorSpace.h"
+#include "FullscreenVideoControllerGStreamer.h"
+#include "GStreamerGWorld.h"
+#include "GStreamerUtilities.h"
+#include "GStreamerVersioning.h"
+#include "GraphicsContext.h"
+#include "GraphicsTypes.h"
+#include "ImageGStreamer.h"
+#include "ImageOrientation.h"
+#include "IntRect.h"
+#include "Logging.h"
+#include "MediaPlayer.h"
+#include "NotImplemented.h"
+#include "VideoSinkGStreamer.h"
+#include "WebKitWebSourceGStreamer.h"
+#include <gst/gst.h>
+#include <gst/video/video.h>
+#include <wtf/text/CString.h>
+
+#ifdef GST_API_VERSION_1
+#include <gst/audio/streamvolume.h>
+#else
+#include <gst/interfaces/streamvolume.h>
+#endif
+
+#if GST_CHECK_VERSION(1, 1, 0) && USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL)
+#include "TextureMapperGL.h"
+#endif
+
+GST_DEBUG_CATEGORY(webkit_media_player_debug);
+#define GST_CAT_DEFAULT webkit_media_player_debug
+
+using namespace std;
+
+namespace WebCore {
+
+static int greatestCommonDivisor(int a, int b)
+{
+ while (b) {
+ int temp = a;
+ a = b;
+ b = temp % b;
+ }
+
+ return ABS(a);
+}
+
+static void mediaPlayerPrivateVolumeChangedCallback(GObject*, GParamSpec*, MediaPlayerPrivateGStreamerBase* player)
+{
+ // This is called when m_volumeElement receives the notify::volume signal.
+ player->volumeChanged();
+}
+
+static gboolean mediaPlayerPrivateVolumeChangeTimeoutCallback(MediaPlayerPrivateGStreamerBase* player)
+{
+ // This is the callback of the timeout source created in ::volumeChanged.
+ player->notifyPlayerOfVolumeChange();
+ return FALSE;
+}
+
+static void mediaPlayerPrivateMuteChangedCallback(GObject*, GParamSpec*, MediaPlayerPrivateGStreamerBase* player)
+{
+ // This is called when m_volumeElement receives the notify::mute signal.
+ player->muteChanged();
+}
+
+static gboolean mediaPlayerPrivateMuteChangeTimeoutCallback(MediaPlayerPrivateGStreamerBase* player)
+{
+ // This is the callback of the timeout source created in ::muteChanged.
+ player->notifyPlayerOfMute();
+ return FALSE;
+}
+
+static void mediaPlayerPrivateRepaintCallback(WebKitVideoSink*, GstBuffer *buffer, MediaPlayerPrivateGStreamerBase* playerPrivate)
+{
+ playerPrivate->triggerRepaint(buffer);
+}
+
+MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase(MediaPlayer* player)
+ : m_player(player)
+ , m_fpsSink(0)
+ , m_readyState(MediaPlayer::HaveNothing)
+ , m_networkState(MediaPlayer::Empty)
+ , m_buffer(0)
+ , m_volumeTimerHandler(0)
+ , m_muteTimerHandler(0)
+ , m_repaintHandler(0)
+ , m_volumeSignalHandler(0)
+ , m_muteSignalHandler(0)
+{
+#if GLIB_CHECK_VERSION(2, 31, 0)
+ m_bufferMutex = WTF::fastNew<GMutex>();
+ g_mutex_init(m_bufferMutex);
+#else
+ m_bufferMutex = g_mutex_new();
+#endif
+}
+
+MediaPlayerPrivateGStreamerBase::~MediaPlayerPrivateGStreamerBase()
+{
+ g_signal_handler_disconnect(m_webkitVideoSink.get(), m_repaintHandler);
+
+#if GLIB_CHECK_VERSION(2, 31, 0)
+ g_mutex_clear(m_bufferMutex);
+ WTF::fastDelete(m_bufferMutex);
+#else
+ g_mutex_free(m_bufferMutex);
+#endif
+
+ if (m_buffer)
+ gst_buffer_unref(m_buffer);
+ m_buffer = 0;
+
+ m_player = 0;
+
+ if (m_muteTimerHandler)
+ g_source_remove(m_muteTimerHandler);
+
+ if (m_volumeTimerHandler)
+ g_source_remove(m_volumeTimerHandler);
+
+ if (m_volumeSignalHandler) {
+ g_signal_handler_disconnect(m_volumeElement.get(), m_volumeSignalHandler);
+ m_volumeSignalHandler = 0;
+ }
+
+ if (m_muteSignalHandler) {
+ g_signal_handler_disconnect(m_volumeElement.get(), m_muteSignalHandler);
+ m_muteSignalHandler = 0;
+ }
+
+#if USE(NATIVE_FULLSCREEN_VIDEO)
+ if (m_fullscreenVideoController)
+ exitFullscreen();
+#endif
+}
+
+// Returns the size of the video
+IntSize MediaPlayerPrivateGStreamerBase::naturalSize() const
+{
+ if (!hasVideo())
+ return IntSize();
+
+ if (!m_videoSize.isEmpty())
+ return m_videoSize;
+
+#ifdef GST_API_VERSION_1
+ GRefPtr<GstCaps> caps = currentVideoSinkCaps();
+#else
+ g_mutex_lock(m_bufferMutex);
+ GRefPtr<GstCaps> caps = m_buffer ? GST_BUFFER_CAPS(m_buffer) : 0;
+ g_mutex_unlock(m_bufferMutex);
+#endif
+ if (!caps)
+ return IntSize();
+
+
+ // TODO: handle possible clean aperture data. See
+ // https://bugzilla.gnome.org/show_bug.cgi?id=596571
+ // TODO: handle possible transformation matrix. See
+ // https://bugzilla.gnome.org/show_bug.cgi?id=596326
+
+ // Get the video PAR and original size, if this fails the
+ // video-sink has likely not yet negotiated its caps.
+ int pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride;
+ IntSize originalSize;
+ GstVideoFormat format;
+ if (!getVideoSizeAndFormatFromCaps(caps.get(), originalSize, format, pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride))
+ return IntSize();
+
+ LOG_MEDIA_MESSAGE("Original video size: %dx%d", originalSize.width(), originalSize.height());
+ LOG_MEDIA_MESSAGE("Pixel aspect ratio: %d/%d", pixelAspectRatioNumerator, pixelAspectRatioDenominator);
+
+ // Calculate DAR based on PAR and video size.
+ int displayWidth = originalSize.width() * pixelAspectRatioNumerator;
+ int displayHeight = originalSize.height() * pixelAspectRatioDenominator;
+
+ // Divide display width and height by their GCD to avoid possible overflows.
+ int displayAspectRatioGCD = greatestCommonDivisor(displayWidth, displayHeight);
+ displayWidth /= displayAspectRatioGCD;
+ displayHeight /= displayAspectRatioGCD;
+
+ // Apply DAR to original video size. This is the same behavior as in xvimagesink's setcaps function.
+ guint64 width = 0, height = 0;
+ if (!(originalSize.height() % displayHeight)) {
+ LOG_MEDIA_MESSAGE("Keeping video original height");
+ width = gst_util_uint64_scale_int(originalSize.height(), displayWidth, displayHeight);
+ height = static_cast<guint64>(originalSize.height());
+ } else if (!(originalSize.width() % displayWidth)) {
+ LOG_MEDIA_MESSAGE("Keeping video original width");
+ height = gst_util_uint64_scale_int(originalSize.width(), displayHeight, displayWidth);
+ width = static_cast<guint64>(originalSize.width());
+ } else {
+ LOG_MEDIA_MESSAGE("Approximating while keeping original video height");
+ width = gst_util_uint64_scale_int(originalSize.height(), displayWidth, displayHeight);
+ height = static_cast<guint64>(originalSize.height());
+ }
+
+ LOG_MEDIA_MESSAGE("Natural size: %" G_GUINT64_FORMAT "x%" G_GUINT64_FORMAT, width, height);
+ m_videoSize = IntSize(static_cast<int>(width), static_cast<int>(height));
+ return m_videoSize;
+}
+
+void MediaPlayerPrivateGStreamerBase::setVolume(float volume)
+{
+ if (!m_volumeElement)
+ return;
+
+ gst_stream_volume_set_volume(m_volumeElement.get(), GST_STREAM_VOLUME_FORMAT_CUBIC, static_cast<double>(volume));
+}
+
+float MediaPlayerPrivateGStreamerBase::volume() const
+{
+ if (!m_volumeElement)
+ return 0;
+
+ return gst_stream_volume_get_volume(m_volumeElement.get(), GST_STREAM_VOLUME_FORMAT_CUBIC);
+}
+
+
+void MediaPlayerPrivateGStreamerBase::notifyPlayerOfVolumeChange()
+{
+ m_volumeTimerHandler = 0;
+
+ if (!m_player || !m_volumeElement)
+ return;
+ double volume;
+ volume = gst_stream_volume_get_volume(m_volumeElement.get(), GST_STREAM_VOLUME_FORMAT_CUBIC);
+ // get_volume() can return values superior to 1.0 if the user
+ // applies software user gain via third party application (GNOME
+ // volume control for instance).
+ volume = CLAMP(volume, 0.0, 1.0);
+ m_player->volumeChanged(static_cast<float>(volume));
+}
+
+void MediaPlayerPrivateGStreamerBase::volumeChanged()
+{
+ if (m_volumeTimerHandler)
+ g_source_remove(m_volumeTimerHandler);
+ m_volumeTimerHandler = g_timeout_add(0, reinterpret_cast<GSourceFunc>(mediaPlayerPrivateVolumeChangeTimeoutCallback), this);
+}
+
+MediaPlayer::NetworkState MediaPlayerPrivateGStreamerBase::networkState() const
+{
+ return m_networkState;
+}
+
+MediaPlayer::ReadyState MediaPlayerPrivateGStreamerBase::readyState() const
+{
+ return m_readyState;
+}
+
+void MediaPlayerPrivateGStreamerBase::sizeChanged()
+{
+ notImplemented();
+}
+
+void MediaPlayerPrivateGStreamerBase::setMuted(bool muted)
+{
+ if (!m_volumeElement)
+ return;
+
+ g_object_set(m_volumeElement.get(), "mute", muted, NULL);
+}
+
+bool MediaPlayerPrivateGStreamerBase::muted() const
+{
+ if (!m_volumeElement)
+ return false;
+
+ bool muted;
+ g_object_get(m_volumeElement.get(), "mute", &muted, NULL);
+ return muted;
+}
+
+void MediaPlayerPrivateGStreamerBase::notifyPlayerOfMute()
+{
+ m_muteTimerHandler = 0;
+
+ if (!m_player || !m_volumeElement)
+ return;
+
+ gboolean muted;
+ g_object_get(m_volumeElement.get(), "mute", &muted, NULL);
+ m_player->muteChanged(static_cast<bool>(muted));
+}
+
+void MediaPlayerPrivateGStreamerBase::muteChanged()
+{
+ if (m_muteTimerHandler)
+ g_source_remove(m_muteTimerHandler);
+ m_muteTimerHandler = g_timeout_add(0, reinterpret_cast<GSourceFunc>(mediaPlayerPrivateMuteChangeTimeoutCallback), this);
+}
+
+
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
+PassRefPtr<BitmapTexture> MediaPlayerPrivateGStreamerBase::updateTexture(TextureMapper* textureMapper)
+{
+ g_mutex_lock(m_bufferMutex);
+ if (!m_buffer) {
+ g_mutex_unlock(m_bufferMutex);
+ return 0;
+ }
+
+ const void* srcData = 0;
+#ifdef GST_API_VERSION_1
+ GRefPtr<GstCaps> caps = currentVideoSinkCaps();
+#else
+ GRefPtr<GstCaps> caps = GST_BUFFER_CAPS(m_buffer);
+#endif
+ if (!caps) {
+ g_mutex_unlock(m_bufferMutex);
+ return 0;
+ }
+
+ IntSize size;
+ GstVideoFormat format;
+ int pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride;
+ if (!getVideoSizeAndFormatFromCaps(caps.get(), size, format, pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride)) {
+ g_mutex_unlock(m_bufferMutex);
+ return 0;
+ }
+
+ RefPtr<BitmapTexture> texture = textureMapper->acquireTextureFromPool(size);
+
+#if GST_CHECK_VERSION(1, 1, 0)
+ GstVideoGLTextureUploadMeta* meta;
+ if ((meta = gst_buffer_get_video_gl_texture_upload_meta(m_buffer))) {
+ if (meta->n_textures == 1) { // BRGx & BGRA formats use only one texture.
+ const BitmapTextureGL* textureGL = static_cast<const BitmapTextureGL*>(texture.get());
+ guint ids[4] = { textureGL->id(), 0, 0, 0 };
+
+ if (gst_video_gl_texture_upload_meta_upload(meta, ids)) {
+ g_mutex_unlock(m_bufferMutex);
+ return texture;
+ }
+ }
+ }
+#endif
+
+#ifdef GST_API_VERSION_1
+ GstMapInfo srcInfo;
+ gst_buffer_map(m_buffer, &srcInfo, GST_MAP_READ);
+ srcData = srcInfo.data;
+#else
+ srcData = GST_BUFFER_DATA(m_buffer);
+#endif
+
+ texture->updateContents(srcData, WebCore::IntRect(WebCore::IntPoint(0, 0), size), WebCore::IntPoint(0, 0), stride, BitmapTexture::UpdateCannotModifyOriginalImageData);
+
+#ifdef GST_API_VERSION_1
+ gst_buffer_unmap(m_buffer, &srcInfo);
+#endif
+
+ g_mutex_unlock(m_bufferMutex);
+ return texture;
+}
+#endif
+
+void MediaPlayerPrivateGStreamerBase::triggerRepaint(GstBuffer* buffer)
+{
+ g_return_if_fail(GST_IS_BUFFER(buffer));
+
+ g_mutex_lock(m_bufferMutex);
+ gst_buffer_replace(&m_buffer, buffer);
+ g_mutex_unlock(m_bufferMutex);
+
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
+ if (supportsAcceleratedRendering() && m_player->mediaPlayerClient()->mediaPlayerRenderingCanBeAccelerated(m_player) && client()) {
+ client()->setPlatformLayerNeedsDisplay();
+ return;
+ }
+#endif
+
+ m_player->repaint();
+}
+
+void MediaPlayerPrivateGStreamerBase::setSize(const IntSize& size)
+{
+ m_size = size;
+}
+
+void MediaPlayerPrivateGStreamerBase::paint(GraphicsContext* context, const IntRect& rect)
+{
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
+ if (client())
+ return;
+#endif
+
+ if (context->paintingDisabled())
+ return;
+
+ if (!m_player->visible())
+ return;
+
+ g_mutex_lock(m_bufferMutex);
+ if (!m_buffer) {
+ g_mutex_unlock(m_bufferMutex);
+ return;
+ }
+
+#ifdef GST_API_VERSION_1
+ GRefPtr<GstCaps> caps = currentVideoSinkCaps();
+#else
+ GRefPtr<GstCaps> caps = GST_BUFFER_CAPS(m_buffer);
+#endif
+ if (!caps) {
+ g_mutex_unlock(m_bufferMutex);
+ return;
+ }
+
+ RefPtr<ImageGStreamer> gstImage = ImageGStreamer::createImage(m_buffer, caps.get());
+ if (!gstImage) {
+ g_mutex_unlock(m_bufferMutex);
+ return;
+ }
+
+ context->drawImage(reinterpret_cast<Image*>(gstImage->image().get()), ColorSpaceSRGB,
+ rect, gstImage->rect(), CompositeCopy, DoNotRespectImageOrientation, false);
+ g_mutex_unlock(m_bufferMutex);
+}
+
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
+void MediaPlayerPrivateGStreamerBase::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity)
+{
+ if (textureMapper->accelerationMode() != TextureMapper::OpenGLMode)
+ return;
+
+ if (!m_player->visible())
+ return;
+
+ RefPtr<BitmapTexture> texture = updateTexture(textureMapper);
+ if (texture)
+ textureMapper->drawTexture(*texture.get(), targetRect, matrix, opacity);
+}
+#endif
+
+#if USE(NATIVE_FULLSCREEN_VIDEO)
+void MediaPlayerPrivateGStreamerBase::enterFullscreen()
+{
+ ASSERT(!m_fullscreenVideoController);
+ m_fullscreenVideoController = FullscreenVideoControllerGStreamer::create(this);
+ if (m_fullscreenVideoController)
+ m_fullscreenVideoController->enterFullscreen();
+}
+
+void MediaPlayerPrivateGStreamerBase::exitFullscreen()
+{
+ if (!m_fullscreenVideoController)
+ return;
+ m_fullscreenVideoController->exitFullscreen();
+ m_fullscreenVideoController.release();
+}
+#endif
+
+bool MediaPlayerPrivateGStreamerBase::supportsFullscreen() const
+{
+ return true;
+}
+
+PlatformMedia MediaPlayerPrivateGStreamerBase::platformMedia() const
+{
+#if USE(NATIVE_FULLSCREEN_VIDEO)
+ PlatformMedia p;
+ p.type = PlatformMedia::GStreamerGWorldType;
+ p.media.gstreamerGWorld = m_gstGWorld.get();
+ return p;
+#else
+ return NoPlatformMedia;
+#endif
+}
+
+MediaPlayer::MovieLoadType MediaPlayerPrivateGStreamerBase::movieLoadType() const
+{
+ if (m_readyState == MediaPlayer::HaveNothing)
+ return MediaPlayer::Unknown;
+
+ if (isLiveStream())
+ return MediaPlayer::LiveStream;
+
+ return MediaPlayer::Download;
+}
+
+GRefPtr<GstCaps> MediaPlayerPrivateGStreamerBase::currentVideoSinkCaps() const
+{
+ if (!m_webkitVideoSink)
+ return 0;
+
+ GstCaps* currentCaps = 0;
+ g_object_get(G_OBJECT(m_webkitVideoSink.get()), "current-caps", &currentCaps, NULL);
+ return adoptGRef(currentCaps);
+}
+
+// This function creates and initializes some internal variables, and returns a
+// pointer to the element that should receive the data flow first
+GstElement* MediaPlayerPrivateGStreamerBase::createVideoSink(GstElement* pipeline)
+{
+ if (!initializeGStreamer())
+ return 0;
+
+#if USE(NATIVE_FULLSCREEN_VIDEO)
+ m_gstGWorld = GStreamerGWorld::createGWorld(pipeline);
+ m_webkitVideoSink = webkitVideoSinkNew(m_gstGWorld.get());
+#else
+ UNUSED_PARAM(pipeline);
+ m_webkitVideoSink = webkitVideoSinkNew();
+#endif
+
+ m_repaintHandler = g_signal_connect(m_webkitVideoSink.get(), "repaint-requested", G_CALLBACK(mediaPlayerPrivateRepaintCallback), this);
+
+#if USE(NATIVE_FULLSCREEN_VIDEO)
+ // Build a new video sink consisting of a bin containing a tee
+ // (meant to distribute data to multiple video sinks) and our
+ // internal video sink. For fullscreen we create an autovideosink
+ // and initially block the data flow towards it and configure it
+
+ m_videoSinkBin = gst_bin_new("video-sink");
+
+ GstElement* videoTee = gst_element_factory_make("tee", "videoTee");
+ GstElement* queue = gst_element_factory_make("queue", 0);
+
+#ifdef GST_API_VERSION_1
+ GRefPtr<GstPad> sinkPad = adoptGRef(gst_element_get_static_pad(videoTee, "sink"));
+ GST_OBJECT_FLAG_SET(GST_OBJECT(sinkPad.get()), GST_PAD_FLAG_PROXY_ALLOCATION);
+#endif
+
+ gst_bin_add_many(GST_BIN(m_videoSinkBin.get()), videoTee, queue, NULL);
+
+ // Link a new src pad from tee to queue1.
+ gst_element_link_pads_full(videoTee, 0, queue, "sink", GST_PAD_LINK_CHECK_NOTHING);
+#endif
+
+ GstElement* actualVideoSink = 0;
+ m_fpsSink = gst_element_factory_make("fpsdisplaysink", "sink");
+ if (m_fpsSink) {
+ // The verbose property has been added in -bad 0.10.22. Making
+ // this whole code depend on it because we don't want
+ // fpsdiplaysink to spit data on stdout.
+ GstElementFactory* factory = GST_ELEMENT_FACTORY(GST_ELEMENT_GET_CLASS(m_fpsSink)->elementfactory);
+ if (gst_plugin_feature_check_version(GST_PLUGIN_FEATURE(factory), 0, 10, 22)) {
+ g_object_set(m_fpsSink, "silent", TRUE , NULL);
+
+ // Turn off text overlay unless logging is enabled.
+#if LOG_DISABLED
+ g_object_set(m_fpsSink, "text-overlay", FALSE , NULL);
+#else
+ WTFLogChannel* channel = getChannelFromName("Media");
+ if (channel->state != WTFLogChannelOn)
+ g_object_set(m_fpsSink, "text-overlay", FALSE , NULL);
+#endif // LOG_DISABLED
+
+ if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_fpsSink), "video-sink")) {
+ g_object_set(m_fpsSink, "video-sink", m_webkitVideoSink.get(), NULL);
+#if USE(NATIVE_FULLSCREEN_VIDEO)
+ gst_bin_add(GST_BIN(m_videoSinkBin.get()), m_fpsSink);
+#endif
+ actualVideoSink = m_fpsSink;
+ } else
+ m_fpsSink = 0;
+ } else
+ m_fpsSink = 0;
+ }
+
+ if (!m_fpsSink) {
+#if USE(NATIVE_FULLSCREEN_VIDEO)
+ gst_bin_add(GST_BIN(m_videoSinkBin.get()), m_webkitVideoSink.get());
+#endif
+ actualVideoSink = m_webkitVideoSink.get();
+ }
+
+ ASSERT(actualVideoSink);
+
+#if USE(NATIVE_FULLSCREEN_VIDEO)
+ // Faster elements linking.
+ gst_element_link_pads_full(queue, "src", actualVideoSink, "sink", GST_PAD_LINK_CHECK_NOTHING);
+
+ // Add a ghostpad to the bin so it can proxy to tee.
+ GRefPtr<GstPad> pad = adoptGRef(gst_element_get_static_pad(videoTee, "sink"));
+ gst_element_add_pad(m_videoSinkBin.get(), gst_ghost_pad_new("sink", pad.get()));
+
+ // Set the bin as video sink of playbin.
+ return m_videoSinkBin.get();
+#else
+ return actualVideoSink;
+#endif
+}
+
+void MediaPlayerPrivateGStreamerBase::setStreamVolumeElement(GstStreamVolume* volume)
+{
+ ASSERT(!m_volumeElement);
+ m_volumeElement = volume;
+
+ g_object_set(m_volumeElement.get(), "mute", m_player->muted(), "volume", m_player->volume(), NULL);
+
+ m_volumeSignalHandler = g_signal_connect(m_volumeElement.get(), "notify::volume", G_CALLBACK(mediaPlayerPrivateVolumeChangedCallback), this);
+ m_muteSignalHandler = g_signal_connect(m_volumeElement.get(), "notify::mute", G_CALLBACK(mediaPlayerPrivateMuteChangedCallback), this);
+}
+
+unsigned MediaPlayerPrivateGStreamerBase::decodedFrameCount() const
+{
+ guint64 decodedFrames = 0;
+ if (m_fpsSink)
+ g_object_get(m_fpsSink, "frames-rendered", &decodedFrames, NULL);
+ return static_cast<unsigned>(decodedFrames);
+}
+
+unsigned MediaPlayerPrivateGStreamerBase::droppedFrameCount() const
+{
+ guint64 framesDropped = 0;
+ if (m_fpsSink)
+ g_object_get(m_fpsSink, "frames-dropped", &framesDropped, NULL);
+ return static_cast<unsigned>(framesDropped);
+}
+
+unsigned MediaPlayerPrivateGStreamerBase::audioDecodedByteCount() const
+{
+ GstQuery* query = gst_query_new_position(GST_FORMAT_BYTES);
+ gint64 position = 0;
+
+ if (audioSink() && gst_element_query(audioSink(), query))
+ gst_query_parse_position(query, 0, &position);
+
+ gst_query_unref(query);
+ return static_cast<unsigned>(position);
+}
+
+unsigned MediaPlayerPrivateGStreamerBase::videoDecodedByteCount() const
+{
+ GstQuery* query = gst_query_new_position(GST_FORMAT_BYTES);
+ gint64 position = 0;
+
+ if (gst_element_query(m_webkitVideoSink.get(), query))
+ gst_query_parse_position(query, 0, &position);
+
+ gst_query_unref(query);
+ return static_cast<unsigned>(position);
+}
+
+}
+
+#endif // USE(GSTREAMER)
diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h
new file mode 100644
index 000000000..008b921df
--- /dev/null
+++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2007, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2007 Collabora Ltd. All rights reserved.
+ * Copyright (C) 2007 Alp Toker <alp@atoker.com>
+ * Copyright (C) 2009, 2010 Igalia S.L
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * aint with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef MediaPlayerPrivateGStreamerBase_h
+#define MediaPlayerPrivateGStreamerBase_h
+#if ENABLE(VIDEO) && USE(GSTREAMER)
+
+#include "GRefPtrGStreamer.h"
+#include "MediaPlayerPrivate.h"
+
+#include <glib.h>
+
+#include <wtf/Forward.h>
+
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
+#include "TextureMapperPlatformLayer.h"
+#endif
+
+typedef struct _GstBuffer GstBuffer;
+typedef struct _GstElement GstElement;
+typedef struct _GstMessage GstMessage;
+typedef struct _GstStreamVolume GstStreamVolume;
+typedef struct _WebKitVideoSink WebKitVideoSink;
+
+namespace WebCore {
+
+class FullscreenVideoControllerGStreamer;
+class GraphicsContext;
+class IntSize;
+class IntRect;
+class GStreamerGWorld;
+
+class MediaPlayerPrivateGStreamerBase : public MediaPlayerPrivateInterface
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
+ , public TextureMapperPlatformLayer
+#endif
+{
+
+public:
+ ~MediaPlayerPrivateGStreamerBase();
+
+ IntSize naturalSize() const;
+
+ void setVolume(float);
+ float volume() const;
+ void volumeChanged();
+ void notifyPlayerOfVolumeChange();
+
+ bool supportsMuting() const { return true; }
+ void setMuted(bool);
+ bool muted() const;
+ void muteChanged();
+ void notifyPlayerOfMute();
+
+ MediaPlayer::NetworkState networkState() const;
+ MediaPlayer::ReadyState readyState() const;
+
+ void setVisible(bool) { }
+ void setSize(const IntSize&);
+ void sizeChanged();
+
+ void triggerRepaint(GstBuffer*);
+ void paint(GraphicsContext*, const IntRect&);
+
+ virtual bool hasSingleSecurityOrigin() const { return true; }
+ virtual float maxTimeLoaded() const { return 0.0; }
+
+#if USE(NATIVE_FULLSCREEN_VIDEO)
+ void enterFullscreen();
+ void exitFullscreen();
+ bool canEnterFullscreen() const { return true; }
+#endif
+
+ bool supportsFullscreen() const;
+ PlatformMedia platformMedia() const;
+
+ MediaPlayer::MovieLoadType movieLoadType() const;
+ virtual bool isLiveStream() const = 0;
+
+ MediaPlayer* mediaPlayer() const { return m_player; }
+
+ unsigned decodedFrameCount() const;
+ unsigned droppedFrameCount() const;
+ unsigned audioDecodedByteCount() const;
+ unsigned videoDecodedByteCount() const;
+
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
+ virtual PlatformLayer* platformLayer() const { return const_cast<MediaPlayerPrivateGStreamerBase*>(this); }
+ virtual bool supportsAcceleratedRendering() const { return true; }
+ virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float);
+#endif
+
+protected:
+ MediaPlayerPrivateGStreamerBase(MediaPlayer*);
+ GstElement* createVideoSink(GstElement* pipeline);
+ void setStreamVolumeElement(GstStreamVolume*);
+ virtual GstElement* audioSink() const { return 0; }
+ GRefPtr<GstCaps> currentVideoSinkCaps() const;
+
+ MediaPlayer* m_player;
+ GRefPtr<GstStreamVolume> m_volumeElement;
+ GRefPtr<GstElement> m_webkitVideoSink;
+ GRefPtr<GstElement> m_videoSinkBin;
+ GstElement* m_fpsSink;
+ MediaPlayer::ReadyState m_readyState;
+ MediaPlayer::NetworkState m_networkState;
+ IntSize m_size;
+ GMutex* m_bufferMutex;
+ GstBuffer* m_buffer;
+#if USE(NATIVE_FULLSCREEN_VIDEO)
+ RefPtr<GStreamerGWorld> m_gstGWorld;
+ OwnPtr<FullscreenVideoControllerGStreamer> m_fullscreenVideoController;
+#endif
+ unsigned long m_volumeTimerHandler;
+ unsigned long m_muteTimerHandler;
+ unsigned long m_repaintHandler;
+ unsigned long m_volumeSignalHandler;
+ unsigned long m_muteSignalHandler;
+ mutable IntSize m_videoSize;
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS)
+ PassRefPtr<BitmapTexture> updateTexture(TextureMapper*);
+#endif
+};
+}
+
+#endif // USE(GSTREAMER)
+#endif
diff --git a/Source/WebCore/platform/graphics/gstreamer/PlatformVideoWindow.h b/Source/WebCore/platform/graphics/gstreamer/PlatformVideoWindow.h
index 2f8d365ff..4a1bc9f0f 100644
--- a/Source/WebCore/platform/graphics/gstreamer/PlatformVideoWindow.h
+++ b/Source/WebCore/platform/graphics/gstreamer/PlatformVideoWindow.h
@@ -19,7 +19,7 @@
#ifndef PlatformVideoWindow_h
#define PlatformVideoWindow_h
-#if ENABLE(VIDEO) && USE(GSTREAMER) && !defined(GST_API_VERSION_1)
+#if ENABLE(VIDEO) && USE(GSTREAMER) && USE(NATIVE_FULLSCREEN_VIDEO)
#include "Widget.h"
#include <wtf/PassRefPtr.h>
@@ -61,5 +61,5 @@ class PlatformVideoWindow : public RefCounted<PlatformVideoWindow> {
};
}
-#endif // USE(GSTREAMER) && !defined(GST_API_VERSION_1)
+#endif // USE(GSTREAMER) && USE(NATIVE_FULLSCREEN_VIDEO)
#endif
diff --git a/Source/WebCore/platform/graphics/gstreamer/PlatformVideoWindowGtk.cpp b/Source/WebCore/platform/graphics/gstreamer/PlatformVideoWindowGtk.cpp
index b83881112..0c3572b27 100644
--- a/Source/WebCore/platform/graphics/gstreamer/PlatformVideoWindowGtk.cpp
+++ b/Source/WebCore/platform/graphics/gstreamer/PlatformVideoWindowGtk.cpp
@@ -19,7 +19,7 @@
#include "config.h"
#include "PlatformVideoWindow.h"
-#if ENABLE(VIDEO) && USE(GSTREAMER) && !defined(GST_API_VERSION_1)
+#if ENABLE(VIDEO) && USE(GSTREAMER) && USE(NATIVE_FULLSCREEN_VIDEO)
#include <gtk/gtk.h>
@@ -48,8 +48,7 @@ PlatformVideoWindow::PlatformVideoWindow()
PlatformVideoWindow::~PlatformVideoWindow()
{
- if (m_videoWindow && m_window) {
- gtk_container_remove(GTK_CONTAINER(m_window), m_videoWindow);
+ if (m_videoWindow) {
gtk_widget_destroy(m_videoWindow);
m_videoWindow = 0;
}
@@ -65,5 +64,5 @@ PlatformVideoWindow::~PlatformVideoWindow()
void PlatformVideoWindow::prepareForOverlay(GstMessage*)
{
}
-#endif // ENABLE(VIDEO) && USE(GSTREAMER) && !defined(GST_API_VERSION_1)
+#endif // ENABLE(VIDEO) && USE(GSTREAMER) && USE(NATIVE_FULLSCREEN_VIDEO)
diff --git a/Source/WebCore/platform/graphics/gstreamer/PlatformVideoWindowMac.mm b/Source/WebCore/platform/graphics/gstreamer/PlatformVideoWindowMac.mm
index 952fb7f61..a34ab78e4 100644
--- a/Source/WebCore/platform/graphics/gstreamer/PlatformVideoWindowMac.mm
+++ b/Source/WebCore/platform/graphics/gstreamer/PlatformVideoWindowMac.mm
@@ -28,7 +28,7 @@ using namespace WebCore;
PlatformVideoWindow::PlatformVideoWindow()
{
- m_window.adoptNS([[NSView alloc] init]);
+ m_window = adoptNS([[NSView alloc] init]);
m_videoWindowId = reinterpret_cast<unsigned long>(m_window.get());
}
diff --git a/Source/WebCore/platform/graphics/gstreamer/PlatformVideoWindowPrivate.h b/Source/WebCore/platform/graphics/gstreamer/PlatformVideoWindowPrivate.h
index f48ff836e..972b522be 100644
--- a/Source/WebCore/platform/graphics/gstreamer/PlatformVideoWindowPrivate.h
+++ b/Source/WebCore/platform/graphics/gstreamer/PlatformVideoWindowPrivate.h
@@ -19,6 +19,7 @@
#ifndef PlatformVideoWindowPrivate_h
#define PlatformVideoWindowPrivate_h
+#if ENABLE(VIDEO) && USE(GSTREAMER) && USE(NATIVE_FULLSCREEN_VIDEO)
#include <QEvent>
#include <QTimer>
@@ -55,5 +56,5 @@ private:
} // namespace WebCore
-
+#endif // ENABLE(VIDEO) && USE(GSTREAMER) && USE(NATIVE_FULLSCREEN_VIDEO)
#endif // PlatformVideoWindowPrivate_h
diff --git a/Source/WebCore/platform/graphics/gstreamer/PlatformVideoWindowQt.cpp b/Source/WebCore/platform/graphics/gstreamer/PlatformVideoWindowQt.cpp
index 11b6fb7e3..1dcfd014f 100644
--- a/Source/WebCore/platform/graphics/gstreamer/PlatformVideoWindowQt.cpp
+++ b/Source/WebCore/platform/graphics/gstreamer/PlatformVideoWindowQt.cpp
@@ -19,7 +19,7 @@
#include "config.h"
#include "PlatformVideoWindow.h"
-#if ENABLE(VIDEO) && USE(GSTREAMER) && !defined(GST_API_VERSION_1)
+#if ENABLE(VIDEO) && USE(GSTREAMER) && USE(NATIVE_FULLSCREEN_VIDEO)
#include "HTMLVideoElement.h"
#include "PlatformVideoWindowPrivate.h"
@@ -130,4 +130,4 @@ PlatformVideoWindow::~PlatformVideoWindow()
void PlatformVideoWindow::prepareForOverlay(GstMessage*)
{
}
-#endif // ENABLE(VIDEO) && USE(GSTREAMER) && !defined(GST_API_VERSION_1)
+#endif // ENABLE(VIDEO) && USE(GSTREAMER) && USE(NATIVE_FULLSCREEN_VIDEO)
diff --git a/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp
index d852184c0..f7af7ac10 100644
--- a/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp
+++ b/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp
@@ -26,9 +26,9 @@
*/
#include "config.h"
-#if USE(GSTREAMER)
#include "VideoSinkGStreamer.h"
+#if ENABLE(VIDEO) && USE(GSTREAMER)
#include "GRefPtrGStreamer.h"
#include "GStreamerVersioning.h"
#include "IntSize.h"
@@ -41,19 +41,29 @@
#include <wtf/FastAllocBase.h>
// CAIRO_FORMAT_RGB24 used to render the video buffers is little/big endian dependant.
+#ifdef GST_API_VERSION_1
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
-#ifndef GST_API_VERSION_1
-#define WEBKIT_VIDEO_SINK_PAD_CAPS GST_VIDEO_CAPS_BGRx ";" GST_VIDEO_CAPS_BGRA
+#define GST_CAPS_FORMAT "{ BGRx, BGRA }"
#else
-#define WEBKIT_VIDEO_SINK_PAD_CAPS GST_VIDEO_CAPS_MAKE("{ BGRx, BGRA }")
+#define GST_CAPS_FORMAT "{ xRGB, ARGB }"
#endif
+#if GST_CHECK_VERSION(1, 1, 0)
+#define GST_FEATURED_CAPS GST_VIDEO_CAPS_MAKE_WITH_FEATURES(GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META, GST_CAPS_FORMAT) ";"
#else
-#ifndef GST_API_VERSION_1
-#define WEBKIT_VIDEO_SINK_PAD_CAPS GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_ARGB
-#else
-#define WEBKIT_VIDEO_SINK_PAD_CAPS GST_VIDEO_CAPS_MAKE("{ xRGB, ARGB }")
+#define GST_FEATURED_CAPS
#endif
+#endif // GST_API_VERSION_1
+
+#ifdef GST_API_VERSION_1
+#define WEBKIT_VIDEO_SINK_PAD_CAPS GST_FEATURED_CAPS GST_VIDEO_CAPS_MAKE(GST_CAPS_FORMAT)
+#else
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+#define WEBKIT_VIDEO_SINK_PAD_CAPS GST_VIDEO_CAPS_BGRx ";" GST_VIDEO_CAPS_BGRA
+#else
+#define WEBKIT_VIDEO_SINK_PAD_CAPS GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_ARGB
#endif
+#endif // GST_API_VERSION_1
+
static GstStaticPadTemplate s_sinkTemplate = GST_STATIC_PAD_TEMPLATE("sink", GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS(WEBKIT_VIDEO_SINK_PAD_CAPS));
@@ -66,7 +76,8 @@ enum {
};
enum {
- PROP_0
+ PROP_0,
+ PROP_CAPS
};
static guint webkitVideoSinkSignals[LAST_SIGNAL] = { 0, };
@@ -81,10 +92,12 @@ struct _WebKitVideoSinkPrivate {
GstVideoInfo info;
#endif
-#ifndef GST_API_VERSION_1
+#if USE(NATIVE_FULLSCREEN_VIDEO)
WebCore::GStreamerGWorld* gstGWorld;
#endif
+ GstCaps* currentCaps;
+
// If this is TRUE all processing should finish ASAP
// This is necessary because there could be a race between
// unlock() and render(), where unlock() wins, signals the
@@ -154,7 +167,7 @@ static GstFlowReturn webkitVideoSinkRender(GstBaseSink* baseSink, GstBuffer* buf
return GST_FLOW_OK;
}
-#ifndef GST_API_VERSION_1
+#if USE(NATIVE_FULLSCREEN_VIDEO)
// Ignore buffers if the video is already in fullscreen using
// another sink.
if (priv->gstGWorld->isFullscreen()) {
@@ -286,6 +299,24 @@ static void webkitVideoSinkDispose(GObject* object)
G_OBJECT_CLASS(parent_class)->dispose(object);
}
+static void webkitVideoSinkGetProperty(GObject* object, guint propertyId, GValue* value, GParamSpec* parameterSpec)
+{
+ WebKitVideoSink* sink = WEBKIT_VIDEO_SINK(object);
+ WebKitVideoSinkPrivate* priv = sink->priv;
+
+ switch (propertyId) {
+ case PROP_CAPS: {
+ GstCaps* caps = priv->currentCaps;
+ if (caps)
+ gst_caps_ref(caps);
+ g_value_take_boxed(value, caps);
+ break;
+ }
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, parameterSpec);
+ }
+}
+
static void unlockBufferMutex(WebKitVideoSinkPrivate* priv)
{
g_mutex_lock(priv->bufferMutex);
@@ -323,7 +354,15 @@ static gboolean webkitVideoSinkUnlockStop(GstBaseSink* baseSink)
static gboolean webkitVideoSinkStop(GstBaseSink* baseSink)
{
- unlockBufferMutex(WEBKIT_VIDEO_SINK(baseSink)->priv);
+ WebKitVideoSinkPrivate* priv = WEBKIT_VIDEO_SINK(baseSink)->priv;
+
+ unlockBufferMutex(priv);
+
+ if (priv->currentCaps) {
+ gst_caps_unref(priv->currentCaps);
+ priv->currentCaps = 0;
+ }
+
return TRUE;
}
@@ -337,6 +376,25 @@ static gboolean webkitVideoSinkStart(GstBaseSink* baseSink)
return TRUE;
}
+static gboolean webkitVideoSinkSetCaps(GstBaseSink* baseSink, GstCaps* caps)
+{
+ WebKitVideoSink* sink = WEBKIT_VIDEO_SINK(baseSink);
+ WebKitVideoSinkPrivate* priv = sink->priv;
+
+ GST_DEBUG_OBJECT(sink, "Current caps %" GST_PTR_FORMAT ", setting caps %" GST_PTR_FORMAT, priv->currentCaps, caps);
+
+#ifdef GST_API_VERSION_1
+ GstVideoInfo info;
+ if (!gst_video_info_from_caps(&info, caps)) {
+ GST_ERROR_OBJECT(sink, "Invalid caps %" GST_PTR_FORMAT, caps);
+ return FALSE;
+ }
+#endif
+
+ gst_caps_replace(&priv->currentCaps, caps);
+ return TRUE;
+}
+
#ifdef GST_API_VERSION_1
static gboolean webkitVideoSinkProposeAllocation(GstBaseSink* baseSink, GstQuery* query)
{
@@ -351,6 +409,9 @@ static gboolean webkitVideoSinkProposeAllocation(GstBaseSink* baseSink, GstQuery
gst_query_add_allocation_meta(query, GST_VIDEO_META_API_TYPE, 0);
gst_query_add_allocation_meta(query, GST_VIDEO_CROP_META_API_TYPE, 0);
+#if GST_CHECK_VERSION(1, 1, 0)
+ gst_query_add_allocation_meta(query, GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE, 0);
+#endif
return TRUE;
}
#endif
@@ -390,6 +451,7 @@ static void webkit_video_sink_class_init(WebKitVideoSinkClass* klass)
g_type_class_add_private(klass, sizeof(WebKitVideoSinkPrivate));
gobjectClass->dispose = webkitVideoSinkDispose;
+ gobjectClass->get_property = webkitVideoSinkGetProperty;
baseSinkClass->unlock = webkitVideoSinkUnlock;
baseSinkClass->unlock_stop = webkitVideoSinkUnlockStop;
@@ -397,10 +459,14 @@ static void webkit_video_sink_class_init(WebKitVideoSinkClass* klass)
baseSinkClass->preroll = webkitVideoSinkRender;
baseSinkClass->stop = webkitVideoSinkStop;
baseSinkClass->start = webkitVideoSinkStart;
+ baseSinkClass->set_caps = webkitVideoSinkSetCaps;
#ifdef GST_API_VERSION_1
baseSinkClass->propose_allocation = webkitVideoSinkProposeAllocation;
#endif
+ g_object_class_install_property(gobjectClass, PROP_CAPS,
+ g_param_spec_boxed("current-caps", "Current-Caps", "Current caps", GST_TYPE_CAPS, G_PARAM_READABLE));
+
webkitVideoSinkSignals[REPAINT_REQUESTED] = g_signal_new("repaint-requested",
G_TYPE_FROM_CLASS(klass),
static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
@@ -418,7 +484,7 @@ static void webkit_video_sink_class_init(WebKitVideoSinkClass* klass)
}
-#ifndef GST_API_VERSION_1
+#if USE(NATIVE_FULLSCREEN_VIDEO)
GstElement* webkitVideoSinkNew(WebCore::GStreamerGWorld* gstGWorld)
{
GstElement* element = GST_ELEMENT(g_object_new(WEBKIT_TYPE_VIDEO_SINK, 0));
@@ -432,4 +498,4 @@ GstElement* webkitVideoSinkNew()
}
#endif
-#endif // USE(GSTREAMER)
+#endif // ENABLE(VIDEO) && USE(GSTREAMER)
diff --git a/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.h b/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.h
index 061b694de..8cfd2aeda 100644
--- a/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.h
+++ b/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.h
@@ -22,7 +22,7 @@
#if ENABLE(VIDEO) && USE(GSTREAMER)
-#ifndef GST_API_VERSION_1
+#if USE(NATIVE_FULLSCREEN_VIDEO)
#include "GStreamerGWorld.h"
#endif
@@ -61,7 +61,7 @@ struct _WebKitVideoSinkClass {
GType webkit_video_sink_get_type() G_GNUC_CONST;
-#ifndef GST_API_VERSION_1
+#if USE(NATIVE_FULLSCREEN_VIDEO)
GstElement* webkitVideoSinkNew(WebCore::GStreamerGWorld*);
#else
GstElement* webkitVideoSinkNew();
diff --git a/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp
index f804d1f7e..1bbe13eaa 100644
--- a/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp
+++ b/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009, 2010 Sebastian Dröge <sebastian.droege@collabora.co.uk>
+ * Copyright (C) 2013 Collabora Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -21,34 +22,80 @@
#if ENABLE(VIDEO) && USE(GSTREAMER)
-#include "Document.h"
-#include "Frame.h"
+#include "CachedRawResource.h"
+#include "CachedRawResourceClient.h"
+#include "CachedResourceHandle.h"
+#include "CachedResourceLoader.h"
+#include "CachedResourceRequest.h"
#include "GRefPtrGStreamer.h"
#include "GStreamerVersioning.h"
#include "MediaPlayer.h"
-#include "NetworkingContext.h"
#include "NotImplemented.h"
+#include "ResourceHandle.h"
#include "ResourceHandleClient.h"
-#include "ResourceHandleInternal.h"
#include "ResourceRequest.h"
#include "ResourceResponse.h"
-
#include <gst/app/gstappsrc.h>
+#include <gst/gst.h>
#include <gst/pbutils/missing-plugins.h>
-
#include <wtf/Noncopyable.h>
+#include <wtf/gobject/GMutexLocker.h>
#include <wtf/gobject/GOwnPtr.h>
#include <wtf/gobject/GRefPtr.h>
#include <wtf/text/CString.h>
using namespace WebCore;
-class StreamingClient : public ResourceHandleClient {
- WTF_MAKE_NONCOPYABLE(StreamingClient); WTF_MAKE_FAST_ALLOCATED;
+class StreamingClient {
public:
StreamingClient(WebKitWebSrc*);
virtual ~StreamingClient();
+ virtual bool loadFailed() const = 0;
+ virtual void setDefersLoading(bool) = 0;
+
+ protected:
+ char* createReadBuffer(size_t requestedSize, size_t& actualSize);
+ void handleResponseReceived(const ResourceResponse&);
+ void handleDataReceived(const char*, int);
+ void handleNotifyFinished();
+
+ GRefPtr<GstElement> m_src;
+};
+
+class CachedResourceStreamingClient : public CachedRawResourceClient, public StreamingClient {
+ WTF_MAKE_NONCOPYABLE(CachedResourceStreamingClient); WTF_MAKE_FAST_ALLOCATED;
+ public:
+ CachedResourceStreamingClient(WebKitWebSrc*, CachedResourceLoader*, const ResourceRequest&);
+ virtual ~CachedResourceStreamingClient();
+
+ // StreamingClient virtual methods.
+ virtual bool loadFailed() const;
+ virtual void setDefersLoading(bool);
+
+ private:
+ // CachedResourceClient virtual methods.
+ virtual char* getOrCreateReadBuffer(CachedResource*, size_t requestedSize, size_t& actualSize);
+ virtual void responseReceived(CachedResource*, const ResourceResponse&);
+ virtual void dataReceived(CachedResource*, const char*, int);
+ virtual void notifyFinished(CachedResource*);
+
+ CachedResourceHandle<CachedRawResource> m_resource;
+};
+
+class ResourceHandleStreamingClient : public ResourceHandleClient, public StreamingClient {
+ WTF_MAKE_NONCOPYABLE(ResourceHandleStreamingClient); WTF_MAKE_FAST_ALLOCATED;
+ public:
+ ResourceHandleStreamingClient(WebKitWebSrc*, const ResourceRequest&);
+ virtual ~ResourceHandleStreamingClient();
+
+ // StreamingClient virtual methods.
+ virtual bool loadFailed() const;
+ virtual void setDefersLoading(bool);
+
+ private:
+ // ResourceHandleClient virtual methods.
+ virtual char* getOrCreateReadBuffer(size_t requestedSize, size_t& actualSize);
virtual void willSendRequest(ResourceHandle*, ResourceRequest&, const ResourceResponse&);
virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&);
virtual void didReceiveData(ResourceHandle*, const char*, int, int);
@@ -57,8 +104,7 @@ class StreamingClient : public ResourceHandleClient {
virtual void wasBlocked(ResourceHandle*);
virtual void cannotShowURL(ResourceHandle*);
- private:
- WebKitWebSrc* m_src;
+ RefPtr<ResourceHandle> m_resource;
};
#define WEBKIT_WEB_SRC_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_SRC, WebKitWebSrcPrivate))
@@ -67,11 +113,9 @@ struct _WebKitWebSrcPrivate {
GstPad* srcpad;
gchar* uri;
- RefPtr<WebCore::Frame> frame;
WebCore::MediaPlayer* player;
StreamingClient* client;
- RefPtr<ResourceHandle> resourceHandle;
guint64 offset;
guint64 size;
@@ -80,10 +124,14 @@ struct _WebKitWebSrcPrivate {
guint64 requestedOffset;
+ guint startID;
+ guint stopID;
guint needDataID;
guint enoughDataID;
guint seekID;
+ GRefPtr<GstBuffer> buffer;
+
// icecast stuff
gboolean iradioMode;
gchar* iradioName;
@@ -115,6 +163,7 @@ GST_DEBUG_CATEGORY_STATIC(webkit_web_src_debug);
static void webKitWebSrcUriHandlerInit(gpointer gIface, gpointer ifaceData);
+static void webKitWebSrcDispose(GObject*);
static void webKitWebSrcFinalize(GObject*);
static void webKitWebSrcSetProperty(GObject*, guint propertyID, const GValue*, GParamSpec*);
static void webKitWebSrcGetProperty(GObject*, guint propertyID, GValue*, GParamSpec*);
@@ -129,8 +178,6 @@ static void webKitWebSrcNeedDataCb(GstAppSrc*, guint length, gpointer userData);
static void webKitWebSrcEnoughDataCb(GstAppSrc*, gpointer userData);
static gboolean webKitWebSrcSeekDataCb(GstAppSrc*, guint64 offset, gpointer userData);
-static void webKitWebSrcStop(WebKitWebSrc*, bool);
-
static GstAppSrcCallbacks appsrcCallbacks = {
webKitWebSrcNeedDataCb,
webKitWebSrcEnoughDataCb,
@@ -150,6 +197,7 @@ static void webkit_web_src_class_init(WebKitWebSrcClass* klass)
GObjectClass* oklass = G_OBJECT_CLASS(klass);
GstElementClass* eklass = GST_ELEMENT_CLASS(klass);
+ oklass->dispose = webKitWebSrcDispose;
oklass->finalize = webKitWebSrcFinalize;
oklass->set_property = webKitWebSrcSetProperty;
oklass->get_property = webKitWebSrcGetProperty;
@@ -183,7 +231,7 @@ static void webkit_web_src_class_init(WebKitWebSrcClass* klass)
"Genre of the stream",
0,
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
-
+
g_object_class_install_property(oklass,
PROP_IRADIO_URL,
g_param_spec_string("iradio-url",
@@ -221,8 +269,6 @@ static void webkit_web_src_init(WebKitWebSrc* src)
src->priv = priv;
- priv->client = new StreamingClient(src);
-
priv->appsrc = GST_APP_SRC(gst_element_factory_make("appsrc", 0));
if (!priv->appsrc) {
GST_ERROR_OBJECT(src, "Failed to create appsrc");
@@ -271,19 +317,28 @@ static void webkit_web_src_init(WebKitWebSrc* src)
if (priv->haveAppSrc27)
g_object_set(priv->appsrc, "min-percent", 20, NULL);
- webKitWebSrcStop(src, false);
+ gst_app_src_set_caps(priv->appsrc, 0);
+ gst_app_src_set_size(priv->appsrc, -1);
}
-static void webKitWebSrcFinalize(GObject* object)
+static void webKitWebSrcDispose(GObject* object)
{
WebKitWebSrc* src = WEBKIT_WEB_SRC(object);
WebKitWebSrcPrivate* priv = src->priv;
- delete priv->client;
+ priv->player = 0;
+
+ GST_CALL_PARENT(G_OBJECT_CLASS, dispose, (object));
+}
+
+static void webKitWebSrcFinalize(GObject* object)
+{
+ WebKitWebSrc* src = WEBKIT_WEB_SRC(object);
+ WebKitWebSrcPrivate* priv = src->priv;
g_free(priv->uri);
- GST_CALL_PARENT(G_OBJECT_CLASS, finalize, ((GObject* )(src)));
+ GST_CALL_PARENT(G_OBJECT_CLASS, finalize, (object));
}
static void webKitWebSrcSetProperty(GObject* object, guint propID, const GValue* value, GParamSpec* pspec)
@@ -292,9 +347,11 @@ static void webKitWebSrcSetProperty(GObject* object, guint propID, const GValue*
WebKitWebSrcPrivate* priv = src->priv;
switch (propID) {
- case PROP_IRADIO_MODE:
+ case PROP_IRADIO_MODE: {
+ GMutexLocker locker(GST_OBJECT_GET_LOCK(src));
priv->iradioMode = g_value_get_boolean(value);
break;
+ }
case PROP_LOCATION:
#ifdef GST_API_VERSION_1
gst_uri_handler_set_uri(reinterpret_cast<GstURIHandler*>(src), g_value_get_string(value), 0);
@@ -313,6 +370,7 @@ static void webKitWebSrcGetProperty(GObject* object, guint propID, GValue* value
WebKitWebSrc* src = WEBKIT_WEB_SRC(object);
WebKitWebSrcPrivate* priv = src->priv;
+ GMutexLocker locker(GST_OBJECT_GET_LOCK(src));
switch (propID) {
case PROP_IRADIO_MODE:
g_value_set_boolean(value, priv->iradioMode);
@@ -338,23 +396,14 @@ static void webKitWebSrcGetProperty(GObject* object, guint propID, GValue* value
}
}
-
-static void webKitWebSrcStop(WebKitWebSrc* src, bool seeking)
+static void removeTimeoutSources(WebKitWebSrc* src)
{
WebKitWebSrcPrivate* priv = src->priv;
- if (priv->resourceHandle) {
- priv->resourceHandle->cancel();
- priv->resourceHandle.release();
- }
- priv->resourceHandle = 0;
-
- if (priv->frame && !seeking)
- priv->frame.clear();
-
- priv->player = 0;
+ if (priv->startID)
+ g_source_remove(priv->startID);
+ priv->startID = 0;
- GST_OBJECT_LOCK(src);
if (priv->needDataID)
g_source_remove(priv->needDataID);
priv->needDataID = 0;
@@ -366,9 +415,34 @@ static void webKitWebSrcStop(WebKitWebSrc* src, bool seeking)
if (priv->seekID)
g_source_remove(priv->seekID);
priv->seekID = 0;
+}
+
+static gboolean webKitWebSrcStop(WebKitWebSrc* src)
+{
+ WebKitWebSrcPrivate* priv = src->priv;
+
+ ASSERT(isMainThread());
+
+ GMutexLocker locker(GST_OBJECT_GET_LOCK(src));
+
+ bool seeking = priv->seekID;
+
+ removeTimeoutSources(src);
+ priv->stopID = 0;
+
+ if (priv->client) {
+ delete priv->client;
+ priv->client = 0;
+ }
+
+ if (priv->buffer) {
+#ifdef GST_API_VERSION_1
+ unmapGstBuffer(priv->buffer.get());
+#endif
+ priv->buffer.clear();
+ }
priv->paused = FALSE;
- GST_OBJECT_UNLOCK(src);
g_free(priv->iradioName);
priv->iradioName = 0;
@@ -382,44 +456,52 @@ static void webKitWebSrcStop(WebKitWebSrc* src, bool seeking)
g_free(priv->iradioTitle);
priv->iradioTitle = 0;
- if (priv->appsrc) {
- gst_app_src_set_caps(priv->appsrc, 0);
- if (!seeking)
- gst_app_src_set_size(priv->appsrc, -1);
- }
-
priv->offset = 0;
priv->seekable = FALSE;
if (!seeking) {
priv->size = 0;
priv->requestedOffset = 0;
+ priv->player = 0;
+ }
+
+ locker.unlock();
+
+ if (priv->appsrc) {
+ gst_app_src_set_caps(priv->appsrc, 0);
+ if (!seeking)
+ gst_app_src_set_size(priv->appsrc, -1);
}
GST_DEBUG_OBJECT(src, "Stopped request");
+
+ return FALSE;
}
-static bool webKitWebSrcStart(WebKitWebSrc* src)
+static gboolean webKitWebSrcStart(WebKitWebSrc* src)
{
WebKitWebSrcPrivate* priv = src->priv;
+ ASSERT(isMainThread());
+
+ GMutexLocker locker(GST_OBJECT_GET_LOCK(src));
+
+ priv->startID = 0;
+
if (!priv->uri) {
GST_ERROR_OBJECT(src, "No URI provided");
- return false;
+ locker.unlock();
+ webKitWebSrcStop(src);
+ return FALSE;
}
-
+
+ ASSERT(!priv->client);
+
KURL url = KURL(KURL(), priv->uri);
ResourceRequest request(url);
request.setAllowCookies(true);
- NetworkingContext* context = 0;
- FrameLoader* loader = priv->frame ? priv->frame->loader() : 0;
- if (loader) {
- loader->addExtraFieldsToSubresourceRequest(request);
- context = loader->networkingContext();
- }
-
if (priv->player)
request.setHTTPReferrer(priv->player->referrer());
@@ -434,6 +516,7 @@ static bool webKitWebSrcStart(WebKitWebSrc* src)
val.set(g_strdup_printf("bytes=%" G_GUINT64_FORMAT "-", priv->requestedOffset));
request.setHTTPHeaderField("Range", val.get());
}
+ priv->offset = priv->requestedOffset;
if (priv->iradioMode)
request.setHTTPHeaderField("icy-metadata", "1");
@@ -441,15 +524,26 @@ static bool webKitWebSrcStart(WebKitWebSrc* src)
// Needed to use DLNA streaming servers
request.setHTTPHeaderField("transferMode.dlna", "Streaming");
- priv->resourceHandle = ResourceHandle::create(context, request, priv->client, false, false);
- if (!priv->resourceHandle) {
- GST_ERROR_OBJECT(src, "Failed to create ResourceHandle");
- return false;
+ if (priv->player) {
+ if (CachedResourceLoader* loader = priv->player->cachedResourceLoader())
+ priv->client = new CachedResourceStreamingClient(src, loader, request);
}
- GST_DEBUG_OBJECT(src, "Started request");
+ if (!priv->client)
+ priv->client = new ResourceHandleStreamingClient(src, request);
- return true;
+ if (!priv->client || priv->client->loadFailed()) {
+ GST_ERROR_OBJECT(src, "Failed to setup streaming client");
+ if (priv->client) {
+ delete priv->client;
+ priv->client = 0;
+ }
+ locker.unlock();
+ webKitWebSrcStop(src);
+ return FALSE;
+ }
+ GST_DEBUG_OBJECT(src, "Started request");
+ return FALSE;
}
static GstStateChangeReturn webKitWebSrcChangeState(GstElement* element, GstStateChange transition)
@@ -477,15 +571,17 @@ static GstStateChangeReturn webKitWebSrcChangeState(GstElement* element, GstStat
return ret;
}
+ GMutexLocker locker(GST_OBJECT_GET_LOCK(src));
switch (transition) {
case GST_STATE_CHANGE_READY_TO_PAUSED:
GST_DEBUG_OBJECT(src, "READY->PAUSED");
- if (!webKitWebSrcStart(src))
- ret = GST_STATE_CHANGE_FAILURE;
+ priv->startID = g_idle_add_full(G_PRIORITY_DEFAULT, (GSourceFunc) webKitWebSrcStart, gst_object_ref(src), (GDestroyNotify) gst_object_unref);
break;
case GST_STATE_CHANGE_PAUSED_TO_READY:
GST_DEBUG_OBJECT(src, "PAUSED->READY");
- webKitWebSrcStop(src, false);
+ // cancel pending sources
+ removeTimeoutSources(src);
+ priv->stopID = g_idle_add_full(G_PRIORITY_DEFAULT, (GSourceFunc) webKitWebSrcStop, gst_object_ref(src), (GDestroyNotify) gst_object_unref);
break;
default:
break;
@@ -496,7 +592,7 @@ static GstStateChangeReturn webKitWebSrcChangeState(GstElement* element, GstStat
static gboolean webKitWebSrcQueryWithParent(GstPad* pad, GstObject* parent, GstQuery* query)
{
- WebKitWebSrc* webkitSrc = WEBKIT_WEB_SRC(GST_ELEMENT(parent));
+ WebKitWebSrc* src = WEBKIT_WEB_SRC(GST_ELEMENT(parent));
gboolean result = FALSE;
switch (GST_QUERY_TYPE(query)) {
@@ -505,15 +601,17 @@ static gboolean webKitWebSrcQueryWithParent(GstPad* pad, GstObject* parent, GstQ
gst_query_parse_duration(query, &format, NULL);
- GST_DEBUG_OBJECT(webkitSrc, "duration query in format %s", gst_format_get_name(format));
- if ((format == GST_FORMAT_BYTES) && (webkitSrc->priv->size > 0)) {
- gst_query_set_duration(query, format, webkitSrc->priv->size);
+ GST_DEBUG_OBJECT(src, "duration query in format %s", gst_format_get_name(format));
+ GMutexLocker locker(GST_OBJECT_GET_LOCK(src));
+ if (format == GST_FORMAT_BYTES && src->priv->size > 0) {
+ gst_query_set_duration(query, format, src->priv->size);
result = TRUE;
}
break;
}
case GST_QUERY_URI: {
- gst_query_set_uri(query, webkitSrc->priv->uri);
+ GMutexLocker locker(GST_OBJECT_GET_LOCK(src));
+ gst_query_set_uri(query, src->priv->uri);
result = TRUE;
break;
}
@@ -554,7 +652,12 @@ const gchar* const* webKitWebSrcGetProtocols(GType)
static gchar* webKitWebSrcGetUri(GstURIHandler* handler)
{
- return g_strdup(WEBKIT_WEB_SRC(handler)->priv->uri);
+ WebKitWebSrc* src = WEBKIT_WEB_SRC(handler);
+ gchar* ret;
+
+ GMutexLocker locker(GST_OBJECT_GET_LOCK(src));
+ ret = g_strdup(src->priv->uri);
+ return ret;
}
static gboolean webKitWebSrcSetUri(GstURIHandler* handler, const gchar* uri, GError** error)
@@ -567,6 +670,8 @@ static gboolean webKitWebSrcSetUri(GstURIHandler* handler, const gchar* uri, GEr
return FALSE;
}
+ GMutexLocker locker(GST_OBJECT_GET_LOCK(src));
+
g_free(priv->uri);
priv->uri = 0;
@@ -598,7 +703,12 @@ static gchar** webKitWebSrcGetProtocols(void)
static const gchar* webKitWebSrcGetUri(GstURIHandler* handler)
{
- return g_strdup(WEBKIT_WEB_SRC(handler)->priv->uri);
+ WebKitWebSrc* src = WEBKIT_WEB_SRC(handler);
+ gchar* ret;
+
+ GMutexLocker locker(GST_OBJECT_GET_LOCK(src));
+ ret = g_strdup(src->priv->uri);
+ return ret;
}
static gboolean webKitWebSrcSetUri(GstURIHandler* handler, const gchar* uri)
@@ -611,6 +721,8 @@ static gboolean webKitWebSrcSetUri(GstURIHandler* handler, const gchar* uri)
return FALSE;
}
+ GMutexLocker locker(GST_OBJECT_GET_LOCK(src));
+
g_free(priv->uri);
priv->uri = 0;
@@ -645,12 +757,19 @@ static gboolean webKitWebSrcNeedDataMainCb(WebKitWebSrc* src)
{
WebKitWebSrcPrivate* priv = src->priv;
- priv->resourceHandle->setDefersLoading(false);
+ ASSERT(isMainThread());
+
+ GMutexLocker locker(GST_OBJECT_GET_LOCK(src));
+ // already stopped
+ if (!priv->needDataID)
+ return FALSE;
- GST_OBJECT_LOCK(src);
priv->paused = FALSE;
priv->needDataID = 0;
- GST_OBJECT_UNLOCK(src);
+ locker.unlock();
+
+ if (priv->client)
+ priv->client->setDefersLoading(false);
return FALSE;
}
@@ -661,27 +780,31 @@ static void webKitWebSrcNeedDataCb(GstAppSrc*, guint length, gpointer userData)
GST_DEBUG_OBJECT(src, "Need more data: %u", length);
- GST_OBJECT_LOCK(src);
+ GMutexLocker locker(GST_OBJECT_GET_LOCK(src));
if (priv->needDataID || !priv->paused) {
- GST_OBJECT_UNLOCK(src);
return;
}
- priv->needDataID = g_timeout_add_full(G_PRIORITY_DEFAULT, 0, (GSourceFunc) webKitWebSrcNeedDataMainCb, gst_object_ref(src), (GDestroyNotify) gst_object_unref);
- GST_OBJECT_UNLOCK(src);
+ priv->needDataID = g_idle_add_full(G_PRIORITY_DEFAULT, (GSourceFunc) webKitWebSrcNeedDataMainCb, gst_object_ref(src), (GDestroyNotify) gst_object_unref);
}
static gboolean webKitWebSrcEnoughDataMainCb(WebKitWebSrc* src)
{
WebKitWebSrcPrivate* priv = src->priv;
- priv->resourceHandle->setDefersLoading(true);
+ ASSERT(isMainThread());
+
+ GMutexLocker locker(GST_OBJECT_GET_LOCK(src));
+ // already stopped
+ if (!priv->enoughDataID)
+ return FALSE;
- GST_OBJECT_LOCK(src);
priv->paused = TRUE;
priv->enoughDataID = 0;
- GST_OBJECT_UNLOCK(src);
+ locker.unlock();
+ if (priv->client)
+ priv->client->setDefersLoading(true);
return FALSE;
}
@@ -692,19 +815,27 @@ static void webKitWebSrcEnoughDataCb(GstAppSrc*, gpointer userData)
GST_DEBUG_OBJECT(src, "Have enough data");
- GST_OBJECT_LOCK(src);
+ GMutexLocker locker(GST_OBJECT_GET_LOCK(src));
if (priv->enoughDataID || priv->paused) {
- GST_OBJECT_UNLOCK(src);
return;
}
- priv->enoughDataID = g_timeout_add_full(G_PRIORITY_DEFAULT, 0, (GSourceFunc) webKitWebSrcEnoughDataMainCb, gst_object_ref(src), (GDestroyNotify) gst_object_unref);
- GST_OBJECT_UNLOCK(src);
+ priv->enoughDataID = g_idle_add_full(G_PRIORITY_DEFAULT, (GSourceFunc) webKitWebSrcEnoughDataMainCb, gst_object_ref(src), (GDestroyNotify) gst_object_unref);
}
static gboolean webKitWebSrcSeekMainCb(WebKitWebSrc* src)
{
- webKitWebSrcStop(src, true);
+ WebKitWebSrcPrivate* priv = src->priv;
+
+ ASSERT(isMainThread());
+
+ GMutexLocker locker(GST_OBJECT_GET_LOCK(src));
+ // already stopped
+ if (!priv->seekID)
+ return FALSE;
+ locker.unlock();
+
+ webKitWebSrcStop(src);
webKitWebSrcStart(src);
return FALSE;
@@ -716,7 +847,8 @@ static gboolean webKitWebSrcSeekDataCb(GstAppSrc*, guint64 offset, gpointer user
WebKitWebSrcPrivate* priv = src->priv;
GST_DEBUG_OBJECT(src, "Seeking to offset: %" G_GUINT64_FORMAT, offset);
- if (offset == priv->offset)
+ GMutexLocker locker(GST_OBJECT_GET_LOCK(src));
+ if (offset == priv->offset && priv->requestedOffset == priv->offset)
return TRUE;
if (!priv->seekable)
@@ -727,121 +859,140 @@ static gboolean webKitWebSrcSeekDataCb(GstAppSrc*, guint64 offset, gpointer user
GST_DEBUG_OBJECT(src, "Doing range-request seek");
priv->requestedOffset = offset;
- GST_OBJECT_LOCK(src);
if (priv->seekID)
g_source_remove(priv->seekID);
- priv->seekID = g_timeout_add_full(G_PRIORITY_DEFAULT, 0, (GSourceFunc) webKitWebSrcSeekMainCb, gst_object_ref(src), (GDestroyNotify) gst_object_unref);
- GST_OBJECT_UNLOCK(src);
-
+ priv->seekID = g_idle_add_full(G_PRIORITY_DEFAULT, (GSourceFunc) webKitWebSrcSeekMainCb, gst_object_ref(src), (GDestroyNotify) gst_object_unref);
return TRUE;
}
void webKitWebSrcSetMediaPlayer(WebKitWebSrc* src, WebCore::MediaPlayer* player)
{
- WebKitWebSrcPrivate* priv = src->priv;
- WebCore::Frame* frame = 0;
-
- WebCore::Document* document = player->mediaPlayerClient()->mediaPlayerOwningDocument();
- if (document)
- frame = document->frame();
-
- priv->frame = frame;
- priv->player = player;
+ ASSERT(player);
+ GMutexLocker locker(GST_OBJECT_GET_LOCK(src));
+ src->priv->player = player;
}
-StreamingClient::StreamingClient(WebKitWebSrc* src) : m_src(src)
+StreamingClient::StreamingClient(WebKitWebSrc* src)
+ : m_src(adoptGRef(static_cast<GstElement*>(gst_object_ref(src))))
{
-
}
StreamingClient::~StreamingClient()
{
-
}
-void StreamingClient::willSendRequest(ResourceHandle*, ResourceRequest&, const ResourceResponse&)
+char* StreamingClient::createReadBuffer(size_t requestedSize, size_t& actualSize)
{
+ WebKitWebSrc* src = WEBKIT_WEB_SRC(m_src.get());
+ WebKitWebSrcPrivate* priv = src->priv;
+
+ ASSERT(!priv->buffer);
+
+ GstBuffer* buffer = gst_buffer_new_and_alloc(requestedSize);
+
+#ifdef GST_API_VERSION_1
+ mapGstBuffer(buffer);
+#endif
+
+ GMutexLocker locker(GST_OBJECT_GET_LOCK(src));
+ priv->buffer = adoptGRef(buffer);
+ locker.unlock();
+
+ actualSize = getGstBufferSize(buffer);
+ return getGstBufferDataPointer(buffer);
}
-void StreamingClient::didReceiveResponse(ResourceHandle*, const ResourceResponse& response)
+void StreamingClient::handleResponseReceived(const ResourceResponse& response)
{
- WebKitWebSrcPrivate* priv = m_src->priv;
+ WebKitWebSrc* src = WEBKIT_WEB_SRC(m_src.get());
+ WebKitWebSrcPrivate* priv = src->priv;
- GST_DEBUG_OBJECT(m_src, "Received response: %d", response.httpStatusCode());
+ GST_DEBUG_OBJECT(src, "Received response: %d", response.httpStatusCode());
+
+ GMutexLocker locker(GST_OBJECT_GET_LOCK(src));
// If we seeked we need 206 == PARTIAL_CONTENT
if (priv->requestedOffset && response.httpStatusCode() != 206) {
- GST_ELEMENT_ERROR(m_src, RESOURCE, READ, (0), (0));
+ locker.unlock();
+ GST_ELEMENT_ERROR(src, RESOURCE, READ, (0), (0));
gst_app_src_end_of_stream(priv->appsrc);
- webKitWebSrcStop(m_src, false);
+ webKitWebSrcStop(src);
return;
}
long long length = response.expectedContentLength();
- if (length > 0) {
+ if (length > 0)
length += priv->requestedOffset;
- gst_app_src_set_size(priv->appsrc, length);
-
-#ifndef GST_API_VERSION_1
- if (!priv->haveAppSrc27) {
- gst_segment_set_duration(&GST_BASE_SRC(priv->appsrc)->segment, GST_FORMAT_BYTES, length);
- gst_element_post_message(GST_ELEMENT(priv->appsrc),
- gst_message_new_duration(GST_OBJECT(priv->appsrc),
- GST_FORMAT_BYTES, length));
- }
-#endif
- }
priv->size = length >= 0 ? length : 0;
priv->seekable = length > 0 && g_ascii_strcasecmp("none", response.httpHeaderField("Accept-Ranges").utf8().data());
- // icecast stuff
- String value = response.httpHeaderField("icy-metaint");
- if (!value.isEmpty()) {
- gchar* endptr = 0;
- gint64 icyMetaInt = g_ascii_strtoll(value.utf8().data(), &endptr, 10);
-
- if (endptr && *endptr == '\0' && icyMetaInt > 0) {
- GRefPtr<GstCaps> caps = adoptGRef(gst_caps_new_simple("application/x-icy", "metadata-interval", G_TYPE_INT, (gint) icyMetaInt, NULL));
-
- gst_app_src_set_caps(priv->appsrc, caps.get());
- }
- }
-
#ifdef GST_API_VERSION_1
GstTagList* tags = gst_tag_list_new_empty();
#else
GstTagList* tags = gst_tag_list_new();
#endif
- value = response.httpHeaderField("icy-name");
+ String value = response.httpHeaderField("icy-name");
if (!value.isEmpty()) {
g_free(priv->iradioName);
priv->iradioName = g_strdup(value.utf8().data());
- g_object_notify(G_OBJECT(m_src), "iradio-name");
+ g_object_notify(G_OBJECT(src), "iradio-name");
gst_tag_list_add(tags, GST_TAG_MERGE_REPLACE, GST_TAG_ORGANIZATION, priv->iradioName, NULL);
}
value = response.httpHeaderField("icy-genre");
if (!value.isEmpty()) {
g_free(priv->iradioGenre);
priv->iradioGenre = g_strdup(value.utf8().data());
- g_object_notify(G_OBJECT(m_src), "iradio-genre");
+ g_object_notify(G_OBJECT(src), "iradio-genre");
gst_tag_list_add(tags, GST_TAG_MERGE_REPLACE, GST_TAG_GENRE, priv->iradioGenre, NULL);
}
value = response.httpHeaderField("icy-url");
if (!value.isEmpty()) {
g_free(priv->iradioUrl);
priv->iradioUrl = g_strdup(value.utf8().data());
- g_object_notify(G_OBJECT(m_src), "iradio-url");
+ g_object_notify(G_OBJECT(src), "iradio-url");
gst_tag_list_add(tags, GST_TAG_MERGE_REPLACE, GST_TAG_LOCATION, priv->iradioUrl, NULL);
}
value = response.httpHeaderField("icy-title");
if (!value.isEmpty()) {
g_free(priv->iradioTitle);
priv->iradioTitle = g_strdup(value.utf8().data());
- g_object_notify(G_OBJECT(m_src), "iradio-title");
+ g_object_notify(G_OBJECT(src), "iradio-title");
gst_tag_list_add(tags, GST_TAG_MERGE_REPLACE, GST_TAG_TITLE, priv->iradioTitle, NULL);
}
+ locker.unlock();
+
+ // notify size/duration
+ if (length > 0) {
+ gst_app_src_set_size(priv->appsrc, length);
+
+#ifndef GST_API_VERSION_1
+ if (!priv->haveAppSrc27) {
+ gst_segment_set_duration(&GST_BASE_SRC(priv->appsrc)->segment, GST_FORMAT_BYTES, length);
+ gst_element_post_message(GST_ELEMENT(priv->appsrc),
+ gst_message_new_duration(GST_OBJECT(priv->appsrc),
+ GST_FORMAT_BYTES, length));
+ }
+#endif
+ } else
+ gst_app_src_set_size(priv->appsrc, -1);
+
+ // icecast stuff
+ value = response.httpHeaderField("icy-metaint");
+ if (!value.isEmpty()) {
+ gchar* endptr = 0;
+ gint64 icyMetaInt = g_ascii_strtoll(value.utf8().data(), &endptr, 10);
+
+ if (endptr && *endptr == '\0' && icyMetaInt > 0) {
+ GRefPtr<GstCaps> caps = adoptGRef(gst_caps_new_simple("application/x-icy", "metadata-interval", G_TYPE_INT, (gint) icyMetaInt, NULL));
+
+ gst_app_src_set_caps(priv->appsrc, caps.get());
+ }
+ } else
+ gst_app_src_set_caps(priv->appsrc, 0);
+
+ // notify tags
if (gst_tag_list_is_empty(tags))
#ifdef GST_API_VERSION_1
gst_tag_list_unref(tags);
@@ -849,67 +1000,220 @@ void StreamingClient::didReceiveResponse(ResourceHandle*, const ResourceResponse
gst_tag_list_free(tags);
#endif
else
- notifyGstTagsOnPad(GST_ELEMENT(m_src), m_src->priv->srcpad, tags);
+ notifyGstTagsOnPad(GST_ELEMENT(src), priv->srcpad, tags);
}
-void StreamingClient::didReceiveData(ResourceHandle* handle, const char* data, int length, int)
+void StreamingClient::handleDataReceived(const char* data, int length)
{
- WebKitWebSrcPrivate* priv = m_src->priv;
+ WebKitWebSrc* src = WEBKIT_WEB_SRC(m_src.get());
+ WebKitWebSrcPrivate* priv = src->priv;
- GST_LOG_OBJECT(m_src, "Have %d bytes of data", length);
+ GMutexLocker locker(GST_OBJECT_GET_LOCK(src));
- if (priv->seekID || handle != priv->resourceHandle) {
- GST_DEBUG_OBJECT(m_src, "Seek in progress, ignoring data");
- return;
- }
+ GST_LOG_OBJECT(src, "Have %d bytes of data", priv->buffer ? getGstBufferSize(priv->buffer.get()) : length);
- GstBuffer* buffer = gst_buffer_new_and_alloc(length);
+ ASSERT(!priv->buffer || data == getGstBufferDataPointer(priv->buffer.get()));
#ifdef GST_API_VERSION_1
- gst_buffer_fill(buffer, 0, data, length);
-#else
- memcpy(GST_BUFFER_DATA(buffer), data, length);
+ if (priv->buffer)
+ unmapGstBuffer(priv->buffer.get());
#endif
- GST_BUFFER_OFFSET(buffer) = priv->offset;
+
+ if (priv->seekID) {
+ GST_DEBUG_OBJECT(src, "Seek in progress, ignoring data");
+ priv->buffer.clear();
+ return;
+ }
+
+ // Ports using the GStreamer backend but not the soup implementation of ResourceHandle
+ // won't be using buffers provided by this client, the buffer is created here in that case.
+ if (!priv->buffer)
+ priv->buffer = adoptGRef(createGstBufferForData(data, length));
+ else
+ setGstBufferSize(priv->buffer.get(), length);
+
+ GST_BUFFER_OFFSET(priv->buffer.get()) = priv->offset;
+ if (priv->requestedOffset == priv->offset)
+ priv->requestedOffset += length;
priv->offset += length;
- GST_BUFFER_OFFSET_END(buffer) = priv->offset;
+ // priv->size == 0 if received length on didReceiveResponse < 0.
+ if (priv->size > 0 && priv->offset > priv->size) {
+ GST_DEBUG_OBJECT(src, "Updating internal size from %" G_GUINT64_FORMAT " to %" G_GUINT64_FORMAT, priv->size, priv->offset);
+ gst_app_src_set_size(priv->appsrc, priv->offset);
+ priv->size = priv->offset;
+ }
+ GST_BUFFER_OFFSET_END(priv->buffer.get()) = priv->offset;
- GstFlowReturn ret = gst_app_src_push_buffer(priv->appsrc, buffer);
+ locker.unlock();
+
+ GstFlowReturn ret = gst_app_src_push_buffer(priv->appsrc, priv->buffer.leakRef());
#ifdef GST_API_VERSION_1
if (ret != GST_FLOW_OK && ret != GST_FLOW_EOS)
#else
if (ret != GST_FLOW_OK && ret != GST_FLOW_UNEXPECTED)
#endif
- GST_ELEMENT_ERROR(m_src, CORE, FAILED, (0), (0));
+ GST_ELEMENT_ERROR(src, CORE, FAILED, (0), (0));
}
-void StreamingClient::didFinishLoading(ResourceHandle*, double)
+void StreamingClient::handleNotifyFinished()
{
- WebKitWebSrcPrivate* priv = m_src->priv;
+ WebKitWebSrc* src = WEBKIT_WEB_SRC(m_src.get());
+ WebKitWebSrcPrivate* priv = src->priv;
- GST_DEBUG_OBJECT(m_src, "Have EOS");
+ GST_DEBUG_OBJECT(src, "Have EOS");
- if (!priv->seekID)
- gst_app_src_end_of_stream(m_src->priv->appsrc);
+ GMutexLocker locker(GST_OBJECT_GET_LOCK(src));
+ if (!priv->seekID) {
+ locker.unlock();
+ gst_app_src_end_of_stream(priv->appsrc);
+ }
}
-void StreamingClient::didFail(ResourceHandle*, const ResourceError& error)
+CachedResourceStreamingClient::CachedResourceStreamingClient(WebKitWebSrc* src, CachedResourceLoader* resourceLoader, const ResourceRequest& request)
+ : StreamingClient(src)
{
- GST_ERROR_OBJECT(m_src, "Have failure: %s", error.localizedDescription().utf8().data());
- GST_ELEMENT_ERROR(m_src, RESOURCE, FAILED, ("%s", error.localizedDescription().utf8().data()), (0));
- gst_app_src_end_of_stream(m_src->priv->appsrc);
+ CachedResourceRequest cacheRequest(request, ResourceLoaderOptions(SendCallbacks, DoNotSniffContent, DoNotBufferData, DoNotAllowStoredCredentials, DoNotAskClientForCrossOriginCredentials, DoSecurityCheck, UseDefaultOriginRestrictionsForType));
+ m_resource = resourceLoader->requestRawResource(cacheRequest);
+ if (m_resource)
+ m_resource->addClient(this);
}
-void StreamingClient::wasBlocked(ResourceHandle*)
+CachedResourceStreamingClient::~CachedResourceStreamingClient()
{
- GST_ERROR_OBJECT(m_src, "Request was blocked");
- GST_ELEMENT_ERROR(m_src, RESOURCE, OPEN_READ, ("Access to \"%s\" was blocked", m_src->priv->uri), (0));
+ if (m_resource) {
+ m_resource->removeClient(this);
+ m_resource = 0;
+ }
}
-void StreamingClient::cannotShowURL(ResourceHandle*)
+bool CachedResourceStreamingClient::loadFailed() const
{
- GST_ERROR_OBJECT(m_src, "Cannot show URL");
- GST_ELEMENT_ERROR(m_src, RESOURCE, OPEN_READ, ("Can't show \"%s\"", m_src->priv->uri), (0));
+ return !m_resource;
+}
+
+void CachedResourceStreamingClient::setDefersLoading(bool defers)
+{
+ if (m_resource)
+ m_resource->setDefersLoading(defers);
+}
+
+char* CachedResourceStreamingClient::getOrCreateReadBuffer(CachedResource*, size_t requestedSize, size_t& actualSize)
+{
+ return createReadBuffer(requestedSize, actualSize);
+}
+
+void CachedResourceStreamingClient::responseReceived(CachedResource*, const ResourceResponse& response)
+{
+ handleResponseReceived(response);
+}
+
+void CachedResourceStreamingClient::dataReceived(CachedResource*, const char* data, int length)
+{
+ handleDataReceived(data, length);
+}
+
+void CachedResourceStreamingClient::notifyFinished(CachedResource* resource)
+{
+ if (resource->loadFailedOrCanceled()) {
+ WebKitWebSrc* src = WEBKIT_WEB_SRC(m_src.get());
+
+ if (!resource->wasCanceled()) {
+ const ResourceError& error = resource->resourceError();
+ GST_ERROR_OBJECT(src, "Have failure: %s", error.localizedDescription().utf8().data());
+ GST_ELEMENT_ERROR(src, RESOURCE, FAILED, ("%s", error.localizedDescription().utf8().data()), (0));
+ }
+ gst_app_src_end_of_stream(src->priv->appsrc);
+ return;
+ }
+
+ handleNotifyFinished();
+}
+
+ResourceHandleStreamingClient::ResourceHandleStreamingClient(WebKitWebSrc* src, const ResourceRequest& request)
+ : StreamingClient(src)
+{
+ m_resource = ResourceHandle::create(0 /*context*/, request, this, false, false);
+}
+
+ResourceHandleStreamingClient::~ResourceHandleStreamingClient()
+{
+ if (m_resource) {
+ m_resource->cancel();
+ m_resource.release();
+ m_resource = 0;
+ }
+}
+
+bool ResourceHandleStreamingClient::loadFailed() const
+{
+ return !m_resource;
+}
+
+void ResourceHandleStreamingClient::setDefersLoading(bool defers)
+{
+ if (m_resource)
+ m_resource->setDefersLoading(defers);
+}
+
+char* ResourceHandleStreamingClient::getOrCreateReadBuffer(size_t requestedSize, size_t& actualSize)
+{
+ return createReadBuffer(requestedSize, actualSize);
+}
+
+void ResourceHandleStreamingClient::willSendRequest(ResourceHandle*, ResourceRequest&, const ResourceResponse&)
+{
+}
+
+void ResourceHandleStreamingClient::didReceiveResponse(ResourceHandle*, const ResourceResponse& response)
+{
+ handleResponseReceived(response);
+}
+
+void ResourceHandleStreamingClient::didReceiveData(ResourceHandle*, const char* data, int length, int)
+{
+ handleDataReceived(data, length);
+}
+
+void ResourceHandleStreamingClient::didFinishLoading(ResourceHandle*, double)
+{
+ handleNotifyFinished();
+}
+
+void ResourceHandleStreamingClient::didFail(ResourceHandle*, const ResourceError& error)
+{
+ WebKitWebSrc* src = WEBKIT_WEB_SRC(m_src.get());
+
+ GST_ERROR_OBJECT(src, "Have failure: %s", error.localizedDescription().utf8().data());
+ GST_ELEMENT_ERROR(src, RESOURCE, FAILED, ("%s", error.localizedDescription().utf8().data()), (0));
+ gst_app_src_end_of_stream(src->priv->appsrc);
+}
+
+void ResourceHandleStreamingClient::wasBlocked(ResourceHandle*)
+{
+ WebKitWebSrc* src = WEBKIT_WEB_SRC(m_src.get());
+ GOwnPtr<gchar> uri;
+
+ GST_ERROR_OBJECT(src, "Request was blocked");
+
+ GMutexLocker locker(GST_OBJECT_GET_LOCK(src));
+ uri.set(g_strdup(src->priv->uri));
+ locker.unlock();
+
+ GST_ELEMENT_ERROR(src, RESOURCE, OPEN_READ, ("Access to \"%s\" was blocked", uri.get()), (0));
+}
+
+void ResourceHandleStreamingClient::cannotShowURL(ResourceHandle*)
+{
+ WebKitWebSrc* src = WEBKIT_WEB_SRC(m_src.get());
+ GOwnPtr<gchar> uri;
+
+ GST_ERROR_OBJECT(src, "Cannot show URL");
+
+ GMutexLocker locker(GST_OBJECT_GET_LOCK(src));
+ uri.set(g_strdup(src->priv->uri));
+ locker.unlock();
+
+ GST_ELEMENT_ERROR(src, RESOURCE, OPEN_READ, ("Can't show \"%s\"", uri.get()), (0));
}
#endif // USE(GSTREAMER)
diff --git a/Source/WebCore/platform/graphics/gtk/FullscreenVideoControllerGtk.cpp b/Source/WebCore/platform/graphics/gtk/FullscreenVideoControllerGtk.cpp
new file mode 100644
index 000000000..a2f08b655
--- /dev/null
+++ b/Source/WebCore/platform/graphics/gtk/FullscreenVideoControllerGtk.cpp
@@ -0,0 +1,454 @@
+/*
+ * Copyright (C) 2013 Igalia S.L
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#if ENABLE(VIDEO) && USE(GSTREAMER) && USE(NATIVE_FULLSCREEN_VIDEO)
+
+#include "FullscreenVideoControllerGtk.h"
+
+#include "FullscreenVideoControllerGStreamer.h"
+#include "GRefPtrGtk.h"
+#include "GStreamerGWorld.h"
+#include "GtkVersioning.h"
+#include "MediaPlayer.h"
+#include "MediaPlayerPrivateGStreamerBase.h"
+
+#include <gdk/gdk.h>
+#include <gdk/gdkkeysyms.h>
+#include <glib/gi18n-lib.h>
+#include <gtk/gtk.h>
+#include <wtf/text/CString.h>
+
+#define HUD_AUTO_HIDE_INTERVAL 3000 // 3 seconds
+#define PROGRESS_BAR_UPDATE_INTERVAL 150 // 150ms
+
+// Use symbolic icons only if we build with GTK+-3 support. They could
+// be enabled for the GTK+2 build but we'd need to bump the required
+// version to at least 2.22.
+#if GTK_MAJOR_VERSION > 2
+#define ICON_NAME_SUFFIX "-symbolic"
+#else
+#define ICON_NAME_SUFFIX
+#endif
+
+#define PLAY_ICON_NAME "media-playback-start" ICON_NAME_SUFFIX
+#define PAUSE_ICON_NAME "media-playback-pause" ICON_NAME_SUFFIX
+#define EXIT_FULLSCREEN_ICON_NAME "view-restore" ICON_NAME_SUFFIX
+
+namespace WebCore {
+
+static gboolean hideHudCallback(FullscreenVideoControllerGtk* controller)
+{
+ controller->hideHud();
+ return FALSE;
+}
+
+static gboolean onFullscreenGtkMotionNotifyEvent(GtkWidget* widget, GdkEventMotion* event, FullscreenVideoControllerGtk* controller)
+{
+ controller->showHud(true);
+ return TRUE;
+}
+
+static void onFullscreenGtkActiveNotification(GtkWidget* widget, GParamSpec* property, FullscreenVideoControllerGtk* controller)
+{
+ if (!gtk_window_is_active(GTK_WINDOW(widget)))
+ controller->hideHud();
+}
+
+static gboolean onFullscreenGtkConfigureEvent(GtkWidget* widget, GdkEventConfigure* event, FullscreenVideoControllerGtk* controller)
+{
+ controller->gtkConfigure(event);
+ return TRUE;
+}
+
+static void onFullscreenGtkDestroy(GtkWidget* widget, FullscreenVideoControllerGtk* controller)
+{
+ controller->exitFullscreen();
+}
+
+static void togglePlayPauseActivated(GtkAction* action, FullscreenVideoControllerGtk* controller)
+{
+ controller->togglePlay();
+}
+
+static void exitFullscreenActivated(GtkAction* action, FullscreenVideoControllerGtk* controller)
+{
+ controller->exitOnUserRequest();
+}
+
+static gboolean progressBarUpdateCallback(FullscreenVideoControllerGtk* controller)
+{
+ return controller->updateHudProgressBar();
+}
+
+static gboolean timeScaleButtonPressed(GtkWidget* widget, GdkEventButton* event, FullscreenVideoControllerGtk* controller)
+{
+ if (event->type != GDK_BUTTON_PRESS)
+ return FALSE;
+
+ controller->beginSeek();
+ return FALSE;
+}
+
+static gboolean timeScaleButtonReleased(GtkWidget* widget, GdkEventButton* event, FullscreenVideoControllerGtk* controller)
+{
+ controller->endSeek();
+ return FALSE;
+}
+
+static void timeScaleValueChanged(GtkWidget* widget, FullscreenVideoControllerGtk* controller)
+{
+ controller->doSeek();
+}
+
+static void volumeValueChanged(GtkScaleButton *button, gdouble value, FullscreenVideoControllerGtk* controller)
+{
+ controller->setVolume(static_cast<float>(value));
+}
+
+
+FullscreenVideoControllerGtk::FullscreenVideoControllerGtk(MediaPlayerPrivateGStreamerBase* player)
+ : FullscreenVideoControllerGStreamer(player)
+ , m_hudTimeoutId(0)
+ , m_progressBarUpdateId(0)
+ , m_seekLock(false)
+ , m_window(0)
+ , m_hudWindow(0)
+ , m_volumeButton(0)
+ , m_keyPressSignalId(0)
+ , m_destroySignalId(0)
+ , m_isActiveSignalId(0)
+ , m_motionNotifySignalId(0)
+ , m_configureEventSignalId(0)
+ , m_hudMotionNotifySignalId(0)
+ , m_timeScaleButtonPressedSignalId(0)
+ , m_timeScaleButtonReleasedSignalId(0)
+ , m_playActionActivateSignalId(0)
+ , m_exitFullcreenActionActivateSignalId(0)
+{
+}
+
+void FullscreenVideoControllerGtk::gtkConfigure(GdkEventConfigure* event)
+{
+ updateHudPosition();
+}
+
+void FullscreenVideoControllerGtk::showHud(bool autoHide)
+{
+ if (!m_hudWindow)
+ return;
+
+ if (m_hudTimeoutId) {
+ g_source_remove(m_hudTimeoutId);
+ m_hudTimeoutId = 0;
+ }
+
+ // Show the cursor.
+ GdkWindow* window = gtk_widget_get_window(m_window);
+ gdk_window_set_cursor(window, 0);
+
+ // Update the progress bar immediately before showing the window.
+ updateHudProgressBar();
+ gtk_widget_show_all(m_hudWindow);
+ updateHudPosition();
+
+ // Start periodic updates of the progress bar.
+ if (!m_progressBarUpdateId)
+ m_progressBarUpdateId = g_timeout_add(PROGRESS_BAR_UPDATE_INTERVAL, reinterpret_cast<GSourceFunc>(progressBarUpdateCallback), this);
+
+ // Hide the hud in few seconds, if requested.
+ if (autoHide)
+ m_hudTimeoutId = g_timeout_add(HUD_AUTO_HIDE_INTERVAL, reinterpret_cast<GSourceFunc>(hideHudCallback), this);
+}
+
+void FullscreenVideoControllerGtk::hideHud()
+{
+ if (m_hudTimeoutId) {
+ g_source_remove(m_hudTimeoutId);
+ m_hudTimeoutId = 0;
+ }
+
+ if (!m_hudWindow)
+ return;
+
+ // Keep the hud visible if a seek is in progress or if the volume
+ // popup is visible.
+ GtkWidget* volumePopup = gtk_scale_button_get_popup(GTK_SCALE_BUTTON(m_volumeButton));
+ if (m_seekLock || gtk_widget_get_visible(volumePopup)) {
+ showHud(true);
+ return;
+ }
+
+ GdkWindow* window = gtk_widget_get_window(m_window);
+ GRefPtr<GdkCursor> cursor = adoptGRef(gdk_cursor_new(GDK_BLANK_CURSOR));
+ gdk_window_set_cursor(window, cursor.get());
+
+ gtk_widget_hide(m_hudWindow);
+
+ if (m_progressBarUpdateId) {
+ g_source_remove(m_progressBarUpdateId);
+ m_progressBarUpdateId = 0;
+ }
+}
+
+static gboolean onFullscreenGtkKeyPressEvent(GtkWidget* widget, GdkEventKey* event, FullscreenVideoControllerGtk* controller)
+{
+ switch (event->keyval) {
+ case GDK_Escape:
+ controller->exitOnUserRequest();
+ break;
+ case GDK_space:
+ case GDK_Return:
+ controller->togglePlay();
+ break;
+ case GDK_Up:
+ controller->increaseVolume();
+ break;
+ case GDK_Down:
+ controller->decreaseVolume();
+ break;
+ default:
+ break;
+ }
+
+ return TRUE;
+}
+
+void FullscreenVideoControllerGtk::initializeWindow()
+{
+ m_window = reinterpret_cast<GtkWidget*>(m_gstreamerGWorld->platformVideoWindow()->window());
+
+ if (!m_hudWindow)
+ createHud();
+
+ // Ensure black background.
+#ifdef GTK_API_VERSION_2
+ GdkColor color = { 1, 0, 0, 0 };
+ gtk_widget_modify_bg(m_window, GTK_STATE_NORMAL, &color);
+#else
+ GdkRGBA color = { 0, 0, 0, 1};
+ gtk_widget_override_background_color(m_window, GTK_STATE_FLAG_NORMAL, &color);
+#endif
+ gtk_widget_set_double_buffered(m_window, FALSE);
+
+ m_keyPressSignalId = g_signal_connect(m_window, "key-press-event", G_CALLBACK(onFullscreenGtkKeyPressEvent), this);
+ m_destroySignalId = g_signal_connect(m_window, "destroy", G_CALLBACK(onFullscreenGtkDestroy), this);
+ m_isActiveSignalId = g_signal_connect(m_window, "notify::is-active", G_CALLBACK(onFullscreenGtkActiveNotification), this);
+
+ gtk_widget_show_all(m_window);
+
+ GdkWindow* window = gtk_widget_get_window(m_window);
+ GRefPtr<GdkCursor> cursor = adoptGRef(gdk_cursor_new(GDK_BLANK_CURSOR));
+ gdk_window_set_cursor(window, cursor.get());
+
+ m_motionNotifySignalId = g_signal_connect(m_window, "motion-notify-event", G_CALLBACK(onFullscreenGtkMotionNotifyEvent), this);
+ m_configureEventSignalId = g_signal_connect(m_window, "configure-event", G_CALLBACK(onFullscreenGtkConfigureEvent), this);
+
+ gtk_window_fullscreen(GTK_WINDOW(m_window));
+ showHud(true);
+}
+
+void FullscreenVideoControllerGtk::updateHudPosition()
+{
+ if (!m_hudWindow)
+ return;
+
+ // Get the screen rectangle.
+ GdkScreen* screen = gtk_window_get_screen(GTK_WINDOW(m_window));
+ GdkWindow* window = gtk_widget_get_window(m_window);
+ GdkRectangle fullscreenRectangle;
+ gdk_screen_get_monitor_geometry(screen, gdk_screen_get_monitor_at_window(screen, window), &fullscreenRectangle);
+
+ // Get the popup window size.
+ int hudWidth, hudHeight;
+ gtk_window_get_size(GTK_WINDOW(m_hudWindow), &hudWidth, &hudHeight);
+
+ // Resize the hud to the full width of the screen.
+ gtk_window_resize(GTK_WINDOW(m_hudWindow), fullscreenRectangle.width, hudHeight);
+
+ // Move the hud to the bottom of the screen.
+ gtk_window_move(GTK_WINDOW(m_hudWindow), fullscreenRectangle.x, fullscreenRectangle.height + fullscreenRectangle.y - hudHeight);
+}
+
+void FullscreenVideoControllerGtk::destroyWindow()
+{
+ if (!m_hudWindow)
+ return;
+
+ g_signal_handler_disconnect(m_window, m_keyPressSignalId);
+ g_signal_handler_disconnect(m_window, m_destroySignalId);
+ g_signal_handler_disconnect(m_window, m_isActiveSignalId);
+ g_signal_handler_disconnect(m_window, m_motionNotifySignalId);
+ g_signal_handler_disconnect(m_window, m_configureEventSignalId);
+ g_signal_handler_disconnect(m_hudWindow, m_hudMotionNotifySignalId);
+ g_signal_handler_disconnect(m_timeHScale, m_timeScaleButtonPressedSignalId);
+ g_signal_handler_disconnect(m_timeHScale, m_timeScaleButtonReleasedSignalId);
+ g_signal_handler_disconnect(m_timeHScale, m_hscaleUpdateId);
+ g_signal_handler_disconnect(m_volumeButton, m_volumeUpdateId);
+ g_signal_handler_disconnect(m_playPauseAction, m_playActionActivateSignalId);
+ g_signal_handler_disconnect(m_exitFullscreenAction, m_exitFullcreenActionActivateSignalId);
+
+ if (m_hudTimeoutId) {
+ g_source_remove(m_hudTimeoutId);
+ m_hudTimeoutId = 0;
+ }
+
+ if (m_progressBarUpdateId) {
+ g_source_remove(m_progressBarUpdateId);
+ m_progressBarUpdateId = 0;
+ }
+
+ gtk_widget_hide(m_window);
+
+ if (m_hudWindow)
+ gtk_widget_destroy(m_hudWindow);
+ m_hudWindow = 0;
+}
+
+void FullscreenVideoControllerGtk::playStateChanged()
+{
+ if (m_client->mediaPlayerIsPaused())
+ g_object_set(m_playPauseAction, "tooltip", _("Play"), "icon-name", PLAY_ICON_NAME, NULL);
+ else
+ g_object_set(m_playPauseAction, "tooltip", _("Pause"), "icon-name", PAUSE_ICON_NAME, NULL);
+ showHud(!m_client->mediaPlayerIsPaused());
+}
+
+void FullscreenVideoControllerGtk::volumeChanged()
+{
+ if (!m_volumeButton)
+ return;
+
+ g_signal_handler_block(m_volumeButton, m_volumeUpdateId);
+ gtk_scale_button_set_value(GTK_SCALE_BUTTON(m_volumeButton), m_player->volume());
+ g_signal_handler_unblock(m_volumeButton, m_volumeUpdateId);
+}
+
+void FullscreenVideoControllerGtk::muteChanged()
+{
+ if (!m_volumeButton)
+ return;
+
+ g_signal_handler_block(m_volumeButton, m_volumeUpdateId);
+ gtk_scale_button_set_value(GTK_SCALE_BUTTON(m_volumeButton), m_player->muted() ? 0 : m_player->volume());
+ g_signal_handler_unblock(m_volumeButton, m_volumeUpdateId);
+}
+
+void FullscreenVideoControllerGtk::beginSeek()
+{
+ m_seekLock = true;
+}
+
+void FullscreenVideoControllerGtk::doSeek()
+{
+ if (!m_seekLock)
+ return;
+
+ m_player->seek(gtk_range_get_value(GTK_RANGE(m_timeHScale))*m_player->duration() / 100);
+}
+
+void FullscreenVideoControllerGtk::endSeek()
+{
+ m_seekLock = false;
+}
+
+gboolean FullscreenVideoControllerGtk::updateHudProgressBar()
+{
+ float mediaDuration(m_player->duration());
+ float mediaPosition(m_player->currentTime());
+
+ if (!m_seekLock) {
+ gdouble value = 0.0;
+
+ if (mediaPosition && mediaDuration)
+ value = (mediaPosition * 100.0) / mediaDuration;
+
+ GtkAdjustment* adjustment = gtk_range_get_adjustment(GTK_RANGE(m_timeHScale));
+ gtk_adjustment_set_value(adjustment, value);
+ }
+
+ gtk_range_set_fill_level(GTK_RANGE(m_timeHScale), (m_player->maxTimeLoaded() / mediaDuration)* 100);
+
+ gchar* label = g_strdup_printf("%s / %s", timeToString(mediaPosition).utf8().data(), timeToString(mediaDuration).utf8().data());
+ gtk_label_set_text(GTK_LABEL(m_timeLabel), label);
+ g_free(label);
+ return TRUE;
+}
+
+void FullscreenVideoControllerGtk::createHud()
+{
+ m_hudWindow = gtk_window_new(GTK_WINDOW_POPUP);
+ gtk_window_set_gravity(GTK_WINDOW(m_hudWindow), GDK_GRAVITY_SOUTH_WEST);
+ gtk_window_set_type_hint(GTK_WINDOW(m_hudWindow), GDK_WINDOW_TYPE_HINT_NORMAL);
+
+ m_hudMotionNotifySignalId = g_signal_connect(m_hudWindow, "motion-notify-event", G_CALLBACK(onFullscreenGtkMotionNotifyEvent), this);
+
+#ifdef GTK_API_VERSION_2
+ GtkWidget* hbox = gtk_hbox_new(FALSE, 4);
+#else
+ GtkWidget* hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
+#endif
+ gtk_container_add(GTK_CONTAINER(m_hudWindow), hbox);
+
+ m_playPauseAction = gtk_action_new("play", _("Play / Pause"), _("Play or pause the media"), PAUSE_ICON_NAME);
+ m_playActionActivateSignalId = g_signal_connect(m_playPauseAction, "activate", G_CALLBACK(togglePlayPauseActivated), this);
+
+ GtkWidget* item = gtk_action_create_tool_item(m_playPauseAction);
+ gtk_box_pack_start(GTK_BOX(hbox), item, FALSE, TRUE, 0);
+
+ GtkWidget* label = gtk_label_new(_("Time:"));
+ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, TRUE, 0);
+
+ GtkAdjustment* adjustment = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 100.0, 0.1, 1.0, 1.0));
+#ifdef GTK_API_VERSION_2
+ m_timeHScale = gtk_hscale_new(adjustment);
+#else
+ m_timeHScale = gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, adjustment);
+#endif
+ gtk_scale_set_draw_value(GTK_SCALE(m_timeHScale), FALSE);
+ gtk_range_set_show_fill_level(GTK_RANGE(m_timeHScale), TRUE);
+ m_timeScaleButtonPressedSignalId = g_signal_connect(m_timeHScale, "button-press-event", G_CALLBACK(timeScaleButtonPressed), this);
+ m_timeScaleButtonReleasedSignalId = g_signal_connect(m_timeHScale, "button-release-event", G_CALLBACK(timeScaleButtonReleased), this);
+ m_hscaleUpdateId = g_signal_connect(m_timeHScale, "value-changed", G_CALLBACK(timeScaleValueChanged), this);
+
+ gtk_box_pack_start(GTK_BOX(hbox), m_timeHScale, TRUE, TRUE, 0);
+
+ m_timeLabel = gtk_label_new("");
+ gtk_box_pack_start(GTK_BOX(hbox), m_timeLabel, FALSE, TRUE, 0);
+
+ // Volume button.
+ m_volumeButton = gtk_volume_button_new();
+ gtk_box_pack_start(GTK_BOX(hbox), m_volumeButton, FALSE, TRUE, 0);
+ gtk_scale_button_set_value(GTK_SCALE_BUTTON(m_volumeButton), m_player->volume());
+ m_volumeUpdateId = g_signal_connect(m_volumeButton, "value-changed", G_CALLBACK(volumeValueChanged), this);
+
+ m_exitFullscreenAction = gtk_action_new("exit", _("Exit Fullscreen"), _("Exit from fullscreen mode"), EXIT_FULLSCREEN_ICON_NAME);
+ m_exitFullcreenActionActivateSignalId = g_signal_connect(m_exitFullscreenAction, "activate", G_CALLBACK(exitFullscreenActivated), this);
+ g_object_set(m_exitFullscreenAction, "icon-name", EXIT_FULLSCREEN_ICON_NAME, NULL);
+ item = gtk_action_create_tool_item(m_exitFullscreenAction);
+ gtk_box_pack_start(GTK_BOX(hbox), item, FALSE, TRUE, 0);
+
+ m_progressBarUpdateId = g_timeout_add(PROGRESS_BAR_UPDATE_INTERVAL, reinterpret_cast<GSourceFunc>(progressBarUpdateCallback), this);
+
+ playStateChanged();
+}
+
+} // namespace WebCore
+#endif
diff --git a/Source/WebCore/platform/graphics/gtk/FullscreenVideoControllerGtk.h b/Source/WebCore/platform/graphics/gtk/FullscreenVideoControllerGtk.h
new file mode 100644
index 000000000..d5770c598
--- /dev/null
+++ b/Source/WebCore/platform/graphics/gtk/FullscreenVideoControllerGtk.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2013 Igalia S.L
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef FullscreenVideoControllerGtk_h
+#define FullscreenVideoControllerGtk_h
+
+#if ENABLE(VIDEO) && USE(GSTREAMER) && USE(NATIVE_FULLSCREEN_VIDEO)
+
+#include "FullscreenVideoControllerGStreamer.h"
+
+namespace WebCore {
+
+class FullscreenVideoControllerGtk : public FullscreenVideoControllerGStreamer {
+public:
+ FullscreenVideoControllerGtk(MediaPlayerPrivateGStreamerBase*);
+
+ void gtkConfigure(GdkEventConfigure*);
+
+ void playStateChanged();
+
+ void beginSeek();
+ void doSeek();
+ void endSeek();
+
+ void hideHud();
+ void showHud(bool);
+ gboolean updateHudProgressBar();
+
+ void volumeChanged();
+ void muteChanged();
+
+private:
+ void initializeWindow();
+ void destroyWindow();
+
+ void createHud();
+ void updateHudPosition();
+
+ guint m_hudTimeoutId;
+ guint m_progressBarUpdateId;
+ guint m_progressBarFillUpdateId;
+ guint m_hscaleUpdateId;
+ guint m_volumeUpdateId;
+ bool m_seekLock;
+ GtkWidget* m_window;
+ GtkWidget* m_hudWindow;
+ GtkAction* m_playPauseAction;
+ GtkAction* m_exitFullscreenAction;
+ GtkWidget* m_timeHScale;
+ GtkWidget* m_timeLabel;
+ GtkWidget* m_volumeButton;
+
+ unsigned long m_keyPressSignalId;
+ unsigned long m_destroySignalId;
+ unsigned long m_isActiveSignalId;
+ unsigned long m_motionNotifySignalId;
+ unsigned long m_configureEventSignalId;
+ unsigned long m_hudMotionNotifySignalId;
+ unsigned long m_timeScaleButtonPressedSignalId;
+ unsigned long m_timeScaleButtonReleasedSignalId;
+ unsigned long m_playActionActivateSignalId;
+ unsigned long m_exitFullcreenActionActivateSignalId;
+};
+
+}
+#endif
+
+#endif // FullscreenVideoControllerGtk_h
diff --git a/Source/WebCore/platform/graphics/gtk/ImageBufferGtk.cpp b/Source/WebCore/platform/graphics/gtk/ImageBufferGtk.cpp
index 46ff53b4f..dac5ee348 100644
--- a/Source/WebCore/platform/graphics/gtk/ImageBufferGtk.cpp
+++ b/Source/WebCore/platform/graphics/gtk/ImageBufferGtk.cpp
@@ -71,7 +71,7 @@ String ImageBuffer::toDataURL(const String& mimeType, const double* quality, Coo
GOwnPtr<gchar> buffer(0);
gsize bufferSize;
- if (!encodeImage(m_data.m_surface, mimeType, quality, buffer, bufferSize))
+ if (!encodeImage(m_data.m_surface.get(), mimeType, quality, buffer, bufferSize))
return "data:,";
Vector<char> base64Data;
diff --git a/Source/WebCore/platform/graphics/gtk/ImageGtk.cpp b/Source/WebCore/platform/graphics/gtk/ImageGtk.cpp
index 9d9fbeff0..19e91cda8 100644
--- a/Source/WebCore/platform/graphics/gtk/ImageGtk.cpp
+++ b/Source/WebCore/platform/graphics/gtk/ImageGtk.cpp
@@ -108,8 +108,8 @@ PassRefPtr<Image> Image::loadPlatformThemeIcon(const char* name, int size)
GdkPixbuf* BitmapImage::getGdkPixbuf()
{
- NativeImageCairo* image = nativeImageForCurrentFrame();
- return image ? cairoImageSurfaceToGdkPixbuf(image->surface()) : 0;
+ RefPtr<cairo_surface_t> surface = nativeImageForCurrentFrame();
+ return surface ? cairoImageSurfaceToGdkPixbuf(surface.get()) : 0;
}
}
diff --git a/Source/WebCore/platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp b/Source/WebCore/platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp
deleted file mode 100644
index 8a4d8720c..000000000
--- a/Source/WebCore/platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp
+++ /dev/null
@@ -1,510 +0,0 @@
-/*
- * Copyright (c) 2010 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ComplexTextControllerHarfBuzz.h"
-
-#include "FloatRect.h"
-#include "Font.h"
-#include "SurrogatePairAwareTextIterator.h"
-#include "TextRun.h"
-
-#if OS(ANDROID)
-#include "FontCache.h"
-#include "SkTypeface_android.h"
-#endif
-
-extern "C" {
-#include "harfbuzz-unicode.h"
-}
-
-#include <unicode/normlzr.h>
-
-namespace WebCore {
-
-// Harfbuzz uses 26.6 fixed point values for pixel offsets. However, we don't
-// handle subpixel positioning so this function is used to truncate Harfbuzz
-// values to a number of pixels.
-static int truncateFixedPointToInteger(HB_Fixed value)
-{
- return value >> 6;
-}
-
-ComplexTextController::ComplexTextController(const Font* font, const TextRun& run, int startingX, int startingY)
- : HarfBuzzShaperBase(font, run)
-{
- NormalizeMode mode = m_run.rtl() ? NormalizeMirrorChars : DoNotNormalizeMirrorChars;
- setNormalizedBuffer(mode);
-
- memset(&m_item, 0, sizeof(m_item));
- // We cannot know, ahead of time, how many glyphs a given script run
- // will produce. We take a guess that script runs will not produce more
- // than twice as many glyphs as there are code points plus a bit of
- // padding and fallback if we find that we are wrong.
- createGlyphArrays((m_normalizedBufferLength + 2) * 2);
-
- m_item.face = 0;
- m_item.font = allocHarfbuzzFont();
-
- m_item.item.bidiLevel = m_run.rtl();
-
- m_item.string = m_normalizedBuffer.get();
- m_item.stringLength = m_normalizedBufferLength;
-
- reset(startingX);
- m_startingY = startingY;
-
- setPadding(m_run.expansion());
-}
-
-ComplexTextController::~ComplexTextController()
-{
- fastFree(m_item.font);
- deleteGlyphArrays();
-}
-
-void ComplexTextController::reset(int offset)
-{
- m_indexOfNextScriptRun = 0;
- m_offsetX = offset;
-}
-
-void ComplexTextController::setupForRTL()
-{
- int padding = m_padding;
- // FIXME: this causes us to shape the text twice -- once to compute the width and then again
- // below when actually rendering. Change ComplexTextController to match platform/mac and
- // platform/chromium/win by having it store the shaped runs, so we can reuse the results.
- reset(m_offsetX + widthOfFullRun());
- // We need to set the padding again because ComplexTextController layout consumed the value.
- // Fixing the above problem would help here too.
- setPadding(padding);
-}
-
-// Advance to the next script run, returning false when the end of the
-// TextRun has been reached.
-bool ComplexTextController::nextScriptRun()
-{
- // Ensure we're not pointing at the small caps buffer.
- m_item.string = m_normalizedBuffer.get();
-
- if (!hb_utf16_script_run_next(0, &m_item.item, m_normalizedBuffer.get(), m_normalizedBufferLength, &m_indexOfNextScriptRun))
- return false;
-
- // It is actually wrong to consider script runs at all in this code.
- // Other WebKit code (e.g. Mac) segments complex text just by finding
- // the longest span of text covered by a single font.
- // But we currently need to call hb_utf16_script_run_next anyway to fill
- // in the harfbuzz data structures to e.g. pick the correct script's shaper.
- // So we allow that to run first, then do a second pass over the range it
- // found and take the largest subregion that stays within a single font.
- SurrogatePairAwareTextIterator iterator(static_cast<const UChar*>(&m_item.string[m_item.item.pos]), 0, static_cast<int>(m_item.item.length), static_cast<int>(m_item.item.length));
- UChar32 character;
- unsigned clusterLength = 0;
- if (!iterator.consume(character, clusterLength))
- return false;
- m_currentFontData = m_font->glyphDataForCharacter(character, false).fontData;
- iterator.advance(clusterLength);
- while (iterator.consume(character, clusterLength)) {
- const SimpleFontData* nextFontData = m_font->glyphDataForCharacter(character, false).fontData;
- if (nextFontData != m_currentFontData)
- break;
- iterator.advance(clusterLength);
- }
- m_item.item.length = iterator.currentCharacter();
- m_indexOfNextScriptRun = m_item.item.pos + iterator.currentCharacter();
-
- setupFontForScriptRun();
- shapeGlyphs();
- setGlyphPositions(rtl());
-
- return true;
-}
-
-float ComplexTextController::widthOfFullRun()
-{
- float widthSum = 0;
- while (nextScriptRun())
- widthSum += width();
-
- return widthSum;
-}
-
-static void setupFontFeatures(const FontFeatureSettings* settings, HB_FaceRec_* hbFace)
-{
- if (!settings)
- return;
-
- if (hbFace->gsub)
- HB_GSUB_Clear_Features(hbFace->gsub);
- if (hbFace->gpos)
- HB_GPOS_Clear_Features(hbFace->gpos);
-
- HB_UShort scriptIndex = 0;
- HB_GSUB_Select_Script(hbFace->gsub, HB_MAKE_TAG('D', 'F', 'L', 'T'), &scriptIndex);
- size_t numFeatures = settings->size();
- for (size_t i = 0; i < numFeatures; ++i) {
- if (!settings->at(i).value())
- continue;
- HB_UShort featureIndex = 0;
- const UChar* tag = settings->at(i).tag().characters();
- HB_UInt feature = HB_MAKE_TAG(tag[0], tag[1], tag[2], tag[3]);
- if (hbFace->gsub && HB_GSUB_Select_Feature(hbFace->gsub, feature, scriptIndex, 0xffff, &featureIndex) == HB_Err_Ok)
- HB_GSUB_Add_Feature(hbFace->gsub, featureIndex, settings->at(i).value());
- else if (hbFace->gpos && HB_GPOS_Select_Feature(hbFace->gpos, feature, scriptIndex, 0xffff, &featureIndex) == HB_Err_Ok)
- HB_GPOS_Add_Feature(hbFace->gpos, featureIndex, settings->at(i).value());
- }
-}
-
-static UChar32 surrogatePairAwareFirstCharacter(const UChar* characters, unsigned length)
-{
- if (U16_IS_SURROGATE(characters[0])) {
- if (!U16_IS_SURROGATE_LEAD(characters[0]) || length < 2 || !U16_IS_TRAIL(characters[1]))
- return ' ';
- return U16_GET_SUPPLEMENTARY(characters[0], characters[1]);
- }
- return characters[0];
-}
-
-const FontPlatformData* ComplexTextController::getComplexFontPlatformData()
-{
-#if OS(ANDROID)
- // There are 2 kinds of font on Android: system fonts and fallback fonts.
- // System fonts have a name, and are accessible in FontPlatformData.
- // Fallback fonts do not have specific names, so they are not accessible
- // from WebKit directly. To feed Harfbuzz, use a trick to get correct
- // SkTypeface based on script.
- FallbackScripts fallbackScript = kFallbackScriptNumber; // invalid script value.
- switch (m_item.item.script) {
- case HB_Script_Arabic:
- fallbackScript = kArabic_FallbackScript;
- break;
- case HB_Script_Armenian:
- fallbackScript = kArmenian_FallbackScript;
- break;
- case HB_Script_Bengali:
- fallbackScript = kBengali_FallbackScript;
- break;
- case HB_Script_Devanagari:
- fallbackScript = kDevanagari_FallbackScript;
- break;
- case HB_Script_Georgian:
- fallbackScript = kGeorgian_FallbackScript;
- break;
- case HB_Script_Hebrew:
- if (m_font->fontDescription().weight() >= FontWeightBold)
- fallbackScript = kHebrewBold_FallbackScript;
- else
- fallbackScript = kHebrewRegular_FallbackScript;
- break;
- case HB_Script_Kannada:
- fallbackScript = kKannada_FallbackScript;
- break;
- case HB_Script_Malayalam:
- fallbackScript = kMalayalam_FallbackScript;
- break;
- case HB_Script_Tamil:
- if (m_font->fontDescription().weight() >= FontWeightBold)
- fallbackScript = kTamilBold_FallbackScript;
- else
- fallbackScript = kTamilRegular_FallbackScript;
- break;
- case HB_Script_Telugu:
- fallbackScript = kTelugu_FallbackScript;
- break;
- case HB_Script_Thai:
- fallbackScript = kThai_FallbackScript;
- break;
- default:
- return 0;
- }
- return fontCache()->getCachedFontPlatformData(m_font->fontDescription(), SkGetFallbackScriptID(fallbackScript), true);
-#else
- // Only Android needs the extra logic.
- return 0;
-#endif
-}
-
-void ComplexTextController::setupFontForScriptRun()
-{
- FontDataVariant fontDataVariant = AutoVariant;
- // Determine if this script run needs to be converted to small caps.
- // nextScriptRun() will always send us a run of the same case, because a
- // case change while in small-caps mode always results in different
- // FontData, so we only need to check the first character's case.
- if (m_font->isSmallCaps() && u_islower(m_item.string[m_item.item.pos])) {
- m_smallCapsString = String(m_normalizedBuffer.get() + m_item.item.pos, m_item.item.length);
- m_smallCapsString.makeUpper();
- m_item.string = m_smallCapsString.characters();
- m_item.item.pos = 0;
- fontDataVariant = SmallCapsVariant;
- }
- const FontPlatformData* platformData = getComplexFontPlatformData();
- if (!platformData) {
- UChar32 current = surrogatePairAwareFirstCharacter(static_cast<const UChar*>(&m_item.string[m_item.item.pos]), m_item.item.length - m_item.item.pos);
- const FontData* fontData = m_font->glyphDataForCharacter(current, false, fontDataVariant).fontData;
- platformData = &fontData->fontDataForCharacter(' ')->platformData();
- }
- m_item.face = platformData->harfbuzzFace()->face();
- // We only need to setup font features at the beginning of the run.
- if (!m_item.item.pos)
- setupFontFeatures(m_font->fontDescription().featureSettings(), m_item.face);
- void* opaquePlatformData = const_cast<FontPlatformData*>(platformData);
- m_item.font->userData = opaquePlatformData;
-
- int size = platformData->size();
- m_item.font->x_ppem = size;
- m_item.font->y_ppem = size;
- // x_ and y_scale are the conversion factors from font design space (fEmSize) to 1/64th of device pixels in 16.16 format.
- const int devicePixelFraction = 64;
- const int multiplyFor16Dot16 = 1 << 16;
- int scale = devicePixelFraction * size * multiplyFor16Dot16 / platformData->emSizeInFontUnits();
- m_item.font->x_scale = scale;
- m_item.font->y_scale = scale;
-}
-
-void ComplexTextController::deleteGlyphArrays()
-{
- delete[] m_item.glyphs;
- delete[] m_item.attributes;
- delete[] m_item.advances;
- delete[] m_item.offsets;
- delete[] m_item.log_clusters;
- delete[] m_glyphs16;
- delete[] m_positions;
-}
-
-void ComplexTextController::createGlyphArrays(int size)
-{
- m_item.glyphs = new HB_Glyph[size];
- m_item.attributes = new HB_GlyphAttributes[size];
- m_item.advances = new HB_Fixed[size];
- m_item.offsets = new HB_FixedPoint[size];
- m_item.log_clusters = new unsigned short[size];
-
- m_glyphs16 = new uint16_t[size];
- m_positions = new SkPoint[size];
-
- m_item.num_glyphs = size;
- m_glyphsArrayCapacity = size; // Save the GlyphArrays size.
- resetGlyphArrays();
-}
-
-void ComplexTextController::resetGlyphArrays()
-{
- int size = m_item.num_glyphs;
- // All the types here don't have pointers. It is safe to reset to
- // zero unless Harfbuzz breaks the compatibility in the future.
- memset(m_item.glyphs, 0, size * sizeof(HB_Glyph));
- memset(m_item.attributes, 0, size * sizeof(HB_GlyphAttributes));
- memset(m_item.advances, 0, size * sizeof(HB_Fixed));
- memset(m_item.offsets, 0, size * sizeof(HB_FixedPoint));
- memset(m_glyphs16, 0, size * sizeof(uint16_t));
- memset(m_positions, 0, size * sizeof(SkPoint));
-}
-
-void ComplexTextController::shapeGlyphs()
-{
- // HB_ShapeItem() resets m_item.num_glyphs. If the previous call to
- // HB_ShapeItem() used less space than was available, the capacity of
- // the array may be larger than the current value of m_item.num_glyphs.
- // So, we need to reset the num_glyphs to the capacity of the array.
- m_item.num_glyphs = m_glyphsArrayCapacity;
- resetGlyphArrays();
- while (!HB_ShapeItem(&m_item)) {
- // We overflowed our arrays. Resize and retry.
- // HB_ShapeItem fills in m_item.num_glyphs with the needed size.
- deleteGlyphArrays();
- // The |+ 1| here is a workaround for a bug in Harfbuzz: the Khmer
- // shaper (at least) can fail because of insufficient glyph buffers
- // and request 0 additional glyphs: throwing us into an infinite
- // loop.
- createGlyphArrays(m_item.num_glyphs + 1);
- }
-}
-
-void ComplexTextController::setGlyphPositions(bool isRTL)
-{
- const double rtlFlip = isRTL ? -1 : 1;
- double position = 0;
-
- // logClustersIndex indexes logClusters for the first codepoint of the current glyph.
- // Each time we advance a glyph, we skip over all the codepoints that contributed to the current glyph.
- size_t logClustersIndex = 0;
-
- // Iterate through the glyphs in logical order, flipping for RTL where necessary.
- // Glyphs are positioned starting from m_offsetX; in RTL mode they go leftwards from there.
- for (size_t i = 0; i < m_item.num_glyphs; ++i) {
- while (logClustersIndex < m_item.item.length && m_item.log_clusters[logClustersIndex] < i)
- logClustersIndex++;
-
- // If the current glyph is just after a space, add in the word spacing.
- if (logClustersIndex < m_item.item.length && isWordEnd(m_item.item.pos + logClustersIndex))
- position += determineWordBreakSpacing();
-
- m_glyphs16[i] = m_item.glyphs[i];
- double offsetX = truncateFixedPointToInteger(m_item.offsets[i].x);
- double offsetY = truncateFixedPointToInteger(m_item.offsets[i].y);
- double advance = truncateFixedPointToInteger(m_item.advances[i]);
- if (isRTL)
- offsetX -= advance;
-
- m_positions[i].set(m_offsetX + (position * rtlFlip) + offsetX,
- m_startingY + offsetY);
-
- if (m_currentFontData->isZeroWidthSpaceGlyph(m_glyphs16[i]))
- continue;
-
- // At the end of each cluster, add in the letter spacing.
- if (i + 1 == m_item.num_glyphs || m_item.attributes[i + 1].clusterStart)
- position += m_letterSpacing;
-
- position += advance;
- }
- m_pixelWidth = std::max(position, 0.0);
- m_offsetX += m_pixelWidth * rtlFlip;
-}
-
-int ComplexTextController::glyphIndexForXPositionInScriptRun(int targetX) const
-{
- // Iterate through the glyphs in logical order, seeing whether targetX falls between the previous
- // position and halfway through the current glyph.
- // FIXME: this code probably belongs in ComplexTextController.
- int lastX = offsetX() - (rtl() ? -m_pixelWidth : m_pixelWidth);
- for (int glyphIndex = 0; static_cast<unsigned>(glyphIndex) < length(); ++glyphIndex) {
- int advance = truncateFixedPointToInteger(m_item.advances[glyphIndex]);
- int nextX = static_cast<int>(positions()[glyphIndex].x()) + advance / 2;
- if (std::min(nextX, lastX) <= targetX && targetX <= std::max(nextX, lastX))
- return glyphIndex;
- lastX = nextX;
- }
-
- return length() - 1;
-}
-
-int ComplexTextController::offsetForPosition(int targetX)
-{
- unsigned basePosition = 0;
-
- int x = offsetX();
- while (nextScriptRun()) {
- int nextX = offsetX();
-
- if (std::min(x, nextX) <= targetX && targetX <= std::max(x, nextX)) {
- // The x value in question is within this script run.
- const int glyphIndex = glyphIndexForXPositionInScriptRun(targetX);
-
- // Now that we have a glyph index, we have to turn that into a
- // code-point index. Because of ligatures, several code-points may
- // have gone into a single glyph. We iterate over the clusters log
- // and find the first code-point which contributed to the glyph.
-
- // Some shapers (i.e. Khmer) will produce cluster logs which report
- // that /no/ code points contributed to certain glyphs. Because of
- // this, we take any code point which contributed to the glyph in
- // question, or any subsequent glyph. If we run off the end, then
- // we take the last code point.
- for (unsigned j = 0; j < numCodePoints(); ++j) {
- if (m_item.log_clusters[j] >= glyphIndex)
- return basePosition + j;
- }
-
- return basePosition + numCodePoints() - 1;
- }
-
- basePosition += numCodePoints();
- }
-
- return basePosition;
-}
-
-FloatRect ComplexTextController::selectionRect(const FloatPoint& point, int height, int from, int to)
-{
- int fromX = -1, toX = -1;
- // Iterate through the script runs in logical order, searching for the run covering the positions of interest.
- while (nextScriptRun() && (fromX == -1 || toX == -1)) {
- if (fromX == -1 && from >= 0 && static_cast<unsigned>(from) < numCodePoints()) {
- // |from| is within this script run. So we index the clusters log to
- // find which glyph this code-point contributed to and find its x
- // position.
- int glyph = m_item.log_clusters[from];
- fromX = positions()[glyph].x();
- if (rtl())
- fromX += truncateFixedPointToInteger(m_item.advances[glyph]);
- } else
- from -= numCodePoints();
-
- if (toX == -1 && to >= 0 && static_cast<unsigned>(to) < numCodePoints()) {
- int glyph = m_item.log_clusters[to];
- toX = positions()[glyph].x();
- if (rtl())
- toX += truncateFixedPointToInteger(m_item.advances[glyph]);
- } else
- to -= numCodePoints();
- }
-
- // The position in question might be just after the text.
- if (fromX == -1)
- fromX = offsetX();
- if (toX == -1)
- toX = offsetX();
-
- ASSERT(fromX != -1 && toX != -1);
-
- if (fromX < toX)
- return FloatRect(point.x() + fromX, point.y(), toX - fromX, height);
-
- return FloatRect(point.x() + toX, point.y(), fromX - toX, height);
-}
-
-void ComplexTextController::glyphsForRange(int from, int to, int& fromGlyph, int& glyphLength)
-{
- // Character offsets within the current run. THESE MAY NOT BE IN RANGE and may
- // be negative, etc. The code below handles this.
- int fromChar = from - m_item.item.pos;
- int toChar = to - m_item.item.pos;
-
- // See if there are any characters in the current run.
- if (!numCodePoints() || fromChar >= static_cast<int>(numCodePoints()) || toChar <= 0) {
- fromGlyph = -1;
- glyphLength = 0;
- return;
- }
-
- // Compute the starting glyph within this span. |from| and |to| are
- // global offsets that may intersect arbitrarily with our local run.
- fromGlyph = m_item.log_clusters[fromChar < 0 ? 0 : fromChar];
- if (toChar >= static_cast<int>(numCodePoints()))
- glyphLength = length() - fromGlyph;
- else
- glyphLength = m_item.log_clusters[toChar] - fromGlyph;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.h b/Source/WebCore/platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.h
deleted file mode 100644
index 1758a3cab..000000000
--- a/Source/WebCore/platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (c) 2010 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ComplexTextControllerHarfBuzz_h
-#define ComplexTextControllerHarfBuzz_h
-
-#include "HarfBuzzShaperBase.h"
-#include "HarfBuzzSkia.h"
-#include "SkPoint.h"
-#include "SkScalar.h"
-#include "TextRun.h"
-
-extern "C" {
-#include "harfbuzz-shaper.h"
-}
-
-#include <unicode/uchar.h>
-#include <wtf/OwnArrayPtr.h>
-#include <wtf/OwnPtr.h>
-
-namespace WebCore {
-
-class Font;
-class FontPlatformData;
-class SimpleFontData;
-
-// ComplexTextController walks a TextRun and presents each script run in sequence. A
-// TextRun is a sequence of code-points with the same embedding level (i.e. they
-// are all left-to-right or right-to-left). A script run is a subsequence where
-// all the characters have the same script (e.g. Arabic, Thai etc). Shaping is
-// only ever done with script runs since the shapers only know how to deal with
-// a single script.
-//
-// Iteration is always in logical (aka reading) order. For RTL text that means
-// the rightmost part of the text will be first.
-//
-// Once you have setup the object, call |nextScriptRun| to get the first script
-// run. This will return false when the iteration is complete. At any time you
-// can call |reset| to start over again.
-class ComplexTextController : public HarfBuzzShaperBase {
-public:
- ComplexTextController(const Font*, const TextRun&, int startingX, int startingY);
- virtual ~ComplexTextController();
-
- void reset(int offset);
- // Advance to the next script run, returning false when the end of the
- // TextRun has been reached.
- bool nextScriptRun();
- float widthOfFullRun();
-
- void setupForRTL();
- bool rtl() const { return m_run.rtl(); }
- const uint16_t* glyphs() const { return m_glyphs16; }
-
- // Return the start index and length of glyphs for the range [from, to) in the current script run.
- void glyphsForRange(int from, int to, int& fromGlyph, int& glyphLength);
-
- // Return the length of the array returned by |glyphs|
- unsigned length() const { return m_item.num_glyphs; }
-
- // Return the offset for each of the glyphs. Note that this is translated
- // by the current x offset and that the x offset is updated for each script
- // run.
- const SkPoint* positions() const { return m_positions; }
-
- // return the number of code points in the current script run
- unsigned numCodePoints() const { return m_item.item.length; }
-
- // Return the current pixel position of the controller.
- unsigned offsetX() const { return m_offsetX; }
-
- const FontPlatformData* fontPlatformDataForScriptRun() { return reinterpret_cast<FontPlatformData*>(m_item.font->userData); }
-
- int offsetForPosition(int);
- FloatRect selectionRect(const FloatPoint&, int height, int from , int to);
-
-private:
- // Return the width (in px) of the current script run.
- unsigned width() const { return m_pixelWidth; }
-
- const FontPlatformData* getComplexFontPlatformData();
- void setupFontForScriptRun();
- void deleteGlyphArrays();
- void createGlyphArrays(int);
- void resetGlyphArrays();
- void shapeGlyphs();
- void setGlyphPositions(bool);
-
- int glyphIndexForXPositionInScriptRun(int targetX) const;
-
- const SimpleFontData* m_currentFontData;
- HB_ShaperItem m_item;
- uint16_t* m_glyphs16; // A vector of 16-bit glyph ids.
- SkPoint* m_positions; // A vector of positions for each glyph.
- ssize_t m_indexOfNextScriptRun; // Indexes the script run in |m_run|.
- int m_offsetX; // Offset in pixels to the start of the next script run.
- int m_startingY; // The Y starting point of the script run.
- unsigned m_pixelWidth; // Width (in px) of the current script run.
- unsigned m_glyphsArrayCapacity; // Current size of all the Harfbuzz arrays.
-
- String m_smallCapsString; // substring of m_run converted to small caps.
-};
-
-} // namespace WebCore
-
-#endif // ComplexTextControllerHarfBuzz_h
diff --git a/Source/WebCore/platform/graphics/harfbuzz/FontHarfBuzz.cpp b/Source/WebCore/platform/graphics/harfbuzz/FontHarfBuzz.cpp
deleted file mode 100644
index 5c7900488..000000000
--- a/Source/WebCore/platform/graphics/harfbuzz/FontHarfBuzz.cpp
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Font.h"
-
-#if USE(HARFBUZZ_NG)
-#include "HarfBuzzShaper.h"
-#else
-#include "ComplexTextControllerHarfBuzz.h"
-#include "HarfBuzzSkia.h"
-#endif
-
-#include "FloatRect.h"
-#include "GlyphBuffer.h"
-#include "GraphicsContext.h"
-#include "NotImplemented.h"
-#include "PlatformContextSkia.h"
-#include "SimpleFontData.h"
-
-#include "SkCanvas.h"
-#include "SkPaint.h"
-#include "SkTemplates.h"
-#include "SkTypeface.h"
-#include "SkUtils.h"
-
-#include <wtf/unicode/Unicode.h>
-
-namespace WebCore {
-
-bool Font::canReturnFallbackFontsForComplexText()
-{
- return false;
-}
-
-bool Font::canExpandAroundIdeographsInComplexText()
-{
- return false;
-}
-
-void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
- const GlyphBuffer& glyphBuffer, int from, int numGlyphs,
- const FloatPoint& point) const {
- SkASSERT(sizeof(GlyphBufferGlyph) == sizeof(uint16_t)); // compile-time assert
-
- const GlyphBufferGlyph* glyphs = glyphBuffer.glyphs(from);
- SkScalar x = SkFloatToScalar(point.x());
- SkScalar y = SkFloatToScalar(point.y());
-
- // FIXME: text rendering speed:
- // Android has code in their WebCore fork to special case when the
- // GlyphBuffer has no advances other than the defaults. In that case the
- // text drawing can proceed faster. However, it's unclear when those
- // patches may be upstreamed to WebKit so we always use the slower path
- // here.
- const GlyphBufferAdvance* adv = glyphBuffer.advances(from);
- SkAutoSTMalloc<32, SkPoint> storage(numGlyphs), storage2(numGlyphs), storage3(numGlyphs);
- SkPoint* pos = storage.get();
- SkPoint* vPosBegin = storage2.get();
- SkPoint* vPosEnd = storage3.get();
-
- bool isVertical = font->platformData().orientation() == Vertical;
- for (int i = 0; i < numGlyphs; i++) {
- SkScalar myWidth = SkFloatToScalar(adv[i].width());
- pos[i].set(x, y);
- if (isVertical) {
- vPosBegin[i].set(x + myWidth, y);
- vPosEnd[i].set(x + myWidth, y - myWidth);
- }
- x += myWidth;
- y += SkFloatToScalar(adv[i].height());
- }
-
- PlatformContextSkia* platformContext = gc->platformContext();
- TextDrawingModeFlags textMode = gc->platformContext()->getTextDrawingMode();
-
- // We draw text up to two times (once for fill, once for stroke).
- if (textMode & TextModeFill) {
- SkPaint paint;
- gc->platformContext()->setupPaintForFilling(&paint);
- font->platformData().setupPaint(&paint);
- gc->platformContext()->adjustTextRenderMode(&paint);
- paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
-
- if (isVertical) {
- SkPath path;
- for (int i = 0; i < numGlyphs; ++i) {
- path.reset();
- path.moveTo(vPosBegin[i]);
- path.lineTo(vPosEnd[i]);
- platformContext->drawTextOnPath(glyphs + i, 2, path, 0, paint);
- }
- } else
- platformContext->drawPosText(glyphs, numGlyphs << 1, pos, paint);
- }
-
- if ((textMode & TextModeStroke)
- && gc->platformContext()->getStrokeStyle() != NoStroke
- && gc->platformContext()->getStrokeThickness() > 0) {
-
- SkPaint paint;
- gc->platformContext()->setupPaintForStroking(&paint, 0, 0);
- font->platformData().setupPaint(&paint);
- gc->platformContext()->adjustTextRenderMode(&paint);
- paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
-
- if (textMode & TextModeFill) {
- // If we also filled, we don't want to draw shadows twice.
- // See comment in FontChromiumWin.cpp::paintSkiaText() for more details.
- // Since we use the looper for shadows, we remove it (if any) now.
- paint.setLooper(0);
- }
-
- if (isVertical) {
- SkPath path;
- for (int i = 0; i < numGlyphs; ++i) {
- path.reset();
- path.moveTo(vPosBegin[i]);
- path.lineTo(vPosEnd[i]);
- platformContext->drawTextOnPath(glyphs + i, 2, path, 0, paint);
- }
- } else
- platformContext->drawPosText(glyphs, numGlyphs << 1, pos, paint);
- }
-}
-
-static void setupForTextPainting(SkPaint* paint, SkColor color)
-{
- paint->setTextEncoding(SkPaint::kGlyphID_TextEncoding);
- paint->setColor(color);
-}
-
-void Font::drawComplexText(GraphicsContext* gc, const TextRun& run,
- const FloatPoint& point, int from, int to) const
-{
- if (!run.length())
- return;
-
- TextDrawingModeFlags textMode = gc->platformContext()->getTextDrawingMode();
- bool fill = textMode & TextModeFill;
- bool stroke = (textMode & TextModeStroke)
- && gc->platformContext()->getStrokeStyle() != NoStroke
- && gc->platformContext()->getStrokeThickness() > 0;
-
- if (!fill && !stroke)
- return;
-
- SkPaint strokePaint, fillPaint;
- if (fill) {
- gc->platformContext()->setupPaintForFilling(&fillPaint);
- setupForTextPainting(&fillPaint, gc->fillColor().rgb());
- }
- if (stroke) {
- gc->platformContext()->setupPaintForStroking(&strokePaint, 0, 0);
- setupForTextPainting(&strokePaint, gc->strokeColor().rgb());
- }
-
-#if USE(HARFBUZZ_NG)
- GlyphBuffer glyphBuffer;
- HarfBuzzShaper shaper(this, run);
- shaper.setDrawRange(from, to);
- if (!shaper.shape(&glyphBuffer))
- return;
- FloatPoint adjustedPoint = shaper.adjustStartPoint(point);
- drawGlyphBuffer(gc, run, glyphBuffer, adjustedPoint);
-#else
- PlatformContextSkia* platformContext = gc->platformContext();
- ComplexTextController controller(this, run, point.x(), point.y());
- if (run.rtl())
- controller.setupForRTL();
-
- while (controller.nextScriptRun()) {
- // Check if there is any glyph found in the current script run.
- int fromGlyph, glyphLength;
- controller.glyphsForRange(from, to, fromGlyph, glyphLength);
- if (fromGlyph < 0 || glyphLength <= 0)
- continue;
-
- if (fill) {
- controller.fontPlatformDataForScriptRun()->setupPaint(&fillPaint);
- gc->platformContext()->adjustTextRenderMode(&fillPaint);
- platformContext->drawPosText(controller.glyphs() + fromGlyph, glyphLength << 1, controller.positions() + fromGlyph, fillPaint);
- }
-
- if (stroke) {
- controller.fontPlatformDataForScriptRun()->setupPaint(&strokePaint);
- gc->platformContext()->adjustTextRenderMode(&strokePaint);
- platformContext->drawPosText(controller.glyphs() + fromGlyph, glyphLength << 1, controller.positions() + fromGlyph, strokePaint);
- }
- }
-#endif
-}
-
-void Font::drawEmphasisMarksForComplexText(GraphicsContext* /* context */, const TextRun& /* run */, const AtomicString& /* mark */, const FloatPoint& /* point */, int /* from */, int /* to */) const
-{
- notImplemented();
-}
-
-float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>* /* fallbackFonts */, GlyphOverflow* /* glyphOverflow */) const
-{
-#if USE(HARFBUZZ_NG)
- HarfBuzzShaper shaper(this, run);
- if (!shaper.shape())
- return 0;
- return shaper.totalWidth();
-#else
- ComplexTextController controller(this, run, 0, 0);
- return controller.widthOfFullRun();
-#endif
-}
-
-// Return the code point index for the given |x| offset into the text run.
-int Font::offsetForPositionForComplexText(const TextRun& run, float xFloat,
- bool includePartialGlyphs) const
-{
- // FIXME: This truncation is not a problem for HTML, but only affects SVG, which passes floating-point numbers
- // to Font::offsetForPosition(). Bug http://webkit.org/b/40673 tracks fixing this problem.
- int targetX = static_cast<int>(xFloat);
-
-#if USE(HARFBUZZ_NG)
- HarfBuzzShaper shaper(this, run);
- if (!shaper.shape())
- return 0;
- return shaper.offsetForPosition(targetX);
-#else
- // (Mac code ignores includePartialGlyphs, and they don't know what it's
- // supposed to do, so we just ignore it as well.)
- ComplexTextController controller(this, run, 0, 0);
- if (run.rtl())
- controller.setupForRTL();
- return controller.offsetForPosition(targetX);
-#endif
-}
-
-// Return the rectangle for selecting the given range of code-points in the TextRun.
-FloatRect Font::selectionRectForComplexText(const TextRun& run,
- const FloatPoint& point, int height,
- int from, int to) const
-{
-#if USE(HARFBUZZ_NG)
- HarfBuzzShaper shaper(this, run);
- if (!shaper.shape())
- return FloatRect();
- return shaper.selectionRect(point, height, from, to);
-#else
- ComplexTextController controller(this, run, 0, 0);
- if (run.rtl())
- controller.setupForRTL();
- return controller.selectionRect(point, height, from, to);
-#endif
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.cpp b/Source/WebCore/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.cpp
deleted file mode 100644
index 7532d733d..000000000
--- a/Source/WebCore/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.cpp
+++ /dev/null
@@ -1,371 +0,0 @@
-/*
- * Copyright (c) 2006, 2007, 2008, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FontPlatformDataHarfBuzz.h"
-
-#include "FontCache.h"
-#include "NotImplemented.h"
-#include "SkAdvancedTypefaceMetrics.h"
-#include "SkFontHost.h"
-#include "SkPaint.h"
-#include "SkTypeface.h"
-
-#if USE(HARFBUZZ_NG)
-#include "HarfBuzzNGFace.h"
-#else
-#include "HarfBuzzSkia.h"
-#endif
-
-#include <public/linux/WebFontInfo.h>
-#include <public/linux/WebFontRenderStyle.h>
-#include <public/linux/WebSandboxSupport.h>
-#include <public/Platform.h>
-#include <wtf/text/StringImpl.h>
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
-
-static SkPaint::Hinting skiaHinting = SkPaint::kNormal_Hinting;
-static bool useSkiaAutoHint = true;
-static bool useSkiaBitmaps = true;
-static bool useSkiaAntiAlias = true;
-static bool useSkiaSubpixelRendering = false;
-static bool useSkiaSubpixelPositioning = false;
-
-void FontPlatformData::setHinting(SkPaint::Hinting hinting)
-{
- skiaHinting = hinting;
-}
-
-void FontPlatformData::setAutoHint(bool useAutoHint)
-{
- useSkiaAutoHint = useAutoHint;
-}
-
-void FontPlatformData::setUseBitmaps(bool useBitmaps)
-{
- useSkiaBitmaps = useBitmaps;
-}
-
-void FontPlatformData::setAntiAlias(bool useAntiAlias)
-{
- useSkiaAntiAlias = useAntiAlias;
-}
-
-void FontPlatformData::setSubpixelRendering(bool useSubpixelRendering)
-{
- useSkiaSubpixelRendering = useSubpixelRendering;
-}
-
-void FontPlatformData::setSubpixelPositioning(bool useSubpixelPositioning)
-{
- useSkiaSubpixelPositioning = useSubpixelPositioning;
-}
-
-FontPlatformData::FontPlatformData(WTF::HashTableDeletedValueType)
- : m_typeface(hashTableDeletedFontValue())
- , m_textSize(0)
- , m_emSizeInFontUnits(0)
- , m_fakeBold(false)
- , m_fakeItalic(false)
- , m_orientation(Horizontal)
- , m_textOrientation(TextOrientationVerticalRight)
-{
-}
-
-FontPlatformData::FontPlatformData()
- : m_typeface(0)
- , m_textSize(0)
- , m_emSizeInFontUnits(0)
- , m_fakeBold(false)
- , m_fakeItalic(false)
- , m_orientation(Horizontal)
- , m_textOrientation(TextOrientationVerticalRight)
-{
-}
-
-FontPlatformData::FontPlatformData(float textSize, bool fakeBold, bool fakeItalic)
- : m_typeface(0)
- , m_textSize(textSize)
- , m_emSizeInFontUnits(0)
- , m_fakeBold(fakeBold)
- , m_fakeItalic(fakeItalic)
- , m_orientation(Horizontal)
- , m_textOrientation(TextOrientationVerticalRight)
-{
-}
-
-FontPlatformData::FontPlatformData(const FontPlatformData& src)
- : m_typeface(src.m_typeface)
- , m_family(src.m_family)
- , m_textSize(src.m_textSize)
- , m_emSizeInFontUnits(src.m_emSizeInFontUnits)
- , m_fakeBold(src.m_fakeBold)
- , m_fakeItalic(src.m_fakeItalic)
- , m_orientation(src.m_orientation)
- , m_textOrientation(src.m_textOrientation)
- , m_style(src.m_style)
- , m_harfbuzzFace(src.m_harfbuzzFace)
-{
- SkSafeRef(m_typeface);
-}
-
-FontPlatformData::FontPlatformData(SkTypeface* tf, const char* family, float textSize, bool fakeBold, bool fakeItalic, FontOrientation orientation, TextOrientation textOrientation)
- : m_typeface(tf)
- , m_family(family)
- , m_textSize(textSize)
- , m_emSizeInFontUnits(0)
- , m_fakeBold(fakeBold)
- , m_fakeItalic(fakeItalic)
- , m_orientation(orientation)
- , m_textOrientation(textOrientation)
-{
- SkSafeRef(m_typeface);
- querySystemForRenderStyle();
-}
-
-FontPlatformData::FontPlatformData(const FontPlatformData& src, float textSize)
- : m_typeface(src.m_typeface)
- , m_family(src.m_family)
- , m_textSize(textSize)
- , m_emSizeInFontUnits(src.m_emSizeInFontUnits)
- , m_fakeBold(src.m_fakeBold)
- , m_fakeItalic(src.m_fakeItalic)
- , m_orientation(src.m_orientation)
- , m_textOrientation(src.m_textOrientation)
- , m_harfbuzzFace(src.m_harfbuzzFace)
-{
- SkSafeRef(m_typeface);
- querySystemForRenderStyle();
-}
-
-FontPlatformData::~FontPlatformData()
-{
- SkSafeUnref(m_typeface);
-}
-
-int FontPlatformData::emSizeInFontUnits() const
-{
- if (m_emSizeInFontUnits)
- return m_emSizeInFontUnits;
-
- // FIXME: Switch to the SkTypeface::GetUnitsPerEm API once this becomes available.
- // https://bugs.webkit.org/show_bug.cgi?id=75961
-#if OS(ANDROID)
- // Android doesn't currently support Skia's getAdvancedTypefaceMetrics(),
- // but it has access to another method to replace this functionality.
- m_emSizeInFontUnits = SkFontHost::GetUnitsPerEm(m_typeface->uniqueID());
-#else
- SkAdvancedTypefaceMetrics* metrics = m_typeface->getAdvancedTypefaceMetrics(SkAdvancedTypefaceMetrics::kNo_PerGlyphInfo);
- m_emSizeInFontUnits = metrics->fEmSize;
- metrics->unref();
-#endif
- return m_emSizeInFontUnits;
-}
-
-FontPlatformData& FontPlatformData::operator=(const FontPlatformData& src)
-{
- SkRefCnt_SafeAssign(m_typeface, src.m_typeface);
-
- m_family = src.m_family;
- m_textSize = src.m_textSize;
- m_fakeBold = src.m_fakeBold;
- m_fakeItalic = src.m_fakeItalic;
- m_harfbuzzFace = src.m_harfbuzzFace;
- m_orientation = src.m_orientation;
- m_textOrientation = src.m_textOrientation;
- m_style = src.m_style;
- m_emSizeInFontUnits = src.m_emSizeInFontUnits;
-
- return *this;
-}
-
-#ifndef NDEBUG
-String FontPlatformData::description() const
-{
- return String();
-}
-#endif
-
-void FontPlatformData::setupPaint(SkPaint* paint) const
-{
- paint->setAntiAlias(m_style.useAntiAlias);
- paint->setHinting(static_cast<SkPaint::Hinting>(m_style.hintStyle));
- paint->setEmbeddedBitmapText(m_style.useBitmaps);
- paint->setAutohinted(m_style.useAutoHint);
- paint->setSubpixelText(m_style.useSubpixelPositioning);
- if (m_style.useAntiAlias)
- paint->setLCDRenderText(m_style.useSubpixelRendering);
-
- const float ts = m_textSize >= 0 ? m_textSize : 12;
- paint->setTextSize(SkFloatToScalar(ts));
- paint->setTypeface(m_typeface);
- paint->setFakeBoldText(m_fakeBold);
- paint->setTextSkewX(m_fakeItalic ? -SK_Scalar1 / 4 : 0);
-}
-
-SkFontID FontPlatformData::uniqueID() const
-{
- return m_typeface->uniqueID();
-}
-
-bool FontPlatformData::operator==(const FontPlatformData& a) const
-{
- // If either of the typeface pointers are invalid (either 0 or the
- // special deleted value) then we test for pointer equality. Otherwise, we
- // call SkTypeface::Equal on the valid pointers.
- bool typefacesEqual;
- if (m_typeface == hashTableDeletedFontValue()
- || a.m_typeface == hashTableDeletedFontValue()
- || !m_typeface
- || !a.m_typeface)
- typefacesEqual = m_typeface == a.m_typeface;
- else
- typefacesEqual = SkTypeface::Equal(m_typeface, a.m_typeface);
-
- return typefacesEqual
- && m_textSize == a.m_textSize
- && m_fakeBold == a.m_fakeBold
- && m_fakeItalic == a.m_fakeItalic
- && m_orientation == a.m_orientation
- && m_textOrientation == a.m_textOrientation
- && m_style == a.m_style;
-}
-
-unsigned FontPlatformData::hash() const
-{
- unsigned h = SkTypeface::UniqueID(m_typeface);
- h ^= 0x01010101 * ((static_cast<int>(m_textOrientation) << 3) | (static_cast<int>(m_orientation) << 2) | (static_cast<int>(m_fakeBold) << 1) | static_cast<int>(m_fakeItalic));
-
- // This memcpy is to avoid a reinterpret_cast that breaks strict-aliasing
- // rules. Memcpy is generally optimized enough so that performance doesn't
- // matter here.
- uint32_t textSizeBytes;
- memcpy(&textSizeBytes, &m_textSize, sizeof(uint32_t));
- h ^= textSizeBytes;
-
- return h;
-}
-
-bool FontPlatformData::isFixedPitch() const
-{
- notImplemented();
- return false;
-}
-
-#if USE(HARFBUZZ_NG)
-HarfBuzzNGFace* FontPlatformData::harfbuzzFace() const
-{
- if (!m_harfbuzzFace)
- m_harfbuzzFace = HarfBuzzNGFace::create(const_cast<FontPlatformData*>(this), uniqueID());
-
- return m_harfbuzzFace.get();
-}
-#else
-HarfbuzzFace* FontPlatformData::harfbuzzFace() const
-{
- if (!m_harfbuzzFace)
- m_harfbuzzFace = HarfbuzzFace::create(const_cast<FontPlatformData*>(this));
-
- return m_harfbuzzFace.get();
-}
-#endif
-
-void FontPlatformData::getRenderStyleForStrike(const char* font, int sizeAndStyle)
-{
- WebKit::WebFontRenderStyle style;
-
-#if OS(ANDROID)
- style.setDefaults();
-#else
- if (!font || !*font)
- style.setDefaults(); // It's probably a webfont. Take the system defaults.
- else if (WebKit::Platform::current()->sandboxSupport())
- WebKit::Platform::current()->sandboxSupport()->getRenderStyleForStrike(font, sizeAndStyle, &style);
- else
- WebKit::WebFontInfo::renderStyleForStrike(font, sizeAndStyle, &style);
-#endif
-
- style.toFontRenderStyle(&m_style);
-}
-
-void FontPlatformData::querySystemForRenderStyle()
-{
- getRenderStyleForStrike(m_family.data(), (((int)m_textSize) << 2) | (m_typeface->style() & 3));
-
- // Fix FontRenderStyle::NoPreference to actual styles.
- if (m_style.useAntiAlias == FontRenderStyle::NoPreference)
- m_style.useAntiAlias = useSkiaAntiAlias;
-
- if (!m_style.useHinting)
- m_style.hintStyle = SkPaint::kNo_Hinting;
- else if (m_style.useHinting == FontRenderStyle::NoPreference)
- m_style.hintStyle = skiaHinting;
-
- if (m_style.useBitmaps == FontRenderStyle::NoPreference)
- m_style.useBitmaps = useSkiaBitmaps;
- if (m_style.useAutoHint == FontRenderStyle::NoPreference)
- m_style.useAutoHint = useSkiaAutoHint;
- if (m_style.useSubpixelPositioning == FontRenderStyle::NoPreference)
- m_style.useSubpixelPositioning = useSkiaSubpixelPositioning;
- if (m_style.useAntiAlias == FontRenderStyle::NoPreference)
- m_style.useAntiAlias = useSkiaAntiAlias;
- if (m_style.useSubpixelRendering == FontRenderStyle::NoPreference)
- m_style.useSubpixelRendering = useSkiaSubpixelRendering;
-}
-
-#if ENABLE(OPENTYPE_VERTICAL)
-static SkFontTableTag reverseByteOrder(uint32_t tableTag)
-{
- return (tableTag >> 24) | ((tableTag >> 8) & 0xff00) | ((tableTag & 0xff00) << 8) | ((tableTag & 0xff) << 24);
-}
-
-PassRefPtr<OpenTypeVerticalData> FontPlatformData::verticalData() const
-{
- return fontCache()->getVerticalData(uniqueID(), *this);
-}
-
-PassRefPtr<SharedBuffer> FontPlatformData::openTypeTable(uint32_t table) const
-{
- RefPtr<SharedBuffer> buffer;
-
- SkFontTableTag tag = reverseByteOrder(table);
- const size_t tableSize = SkFontHost::GetTableSize(uniqueID(), tag);
- if (tableSize) {
- Vector<char> tableBuffer(tableSize);
- SkFontHost::GetTableData(uniqueID(), tag, 0, tableSize, &tableBuffer[0]);
- buffer = SharedBuffer::adoptVector(tableBuffer);
- }
- return buffer.release();
-}
-#endif
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.h b/Source/WebCore/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.h
deleted file mode 100644
index 4ab86f9ea..000000000
--- a/Source/WebCore/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (c) 2006, 2007, 2008, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef FontPlatformDataHarfBuzz_h
-#define FontPlatformDataHarfBuzz_h
-
-#include "FontOrientation.h"
-#include "FontRenderStyle.h"
-#include "OpenTypeVerticalData.h"
-#include "SharedBuffer.h"
-#include "SkPaint.h"
-#include "TextOrientation.h"
-#include <wtf/Forward.h>
-#include <wtf/RefPtr.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/StringImpl.h>
-
-class SkTypeface;
-typedef uint32_t SkFontID;
-
-namespace WebCore {
-
-class FontDescription;
-
-#if USE(HARFBUZZ_NG)
-class HarfBuzzNGFace;
-#else
-class HarfbuzzFace;
-#endif
-
-// -----------------------------------------------------------------------------
-// FontPlatformData is the handle which WebKit has on a specific face. A face
-// is the tuple of (font, size, ...etc). Here we are just wrapping a Skia
-// SkTypeface pointer and dealing with the reference counting etc.
-// -----------------------------------------------------------------------------
-class FontPlatformData {
-public:
- // Used for deleted values in the font cache's hash tables. The hash table
- // will create us with this structure, and it will compare other values
- // to this "Deleted" one. It expects the Deleted one to be differentiable
- // from the 0 one (created with the empty constructor), so we can't just
- // set everything to 0.
- FontPlatformData(WTF::HashTableDeletedValueType);
- FontPlatformData();
- FontPlatformData(float textSize, bool fakeBold, bool fakeItalic);
- FontPlatformData(const FontPlatformData&);
- FontPlatformData(SkTypeface*, const char* name, float textSize, bool fakeBold, bool fakeItalic, FontOrientation = Horizontal, TextOrientation = TextOrientationVerticalRight);
- FontPlatformData(const FontPlatformData& src, float textSize);
- ~FontPlatformData();
-
- // -------------------------------------------------------------------------
- // Return true iff this font is monospaced (i.e. every glyph has an equal x
- // advance)
- // -------------------------------------------------------------------------
- bool isFixedPitch() const;
-
- // -------------------------------------------------------------------------
- // Setup a Skia painting context to use this font.
- // -------------------------------------------------------------------------
- void setupPaint(SkPaint*) const;
-
- // -------------------------------------------------------------------------
- // Return Skia's unique id for this font. This encodes both the style and
- // the font's file name so refers to a single face.
- // -------------------------------------------------------------------------
- SkFontID uniqueID() const;
-
- unsigned hash() const;
- float size() const { return m_textSize; }
- int emSizeInFontUnits() const;
-
- FontOrientation orientation() const { return m_orientation; }
- void setOrientation(FontOrientation orientation) { m_orientation = orientation; }
- void setFakeBold(bool fakeBold) { m_fakeBold = fakeBold; }
- void setFakeItalic(bool fakeItalic) { m_fakeItalic = fakeItalic; }
- bool operator==(const FontPlatformData&) const;
- FontPlatformData& operator=(const FontPlatformData&);
- bool isHashTableDeletedValue() const { return m_typeface == hashTableDeletedFontValue(); }
-
-#if ENABLE(OPENTYPE_VERTICAL)
- PassRefPtr<OpenTypeVerticalData> verticalData() const;
- PassRefPtr<SharedBuffer> openTypeTable(uint32_t table) const;
-#endif
-
-#ifndef NDEBUG
- String description() const;
-#endif
-
-#if USE(HARFBUZZ_NG)
- HarfBuzzNGFace* harfbuzzFace() const;
-#else
- HarfbuzzFace* harfbuzzFace() const;
-#endif
-
- // The returned styles are all actual styles without FontRenderStyle::NoPreference.
- const FontRenderStyle& fontRenderStyle() const { return m_style; }
-
- // -------------------------------------------------------------------------
- // Global font preferences...
-
- static void setHinting(SkPaint::Hinting);
- static void setAutoHint(bool);
- static void setUseBitmaps(bool);
- static void setAntiAlias(bool);
- static void setSubpixelRendering(bool);
- static void setSubpixelPositioning(bool);
-
-private:
- void getRenderStyleForStrike(const char*, int);
- void querySystemForRenderStyle();
-
- // FIXME: Could SkAutoUnref be used here?
- SkTypeface* m_typeface;
- CString m_family;
- float m_textSize;
- mutable int m_emSizeInFontUnits;
- bool m_fakeBold;
- bool m_fakeItalic;
- FontOrientation m_orientation;
- TextOrientation m_textOrientation;
- FontRenderStyle m_style;
-#if USE(HARFBUZZ_NG)
- mutable RefPtr<HarfBuzzNGFace> m_harfbuzzFace;
-#else
- mutable RefPtr<HarfbuzzFace> m_harfbuzzFace;
-#endif
-
- SkTypeface* hashTableDeletedFontValue() const { return reinterpret_cast<SkTypeface*>(-1); }
-};
-
-} // namespace WebCore
-
-#endif // ifdef FontPlatformDataHarfBuzz_h
diff --git a/Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzNGFace.cpp b/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzFace.cpp
index 50dbd81bd..48d19ad3f 100644
--- a/Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzNGFace.cpp
+++ b/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzFace.cpp
@@ -29,7 +29,7 @@
*/
#include "config.h"
-#include "HarfBuzzNGFace.h"
+#include "HarfBuzzFace.h"
#include "FontPlatformData.h"
#include "hb-ot.h"
@@ -37,8 +37,9 @@
namespace WebCore {
-const hb_tag_t HarfBuzzNGFace::vertTag = HB_TAG('v', 'e', 'r', 't');
-const hb_tag_t HarfBuzzNGFace::vrt2Tag = HB_TAG('v', 'r', 't', '2');
+const hb_tag_t HarfBuzzFace::vertTag = HB_TAG('v', 'e', 'r', 't');
+const hb_tag_t HarfBuzzFace::vrt2Tag = HB_TAG('v', 'r', 't', '2');
+const hb_tag_t HarfBuzzFace::kernTag = HB_TAG('k', 'e', 'r', 'n');
// Though we have FontCache class, which provides the cache mechanism for
// WebKit's font objects, we also need additional caching layer for HarfBuzz
@@ -69,20 +70,20 @@ private:
HashMap<uint32_t, uint16_t> m_glyphCache;
};
-typedef HashMap<uint64_t, RefPtr<FaceCacheEntry>, WTF::IntHash<uint64_t>, WTF::UnsignedWithZeroKeyHashTraits<uint64_t> > HarfBuzzNGFaceCache;
+typedef HashMap<uint64_t, RefPtr<FaceCacheEntry>, WTF::IntHash<uint64_t>, WTF::UnsignedWithZeroKeyHashTraits<uint64_t> > HarfBuzzFaceCache;
-static HarfBuzzNGFaceCache* harfbuzzFaceCache()
+static HarfBuzzFaceCache* harfBuzzFaceCache()
{
- DEFINE_STATIC_LOCAL(HarfBuzzNGFaceCache, s_harfbuzzFaceCache, ());
- return &s_harfbuzzFaceCache;
+ DEFINE_STATIC_LOCAL(HarfBuzzFaceCache, s_harfBuzzFaceCache, ());
+ return &s_harfBuzzFaceCache;
}
-HarfBuzzNGFace::HarfBuzzNGFace(FontPlatformData* platformData, uint64_t uniqueID)
+HarfBuzzFace::HarfBuzzFace(FontPlatformData* platformData, uint64_t uniqueID)
: m_platformData(platformData)
, m_uniqueID(uniqueID)
, m_scriptForVerticalText(HB_SCRIPT_INVALID)
{
- HarfBuzzNGFaceCache::AddResult result = harfbuzzFaceCache()->add(m_uniqueID, 0);
+ HarfBuzzFaceCache::AddResult result = harfBuzzFaceCache()->add(m_uniqueID, 0);
if (result.isNewEntry)
result.iterator->value = FaceCacheEntry::create(createFace());
result.iterator->value->ref();
@@ -90,14 +91,14 @@ HarfBuzzNGFace::HarfBuzzNGFace(FontPlatformData* platformData, uint64_t uniqueID
m_glyphCacheForFaceCacheEntry = result.iterator->value->glyphCache();
}
-HarfBuzzNGFace::~HarfBuzzNGFace()
+HarfBuzzFace::~HarfBuzzFace()
{
- HarfBuzzNGFaceCache::iterator result = harfbuzzFaceCache()->find(m_uniqueID);
- ASSERT(result != harfbuzzFaceCache()->end());
+ HarfBuzzFaceCache::iterator result = harfBuzzFaceCache()->find(m_uniqueID);
+ ASSERT(result != harfBuzzFaceCache()->end());
ASSERT(result.get()->value->refCount() > 1);
result.get()->value->deref();
if (result.get()->value->refCount() == 1)
- harfbuzzFaceCache()->remove(m_uniqueID);
+ harfBuzzFaceCache()->remove(m_uniqueID);
}
static hb_script_t findScriptForVerticalGlyphSubstitution(hb_face_t* face)
@@ -113,15 +114,15 @@ static hb_script_t findScriptForVerticalGlyphSubstitution(hb_face_t* face)
hb_ot_layout_script_get_language_tags(face, HB_OT_TAG_GSUB, scriptIndex, 0, &languageCount, languageTags);
for (unsigned languageIndex = 0; languageIndex < languageCount; ++languageIndex) {
unsigned featureIndex;
- if (hb_ot_layout_language_find_feature(face, HB_OT_TAG_GSUB, scriptIndex, languageIndex, HarfBuzzNGFace::vertTag, &featureIndex)
- || hb_ot_layout_language_find_feature(face, HB_OT_TAG_GSUB, scriptIndex, languageIndex, HarfBuzzNGFace::vrt2Tag, &featureIndex))
+ if (hb_ot_layout_language_find_feature(face, HB_OT_TAG_GSUB, scriptIndex, languageIndex, HarfBuzzFace::vertTag, &featureIndex)
+ || hb_ot_layout_language_find_feature(face, HB_OT_TAG_GSUB, scriptIndex, languageIndex, HarfBuzzFace::vrt2Tag, &featureIndex))
return hb_ot_tag_to_script(scriptTags[scriptIndex]);
}
}
return HB_SCRIPT_INVALID;
}
-void HarfBuzzNGFace::setScriptForVerticalGlyphSubstitution(hb_buffer_t* buffer)
+void HarfBuzzFace::setScriptForVerticalGlyphSubstitution(hb_buffer_t* buffer)
{
if (m_scriptForVerticalText == HB_SCRIPT_INVALID)
m_scriptForVerticalText = findScriptForVerticalGlyphSubstitution(m_face);
diff --git a/Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzNGFace.h b/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzFace.h
index 360daf9cf..8066528b5 100644
--- a/Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzNGFace.h
+++ b/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzFace.h
@@ -28,8 +28,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef HarfBuzzNGFace_h
-#define HarfBuzzNGFace_h
+#ifndef HarfBuzzFace_h
+#define HarfBuzzFace_h
#include <hb.h>
@@ -42,23 +42,24 @@ namespace WebCore {
class FontPlatformData;
-class HarfBuzzNGFace : public RefCounted<HarfBuzzNGFace> {
+class HarfBuzzFace : public RefCounted<HarfBuzzFace> {
public:
static const hb_tag_t vertTag;
static const hb_tag_t vrt2Tag;
+ static const hb_tag_t kernTag;
- static PassRefPtr<HarfBuzzNGFace> create(FontPlatformData* platformData, uint64_t uniqueID)
+ static PassRefPtr<HarfBuzzFace> create(FontPlatformData* platformData, uint64_t uniqueID)
{
- return adoptRef(new HarfBuzzNGFace(platformData, uniqueID));
+ return adoptRef(new HarfBuzzFace(platformData, uniqueID));
}
- ~HarfBuzzNGFace();
+ ~HarfBuzzFace();
hb_font_t* createFont();
void setScriptForVerticalGlyphSubstitution(hb_buffer_t*);
private:
- HarfBuzzNGFace(FontPlatformData*, uint64_t);
+ HarfBuzzFace(FontPlatformData*, uint64_t);
hb_face_t* createFace();
@@ -72,4 +73,4 @@ private:
}
-#endif // HarfBuzzNGFace_h
+#endif // HarfBuzzFace_h
diff --git a/Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzNGFaceCairo.cpp b/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzFaceCairo.cpp
index 2db3d2780..62495aca9 100644
--- a/Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzNGFaceCairo.cpp
+++ b/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzFaceCairo.cpp
@@ -30,7 +30,7 @@
*/
#include "config.h"
-#include "HarfBuzzNGFace.h"
+#include "HarfBuzzFace.h"
#include "FontPlatformData.h"
#include "GlyphBuffer.h"
@@ -46,6 +46,15 @@
namespace WebCore {
+struct HarfBuzzFontData {
+ HarfBuzzFontData(WTF::HashMap<uint32_t, uint16_t>* glyphCacheForFaceCacheEntry, cairo_scaled_font_t* cairoScaledFont)
+ : m_glyphCacheForFaceCacheEntry(glyphCacheForFaceCacheEntry)
+ , m_cairoScaledFont(cairoScaledFont)
+ { }
+ WTF::HashMap<uint32_t, uint16_t>* m_glyphCacheForFaceCacheEntry;
+ cairo_scaled_font_t* m_cairoScaledFont;
+};
+
class CairoFtFaceLocker {
public:
CairoFtFaceLocker(cairo_scaled_font_t* cairoScaledFont) : m_scaledFont(cairoScaledFont) { };
@@ -90,28 +99,32 @@ static void CairoGetGlyphWidthAndExtents(cairo_scaled_font_t* scaledFont, hb_cod
}
}
-static hb_bool_t harfbuzzGetGlyph(hb_font_t*, void* fontData, hb_codepoint_t unicode, hb_codepoint_t, hb_codepoint_t* glyph, void*)
+static hb_bool_t harfBuzzGetGlyph(hb_font_t*, void* fontData, hb_codepoint_t unicode, hb_codepoint_t, hb_codepoint_t* glyph, void*)
{
- FontPlatformData* platformData = reinterpret_cast<FontPlatformData*>(fontData);
- cairo_scaled_font_t* scaledFont = platformData->scaledFont();
+ HarfBuzzFontData* hbFontData = reinterpret_cast<HarfBuzzFontData*>(fontData);
+ cairo_scaled_font_t* scaledFont = hbFontData->m_cairoScaledFont;
ASSERT(scaledFont);
- cairo_glyph_t* glyphs = 0;
- int numGlyphs = 0;
- CString utf8Codepoint = UTF8Encoding().encode(reinterpret_cast<UChar*>(&unicode), 1, QuestionMarksForUnencodables);
- if (CAIRO_STATUS_SUCCESS != cairo_scaled_font_text_to_glyphs(scaledFont, 0, 0, utf8Codepoint.data(), utf8Codepoint.length(), &glyphs, &numGlyphs, 0, 0, 0))
- return false;
- if (!numGlyphs)
- return false;
- *glyph = glyphs[0].index;
- cairo_glyph_free(glyphs);
- return true;
+ WTF::HashMap<uint32_t, uint16_t>::AddResult result = hbFontData->m_glyphCacheForFaceCacheEntry->add(unicode, 0);
+ if (result.isNewEntry) {
+ cairo_glyph_t* glyphs = 0;
+ int numGlyphs = 0;
+ CString utf8Codepoint = UTF8Encoding().encode(reinterpret_cast<UChar*>(&unicode), 1, QuestionMarksForUnencodables);
+ if (cairo_scaled_font_text_to_glyphs(scaledFont, 0, 0, utf8Codepoint.data(), utf8Codepoint.length(), &glyphs, &numGlyphs, 0, 0, 0) != CAIRO_STATUS_SUCCESS)
+ return false;
+ if (!numGlyphs)
+ return false;
+ result.iterator->value = glyphs[0].index;
+ cairo_glyph_free(glyphs);
+ }
+ *glyph = result.iterator->value;
+ return !!*glyph;
}
-static hb_position_t harfbuzzGetGlyphHorizontalAdvance(hb_font_t*, void* fontData, hb_codepoint_t glyph, void*)
+static hb_position_t harfBuzzGetGlyphHorizontalAdvance(hb_font_t*, void* fontData, hb_codepoint_t glyph, void*)
{
- FontPlatformData* platformData = reinterpret_cast<FontPlatformData*>(fontData);
- cairo_scaled_font_t* scaledFont = platformData->scaledFont();
+ HarfBuzzFontData* hbFontData = reinterpret_cast<HarfBuzzFontData*>(fontData);
+ cairo_scaled_font_t* scaledFont = hbFontData->m_cairoScaledFont;
ASSERT(scaledFont);
hb_position_t advance = 0;
@@ -119,41 +132,41 @@ static hb_position_t harfbuzzGetGlyphHorizontalAdvance(hb_font_t*, void* fontDat
return advance;
}
-static hb_bool_t harfbuzzGetGlyphHorizontalOrigin(hb_font_t*, void*, hb_codepoint_t, hb_position_t*, hb_position_t*, void*)
+static hb_bool_t harfBuzzGetGlyphHorizontalOrigin(hb_font_t*, void*, hb_codepoint_t, hb_position_t*, hb_position_t*, void*)
{
// Just return true, following the way that Harfbuzz-FreeType
// implementation does.
return true;
}
-static hb_bool_t harfbuzzGetGlyphExtents(hb_font_t*, void* fontData, hb_codepoint_t glyph, hb_glyph_extents_t* extents, void*)
+static hb_bool_t harfBuzzGetGlyphExtents(hb_font_t*, void* fontData, hb_codepoint_t glyph, hb_glyph_extents_t* extents, void*)
{
- FontPlatformData* platformData = reinterpret_cast<FontPlatformData*>(fontData);
- cairo_scaled_font_t* scaledFont = platformData->scaledFont();
+ HarfBuzzFontData* hbFontData = reinterpret_cast<HarfBuzzFontData*>(fontData);
+ cairo_scaled_font_t* scaledFont = hbFontData->m_cairoScaledFont;
ASSERT(scaledFont);
CairoGetGlyphWidthAndExtents(scaledFont, glyph, 0, extents);
return true;
}
-static hb_font_funcs_t* harfbuzzCairoTextGetFontFuncs()
+static hb_font_funcs_t* harfBuzzCairoTextGetFontFuncs()
{
- static hb_font_funcs_t* harfbuzzCairoFontFuncs = 0;
+ static hb_font_funcs_t* harfBuzzCairoFontFuncs = 0;
// We don't set callback functions which we can't support.
// Harfbuzz will use the fallback implementation if they aren't set.
- if (!harfbuzzCairoFontFuncs) {
- harfbuzzCairoFontFuncs = hb_font_funcs_create();
- hb_font_funcs_set_glyph_func(harfbuzzCairoFontFuncs, harfbuzzGetGlyph, 0, 0);
- hb_font_funcs_set_glyph_h_advance_func(harfbuzzCairoFontFuncs, harfbuzzGetGlyphHorizontalAdvance, 0, 0);
- hb_font_funcs_set_glyph_h_origin_func(harfbuzzCairoFontFuncs, harfbuzzGetGlyphHorizontalOrigin, 0, 0);
- hb_font_funcs_set_glyph_extents_func(harfbuzzCairoFontFuncs, harfbuzzGetGlyphExtents, 0, 0);
- hb_font_funcs_make_immutable(harfbuzzCairoFontFuncs);
+ if (!harfBuzzCairoFontFuncs) {
+ harfBuzzCairoFontFuncs = hb_font_funcs_create();
+ hb_font_funcs_set_glyph_func(harfBuzzCairoFontFuncs, harfBuzzGetGlyph, 0, 0);
+ hb_font_funcs_set_glyph_h_advance_func(harfBuzzCairoFontFuncs, harfBuzzGetGlyphHorizontalAdvance, 0, 0);
+ hb_font_funcs_set_glyph_h_origin_func(harfBuzzCairoFontFuncs, harfBuzzGetGlyphHorizontalOrigin, 0, 0);
+ hb_font_funcs_set_glyph_extents_func(harfBuzzCairoFontFuncs, harfBuzzGetGlyphExtents, 0, 0);
+ hb_font_funcs_make_immutable(harfBuzzCairoFontFuncs);
}
- return harfbuzzCairoFontFuncs;
+ return harfBuzzCairoFontFuncs;
}
-static hb_blob_t* harfbuzzCairoGetTable(hb_face_t*, hb_tag_t tag, void* userData)
+static hb_blob_t* harfBuzzCairoGetTable(hb_face_t*, hb_tag_t tag, void* userData)
{
cairo_scaled_font_t* scaledFont = reinterpret_cast<cairo_scaled_font_t*>(userData);
if (!scaledFont)
@@ -182,17 +195,24 @@ static hb_blob_t* harfbuzzCairoGetTable(hb_face_t*, hb_tag_t tag, void* userData
return hb_blob_create(reinterpret_cast<const char*>(buffer), tableSize, HB_MEMORY_MODE_WRITABLE, buffer, fastFree);
}
-hb_face_t* HarfBuzzNGFace::createFace()
+static void destroyHarfBuzzFontData(void* userData)
+{
+ HarfBuzzFontData* hbFontData = reinterpret_cast<HarfBuzzFontData*>(userData);
+ delete hbFontData;
+}
+
+hb_face_t* HarfBuzzFace::createFace()
{
- hb_face_t* face = hb_face_create_for_tables(harfbuzzCairoGetTable, m_platformData->scaledFont(), 0);
+ hb_face_t* face = hb_face_create_for_tables(harfBuzzCairoGetTable, m_platformData->scaledFont(), 0);
ASSERT(face);
return face;
}
-hb_font_t* HarfBuzzNGFace::createFont()
+hb_font_t* HarfBuzzFace::createFont()
{
hb_font_t* font = hb_font_create(m_face);
- hb_font_set_funcs(font, harfbuzzCairoTextGetFontFuncs(), m_platformData, 0);
+ HarfBuzzFontData* hbFontData = new HarfBuzzFontData(m_glyphCacheForFaceCacheEntry, m_platformData->scaledFont());
+ hb_font_set_funcs(font, harfBuzzCairoTextGetFontFuncs(), hbFontData, destroyHarfBuzzFontData);
const float size = m_platformData->size();
if (floorf(size) == size)
hb_font_set_ppem(font, size, size);
diff --git a/Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzNGFaceCoreText.cpp b/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzFaceCoreText.cpp
index e4c65cd41..5dd819043 100644
--- a/Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzNGFaceCoreText.cpp
+++ b/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzFaceCoreText.cpp
@@ -29,7 +29,7 @@
*/
#include "config.h"
-#include "HarfBuzzNGFace.h"
+#include "HarfBuzzFace.h"
#include "FontPlatformData.h"
#include "HarfBuzzShaper.h"
@@ -85,19 +85,19 @@ static hb_bool_t getGlyphExtents(hb_font_t* hbFont, void* fontData, hb_codepoint
return true;
}
-static hb_font_funcs_t* harfbuzzCoreTextGetFontFuncs()
+static hb_font_funcs_t* harfBuzzCoreTextGetFontFuncs()
{
- static hb_font_funcs_t* harfbuzzCoreTextFontFuncs = 0;
-
- if (!harfbuzzCoreTextFontFuncs) {
- harfbuzzCoreTextFontFuncs = hb_font_funcs_create();
- hb_font_funcs_set_glyph_func(harfbuzzCoreTextFontFuncs, getGlyph, 0, 0);
- hb_font_funcs_set_glyph_h_advance_func(harfbuzzCoreTextFontFuncs, getGlyphHorizontalAdvance, 0, 0);
- hb_font_funcs_set_glyph_h_origin_func(harfbuzzCoreTextFontFuncs, getGlyphHorizontalOrigin, 0, 0);
- hb_font_funcs_set_glyph_extents_func(harfbuzzCoreTextFontFuncs, getGlyphExtents, 0, 0);
- hb_font_funcs_make_immutable(harfbuzzCoreTextFontFuncs);
+ static hb_font_funcs_t* harfBuzzCoreTextFontFuncs = 0;
+
+ if (!harfBuzzCoreTextFontFuncs) {
+ harfBuzzCoreTextFontFuncs = hb_font_funcs_create();
+ hb_font_funcs_set_glyph_func(harfBuzzCoreTextFontFuncs, getGlyph, 0, 0);
+ hb_font_funcs_set_glyph_h_advance_func(harfBuzzCoreTextFontFuncs, getGlyphHorizontalAdvance, 0, 0);
+ hb_font_funcs_set_glyph_h_origin_func(harfBuzzCoreTextFontFuncs, getGlyphHorizontalOrigin, 0, 0);
+ hb_font_funcs_set_glyph_extents_func(harfBuzzCoreTextFontFuncs, getGlyphExtents, 0, 0);
+ hb_font_funcs_make_immutable(harfBuzzCoreTextFontFuncs);
}
- return harfbuzzCoreTextFontFuncs;
+ return harfBuzzCoreTextFontFuncs;
}
static void releaseTableData(void* userData)
@@ -106,7 +106,7 @@ static void releaseTableData(void* userData)
CFRelease(cfData);
}
-static hb_blob_t* harfbuzzCoreTextGetTable(hb_face_t* face, hb_tag_t tag, void* userData)
+static hb_blob_t* harfBuzzCoreTextGetTable(hb_face_t* face, hb_tag_t tag, void* userData)
{
CGFontRef cgFont = reinterpret_cast<CGFontRef>(userData);
CFDataRef cfData = CGFontCopyTableForTag(cgFont, tag);
@@ -120,19 +120,19 @@ static hb_blob_t* harfbuzzCoreTextGetTable(hb_face_t* face, hb_tag_t tag, void*
return hb_blob_create(data, length, HB_MEMORY_MODE_READONLY, reinterpret_cast<void*>(const_cast<__CFData*>(cfData)), releaseTableData);
}
-hb_face_t* HarfBuzzNGFace::createFace()
+hb_face_t* HarfBuzzFace::createFace()
{
// It seems that CTFontCopyTable of MacOSX10.5 sdk doesn't work for
// OpenType layout tables(GDEF, GSUB, GPOS). Use CGFontCopyTableForTag instead.
- hb_face_t* face = hb_face_create_for_tables(harfbuzzCoreTextGetTable, m_platformData->cgFont(), 0);
+ hb_face_t* face = hb_face_create_for_tables(harfBuzzCoreTextGetTable, m_platformData->cgFont(), 0);
ASSERT(face);
return face;
}
-hb_font_t* HarfBuzzNGFace::createFont()
+hb_font_t* HarfBuzzFace::createFont()
{
hb_font_t* font = hb_font_create(m_face);
- hb_font_set_funcs(font, harfbuzzCoreTextGetFontFuncs(), m_platformData, 0);
+ hb_font_set_funcs(font, harfBuzzCoreTextGetFontFuncs(), m_platformData, 0);
const float size = m_platformData->m_size;
hb_font_set_ppem(font, size, size);
const int scale = (1 << 16) * static_cast<int>(size);
diff --git a/Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.cpp b/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.cpp
index 9d2385fd8..572035e4c 100644
--- a/Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.cpp
+++ b/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.cpp
@@ -32,7 +32,7 @@
#include "HarfBuzzShaper.h"
#include "Font.h"
-#include "HarfBuzzNGFace.h"
+#include "HarfBuzzFace.h"
#include "SurrogatePairAwareTextIterator.h"
#include "TextRun.h"
#include "hb-icu.h"
@@ -67,7 +67,7 @@ private:
DestroyFunction m_destroy;
};
-static inline float harfbuzzPositionToFloat(hb_position_t value)
+static inline float harfBuzzPositionToFloat(hb_position_t value)
{
return static_cast<float>(value) / (1 << 16);
}
@@ -81,9 +81,9 @@ HarfBuzzShaper::HarfBuzzRun::HarfBuzzRun(const SimpleFontData* fontData, unsigne
{
}
-void HarfBuzzShaper::HarfBuzzRun::applyShapeResult(hb_buffer_t* harfbuzzBuffer)
+void HarfBuzzShaper::HarfBuzzRun::applyShapeResult(hb_buffer_t* harfBuzzBuffer)
{
- m_numGlyphs = hb_buffer_get_length(harfbuzzBuffer);
+ m_numGlyphs = hb_buffer_get_length(harfBuzzBuffer);
m_glyphs.resize(m_numGlyphs);
m_advances.resize(m_numGlyphs);
m_glyphToCharacterIndexes.resize(m_numGlyphs);
@@ -156,10 +156,18 @@ float HarfBuzzShaper::HarfBuzzRun::xPositionForOffset(unsigned offset)
return position;
}
-static void normalizeCharacters(const UChar* source, UChar* destination, int length)
+static void normalizeCharacters(const TextRun& run, UChar* destination, int length)
{
int position = 0;
bool error = false;
+ const UChar* source;
+ String stringFor8BitRun;
+ if (run.is8Bit()) {
+ stringFor8BitRun = String::make16BitFrom8BitSource(run.characters8(), run.length());
+ source = stringFor8BitRun.characters16();
+ } else
+ source = run.characters16();
+
while (position < length) {
UChar32 character;
int nextPosition = position;
@@ -176,13 +184,20 @@ static void normalizeCharacters(const UChar* source, UChar* destination, int len
}
HarfBuzzShaper::HarfBuzzShaper(const Font* font, const TextRun& run)
- : HarfBuzzShaperBase(font, run)
+ : m_font(font)
+ , m_normalizedBufferLength(0)
+ , m_run(run)
+ , m_wordSpacingAdjustment(font->wordSpacing())
+ , m_padding(0)
+ , m_padPerWordBreak(0)
+ , m_padError(0)
+ , m_letterSpacing(font->letterSpacing())
, m_fromIndex(0)
, m_toIndex(m_run.length())
{
m_normalizedBuffer = adoptArrayPtr(new UChar[m_run.length() + 1]);
m_normalizedBufferLength = m_run.length();
- normalizeCharacters(m_run.characters16(), m_normalizedBuffer.get(), m_normalizedBufferLength);
+ normalizeCharacters(m_run, m_normalizedBuffer.get(), m_normalizedBufferLength);
setPadding(m_run.expansion());
setFontFeatures();
}
@@ -191,10 +206,133 @@ HarfBuzzShaper::~HarfBuzzShaper()
{
}
+static void normalizeSpacesAndMirrorChars(const UChar* source, UChar* destination, int length, HarfBuzzShaper::NormalizeMode normalizeMode)
+{
+ int position = 0;
+ bool error = false;
+ // Iterate characters in source and mirror character if needed.
+ while (position < length) {
+ UChar32 character;
+ int nextPosition = position;
+ U16_NEXT(source, nextPosition, length, character);
+ // Don't normalize tabs as they are not treated as spaces for word-end
+ if (Font::treatAsSpace(character) && character != '\t')
+ character = ' ';
+ else if (Font::treatAsZeroWidthSpace(character))
+ character = zeroWidthSpace;
+ else if (normalizeMode == HarfBuzzShaper::NormalizeMirrorChars)
+ character = u_charMirror(character);
+ U16_APPEND(destination, position, length, character, error);
+ ASSERT_UNUSED(error, !error);
+ position = nextPosition;
+ }
+}
+
+void HarfBuzzShaper::setNormalizedBuffer(NormalizeMode normalizeMode)
+{
+ // Normalize the text run in three ways:
+ // 1) Convert the |originalRun| to NFC normalized form if combining diacritical marks
+ // (U+0300..) are used in the run. This conversion is necessary since most OpenType
+ // fonts (e.g., Arial) don't have substitution rules for the diacritical marks in
+ // their GSUB tables.
+ //
+ // Note that we don't use the icu::Normalizer::isNormalized(UNORM_NFC) API here since
+ // the API returns FALSE (= not normalized) for complex runs that don't require NFC
+ // normalization (e.g., Arabic text). Unless the run contains the diacritical marks,
+ // HarfBuzz will do the same thing for us using the GSUB table.
+ // 2) Convert spacing characters into plain spaces, as some fonts will provide glyphs
+ // for characters like '\n' otherwise.
+ // 3) Convert mirrored characters such as parenthesis for rtl text.
+
+ // Convert to NFC form if the text has diacritical marks.
+ icu::UnicodeString normalizedString;
+ UErrorCode error = U_ZERO_ERROR;
+
+ const UChar* runCharacters;
+ String stringFor8BitRun;
+ if (m_run.is8Bit()) {
+ stringFor8BitRun = String::make16BitFrom8BitSource(m_run.characters8(), m_run.length());
+ runCharacters = stringFor8BitRun.characters16();
+ } else
+ runCharacters = m_run.characters16();
+
+ for (int i = 0; i < m_run.length(); ++i) {
+ UChar ch = runCharacters[i];
+ if (::ublock_getCode(ch) == UBLOCK_COMBINING_DIACRITICAL_MARKS) {
+ icu::Normalizer::normalize(icu::UnicodeString(runCharacters,
+ m_run.length()), UNORM_NFC, 0 /* no options */,
+ normalizedString, error);
+ if (U_FAILURE(error))
+ normalizedString.remove();
+ break;
+ }
+ }
+
+ const UChar* sourceText;
+ if (normalizedString.isEmpty()) {
+ m_normalizedBufferLength = m_run.length();
+ sourceText = runCharacters;
+ } else {
+ m_normalizedBufferLength = normalizedString.length();
+ sourceText = normalizedString.getBuffer();
+ }
+
+ m_normalizedBuffer = adoptArrayPtr(new UChar[m_normalizedBufferLength + 1]);
+ normalizeSpacesAndMirrorChars(sourceText, m_normalizedBuffer.get(), m_normalizedBufferLength, normalizeMode);
+}
+
+bool HarfBuzzShaper::isWordEnd(unsigned index)
+{
+ // This could refer a high-surrogate, but should work.
+ return index && isCodepointSpace(m_normalizedBuffer[index]);
+}
+
+int HarfBuzzShaper::determineWordBreakSpacing()
+{
+ int wordBreakSpacing = m_wordSpacingAdjustment;
+
+ if (m_padding > 0) {
+ int toPad = roundf(m_padPerWordBreak + m_padError);
+ m_padError += m_padPerWordBreak - toPad;
+
+ if (m_padding < toPad)
+ toPad = m_padding;
+ m_padding -= toPad;
+ wordBreakSpacing += toPad;
+ }
+ return wordBreakSpacing;
+}
+
+// setPadding sets a number of pixels to be distributed across the TextRun.
+// WebKit uses this to justify text.
+void HarfBuzzShaper::setPadding(int padding)
+{
+ m_padding = padding;
+ m_padError = 0;
+ if (!m_padding)
+ return;
+
+ // If we have padding to distribute, then we try to give an equal
+ // amount to each space. The last space gets the smaller amount, if
+ // any.
+ unsigned numWordEnds = 0;
+
+ for (unsigned i = 0; i < m_normalizedBufferLength; i++) {
+ if (isWordEnd(i))
+ numWordEnds++;
+ }
+
+ if (numWordEnds)
+ m_padPerWordBreak = m_padding / numWordEnds;
+ else
+ m_padPerWordBreak = 0;
+}
+
+
void HarfBuzzShaper::setDrawRange(int from, int to)
{
- ASSERT(from >= 0);
- ASSERT(to <= m_run.length());
+ ASSERT_WITH_SECURITY_IMPLICATION(from >= 0);
+ ASSERT_WITH_SECURITY_IMPLICATION(to <= m_run.length());
m_fromIndex = from;
m_toIndex = to;
}
@@ -203,12 +341,28 @@ void HarfBuzzShaper::setFontFeatures()
{
const FontDescription& description = m_font->fontDescription();
if (description.orientation() == Vertical) {
- static hb_feature_t vert = { HarfBuzzNGFace::vertTag, 1, 0, static_cast<unsigned>(-1) };
- static hb_feature_t vrt2 = { HarfBuzzNGFace::vrt2Tag, 1, 0, static_cast<unsigned>(-1) };
+ static hb_feature_t vert = { HarfBuzzFace::vertTag, 1, 0, static_cast<unsigned>(-1) };
+ static hb_feature_t vrt2 = { HarfBuzzFace::vrt2Tag, 1, 0, static_cast<unsigned>(-1) };
m_features.append(vert);
m_features.append(vrt2);
}
+ hb_feature_t kerning = { HarfBuzzFace::kernTag, 0, 0, static_cast<unsigned>(-1) };
+ switch (description.kerning()) {
+ case FontDescription::NormalKerning:
+ kerning.value = 1;
+ m_features.append(kerning);
+ break;
+ case FontDescription::NoneKerning:
+ kerning.value = 0;
+ m_features.append(kerning);
+ break;
+ case FontDescription::AutoKerning:
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+
FontFeatureSettings* settings = description.featureSettings();
if (!settings)
return;
@@ -297,7 +451,7 @@ bool HarfBuzzShaper::collectHarfBuzzRuns()
nextScript = uscript_getScript(character, &errorCode);
if (U_FAILURE(errorCode))
return false;
- if ((nextFontData != currentFontData) || ((currentScript != nextScript) && (nextScript != USCRIPT_INHERITED)))
+ if ((nextFontData != currentFontData) || ((currentScript != nextScript) && (nextScript != USCRIPT_INHERITED) && (!uscript_hasScript(character, currentScript))))
break;
if (nextScript == USCRIPT_INHERITED)
nextScript = currentScript;
@@ -305,68 +459,73 @@ bool HarfBuzzShaper::collectHarfBuzzRuns()
}
unsigned numCharactersOfCurrentRun = iterator.currentCharacter() - startIndexOfCurrentRun;
hb_script_t script = hb_icu_script_to_script(currentScript);
- m_harfbuzzRuns.append(HarfBuzzRun::create(currentFontData, startIndexOfCurrentRun, numCharactersOfCurrentRun, m_run.direction(), script));
+ m_harfBuzzRuns.append(HarfBuzzRun::create(currentFontData, startIndexOfCurrentRun, numCharactersOfCurrentRun, m_run.direction(), script));
currentFontData = nextFontData;
startIndexOfCurrentRun = iterator.currentCharacter();
} while (iterator.consume(character, clusterLength));
- return !m_harfbuzzRuns.isEmpty();
+ return !m_harfBuzzRuns.isEmpty();
}
bool HarfBuzzShaper::shapeHarfBuzzRuns(bool shouldSetDirection)
{
- HarfBuzzScopedPtr<hb_buffer_t> harfbuzzBuffer(hb_buffer_create(), hb_buffer_destroy);
+ HarfBuzzScopedPtr<hb_buffer_t> harfBuzzBuffer(hb_buffer_create(), hb_buffer_destroy);
- hb_buffer_set_unicode_funcs(harfbuzzBuffer.get(), hb_icu_get_unicode_funcs());
+ hb_buffer_set_unicode_funcs(harfBuzzBuffer.get(), hb_icu_get_unicode_funcs());
- for (unsigned i = 0; i < m_harfbuzzRuns.size(); ++i) {
- unsigned runIndex = m_run.rtl() ? m_harfbuzzRuns.size() - i - 1 : i;
- HarfBuzzRun* currentRun = m_harfbuzzRuns[runIndex].get();
+ for (unsigned i = 0; i < m_harfBuzzRuns.size(); ++i) {
+ unsigned runIndex = m_run.rtl() ? m_harfBuzzRuns.size() - i - 1 : i;
+ HarfBuzzRun* currentRun = m_harfBuzzRuns[runIndex].get();
const SimpleFontData* currentFontData = currentRun->fontData();
+ if (currentFontData->isSVGFont())
+ return false;
- hb_buffer_set_script(harfbuzzBuffer.get(), currentRun->script());
+ hb_buffer_set_script(harfBuzzBuffer.get(), currentRun->script());
if (shouldSetDirection)
- hb_buffer_set_direction(harfbuzzBuffer.get(), currentRun->rtl() ? HB_DIRECTION_RTL : HB_DIRECTION_LTR);
+ hb_buffer_set_direction(harfBuzzBuffer.get(), currentRun->rtl() ? HB_DIRECTION_RTL : HB_DIRECTION_LTR);
+ else
+ // Leaving direction to HarfBuzz to guess is *really* bad, but will do for now.
+ hb_buffer_guess_segment_properties(harfBuzzBuffer.get());
// Add a space as pre-context to the buffer. This prevents showing dotted-circle
// for combining marks at the beginning of runs.
static const uint16_t preContext = ' ';
- hb_buffer_add_utf16(harfbuzzBuffer.get(), &preContext, 1, 1, 0);
+ hb_buffer_add_utf16(harfBuzzBuffer.get(), &preContext, 1, 1, 0);
if (m_font->isSmallCaps() && u_islower(m_normalizedBuffer[currentRun->startIndex()])) {
String upperText = String(m_normalizedBuffer.get() + currentRun->startIndex(), currentRun->numCharacters());
upperText.makeUpper();
currentFontData = m_font->glyphDataForCharacter(upperText[0], false, SmallCapsVariant).fontData;
- hb_buffer_add_utf16(harfbuzzBuffer.get(), upperText.characters(), currentRun->numCharacters(), 0, currentRun->numCharacters());
+ hb_buffer_add_utf16(harfBuzzBuffer.get(), reinterpret_cast<const uint16_t*>(upperText.characters()), currentRun->numCharacters(), 0, currentRun->numCharacters());
} else
- hb_buffer_add_utf16(harfbuzzBuffer.get(), m_normalizedBuffer.get() + currentRun->startIndex(), currentRun->numCharacters(), 0, currentRun->numCharacters());
+ hb_buffer_add_utf16(harfBuzzBuffer.get(), reinterpret_cast<const uint16_t*>(m_normalizedBuffer.get() + currentRun->startIndex()), currentRun->numCharacters(), 0, currentRun->numCharacters());
FontPlatformData* platformData = const_cast<FontPlatformData*>(&currentFontData->platformData());
- HarfBuzzNGFace* face = platformData->harfbuzzFace();
+ HarfBuzzFace* face = platformData->harfBuzzFace();
if (!face)
return false;
if (m_font->fontDescription().orientation() == Vertical)
- face->setScriptForVerticalGlyphSubstitution(harfbuzzBuffer.get());
+ face->setScriptForVerticalGlyphSubstitution(harfBuzzBuffer.get());
- HarfBuzzScopedPtr<hb_font_t> harfbuzzFont(face->createFont(), hb_font_destroy);
+ HarfBuzzScopedPtr<hb_font_t> harfBuzzFont(face->createFont(), hb_font_destroy);
- hb_shape(harfbuzzFont.get(), harfbuzzBuffer.get(), m_features.isEmpty() ? 0 : m_features.data(), m_features.size());
+ hb_shape(harfBuzzFont.get(), harfBuzzBuffer.get(), m_features.isEmpty() ? 0 : m_features.data(), m_features.size());
- currentRun->applyShapeResult(harfbuzzBuffer.get());
- setGlyphPositionsForHarfBuzzRun(currentRun, harfbuzzBuffer.get());
+ currentRun->applyShapeResult(harfBuzzBuffer.get());
+ setGlyphPositionsForHarfBuzzRun(currentRun, harfBuzzBuffer.get());
- hb_buffer_reset(harfbuzzBuffer.get());
+ hb_buffer_reset(harfBuzzBuffer.get());
}
return true;
}
-void HarfBuzzShaper::setGlyphPositionsForHarfBuzzRun(HarfBuzzRun* currentRun, hb_buffer_t* harfbuzzBuffer)
+void HarfBuzzShaper::setGlyphPositionsForHarfBuzzRun(HarfBuzzRun* currentRun, hb_buffer_t* harfBuzzBuffer)
{
const SimpleFontData* currentFontData = currentRun->fontData();
- hb_glyph_info_t* glyphInfos = hb_buffer_get_glyph_infos(harfbuzzBuffer, 0);
- hb_glyph_position_t* glyphPositions = hb_buffer_get_glyph_positions(harfbuzzBuffer, 0);
+ hb_glyph_info_t* glyphInfos = hb_buffer_get_glyph_infos(harfBuzzBuffer, 0);
+ hb_glyph_position_t* glyphPositions = hb_buffer_get_glyph_positions(harfBuzzBuffer, 0);
unsigned numGlyphs = currentRun->numGlyphs();
uint16_t* glyphToCharacterIndexes = currentRun->glyphToCharacterIndexes();
@@ -376,9 +535,9 @@ void HarfBuzzShaper::setGlyphPositionsForHarfBuzzRun(HarfBuzzRun* currentRun, hb
for (size_t i = 0; i < numGlyphs; ++i) {
bool runEnd = i + 1 == numGlyphs;
uint16_t glyph = glyphInfos[i].codepoint;
- float offsetX = harfbuzzPositionToFloat(glyphPositions[i].x_offset);
- float offsetY = -harfbuzzPositionToFloat(glyphPositions[i].y_offset);
- float advance = harfbuzzPositionToFloat(glyphPositions[i].x_advance);
+ float offsetX = harfBuzzPositionToFloat(glyphPositions[i].x_offset);
+ float offsetY = -harfBuzzPositionToFloat(glyphPositions[i].y_offset);
+ float advance = harfBuzzPositionToFloat(glyphPositions[i].x_advance);
unsigned currentCharacterIndex = currentRun->startIndex() + glyphInfos[i].cluster;
bool isClusterEnd = runEnd || glyphInfos[i].cluster != glyphInfos[i + 1].cluster;
@@ -443,19 +602,19 @@ void HarfBuzzShaper::fillGlyphBufferFromHarfBuzzRun(GlyphBuffer* glyphBuffer, Ha
bool HarfBuzzShaper::fillGlyphBuffer(GlyphBuffer* glyphBuffer)
{
- unsigned numRuns = m_harfbuzzRuns.size();
+ unsigned numRuns = m_harfBuzzRuns.size();
if (m_run.rtl()) {
- m_startOffset = m_harfbuzzRuns.last()->offsets()[0];
+ m_startOffset = m_harfBuzzRuns.last()->offsets()[0];
for (int runIndex = numRuns - 1; runIndex >= 0; --runIndex) {
- HarfBuzzRun* currentRun = m_harfbuzzRuns[runIndex].get();
- FloatPoint firstOffsetOfNextRun = !runIndex ? FloatPoint() : m_harfbuzzRuns[runIndex - 1]->offsets()[0];
+ HarfBuzzRun* currentRun = m_harfBuzzRuns[runIndex].get();
+ FloatPoint firstOffsetOfNextRun = !runIndex ? FloatPoint() : m_harfBuzzRuns[runIndex - 1]->offsets()[0];
fillGlyphBufferFromHarfBuzzRun(glyphBuffer, currentRun, firstOffsetOfNextRun);
}
} else {
- m_startOffset = m_harfbuzzRuns.first()->offsets()[0];
+ m_startOffset = m_harfBuzzRuns.first()->offsets()[0];
for (unsigned runIndex = 0; runIndex < numRuns; ++runIndex) {
- HarfBuzzRun* currentRun = m_harfbuzzRuns[runIndex].get();
- FloatPoint firstOffsetOfNextRun = runIndex == numRuns - 1 ? FloatPoint() : m_harfbuzzRuns[runIndex + 1]->offsets()[0];
+ HarfBuzzRun* currentRun = m_harfBuzzRuns[runIndex].get();
+ FloatPoint firstOffsetOfNextRun = runIndex == numRuns - 1 ? FloatPoint() : m_harfBuzzRuns[runIndex + 1]->offsets()[0];
fillGlyphBufferFromHarfBuzzRun(glyphBuffer, currentRun, firstOffsetOfNextRun);
}
}
@@ -469,26 +628,26 @@ int HarfBuzzShaper::offsetForPosition(float targetX)
if (m_run.rtl()) {
charactersSoFar = m_normalizedBufferLength;
- for (int i = m_harfbuzzRuns.size() - 1; i >= 0; --i) {
- charactersSoFar -= m_harfbuzzRuns[i]->numCharacters();
- float nextX = currentX + m_harfbuzzRuns[i]->width();
+ for (int i = m_harfBuzzRuns.size() - 1; i >= 0; --i) {
+ charactersSoFar -= m_harfBuzzRuns[i]->numCharacters();
+ float nextX = currentX + m_harfBuzzRuns[i]->width();
float offsetForRun = targetX - currentX;
- if (offsetForRun >= 0 && offsetForRun <= m_harfbuzzRuns[i]->width()) {
+ if (offsetForRun >= 0 && offsetForRun <= m_harfBuzzRuns[i]->width()) {
// The x value in question is within this script run.
- const unsigned index = m_harfbuzzRuns[i]->characterIndexForXPosition(offsetForRun);
+ const unsigned index = m_harfBuzzRuns[i]->characterIndexForXPosition(offsetForRun);
return charactersSoFar + index;
}
currentX = nextX;
}
} else {
- for (unsigned i = 0; i < m_harfbuzzRuns.size(); ++i) {
- float nextX = currentX + m_harfbuzzRuns[i]->width();
+ for (unsigned i = 0; i < m_harfBuzzRuns.size(); ++i) {
+ float nextX = currentX + m_harfBuzzRuns[i]->width();
float offsetForRun = targetX - currentX;
- if (offsetForRun >= 0 && offsetForRun <= m_harfbuzzRuns[i]->width()) {
- const unsigned index = m_harfbuzzRuns[i]->characterIndexForXPosition(offsetForRun);
+ if (offsetForRun >= 0 && offsetForRun <= m_harfBuzzRuns[i]->width()) {
+ const unsigned index = m_harfBuzzRuns[i]->characterIndexForXPosition(offsetForRun);
return charactersSoFar + index;
}
- charactersSoFar += m_harfbuzzRuns[i]->numCharacters();
+ charactersSoFar += m_harfBuzzRuns[i]->numCharacters();
currentX = nextX;
}
}
@@ -506,18 +665,18 @@ FloatRect HarfBuzzShaper::selectionRect(const FloatPoint& point, int height, int
if (m_run.rtl())
currentX = m_totalWidth;
- for (unsigned i = 0; i < m_harfbuzzRuns.size(); ++i) {
+ for (unsigned i = 0; i < m_harfBuzzRuns.size(); ++i) {
if (m_run.rtl())
- currentX -= m_harfbuzzRuns[i]->width();
- int numCharacters = m_harfbuzzRuns[i]->numCharacters();
+ currentX -= m_harfBuzzRuns[i]->width();
+ int numCharacters = m_harfBuzzRuns[i]->numCharacters();
if (!foundFromX && from >= 0 && from < numCharacters) {
- fromX = m_harfbuzzRuns[i]->xPositionForOffset(from) + currentX;
+ fromX = m_harfBuzzRuns[i]->xPositionForOffset(from) + currentX;
foundFromX = true;
} else
from -= numCharacters;
if (!foundToX && to >= 0 && to < numCharacters) {
- toX = m_harfbuzzRuns[i]->xPositionForOffset(to) + currentX;
+ toX = m_harfBuzzRuns[i]->xPositionForOffset(to) + currentX;
foundToX = true;
} else
to -= numCharacters;
@@ -525,7 +684,7 @@ FloatRect HarfBuzzShaper::selectionRect(const FloatPoint& point, int height, int
if (foundFromX && foundToX)
break;
if (!m_run.rtl())
- currentX += m_harfbuzzRuns[i]->width();
+ currentX += m_harfBuzzRuns[i]->width();
}
// The position in question might be just after the text.
diff --git a/Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.h b/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.h
index 92ed1911d..5a3d4fbdc 100644
--- a/Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.h
+++ b/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.h
@@ -33,21 +33,27 @@
#include "FloatPoint.h"
#include "GlyphBuffer.h"
-#include "HarfBuzzShaperBase.h"
#include "TextRun.h"
#include "hb.h"
#include <wtf/HashSet.h>
+#include <wtf/OwnArrayPtr.h>
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/Vector.h>
+#include <wtf/unicode/CharacterNames.h>
namespace WebCore {
class Font;
class SimpleFontData;
-class HarfBuzzShaper : public HarfBuzzShaperBase {
+class HarfBuzzShaper {
public:
+ enum NormalizeMode {
+ DoNotNormalizeMirrorChars,
+ NormalizeMirrorChars
+ };
+
HarfBuzzShaper(const Font*, const TextRun&);
virtual ~HarfBuzzShaper();
@@ -101,6 +107,17 @@ private:
float m_width;
};
+ void setNormalizedBuffer(NormalizeMode = DoNotNormalizeMirrorChars);
+
+ bool isWordEnd(unsigned);
+ int determineWordBreakSpacing();
+ // setPadding sets a number of pixels to be distributed across the TextRun.
+ // WebKit uses this to justify text.
+ void setPadding(int);
+
+ // In complex text word-spacing affects each line-break, space (U+0020) and non-breaking space (U+00A0).
+ static bool isCodepointSpace(UChar c) { return c == ' ' || c == noBreakSpace || c == '\n'; }
+
void setFontFeatures();
bool collectHarfBuzzRuns();
@@ -111,8 +128,19 @@ private:
GlyphBufferAdvance createGlyphBufferAdvance(float, float);
+ const Font* m_font;
+ OwnArrayPtr<UChar> m_normalizedBuffer;
+ unsigned m_normalizedBufferLength;
+ const TextRun& m_run;
+
+ int m_wordSpacingAdjustment; // Delta adjustment (pixels) for each word break.
+ float m_padding; // Pixels to be distributed over the line at word breaks.
+ float m_padPerWordBreak; // Pixels to be added to each word break.
+ float m_padError; // m_padPerWordBreak might have a fractional component. Since we only add a whole number of padding pixels at each word break we accumulate error. This is the number of pixels that we are behind so far.
+ int m_letterSpacing; // Pixels to be added after each glyph.
+
Vector<hb_feature_t, 4> m_features;
- Vector<OwnPtr<HarfBuzzRun>, 16> m_harfbuzzRuns;
+ Vector<OwnPtr<HarfBuzzRun>, 16> m_harfBuzzRuns;
FloatPoint m_startOffset;
diff --git a/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaperBase.cpp b/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaperBase.cpp
deleted file mode 100644
index 1b9b7d3a4..000000000
--- a/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaperBase.cpp
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright (c) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "HarfBuzzShaperBase.h"
-
-#include "Font.h"
-#include <unicode/normlzr.h>
-#include <unicode/uchar.h>
-#include <wtf/MathExtras.h>
-#include <wtf/unicode/Unicode.h>
-
-namespace WebCore {
-
-HarfBuzzShaperBase::HarfBuzzShaperBase(const Font* font, const TextRun& run)
- : m_font(font)
- , m_normalizedBufferLength(0)
- , m_run(run)
- , m_wordSpacingAdjustment(font->wordSpacing())
- , m_padding(0)
- , m_padPerWordBreak(0)
- , m_padError(0)
- , m_letterSpacing(font->letterSpacing())
-{
-}
-
-static void normalizeSpacesAndMirrorChars(const UChar* source, UChar* destination, int length, HarfBuzzShaperBase::NormalizeMode normalizeMode)
-{
- int position = 0;
- bool error = false;
- // Iterate characters in source and mirror character if needed.
- while (position < length) {
- UChar32 character;
- int nextPosition = position;
- U16_NEXT(source, nextPosition, length, character);
- // Don't normalize tabs as they are not treated as spaces for word-end
- if (Font::treatAsSpace(character) && character != '\t')
- character = ' ';
- else if (Font::treatAsZeroWidthSpace(character))
- character = zeroWidthSpace;
- else if (normalizeMode == HarfBuzzShaperBase::NormalizeMirrorChars)
- character = u_charMirror(character);
- U16_APPEND(destination, position, length, character, error);
- ASSERT_UNUSED(error, !error);
- position = nextPosition;
- }
-}
-
-void HarfBuzzShaperBase::setNormalizedBuffer(NormalizeMode normalizeMode)
-{
- // Normalize the text run in three ways:
- // 1) Convert the |originalRun| to NFC normalized form if combining diacritical marks
- // (U+0300..) are used in the run. This conversion is necessary since most OpenType
- // fonts (e.g., Arial) don't have substitution rules for the diacritical marks in
- // their GSUB tables.
- //
- // Note that we don't use the icu::Normalizer::isNormalized(UNORM_NFC) API here since
- // the API returns FALSE (= not normalized) for complex runs that don't require NFC
- // normalization (e.g., Arabic text). Unless the run contains the diacritical marks,
- // HarfBuzz will do the same thing for us using the GSUB table.
- // 2) Convert spacing characters into plain spaces, as some fonts will provide glyphs
- // for characters like '\n' otherwise.
- // 3) Convert mirrored characters such as parenthesis for rtl text.
-
- // Convert to NFC form if the text has diacritical marks.
- icu::UnicodeString normalizedString;
- UErrorCode error = U_ZERO_ERROR;
-
- for (int i = 0; i < m_run.length(); ++i) {
- UChar ch = m_run[i];
- if (::ublock_getCode(ch) == UBLOCK_COMBINING_DIACRITICAL_MARKS) {
- icu::Normalizer::normalize(icu::UnicodeString(m_run.characters16(),
- m_run.length()), UNORM_NFC, 0 /* no options */,
- normalizedString, error);
- if (U_FAILURE(error))
- normalizedString.remove();
- break;
- }
- }
-
- const UChar* sourceText;
- if (normalizedString.isEmpty()) {
- m_normalizedBufferLength = m_run.length();
- sourceText = m_run.characters16();
- } else {
- m_normalizedBufferLength = normalizedString.length();
- sourceText = normalizedString.getBuffer();
- }
-
- m_normalizedBuffer = adoptArrayPtr(new UChar[m_normalizedBufferLength + 1]);
- normalizeSpacesAndMirrorChars(sourceText, m_normalizedBuffer.get(), m_normalizedBufferLength, normalizeMode);
-}
-
-bool HarfBuzzShaperBase::isWordEnd(unsigned index)
-{
- // This could refer a high-surrogate, but should work.
- return index && isCodepointSpace(m_normalizedBuffer[index]);
-}
-
-int HarfBuzzShaperBase::determineWordBreakSpacing()
-{
- int wordBreakSpacing = m_wordSpacingAdjustment;
-
- if (m_padding > 0) {
- int toPad = roundf(m_padPerWordBreak + m_padError);
- m_padError += m_padPerWordBreak - toPad;
-
- if (m_padding < toPad)
- toPad = m_padding;
- m_padding -= toPad;
- wordBreakSpacing += toPad;
- }
- return wordBreakSpacing;
-}
-
-// setPadding sets a number of pixels to be distributed across the TextRun.
-// WebKit uses this to justify text.
-void HarfBuzzShaperBase::setPadding(int padding)
-{
- m_padding = padding;
- m_padError = 0;
- if (!m_padding)
- return;
-
- // If we have padding to distribute, then we try to give an equal
- // amount to each space. The last space gets the smaller amount, if
- // any.
- unsigned numWordEnds = 0;
-
- for (unsigned i = 0; i < m_normalizedBufferLength; i++) {
- if (isWordEnd(i))
- numWordEnds++;
- }
-
- if (numWordEnds)
- m_padPerWordBreak = m_padding / numWordEnds;
- else
- m_padPerWordBreak = 0;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaperBase.h b/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaperBase.h
deleted file mode 100644
index be368b2d1..000000000
--- a/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaperBase.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef HarfBuzzShaperBase_h
-#define HarfBuzzShaperBase_h
-
-#include "TextRun.h"
-#include <wtf/OwnArrayPtr.h>
-#include <wtf/unicode/CharacterNames.h>
-
-namespace WebCore {
-
-class Font;
-
-class HarfBuzzShaperBase {
-public:
- enum NormalizeMode {
- DoNotNormalizeMirrorChars,
- NormalizeMirrorChars
- };
-
- HarfBuzzShaperBase(const Font*, const TextRun&);
- virtual ~HarfBuzzShaperBase() { }
-
-protected:
- void setNormalizedBuffer(NormalizeMode = DoNotNormalizeMirrorChars);
-
- bool isWordEnd(unsigned);
- int determineWordBreakSpacing();
- // setPadding sets a number of pixels to be distributed across the TextRun.
- // WebKit uses this to justify text.
- void setPadding(int);
-
- // In complex text word-spacing affects each line-break, space (U+0020) and non-breaking space (U+00A0).
- static bool isCodepointSpace(UChar c) { return c == ' ' || c == noBreakSpace || c == '\n'; }
-
- const Font* m_font;
- OwnArrayPtr<UChar> m_normalizedBuffer;
- unsigned m_normalizedBufferLength;
- const TextRun& m_run;
-
- int m_wordSpacingAdjustment; // delta adjustment (pixels) for each word break.
- float m_padding; // pixels to be distributed over the line at word breaks.
- float m_padPerWordBreak; // pixels to be added to each word break.
- float m_padError; // |m_padPerWordBreak| might have a fractional component.
- // Since we only add a whole number of padding pixels at
- // each word break we accumulate error. This is the
- // number of pixels that we are behind so far.
- int m_letterSpacing; // pixels to be added after each glyph.
-};
-
-} // namespace WebCore
-
-#endif // HarfBuzzShaperBase_h
diff --git a/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzSkia.cpp b/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzSkia.cpp
deleted file mode 100644
index 1e8867bb7..000000000
--- a/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzSkia.cpp
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * Copyright (c) 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "HarfBuzzSkia.h"
-
-#include "FontPlatformData.h"
-
-#include "SkFontHost.h"
-#include "SkPaint.h"
-#include "SkPath.h"
-#include "SkPoint.h"
-#include "SkRect.h"
-#include "SkUtils.h"
-
-#include <wtf/HashMap.h>
-#include <wtf/OwnArrayPtr.h>
-
-extern "C" {
-#include "harfbuzz-shaper.h"
-}
-
-// This file implements the callbacks which Harfbuzz requires by using Skia
-// calls. See the Harfbuzz source for references about what these callbacks do.
-
-namespace WebCore {
-
-static HB_Fixed SkiaScalarToHarfbuzzFixed(SkScalar value)
-{
- // HB_Fixed is a 26.6 fixed point format.
- return value * 64;
-}
-
-static HB_Bool stringToGlyphs(HB_Font hbFont, const HB_UChar16* characters, hb_uint32 length, HB_Glyph* glyphs, hb_uint32* glyphsSize, HB_Bool isRTL)
-{
- FontPlatformData* font = reinterpret_cast<FontPlatformData*>(hbFont->userData);
- SkPaint paint;
-
- font->setupPaint(&paint);
- paint.setTextEncoding(SkPaint::kUTF16_TextEncoding);
-
- unsigned codepoints = 0;
- for (hb_uint32 i = 0; i < length; i++) {
- if (!SkUTF16_IsHighSurrogate(characters[i]))
- codepoints++;
- if (codepoints > *glyphsSize)
- return 0;
- }
-
- int numGlyphs = paint.textToGlyphs(characters, length * sizeof(uint16_t), reinterpret_cast<uint16_t*>(glyphs));
-
- // HB_Glyph is 32-bit, but Skia outputs only 16-bit numbers. So our
- // |glyphs| array needs to be converted.
- for (int i = numGlyphs - 1; i >= 0; --i) {
- uint16_t value;
- // We use a memcpy to avoid breaking strict aliasing rules.
- memcpy(&value, reinterpret_cast<char*>(glyphs) + sizeof(uint16_t) * i, sizeof(uint16_t));
- glyphs[i] = value;
- }
-
- *glyphsSize = numGlyphs;
- return 1;
-}
-
-static void glyphsToAdvances(HB_Font hbFont, const HB_Glyph* glyphs, hb_uint32 numGlyphs, HB_Fixed* advances, int flags)
-{
- FontPlatformData* font = reinterpret_cast<FontPlatformData*>(hbFont->userData);
- SkPaint paint;
-
- font->setupPaint(&paint);
- paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
-
- OwnArrayPtr<uint16_t> glyphs16 = adoptArrayPtr(new uint16_t[numGlyphs]);
- if (!glyphs16.get())
- return;
- for (unsigned i = 0; i < numGlyphs; ++i)
- glyphs16[i] = glyphs[i];
- paint.getTextWidths(glyphs16.get(), numGlyphs * sizeof(uint16_t), reinterpret_cast<SkScalar*>(advances));
-
- // The |advances| values which Skia outputs are SkScalars, which are floats
- // in Chromium. However, Harfbuzz wants them in 26.6 fixed point format.
- // These two formats are both 32-bits long.
- for (unsigned i = 0; i < numGlyphs; ++i) {
- float value;
- // We use a memcpy to avoid breaking strict aliasing rules.
- memcpy(&value, reinterpret_cast<char*>(advances) + sizeof(float) * i, sizeof(float));
- advances[i] = SkiaScalarToHarfbuzzFixed(value);
- }
-}
-
-static HB_Bool canRender(HB_Font hbFont, const HB_UChar16* characters, hb_uint32 length)
-{
- FontPlatformData* font = reinterpret_cast<FontPlatformData*>(hbFont->userData);
- SkPaint paint;
-
- font->setupPaint(&paint);
- paint.setTextEncoding(SkPaint::kUTF16_TextEncoding);
-
- OwnArrayPtr<uint16_t> glyphs16 = adoptArrayPtr(new uint16_t[length]);
- if (!glyphs16.get())
- return 0;
- int numGlyphs = paint.textToGlyphs(characters, length * sizeof(uint16_t), glyphs16.get());
-
- bool canRender = true;
- for (int i = 0; i < numGlyphs; ++i) {
- if (!glyphs16[i]) {
- canRender = false;
- break;
- }
- }
-
- return canRender;
-}
-
-static HB_Error getOutlinePoint(HB_Font hbFont, HB_Glyph glyph, int flags, hb_uint32 point, HB_Fixed* xPos, HB_Fixed* yPos, hb_uint32* resultingNumPoints)
-{
- // We cannot provide the right position of outline points from point index.
- // Just return HB_Err_Ok with resultingNumPoints = 0 so that harfbuzz
- // falls back on using design coordinate value pair.
- // See https://bugs.webkit.org/show_bug.cgi?id=60079 for more details.
- *resultingNumPoints = 0;
- return HB_Err_Ok;
-}
-
-static void getGlyphMetrics(HB_Font hbFont, HB_Glyph glyph, HB_GlyphMetrics* metrics)
-{
- FontPlatformData* font = reinterpret_cast<FontPlatformData*>(hbFont->userData);
- SkPaint paint;
-
- font->setupPaint(&paint);
- paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
- uint16_t glyph16 = glyph;
- SkScalar width;
- SkRect bounds;
- paint.getTextWidths(&glyph16, sizeof(glyph16), &width, &bounds);
-
- metrics->x = SkiaScalarToHarfbuzzFixed(bounds.fLeft);
- metrics->y = SkiaScalarToHarfbuzzFixed(bounds.fTop);
- metrics->width = SkiaScalarToHarfbuzzFixed(bounds.width());
- metrics->height = SkiaScalarToHarfbuzzFixed(bounds.height());
-
- metrics->xOffset = SkiaScalarToHarfbuzzFixed(width);
- // We can't actually get the |y| correct because Skia doesn't export
- // the vertical advance. However, nor we do ever render vertical text at
- // the moment so it's unimportant.
- metrics->yOffset = 0;
-}
-
-static HB_Fixed getFontMetric(HB_Font hbFont, HB_FontMetric metric)
-{
- FontPlatformData* font = reinterpret_cast<FontPlatformData*>(hbFont->userData);
- SkPaint paint;
-
- font->setupPaint(&paint);
- SkPaint::FontMetrics skiaMetrics;
- paint.getFontMetrics(&skiaMetrics);
-
- switch (metric) {
- case HB_FontAscent:
- return SkiaScalarToHarfbuzzFixed(-skiaMetrics.fAscent);
- // We don't support getting the rest of the metrics and Harfbuzz doesn't seem to need them.
- default:
- return 0;
- }
-}
-
-HB_FontClass harfbuzzSkiaClass = {
- stringToGlyphs,
- glyphsToAdvances,
- canRender,
- getOutlinePoint,
- getGlyphMetrics,
- getFontMetric,
-};
-
-HB_Font_* allocHarfbuzzFont()
-{
- HB_Font_* font = reinterpret_cast<HB_Font_*>(fastMalloc(sizeof(HB_Font_)));
- memset(font, 0, sizeof(HB_Font_));
- font->klass = &harfbuzzSkiaClass;
- font->userData = 0;
-
- return font;
-}
-
-HB_Error harfbuzzSkiaGetTable(void* voidface, const HB_Tag tag, HB_Byte* buffer, HB_UInt* len)
-{
- FontPlatformData* font = reinterpret_cast<FontPlatformData*>(voidface);
-
- const size_t tableSize = SkFontHost::GetTableSize(font->uniqueID(), tag);
- if (!tableSize)
- return HB_Err_Invalid_Argument;
- // If Harfbuzz specified a 0 buffer then it's asking for the size of the table.
- if (!buffer) {
- *len = tableSize;
- return HB_Err_Ok;
- }
-
- if (*len < tableSize)
- return HB_Err_Invalid_Argument;
- SkFontHost::GetTableData(font->uniqueID(), tag, 0, tableSize, buffer);
- return HB_Err_Ok;
-}
-
-typedef pair<HB_FaceRec_*, unsigned> FaceCacheEntry;
-typedef HashMap<unsigned int, FaceCacheEntry, WTF::IntHash<unsigned int>, WTF::UnsignedWithZeroKeyHashTraits<unsigned int> > HarfbuzzFaceCache;
-static HarfbuzzFaceCache* gHarfbuzzFaceCache = 0;
-
-static HB_FaceRec_* getCachedHarfbuzzFace(FontPlatformData* platformData)
-{
- if (!gHarfbuzzFaceCache)
- gHarfbuzzFaceCache = new HarfbuzzFaceCache;
- SkFontID uniqueID = platformData->uniqueID();
- HarfbuzzFaceCache::iterator result = gHarfbuzzFaceCache->find(uniqueID);
- if (result == gHarfbuzzFaceCache->end()) {
- FaceCacheEntry entry(HB_NewFace(platformData, harfbuzzSkiaGetTable), 1);
- gHarfbuzzFaceCache->set(uniqueID, entry);
- return entry.first;
- }
- ++(result.get()->value.second);
- return result.get()->value.first;
-}
-
-static void releaseCachedHarfbuzzFace(SkFontID uniqueID)
-{
- HarfbuzzFaceCache::iterator result = gHarfbuzzFaceCache->find(uniqueID);
- ASSERT(result != gHarfbuzzFaceCache->end());
- ASSERT(result.get()->value.second > 0);
- --(result.get()->value.second);
- if (!(result.get()->value.second)) {
- HB_FreeFace(result.get()->value.first);
- gHarfbuzzFaceCache->remove(uniqueID);
- }
-}
-
-HarfbuzzFace::HarfbuzzFace(FontPlatformData* platformData)
- : m_uniqueID(platformData->uniqueID())
-{
- m_harfbuzzFace = getCachedHarfbuzzFace(platformData);
-}
-
-HarfbuzzFace::~HarfbuzzFace()
-{
- releaseCachedHarfbuzzFace(m_uniqueID);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzSkia.h b/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzSkia.h
deleted file mode 100644
index 316b443f1..000000000
--- a/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzSkia.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef HarfBuzzSkia_h
-#define HarfBuzzSkia_h
-
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-
-struct HB_FaceRec_;
-struct HB_Font_;
-
-namespace WebCore {
-
-class FontPlatformData;
-
-class HarfbuzzFace : public RefCounted<HarfbuzzFace> {
-public:
- static PassRefPtr<HarfbuzzFace> create(FontPlatformData* platformData)
- {
- return adoptRef(new HarfbuzzFace(platformData));
- }
-
- ~HarfbuzzFace();
-
- HB_FaceRec_* face() const { return m_harfbuzzFace; }
-
-private:
- explicit HarfbuzzFace(FontPlatformData*);
-
- uint32_t m_uniqueID;
- HB_FaceRec_* m_harfbuzzFace;
-};
-
-// FIXME: Remove this asymmetric alloc/free function.
-// We'll remove this once we move to the new Harfbuzz API.
-HB_Font_* allocHarfbuzzFont();
-
-} // namespace WebCore
-
-#endif
diff --git a/Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzNGFaceSkia.cpp b/Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzNGFaceSkia.cpp
deleted file mode 100644
index 5d39efa73..000000000
--- a/Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzNGFaceSkia.cpp
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Copyright (c) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "HarfBuzzNGFace.h"
-
-#include "FontPlatformData.h"
-#include "GlyphBuffer.h"
-#include "HarfBuzzShaper.h"
-#include "SimpleFontData.h"
-#include "SkFontHost.h"
-#include "SkPaint.h"
-#include "SkPath.h"
-#include "SkPoint.h"
-#include "SkRect.h"
-#include "SkUtils.h"
-
-#include "hb.h"
-#include <wtf/HashMap.h>
-
-namespace WebCore {
-
-// Our implementation of the callbacks which Harfbuzz requires by using Skia
-// calls. See the Harfbuzz source for references about what these callbacks do.
-
-struct HarfBuzzFontData {
- HarfBuzzFontData(WTF::HashMap<uint32_t, uint16_t>* glyphCacheForFaceCacheEntry)
- : m_glyphCacheForFaceCacheEntry(glyphCacheForFaceCacheEntry)
- { }
- SkPaint m_paint;
- WTF::HashMap<uint32_t, uint16_t>* m_glyphCacheForFaceCacheEntry;
-};
-
-static hb_position_t SkiaScalarToHarfbuzzPosition(SkScalar value)
-{
- return SkScalarToFixed(value);
-}
-
-static void SkiaGetGlyphWidthAndExtents(SkPaint* paint, hb_codepoint_t codepoint, hb_position_t* width, hb_glyph_extents_t* extents)
-{
- ASSERT(codepoint <= 0xFFFF);
- paint->setTextEncoding(SkPaint::kGlyphID_TextEncoding);
-
- SkScalar skWidth;
- SkRect skBounds;
- uint16_t glyph = codepoint;
-
- paint->getTextWidths(&glyph, sizeof(glyph), &skWidth, &skBounds);
- if (width)
- *width = SkiaScalarToHarfbuzzPosition(skWidth);
- if (extents) {
- // Invert y-axis because Skia is y-grows-down but we set up harfbuzz to be y-grows-up.
- extents->x_bearing = SkiaScalarToHarfbuzzPosition(skBounds.fLeft);
- extents->y_bearing = SkiaScalarToHarfbuzzPosition(-skBounds.fTop);
- extents->width = SkiaScalarToHarfbuzzPosition(skBounds.width());
- extents->height = SkiaScalarToHarfbuzzPosition(-skBounds.height());
- }
-}
-
-static hb_bool_t harfbuzzGetGlyph(hb_font_t* hbFont, void* fontData, hb_codepoint_t unicode, hb_codepoint_t variationSelector, hb_codepoint_t* glyph, void* userData)
-{
- HarfBuzzFontData* hbFontData = reinterpret_cast<HarfBuzzFontData*>(fontData);
-
- WTF::HashMap<uint32_t, uint16_t>::AddResult result = hbFontData->m_glyphCacheForFaceCacheEntry->add(unicode, 0);
- if (result.isNewEntry) {
- SkPaint* paint = &hbFontData->m_paint;
- paint->setTextEncoding(SkPaint::kUTF32_TextEncoding);
- uint16_t glyph16;
- paint->textToGlyphs(&unicode, sizeof(hb_codepoint_t), &glyph16);
- result.iterator->value = glyph16;
- *glyph = glyph16;
- }
- *glyph = result.iterator->value;
- return !!*glyph;
-}
-
-static hb_position_t harfbuzzGetGlyphHorizontalAdvance(hb_font_t* hbFont, void* fontData, hb_codepoint_t glyph, void* userData)
-{
- HarfBuzzFontData* hbFontData = reinterpret_cast<HarfBuzzFontData*>(fontData);
- hb_position_t advance = 0;
-
- SkiaGetGlyphWidthAndExtents(&hbFontData->m_paint, glyph, &advance, 0);
- return advance;
-}
-
-static hb_bool_t harfbuzzGetGlyphHorizontalOrigin(hb_font_t* hbFont, void* fontData, hb_codepoint_t glyph, hb_position_t* x, hb_position_t* y, void* userData)
-{
- // Just return true, following the way that Harfbuzz-FreeType
- // implementation does.
- return true;
-}
-
-static hb_bool_t harfbuzzGetGlyphExtents(hb_font_t* hbFont, void* fontData, hb_codepoint_t glyph, hb_glyph_extents_t* extents, void* userData)
-{
- HarfBuzzFontData* hbFontData = reinterpret_cast<HarfBuzzFontData*>(fontData);
-
- SkiaGetGlyphWidthAndExtents(&hbFontData->m_paint, glyph, 0, extents);
- return true;
-}
-
-static hb_font_funcs_t* harfbuzzSkiaGetFontFuncs()
-{
- static hb_font_funcs_t* harfbuzzSkiaFontFuncs = 0;
-
- // We don't set callback functions which we can't support.
- // Harfbuzz will use the fallback implementation if they aren't set.
- if (!harfbuzzSkiaFontFuncs) {
- harfbuzzSkiaFontFuncs = hb_font_funcs_create();
- hb_font_funcs_set_glyph_func(harfbuzzSkiaFontFuncs, harfbuzzGetGlyph, 0, 0);
- hb_font_funcs_set_glyph_h_advance_func(harfbuzzSkiaFontFuncs, harfbuzzGetGlyphHorizontalAdvance, 0, 0);
- hb_font_funcs_set_glyph_h_origin_func(harfbuzzSkiaFontFuncs, harfbuzzGetGlyphHorizontalOrigin, 0, 0);
- hb_font_funcs_set_glyph_extents_func(harfbuzzSkiaFontFuncs, harfbuzzGetGlyphExtents, 0, 0);
- hb_font_funcs_make_immutable(harfbuzzSkiaFontFuncs);
- }
- return harfbuzzSkiaFontFuncs;
-}
-
-static hb_blob_t* harfbuzzSkiaGetTable(hb_face_t* face, hb_tag_t tag, void* userData)
-{
- SkFontID uniqueID = static_cast<SkFontID>(reinterpret_cast<uint64_t>(userData));
-
- const size_t tableSize = SkFontHost::GetTableSize(uniqueID, tag);
- if (!tableSize)
- return 0;
-
- char* buffer = reinterpret_cast<char*>(fastMalloc(tableSize));
- if (!buffer)
- return 0;
- size_t actualSize = SkFontHost::GetTableData(uniqueID, tag, 0, tableSize, buffer);
- if (tableSize != actualSize) {
- fastFree(buffer);
- return 0;
- }
-
- return hb_blob_create(const_cast<char*>(buffer), tableSize,
- HB_MEMORY_MODE_WRITABLE, buffer, fastFree);
-}
-
-static void destroyHarfBuzzFontData(void* userData)
-{
- HarfBuzzFontData* hbFontData = reinterpret_cast<HarfBuzzFontData*>(userData);
- delete hbFontData;
-}
-
-hb_face_t* HarfBuzzNGFace::createFace()
-{
- hb_face_t* face = hb_face_create_for_tables(harfbuzzSkiaGetTable, reinterpret_cast<void*>(m_platformData->uniqueID()), 0);
- ASSERT(face);
- return face;
-}
-
-hb_font_t* HarfBuzzNGFace::createFont()
-{
- HarfBuzzFontData* hbFontData = new HarfBuzzFontData(m_glyphCacheForFaceCacheEntry);
- m_platformData->setupPaint(&hbFontData->m_paint);
- hb_font_t* font = hb_font_create(m_face);
- hb_font_set_funcs(font, harfbuzzSkiaGetFontFuncs(), hbFontData, destroyHarfBuzzFontData);
- float size = m_platformData->size();
- int scale = SkiaScalarToHarfbuzzPosition(size);
- hb_font_set_scale(font, scale, scale);
- hb_font_make_immutable(font);
- return font;
-}
-
-GlyphBufferAdvance HarfBuzzShaper::createGlyphBufferAdvance(float width, float height)
-{
- return GlyphBufferAdvance(width, height);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/mac/ColorMac.mm b/Source/WebCore/platform/graphics/mac/ColorMac.mm
index 07d635381..3bc3a5798 100644
--- a/Source/WebCore/platform/graphics/mac/ColorMac.mm
+++ b/Source/WebCore/platform/graphics/mac/ColorMac.mm
@@ -26,13 +26,12 @@
#import "config.h"
#import "ColorMac.h"
+#import <WebCore/BlockExceptions.h>
#import <wtf/RetainPtr.h>
#import <wtf/StdLibExtras.h>
namespace WebCore {
-// NSColor calls don't throw, so no need to block Cocoa exceptions in this file
-
static bool useOldAquaFocusRingColor;
RGBA32 oldAquaFocusRingColor()
@@ -56,7 +55,14 @@ static RGBA32 makeRGBAFromNSColor(NSColor *c)
CGFloat greenComponent;
CGFloat blueComponent;
CGFloat alpha;
- [c getRed:&redComponent green:&greenComponent blue:&blueComponent alpha:&alpha];
+
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
+ NSColor *rgbColor = [c colorUsingColorSpaceName:NSDeviceRGBColorSpace];
+ if (!rgbColor)
+ return makeRGBA(0, 0, 0, 0);
+
+ [rgbColor getRed:&redComponent green:&greenComponent blue:&blueComponent alpha:&alpha];
+ END_BLOCK_OBJC_EXCEPTIONS;
return makeRGBA(255 * redComponent, 255 * greenComponent, 255 * blueComponent, 255 * alpha);
}
diff --git a/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp b/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp
index 87bd52dc0..ace6071e2 100644
--- a/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp
+++ b/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp
@@ -159,9 +159,17 @@ ComplexTextController::ComplexTextController(const Font* font, const TextRun& ru
collectComplexTextRuns();
adjustGlyphsAndAdvances();
- if (!m_isLTROnly)
+ if (!m_isLTROnly) {
m_runIndices.reserveInitialCapacity(m_complexTextRuns.size());
+ m_glyphCountFromStartToIndex.reserveInitialCapacity(m_complexTextRuns.size());
+ unsigned glyphCountSoFar = 0;
+ for (unsigned i = 0; i < m_complexTextRuns.size(); ++i) {
+ m_glyphCountFromStartToIndex.uncheckedAppend(glyphCountSoFar);
+ glyphCountSoFar += m_complexTextRuns[i]->glyphCount();
+ }
+ }
+
m_runWidthSoFar = m_leadingExpansion;
}
@@ -327,11 +335,9 @@ void ComplexTextController::collectComplexTextRuns()
}
nextIsMissingGlyph = false;
-#if !PLATFORM(WX)
nextFontData = m_font.fontDataForCombiningCharacterSequence(sequenceStart, curr - sequenceStart, nextIsSmallCaps ? SmallCapsVariant : NormalVariant);
if (!nextFontData)
nextIsMissingGlyph = true;
-#endif
while (curr < end) {
fontData = nextFontData;
@@ -354,13 +360,11 @@ void ComplexTextController::collectComplexTextRuns()
nextIsMissingGlyph = false;
if (baseCharacter == zeroWidthJoiner)
nextFontData = fontData;
-#if !PLATFORM(WX)
else {
nextFontData = m_font.fontDataForCombiningCharacterSequence(cp + index, curr - cp - index, nextIsSmallCaps ? SmallCapsVariant : NormalVariant);
if (!nextFontData)
nextIsMissingGlyph = true;
}
-#endif
if (nextFontData != fontData || nextIsMissingGlyph != isMissingGlyph) {
int itemStart = static_cast<int>(indexOfFontTransition);
@@ -423,8 +427,21 @@ unsigned ComplexTextController::indexOfCurrentRun(unsigned& leftmostGlyph)
return m_currentRun;
}
+ if (m_runIndices.isEmpty()) {
+ unsigned firstRun = 0;
+ unsigned firstRunOffset = stringBegin(*m_complexTextRuns[0]);
+ for (unsigned i = 1; i < runCount; ++i) {
+ unsigned offset = stringBegin(*m_complexTextRuns[i]);
+ if (offset < firstRunOffset) {
+ firstRun = i;
+ firstRunOffset = offset;
+ }
+ }
+ m_runIndices.uncheckedAppend(firstRun);
+ }
+
while (m_runIndices.size() <= m_currentRun) {
- unsigned offset = m_runIndices.isEmpty() ? 0 : stringEnd(*m_complexTextRuns[m_runIndices.last()]);
+ unsigned offset = stringEnd(*m_complexTextRuns[m_runIndices.last()]);
for (unsigned i = 0; i < runCount; ++i) {
if (offset == stringBegin(*m_complexTextRuns[i])) {
@@ -435,8 +452,7 @@ unsigned ComplexTextController::indexOfCurrentRun(unsigned& leftmostGlyph)
}
unsigned currentRunIndex = m_runIndices[m_currentRun];
- for (unsigned i = 0; i < currentRunIndex; ++i)
- leftmostGlyph += m_complexTextRuns[i]->glyphCount();
+ leftmostGlyph = m_glyphCountFromStartToIndex[currentRunIndex];
return currentRunIndex;
}
@@ -480,6 +496,12 @@ void ComplexTextController::advance(unsigned offset, GlyphBuffer* glyphBuffer, G
if (fallbackFonts && complexTextRun.fontData() != m_font.primaryFont())
fallbackFonts->add(complexTextRun.fontData());
+ // We must store the initial advance for the first glyph we are going to draw.
+ // When leftmostGlyph is 0, it represents the first glyph to draw, taking into
+ // account the text direction.
+ if (glyphBuffer && !leftmostGlyph)
+ glyphBuffer->setInitialAdvance(complexTextRun.initialAdvance());
+
while (m_glyphInCurrentRun < glyphCount) {
unsigned glyphStartOffset = complexTextRun.indexAt(g);
unsigned glyphEndOffset;
@@ -545,6 +567,15 @@ void ComplexTextController::adjustGlyphsAndAdvances()
unsigned glyphCount = complexTextRun.glyphCount();
const SimpleFontData* fontData = complexTextRun.fontData();
+ // Represent the initial advance for a text run by adjusting the advance
+ // of the last glyph of the previous text run in the glyph buffer.
+ if (r && m_adjustedAdvances.size()) {
+ CGSize previousAdvance = m_adjustedAdvances.last();
+ previousAdvance.width += complexTextRun.initialAdvance().width;
+ previousAdvance.height -= complexTextRun.initialAdvance().height;
+ m_adjustedAdvances[m_adjustedAdvances.size() - 1] = previousAdvance;
+ }
+
if (!complexTextRun.isLTR())
m_isLTROnly = false;
diff --git a/Source/WebCore/platform/graphics/mac/ComplexTextController.h b/Source/WebCore/platform/graphics/mac/ComplexTextController.h
index b0dc0713e..3c69f89c3 100644
--- a/Source/WebCore/platform/graphics/mac/ComplexTextController.h
+++ b/Source/WebCore/platform/graphics/mac/ComplexTextController.h
@@ -94,6 +94,7 @@ private:
CFIndex indexEnd() const { return m_indexEnd; }
CFIndex endOffsetAt(size_t i) const { ASSERT(!m_isMonotonic); return m_glyphEndOffsets[i]; }
const CGGlyph* glyphs() const { return m_glyphs; }
+ CGSize initialAdvance() const { return m_initialAdvance; }
const CGSize* advances() const { return m_advances; }
bool isLTR() const { return m_isLTR; }
bool isMonotonic() const { return m_isMonotonic; }
@@ -115,6 +116,7 @@ private:
Vector<CFIndex, 64> m_glyphEndOffsets;
Vector<CGGlyph, 64> m_glyphsVector;
const CGGlyph* m_glyphs;
+ CGSize m_initialAdvance;
Vector<CGSize, 64> m_advancesVector;
const CGSize* m_advances;
bool m_isLTR;
@@ -132,9 +134,10 @@ private:
unsigned indexOfCurrentRun(unsigned& leftmostGlyph);
unsigned incrementCurrentRun(unsigned& leftmostGlyph);
- // The default size of this vector was selected as being the smallest power of two greater than
+ // The initial capacity of these vectors was selected as being the smallest power of two greater than
// the average (3.5) plus one standard deviation (7.5) of nonzero sizes used on Arabic Wikipedia.
Vector<unsigned, 16> m_runIndices;
+ Vector<unsigned, 16> m_glyphCountFromStartToIndex;
const Font& m_font;
const TextRun& m_run;
diff --git a/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm b/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm
index 6250968e7..c588a47dd 100644
--- a/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm
+++ b/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm
@@ -33,15 +33,6 @@
#include <ApplicationServices/ApplicationServices.h>
-#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1050
-// The following symbols are SPI in 10.5.
-extern "C" {
-void CTRunGetAdvances(CTRunRef run, CFRange range, CGSize buffer[]);
-const CGSize* CTRunGetAdvancesPtr(CTRunRef run);
-extern const CFStringRef kCTTypesetterOptionForcedEmbeddingLevel;
-}
-#endif
-
@interface WebCascadeList : NSArray {
@private
const WebCore::Font* _font;
@@ -88,7 +79,7 @@ extern const CFStringRef kCTTypesetterOptionForcedEmbeddingLevel;
const WebCore::SimpleFontData* fontData = _font->fontDataAt(index)->fontDataForCharacter(_character);
fontDescriptor = CTFontCopyFontDescriptor(fontData->platformData().ctFont());
- _fontDescriptors[index] = RetainPtr<CTFontDescriptorRef>(AdoptCF, fontDescriptor);
+ _fontDescriptors[index] = adoptCF(fontDescriptor);
return (id)fontDescriptor;
}
@@ -103,6 +94,7 @@ ComplexTextController::ComplexTextRun::ComplexTextRun(CTRunRef ctRun, const Simp
, m_stringLength(stringLength)
, m_indexBegin(runRange.location)
, m_indexEnd(runRange.location + runRange.length)
+ , m_initialAdvance(wkCTRunGetInitialAdvance(ctRun))
, m_isLTR(!(CTRunGetStatus(ctRun) & kCTRunStatusRightToLeft))
, m_isMonotonic(true)
{
@@ -138,6 +130,7 @@ ComplexTextController::ComplexTextRun::ComplexTextRun(const SimpleFontData* font
, m_stringLength(stringLength)
, m_indexBegin(0)
, m_indexEnd(stringLength)
+ , m_initialAdvance(CGSizeZero)
, m_isLTR(ltr)
, m_isMonotonic(true)
{
@@ -203,14 +196,14 @@ void ComplexTextController::collectComplexTextRunsForCharacters(const UChar* cp,
U16_GET(cp, 0, 0, length, baseCharacter);
fontData = m_font.fontDataAt(0)->fontDataForCharacter(baseCharacter);
- RetainPtr<WebCascadeList> cascadeList(AdoptNS, [[WebCascadeList alloc] initWithFont:&m_font character:baseCharacter]);
+ RetainPtr<WebCascadeList> cascadeList = adoptNS([[WebCascadeList alloc] initWithFont:&m_font character:baseCharacter]);
- stringAttributes.adoptCF(CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, fontData->getCFStringAttributes(m_font.typesettingFeatures(), fontData->platformData().orientation())));
+ stringAttributes = adoptCF(CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, fontData->getCFStringAttributes(m_font.typesettingFeatures(), fontData->platformData().orientation())));
static const void* attributeKeys[] = { kCTFontCascadeListAttribute };
const void* values[] = { cascadeList.get() };
- RetainPtr<CFDictionaryRef> attributes(AdoptCF, CFDictionaryCreate(kCFAllocatorDefault, attributeKeys, values, sizeof(attributeKeys) / sizeof(*attributeKeys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
- RetainPtr<CTFontDescriptorRef> fontDescriptor(AdoptCF, CTFontDescriptorCreateWithAttributes(attributes.get()));
- RetainPtr<CTFontRef> fontWithCascadeList(AdoptCF, CTFontCreateCopyWithAttributes(fontData->platformData().ctFont(), m_font.pixelSize(), 0, fontDescriptor.get()));
+ RetainPtr<CFDictionaryRef> attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, attributeKeys, values, sizeof(attributeKeys) / sizeof(*attributeKeys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+ RetainPtr<CTFontDescriptorRef> fontDescriptor = adoptCF(CTFontDescriptorCreateWithAttributes(attributes.get()));
+ RetainPtr<CTFontRef> fontWithCascadeList = adoptCF(CTFontCreateCopyWithAttributes(fontData->platformData().ctFont(), m_font.pixelSize(), 0, fontDescriptor.get()));
CFDictionarySetValue(const_cast<CFMutableDictionaryRef>(stringAttributes.get()), kCTFontAttributeName, fontWithCascadeList.get());
} else
stringAttributes = fontData->getCFStringAttributes(m_font.typesettingFeatures(), fontData->platformData().orientation());
@@ -228,18 +221,18 @@ void ComplexTextController::collectComplexTextRunsForCharacters(const UChar* cp,
#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
ProviderInfo info = { cp, length, stringAttributes.get() };
- RetainPtr<CTTypesetterRef> typesetter(AdoptCF, wkCreateCTTypesetterWithUniCharProviderAndOptions(&provideStringAndAttributes, 0, &info, m_run.ltr() ? ltrTypesetterOptions : rtlTypesetterOptions));
+ RetainPtr<CTTypesetterRef> typesetter = adoptCF(wkCreateCTTypesetterWithUniCharProviderAndOptions(&provideStringAndAttributes, 0, &info, m_run.ltr() ? ltrTypesetterOptions : rtlTypesetterOptions));
#else
- RetainPtr<CFStringRef> string(AdoptCF, CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, cp, length, kCFAllocatorNull));
- RetainPtr<CFAttributedStringRef> attributedString(AdoptCF, CFAttributedStringCreate(kCFAllocatorDefault, string.get(), stringAttributes.get()));
- RetainPtr<CTTypesetterRef> typesetter(AdoptCF, CTTypesetterCreateWithAttributedStringAndOptions(attributedString.get(), m_run.ltr() ? ltrTypesetterOptions : rtlTypesetterOptions));
+ RetainPtr<CFStringRef> string = adoptCF(CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, cp, length, kCFAllocatorNull));
+ RetainPtr<CFAttributedStringRef> attributedString = adoptCF(CFAttributedStringCreate(kCFAllocatorDefault, string.get(), stringAttributes.get()));
+ RetainPtr<CTTypesetterRef> typesetter = adoptCF(CTTypesetterCreateWithAttributedStringAndOptions(attributedString.get(), m_run.ltr() ? ltrTypesetterOptions : rtlTypesetterOptions));
#endif
- line.adoptCF(CTTypesetterCreateLine(typesetter.get(), CFRangeMake(0, 0)));
+ line = adoptCF(CTTypesetterCreateLine(typesetter.get(), CFRangeMake(0, 0)));
} else {
ProviderInfo info = { cp, length, stringAttributes.get() };
- line.adoptCF(wkCreateCTLineWithUniCharProvider(&provideStringAndAttributes, 0, &info));
+ line = adoptCF(wkCreateCTLineWithUniCharProvider(&provideStringAndAttributes, 0, &info));
}
m_coreTextLines.append(line.get());
@@ -259,11 +252,11 @@ void ComplexTextController::collectComplexTextRunsForCharacters(const UChar* cp,
ASSERT(CFGetTypeID(runFont) == CTFontGetTypeID());
if (!CFEqual(runFont, fontData->platformData().ctFont())) {
// Begin trying to see if runFont matches any of the fonts in the fallback list.
- RetainPtr<CGFontRef> runCGFont(AdoptCF, CTFontCopyGraphicsFont(runFont, 0));
+ RetainPtr<CGFontRef> runCGFont = adoptCF(CTFontCopyGraphicsFont(runFont, 0));
unsigned i = 0;
for (const FontData* candidateFontData = m_font.fontDataAt(i); candidateFontData; candidateFontData = m_font.fontDataAt(++i)) {
runFontData = candidateFontData->fontDataForCharacter(baseCharacter);
- RetainPtr<CGFontRef> cgFont(AdoptCF, CTFontCopyGraphicsFont(runFontData->platformData().ctFont(), 0));
+ RetainPtr<CGFontRef> cgFont = adoptCF(CTFontCopyGraphicsFont(runFontData->platformData().ctFont(), 0));
if (CFEqual(cgFont.get(), runCGFont.get()))
break;
runFontData = 0;
@@ -273,23 +266,18 @@ void ComplexTextController::collectComplexTextRunsForCharacters(const UChar* cp,
// Rather than using runFont as an NSFont and wrapping it in a FontPlatformData, go through
// the font cache and ultimately through NSFontManager in order to get an NSFont with the right
// NSFontRenderingMode.
- RetainPtr<CFStringRef> fontName(AdoptCF, CTFontCopyPostScriptName(runFont));
+ RetainPtr<CFStringRef> fontName = adoptCF(CTFontCopyPostScriptName(runFont));
if (CFEqual(fontName.get(), CFSTR("LastResort"))) {
m_complexTextRuns.append(ComplexTextRun::create(m_font.primaryFont(), cp, stringLocation + runRange.location, runRange.length, m_run.ltr()));
continue;
}
runFontData = fontCache()->getCachedFontData(m_font.fontDescription(), fontName.get(), false, FontCache::DoNotRetain).get();
-#if !PLATFORM(WX)
// Core Text may have used a font that is not known to NSFontManager. In that case, fall back on
// using the font as returned, even though it may not have the best NSFontRenderingMode.
if (!runFontData) {
FontPlatformData runFontPlatformData((NSFont *)runFont, CTFontGetSize(runFont), m_font.fontDescription().usePrinterFont());
runFontData = fontCache()->getCachedFontData(&runFontPlatformData, FontCache::DoNotRetain).get();
}
-#else
- // just assert for now, until we can devise a better fix that works with wx.
- ASSERT(runFontData);
-#endif
}
if (m_fallbackFonts && runFontData != m_font.primaryFont())
m_fallbackFonts->add(runFontData);
diff --git a/Source/WebCore/platform/graphics/mac/FontCacheMac.mm b/Source/WebCore/platform/graphics/mac/FontCacheMac.mm
index 3fa433f3d..591fe1676 100644
--- a/Source/WebCore/platform/graphics/mac/FontCacheMac.mm
+++ b/Source/WebCore/platform/graphics/mac/FontCacheMac.mm
@@ -52,30 +52,17 @@ static void invalidateFontCache(void*)
fontCache()->invalidate();
}
-#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
static void fontCacheRegisteredFontsChangedNotificationCallback(CFNotificationCenterRef, void* observer, CFStringRef name, const void *, CFDictionaryRef)
{
ASSERT_UNUSED(observer, observer == fontCache());
ASSERT_UNUSED(name, CFEqual(name, kCTFontManagerRegisteredFontsChangedNotification));
invalidateFontCache(0);
}
-#else
-static void fontCacheATSNotificationCallback(ATSFontNotificationInfoRef, void*)
-{
- invalidateFontCache(0);
-}
-#endif
void FontCache::platformInit()
{
wkSetUpFontCache();
-#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), this, fontCacheRegisteredFontsChangedNotificationCallback, kCTFontManagerRegisteredFontsChangedNotification, 0, CFNotificationSuspensionBehaviorDeliverImmediately);
-#else
- // kCTFontManagerRegisteredFontsChangedNotification does not exist on Leopard and earlier.
- // FIXME: Passing kATSFontNotifyOptionReceiveWhileSuspended may be an overkill and does not seem to work anyway.
- ATSFontNotificationSubscribe(fontCacheATSNotificationCallback, kATSFontNotifyOptionReceiveWhileSuspended, 0, 0);
-#endif
}
static int toAppKitFontWeight(FontWeight fontWeight)
@@ -99,11 +86,11 @@ static inline bool isAppKitFontWeightBold(NSInteger appKitFontWeight)
return appKitFontWeight >= 7;
}
-PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
+PassRefPtr<SimpleFontData> FontCache::systemFallbackForCharacters(const FontDescription& description, const SimpleFontData* originalFontData, bool isPlatformFont, const UChar* characters, int length)
{
UChar32 character;
U16_GET(characters, 0, 0, length, character);
- const FontPlatformData& platformData = font.fontDataAt(0)->fontDataForCharacter(character)->platformData();
+ const FontPlatformData& platformData = originalFontData->platformData();
NSFont *nsFont = platformData.font();
NSString *string = [[NSString alloc] initWithCharactersNoCopy:const_cast<UChar*>(characters) length:length freeWhenDone:NO];
@@ -115,12 +102,6 @@ PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font,
if (!substituteFont)
return 0;
-#if PLATFORM(CHROMIUM)
- // Chromium can't render AppleColorEmoji.
- if ([[substituteFont familyName] isEqual:@"Apple Color Emoji"])
- return 0;
-#endif
-
// Use the family name from the AppKit-supplied substitute font, requesting the
// traits, weight, and size we want. One way this does better than the original
// AppKit request is that it takes synthetic bold and oblique into account.
@@ -143,9 +124,9 @@ PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font,
size = [nsFont pointSize];
} else {
// For custom fonts nsFont is nil.
- traits = font.italic() ? NSFontItalicTrait : 0;
- weight = toAppKitFontWeight(font.weight());
- size = font.pixelSize();
+ traits = description.italic() ? NSFontItalicTrait : 0;
+ weight = toAppKitFontWeight(description.weight());
+ size = description.computedPixelSize();
}
NSFontTraitMask substituteFontTraits = [fontManager traitsOfFont:substituteFont];
@@ -159,37 +140,35 @@ PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font,
}
}
- substituteFont = font.fontDescription().usePrinterFont() ? [substituteFont printerFont] : [substituteFont screenFont];
+ substituteFont = description.usePrinterFont() ? [substituteFont printerFont] : [substituteFont screenFont];
substituteFontTraits = [fontManager traitsOfFont:substituteFont];
substituteFontWeight = [fontManager weightOfFont:substituteFont];
FontPlatformData alternateFont(substituteFont, platformData.size(), platformData.isPrinterFont(),
- !font.isPlatformFont() && isAppKitFontWeightBold(weight) && !isAppKitFontWeightBold(substituteFontWeight),
- !font.isPlatformFont() && (traits & NSFontItalicTrait) && !(substituteFontTraits & NSFontItalicTrait),
+ !isPlatformFont && isAppKitFontWeightBold(weight) && !isAppKitFontWeightBold(substituteFontWeight),
+ !isPlatformFont && (traits & NSFontItalicTrait) && !(substituteFontTraits & NSFontItalicTrait),
platformData.m_orientation);
return getCachedFontData(&alternateFont, DoNotRetain);
}
-PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font& font)
+PassRefPtr<SimpleFontData> FontCache::similarFontPlatformData(const FontDescription& description)
{
// Attempt to find an appropriate font using a match based on
// the presence of keywords in the the requested names. For example, we'll
// match any name that contains "Arabic" to Geeza Pro.
RefPtr<SimpleFontData> simpleFontData;
- const FontFamily* currFamily = &font.fontDescription().family();
- while (currFamily && !simpleFontData) {
- if (currFamily->family().length()) {
- static String* matchWords[3] = { new String("Arabic"), new String("Pashto"), new String("Urdu") };
- DEFINE_STATIC_LOCAL(AtomicString, geezaStr, ("Geeza Pro", AtomicString::ConstructFromLiteral));
- for (int j = 0; j < 3 && !simpleFontData; ++j)
- if (currFamily->family().contains(*matchWords[j], false))
- simpleFontData = getCachedFontData(font.fontDescription(), geezaStr);
- }
- currFamily = currFamily->next();
+ for (unsigned i = 0; i < description.familyCount(); ++i) {
+ const AtomicString& family = description.familyAt(i);
+ if (family.isEmpty())
+ continue;
+ static String* matchWords[3] = { new String("Arabic"), new String("Pashto"), new String("Urdu") };
+ DEFINE_STATIC_LOCAL(AtomicString, geezaStr, ("Geeza Pro", AtomicString::ConstructFromLiteral));
+ for (int j = 0; j < 3 && !simpleFontData; ++j)
+ if (family.contains(*matchWords[j], false))
+ simpleFontData = getCachedFontData(description, geezaStr);
}
-
return simpleFontData.release();
}
@@ -216,7 +195,7 @@ void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigne
[WebFontCache getTraits:traitsMasks inFamily:familyName];
}
-FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
+PassOwnPtr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
{
NSFontTraitMask traits = fontDescription.italic() ? NSFontItalicTrait : 0;
NSInteger weight = toAppKitFontWeight(fontDescription.weight());
@@ -224,7 +203,7 @@ FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD
NSFont *nsFont = [WebFontCache fontWithFamily:family traits:traits weight:weight size:size];
if (!nsFont)
- return 0;
+ return nullptr;
NSFontManager *fontManager = [NSFontManager sharedFontManager];
NSFontTraitMask actualTraits = 0;
@@ -236,12 +215,8 @@ FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD
bool syntheticBold = isAppKitFontWeightBold(weight) && !isAppKitFontWeightBold(actualWeight);
bool syntheticOblique = (traits & NSFontItalicTrait) && !(actualTraits & NSFontItalicTrait);
- // FontPlatformData::font() can be null for the case of Chromium out-of-process font loading.
- // In that case, we don't want to use the platformData.
- OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platformFont, size, fontDescription.usePrinterFont(), syntheticBold, syntheticOblique, fontDescription.orientation(), fontDescription.textOrientation(), fontDescription.widthVariant()));
- if (!platformData->font())
- return 0;
- return platformData.leakPtr();
+ OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platformFont, size, fontDescription.usePrinterFont(), syntheticBold, syntheticOblique, fontDescription.orientation(), fontDescription.widthVariant()));
+ return platformData.release();
}
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp b/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp
index 9dd95e85a..d4d4df01f 100644
--- a/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp
+++ b/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp
@@ -26,7 +26,7 @@
#include "Font.h"
#include "ComplexTextController.h"
-#include "FontFallbackList.h"
+#include "FontGlyphs.h"
#include "GlyphBuffer.h"
#include "GraphicsContext.h"
#include "IntRect.h"
@@ -34,32 +34,13 @@
#include "TextRun.h"
#include <wtf/MathExtras.h>
-#if PLATFORM(CHROMIUM)
-#include "HarfBuzzShaper.h"
-#endif
-
using namespace std;
namespace WebCore {
-#if PLATFORM(CHROMIUM)
-static bool preferHarfBuzz(const Font* font)
-{
- const FontDescription& description = font->fontDescription();
- return description.featureSettings() && description.featureSettings()->size() > 0;
-}
-#endif
-
FloatRect Font::selectionRectForComplexText(const TextRun& run, const FloatPoint& point, int h,
int from, int to) const
{
-#if PLATFORM(CHROMIUM)
- if (preferHarfBuzz(this)) {
- HarfBuzzShaper shaper(this, run);
- if (shaper.shape())
- return shaper.selectionRect(point, h, from, to);
- }
-#endif
ComplexTextController controller(this, run);
controller.advance(from);
float beforeWidth = controller.runWidthSoFar();
@@ -100,17 +81,6 @@ float Font::getGlyphsAndAdvancesForComplexText(const TextRun& run, int from, int
void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
{
-#if PLATFORM(CHROMIUM)
- if (preferHarfBuzz(this)) {
- GlyphBuffer glyphBuffer;
- HarfBuzzShaper shaper(this, run);
- shaper.setDrawRange(from, to);
- if (shaper.shape(&glyphBuffer)) {
- drawGlyphBuffer(context, run, glyphBuffer, point);
- return;
- }
- }
-#endif
// This glyph buffer holds our glyphs + advances + font data for each glyph.
GlyphBuffer glyphBuffer;
@@ -138,13 +108,6 @@ void Font::drawEmphasisMarksForComplexText(GraphicsContext* context, const TextR
float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
{
-#if PLATFORM(CHROMIUM)
- if (preferHarfBuzz(this)) {
- HarfBuzzShaper shaper(this, run);
- if (shaper.shape())
- return shaper.totalWidth();
- }
-#endif
ComplexTextController controller(this, run, true, fallbackFonts);
if (glyphOverflow) {
glyphOverflow->top = max<int>(glyphOverflow->top, ceilf(-controller.minGlyphBoundingBoxY()) - (glyphOverflow->computeBounds ? 0 : fontMetrics().ascent()));
@@ -157,13 +120,6 @@ float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFon
int Font::offsetForPositionForComplexText(const TextRun& run, float x, bool includePartialGlyphs) const
{
-#if PLATFORM(CHROMIUM)
- if (preferHarfBuzz(this)) {
- HarfBuzzShaper shaper(this, run);
- if (shaper.shape())
- return shaper.offsetForPosition(x);
- }
-#endif
ComplexTextController controller(this, run);
return controller.offsetForPosition(x, includePartialGlyphs);
}
@@ -192,7 +148,7 @@ const SimpleFontData* Font::fontDataForCombiningCharacterSequence(const UChar* c
if (isCJKIdeographOrSymbol(baseCharacter) && !simpleFontData->hasVerticalGlyphs()) {
variant = BrokenIdeographVariant;
simpleFontData = simpleFontData->brokenIdeographFontData().get();
- } else if (m_fontDescription.textOrientation() == TextOrientationVerticalRight) {
+ } else if (m_fontDescription.nonCJKGlyphOrientation() == NonCJKGlyphOrientationVerticalRight) {
SimpleFontData* verticalRightFontData = simpleFontData->verticalRightOrientationFontData().get();
Glyph verticalRightGlyph = verticalRightFontData->glyphForCharacter(baseCharacter);
if (verticalRightGlyph == baseCharacterGlyphData.glyph)
diff --git a/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp b/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp
index d3d872153..be480aa17 100644
--- a/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp
+++ b/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp
@@ -27,70 +27,16 @@
#include "WOFFFileFormat.h"
#include <ApplicationServices/ApplicationServices.h>
-#if USE(SKIA_ON_MAC_CHROMIUM)
-#include "SkStream.h"
-#include "SkTypeface.h"
-#endif
-
namespace WebCore {
-#if USE(SKIA_ON_MAC_CHROMIUM)
-class RemoteFontStream : public SkStream {
-public:
- explicit RemoteFontStream(PassRefPtr<SharedBuffer> buffer)
- : m_buffer(buffer)
- , m_offset(0)
- {
- }
-
- virtual ~RemoteFontStream()
- {
- }
-
- virtual bool rewind()
- {
- m_offset = 0;
- return true;
- }
-
- virtual size_t read(void* buffer, size_t size)
- {
- if (!buffer && !size) {
- // This is request for the length of the stream.
- return m_buffer->size();
- }
- // This is a request to read bytes or skip bytes (when buffer is 0).
- if (!m_buffer->data() || !m_buffer->size())
- return 0;
- size_t left = m_buffer->size() - m_offset;
- size_t bytesToConsume = std::min(left, size);
- if (buffer)
- std::memcpy(buffer, m_buffer->data() + m_offset, bytesToConsume);
- m_offset += bytesToConsume;
- return bytesToConsume;
- }
-
-private:
- RefPtr<SharedBuffer> m_buffer;
- size_t m_offset;
-};
-#endif
-
FontCustomPlatformData::~FontCustomPlatformData()
{
-#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1050
- if (m_atsContainer)
- ATSFontDeactivate(m_atsContainer, NULL, kATSOptionFlagsDefault);
-#endif
-#if USE(SKIA_ON_MAC_CHROMIUM)
- SkSafeUnref(m_typeface);
-#endif
CGFontRelease(m_cgFont);
}
-FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation orientation, TextOrientation textOrientation, FontWidthVariant widthVariant, FontRenderingMode)
+FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation orientation, FontWidthVariant widthVariant, FontRenderingMode)
{
- return FontPlatformData(m_cgFont, size, bold, italic, orientation, textOrientation, widthVariant);
+ return FontPlatformData(m_cgFont, size, bold, italic, orientation, widthVariant);
}
FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
@@ -117,54 +63,14 @@ FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
ATSFontContainerRef containerRef = 0;
- RetainPtr<CGFontRef> cgFontRef;
+ RetainPtr<CFDataRef> bufferData = adoptCF(buffer->createCFData());
+ RetainPtr<CGDataProviderRef> dataProvider = adoptCF(CGDataProviderCreateWithCFData(bufferData.get()));
-#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
- RetainPtr<CFDataRef> bufferData(AdoptCF, buffer->createCFData());
- RetainPtr<CGDataProviderRef> dataProvider(AdoptCF, CGDataProviderCreateWithCFData(bufferData.get()));
-
- cgFontRef.adoptCF(CGFontCreateWithDataProvider(dataProvider.get()));
+ RetainPtr<CGFontRef> cgFontRef = adoptCF(CGFontCreateWithDataProvider(dataProvider.get()));
if (!cgFontRef)
return 0;
-#else
- // Use ATS to activate the font.
-
- // The value "3" means that the font is private and can't be seen by anyone else.
- ATSFontActivateFromMemory((void*)buffer->data(), buffer->size(), 3, kATSFontFormatUnspecified, NULL, kATSOptionFlagsDefault, &containerRef);
- if (!containerRef)
- return 0;
- ItemCount fontCount;
- ATSFontFindFromContainer(containerRef, kATSOptionFlagsDefault, 0, NULL, &fontCount);
-
- // We just support the first font in the list.
- if (fontCount == 0) {
- ATSFontDeactivate(containerRef, NULL, kATSOptionFlagsDefault);
- return 0;
- }
-
- ATSFontRef fontRef = 0;
- ATSFontFindFromContainer(containerRef, kATSOptionFlagsDefault, 1, &fontRef, NULL);
- if (!fontRef) {
- ATSFontDeactivate(containerRef, NULL, kATSOptionFlagsDefault);
- return 0;
- }
-
- cgFontRef.adoptCF(CGFontCreateWithPlatformFont(&fontRef));
- // Workaround for <rdar://problem/5675504>.
- if (cgFontRef && !CGFontGetNumberOfGlyphs(cgFontRef.get()))
- cgFontRef = 0;
- if (!cgFontRef) {
- ATSFontDeactivate(containerRef, NULL, kATSOptionFlagsDefault);
- return 0;
- }
-#endif // PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
FontCustomPlatformData* fontCustomPlatformData = new FontCustomPlatformData(containerRef, cgFontRef.leakRef());
-#if USE(SKIA_ON_MAC_CHROMIUM)
- RemoteFontStream* stream = new RemoteFontStream(buffer);
- fontCustomPlatformData->m_typeface = SkTypeface::CreateFromStream(stream);
- stream->unref();
-#endif
return fontCustomPlatformData;
}
diff --git a/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h
index d63ebf0c2..c7ae1ca1f 100644
--- a/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h
+++ b/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h
@@ -24,7 +24,6 @@
#include "FontOrientation.h"
#include "FontRenderingMode.h"
#include "FontWidthVariant.h"
-#include "TextOrientation.h"
#include <CoreFoundation/CFBase.h>
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
@@ -33,10 +32,6 @@ typedef struct CGFont* CGFontRef;
typedef UInt32 ATSFontContainerRef;
typedef UInt32 ATSFontRef;
-#if USE(SKIA_ON_MAC_CHROMIUM)
-class SkTypeface;
-#endif
-
namespace WebCore {
class FontPlatformData;
@@ -48,23 +43,17 @@ public:
FontCustomPlatformData(ATSFontContainerRef container, CGFontRef cgFont)
: m_atsContainer(container)
, m_cgFont(cgFont)
-#if USE(SKIA_ON_MAC_CHROMIUM)
- , m_typeface(0)
-#endif
{
}
~FontCustomPlatformData();
- FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation = Horizontal, TextOrientation = TextOrientationVerticalRight, FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode);
+ FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation = Horizontal, FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode);
static bool supportsFormat(const String&);
ATSFontContainerRef m_atsContainer;
CGFontRef m_cgFont;
-#if USE(SKIA_ON_MAC_CHROMIUM)
- SkTypeface* m_typeface;
-#endif
};
FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer*);
diff --git a/Source/WebCore/platform/graphics/mac/FontMac.mm b/Source/WebCore/platform/graphics/mac/FontMac.mm
index ea5b88a62..ec38cce15 100644
--- a/Source/WebCore/platform/graphics/mac/FontMac.mm
+++ b/Source/WebCore/platform/graphics/mac/FontMac.mm
@@ -29,6 +29,7 @@
#import "SimpleFontData.h"
#import "WebCoreSystemInterface.h"
#import <AppKit/AppKit.h>
+#import <wtf/MathExtras.h>
#define SYNTHETIC_OBLIQUE_ANGLE 14
@@ -57,21 +58,7 @@ bool Font::canExpandAroundIdeographsInComplexText()
// divides by unitsPerEm.
static bool hasBrokenCTFontGetVerticalTranslationsForGlyphs()
{
-// Chromium runs the same binary on both Leopard and Snow Leopard, so the check has to happen at runtime.
-#if PLATFORM(CHROMIUM)
- static bool isCached = false;
- static bool result;
-
- if (!isCached) {
- SInt32 majorVersion = 0;
- SInt32 minorVersion = 0;
- Gestalt(gestaltSystemVersionMajor, &majorVersion);
- Gestalt(gestaltSystemVersionMinor, &minorVersion);
- result = majorVersion == 10 && minorVersion == 6;
- isCached = true;
- }
- return result;
-#elif !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1060
+#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1060
return true;
#else
return false;
@@ -80,55 +67,14 @@ static bool hasBrokenCTFontGetVerticalTranslationsForGlyphs()
static void showGlyphsWithAdvances(const FloatPoint& point, const SimpleFontData* font, CGContextRef context, const CGGlyph* glyphs, const CGSize* advances, size_t count)
{
+ if (!count)
+ return;
+
CGContextSetTextPosition(context, point.x(), point.y());
const FontPlatformData& platformData = font->platformData();
- if (!platformData.isColorBitmapFont()) {
- CGAffineTransform savedMatrix;
- bool isVertical = font->platformData().orientation() == Vertical;
- if (isVertical) {
- CGAffineTransform rotateLeftTransform = CGAffineTransformMake(0, -1, 1, 0, 0, 0);
- savedMatrix = CGContextGetTextMatrix(context);
- CGAffineTransform runMatrix = CGAffineTransformConcat(savedMatrix, rotateLeftTransform);
- CGContextSetTextMatrix(context, runMatrix);
-
- CGAffineTransform translationsTransform;
- if (hasBrokenCTFontGetVerticalTranslationsForGlyphs()) {
- translationsTransform = CGAffineTransformMake(platformData.m_size, 0, 0, platformData.m_size, 0, 0);
- translationsTransform = CGAffineTransformConcat(translationsTransform, rotateLeftTransform);
- CGFloat unitsPerEm = CGFontGetUnitsPerEm(platformData.cgFont());
- translationsTransform = CGAffineTransformConcat(translationsTransform, CGAffineTransformMakeScale(1 / unitsPerEm, 1 / unitsPerEm));
- } else {
- translationsTransform = rotateLeftTransform;
- }
- Vector<CGSize, 256> translations(count);
- CTFontGetVerticalTranslationsForGlyphs(platformData.ctFont(), glyphs, translations.data(), count);
-
- CGAffineTransform transform = CGAffineTransformInvert(CGContextGetTextMatrix(context));
-
- CGPoint position = FloatPoint(point.x(), point.y() + font->fontMetrics().floatAscent(IdeographicBaseline) - font->fontMetrics().floatAscent());
- Vector<CGPoint, 256> positions(count);
- for (size_t i = 0; i < count; ++i) {
- CGSize translation = CGSizeApplyAffineTransform(translations[i], translationsTransform);
- positions[i] = CGPointApplyAffineTransform(CGPointMake(position.x - translation.width, position.y + translation.height), transform);
- position.x += advances[i].width;
- position.y += advances[i].height;
- }
- CGContextShowGlyphsAtPositions(context, glyphs, positions.data(), count);
- CGContextSetTextMatrix(context, savedMatrix);
- } else {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- CGContextShowGlyphsWithAdvances(context, glyphs, advances, count);
-#pragma clang diagnostic pop
- }
- }
-#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
- else {
- if (!count)
- return;
-
- Vector<CGPoint, 256> positions(count);
+ Vector<CGPoint, 256> positions(count);
+ if (platformData.isColorBitmapFont()) {
CGAffineTransform matrix = CGAffineTransformInvert(CGContextGetTextMatrix(context));
positions[0] = CGPointZero;
for (size_t i = 1; i < count; ++i) {
@@ -136,9 +82,54 @@ static void showGlyphsWithAdvances(const FloatPoint& point, const SimpleFontData
positions[i].x = positions[i - 1].x + advance.width;
positions[i].y = positions[i - 1].y + advance.height;
}
- CTFontDrawGlyphs(platformData.ctFont(), glyphs, positions.data(), count, context);
}
+ bool isVertical = font->platformData().orientation() == Vertical;
+ if (isVertical) {
+ CGAffineTransform savedMatrix;
+ CGAffineTransform rotateLeftTransform = CGAffineTransformMake(0, -1, 1, 0, 0, 0);
+ savedMatrix = CGContextGetTextMatrix(context);
+ CGAffineTransform runMatrix = CGAffineTransformConcat(savedMatrix, rotateLeftTransform);
+ CGContextSetTextMatrix(context, runMatrix);
+
+ CGAffineTransform translationsTransform;
+ if (hasBrokenCTFontGetVerticalTranslationsForGlyphs()) {
+ translationsTransform = CGAffineTransformMake(platformData.m_size, 0, 0, platformData.m_size, 0, 0);
+ translationsTransform = CGAffineTransformConcat(translationsTransform, rotateLeftTransform);
+ CGFloat unitsPerEm = CGFontGetUnitsPerEm(platformData.cgFont());
+ translationsTransform = CGAffineTransformConcat(translationsTransform, CGAffineTransformMakeScale(1 / unitsPerEm, 1 / unitsPerEm));
+ } else
+ translationsTransform = rotateLeftTransform;
+
+ Vector<CGSize, 256> translations(count);
+ CTFontGetVerticalTranslationsForGlyphs(platformData.ctFont(), glyphs, translations.data(), count);
+
+ CGAffineTransform transform = CGAffineTransformInvert(CGContextGetTextMatrix(context));
+
+ CGPoint position = FloatPoint(point.x(), point.y() + font->fontMetrics().floatAscent(IdeographicBaseline) - font->fontMetrics().floatAscent());
+ for (size_t i = 0; i < count; ++i) {
+ CGSize translation = CGSizeApplyAffineTransform(translations[i], translationsTransform);
+ positions[i] = CGPointApplyAffineTransform(CGPointMake(position.x - translation.width, position.y + translation.height), transform);
+ position.x += advances[i].width;
+ position.y += advances[i].height;
+ }
+ if (!platformData.isColorBitmapFont())
+ CGContextShowGlyphsAtPositions(context, glyphs, positions.data(), count);
+#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
+ else
+ CTFontDrawGlyphs(platformData.ctFont(), glyphs, positions.data(), count, context);
+#endif
+ CGContextSetTextMatrix(context, savedMatrix);
+ } else {
+ if (!platformData.isColorBitmapFont())
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ CGContextShowGlyphsWithAdvances(context, glyphs, advances, count);
+#pragma clang diagnostic pop
+#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
+ else
+ CTFontDrawGlyphs(platformData.ctFont(), glyphs, positions.data(), count, context);
#endif
+ }
}
void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point) const
@@ -211,8 +202,13 @@ void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, cons
memcpy(&matrix, [drawFont matrix], sizeof(matrix));
matrix.b = -matrix.b;
matrix.d = -matrix.d;
- if (platformData.m_syntheticOblique)
- matrix = CGAffineTransformConcat(matrix, CGAffineTransformMake(1, 0, -tanf(SYNTHETIC_OBLIQUE_ANGLE * acosf(0) / 90), 1, 0, 0));
+ if (platformData.m_syntheticOblique) {
+ static float obliqueSkew = tanf(SYNTHETIC_OBLIQUE_ANGLE * piFloat / 180);
+ if (font->platformData().orientation() == Vertical)
+ matrix = CGAffineTransformConcat(matrix, CGAffineTransformMake(1, obliqueSkew, 0, 1, 0, 0));
+ else
+ matrix = CGAffineTransformConcat(matrix, CGAffineTransformMake(1, 0, -obliqueSkew, 1, 0, 0));
+ }
CGContextSetTextMatrix(cgContext, matrix);
#if PLATFORM(MAC)
diff --git a/Source/WebCore/platform/graphics/mac/GlyphPageTreeNodeMac.cpp b/Source/WebCore/platform/graphics/mac/GlyphPageTreeNodeMac.cpp
index 45a6691b8..c0e54cb48 100644
--- a/Source/WebCore/platform/graphics/mac/GlyphPageTreeNodeMac.cpp
+++ b/Source/WebCore/platform/graphics/mac/GlyphPageTreeNodeMac.cpp
@@ -36,7 +36,7 @@
namespace WebCore {
-static bool shouldUseCoreText(UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData)
+static bool shouldUseCoreText(const UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData)
{
if (fontData->platformData().isCompositeFontReference())
return true;
@@ -51,6 +51,12 @@ static bool shouldUseCoreText(UChar* buffer, unsigned bufferLength, const Simple
return false;
}
+bool GlyphPage::mayUseMixedFontDataWhenFilling(const UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData)
+{
+ // FIXME: This could be smarter if the logic currently in GlyphPage::fill() got to make the decision about what kind of GlyphPage to construct.
+ return shouldUseCoreText(buffer, bufferLength, fontData);
+}
+
bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData)
{
bool haveGlyphs = false;
@@ -81,9 +87,9 @@ bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned b
}
} else {
// We ask CoreText for possible vertical variant glyphs
- RetainPtr<CFStringRef> string(AdoptCF, CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, buffer, bufferLength, kCFAllocatorNull));
- RetainPtr<CFAttributedStringRef> attributedString(AdoptCF, CFAttributedStringCreate(kCFAllocatorDefault, string.get(), fontData->getCFStringAttributes(0, fontData->hasVerticalGlyphs() ? Vertical : Horizontal)));
- RetainPtr<CTLineRef> line(AdoptCF, CTLineCreateWithAttributedString(attributedString.get()));
+ RetainPtr<CFStringRef> string = adoptCF(CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, buffer, bufferLength, kCFAllocatorNull));
+ RetainPtr<CFAttributedStringRef> attributedString = adoptCF(CFAttributedStringCreate(kCFAllocatorDefault, string.get(), fontData->getCFStringAttributes(0, fontData->hasVerticalGlyphs() ? Vertical : Horizontal)));
+ RetainPtr<CTLineRef> line = adoptCF(CTLineCreateWithAttributedString(attributedString.get()));
CFArrayRef runArray = CTLineGetGlyphRuns(line.get());
CFIndex runCount = CFArrayGetCount(runArray);
@@ -98,7 +104,7 @@ bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned b
// For the CGFont comparison in the loop, use the CGFont that Core Text assigns to the CTFont. This may
// be non-CFEqual to fontData->platformData().cgFont().
- RetainPtr<CGFontRef> cgFont(AdoptCF, CTFontCopyGraphicsFont(fontData->platformData().ctFont(), 0));
+ RetainPtr<CGFontRef> cgFont = adoptCF(CTFontCopyGraphicsFont(fontData->platformData().ctFont(), 0));
for (CFIndex r = 0; r < runCount && !done ; ++r) {
// CTLine could map characters over multiple fonts using its own font fallback list.
@@ -108,7 +114,7 @@ bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned b
CFDictionaryRef attributes = CTRunGetAttributes(ctRun);
CTFontRef runFont = static_cast<CTFontRef>(CFDictionaryGetValue(attributes, kCTFontAttributeName));
- RetainPtr<CGFontRef> runCGFont(AdoptCF, CTFontCopyGraphicsFont(runFont, 0));
+ RetainPtr<CGFontRef> runCGFont = adoptCF(CTFontCopyGraphicsFont(runFont, 0));
// Use CGFont here as CFEqual for CTFont counts all attributes for font.
bool gotBaseFont = CFEqual(cgFont.get(), runCGFont.get());
if (gotBaseFont || fontData->platformData().isCompositeFontReference()) {
diff --git a/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm b/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm
index 82538779c..2613aaaa8 100644
--- a/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm
+++ b/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm
@@ -48,7 +48,6 @@
#include <wtf/Int32Array.h>
#include <wtf/Float32Array.h>
#include <wtf/Uint8Array.h>
-#include <wtf/UnusedParam.h>
#include <wtf/text/CString.h>
namespace WebCore {
@@ -107,9 +106,6 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi
, m_depthStencilBuffer(0)
, m_layerComposited(false)
, m_internalColorFormat(0)
- , m_boundFBO(0)
- , m_activeTexture(GL_TEXTURE0)
- , m_boundTexture0(0)
, m_multisampleFBO(0)
, m_multisampleDepthStencilBuffer(0)
, m_multisampleColorBuffer(0)
@@ -169,7 +165,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi
// Create the WebGLLayer
BEGIN_BLOCK_OBJC_EXCEPTIONS
- m_webGLLayer.adoptNS([[WebGLLayer alloc] initWithGraphicsContext3D:this]);
+ m_webGLLayer = adoptNS([[WebGLLayer alloc] initWithGraphicsContext3D:this]);
#ifndef NDEBUG
[m_webGLLayer.get() setName:@"WebGL Layer"];
#endif
@@ -194,7 +190,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi
::glGenFramebuffersEXT(1, &m_fbo);
::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
- m_boundFBO = m_fbo;
+ m_state.boundFBO = m_fbo;
if (!m_attrs.antialias && (m_attrs.stencil || m_attrs.depth))
::glGenRenderbuffersEXT(1, &m_depthStencilBuffer);
@@ -202,7 +198,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi
if (m_attrs.antialias) {
::glGenFramebuffersEXT(1, &m_multisampleFBO);
::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
- m_boundFBO = m_multisampleFBO;
+ m_state.boundFBO = m_multisampleFBO;
::glGenRenderbuffersEXT(1, &m_multisampleColorBuffer);
if (m_attrs.stencil || m_attrs.depth)
::glGenRenderbuffersEXT(1, &m_multisampleDepthStencilBuffer);
@@ -224,6 +220,10 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi
// Always set to 1 for OpenGL ES.
ANGLEResources.MaxDrawBuffers = 1;
+ GC3Dint range[2], precision;
+ getShaderPrecisionFormat(GraphicsContext3D::FRAGMENT_SHADER, GraphicsContext3D::HIGH_FLOAT, range, &precision);
+ ANGLEResources.FragmentPrecisionHigh = (range[0] || range[1] || precision);
+
m_compiler.setResources(ANGLEResources);
::glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
diff --git a/Source/WebCore/platform/graphics/mac/GraphicsContextMac.mm b/Source/WebCore/platform/graphics/mac/GraphicsContextMac.mm
index 4da16d54d..26b5f7cfd 100644
--- a/Source/WebCore/platform/graphics/mac/GraphicsContextMac.mm
+++ b/Source/WebCore/platform/graphics/mac/GraphicsContextMac.mm
@@ -74,7 +74,7 @@ void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int
offset += radius;
CGColorRef colorRef = color.isValid() ? cachedCGColor(color, ColorSpaceDeviceRGB) : 0;
- RetainPtr<CGMutablePathRef> focusRingPath(AdoptCF, CGPathCreateMutable());
+ RetainPtr<CGMutablePathRef> focusRingPath = adoptCF(CGPathCreateMutable());
unsigned rectCount = rects.size();
for (unsigned i = 0; i < rectCount; i++)
CGPathAddRect(focusRingPath.get(), 0, CGRectInset(rects[i], -offset, -offset));
@@ -187,7 +187,7 @@ CGColorSpaceRef linearRGBColorSpaceRef()
return linearSRGBSpace;
RetainPtr<NSString> iccProfilePath = [[NSBundle bundleWithIdentifier:@"com.apple.WebCore"] pathForResource:@"linearSRGB" ofType:@"icc"];
- RetainPtr<NSData> iccProfileData(AdoptNS, [[NSData alloc] initWithContentsOfFile:iccProfilePath.get()]);
+ RetainPtr<NSData> iccProfileData = adoptNS([[NSData alloc] initWithContentsOfFile:iccProfilePath.get()]);
if (iccProfileData)
linearSRGBSpace = CGColorSpaceCreateWithICCProfile((CFDataRef)iccProfileData.get());
diff --git a/Source/WebCore/platform/graphics/mac/ImageMac.mm b/Source/WebCore/platform/graphics/mac/ImageMac.mm
index 091f2da23..251f5748b 100644
--- a/Source/WebCore/platform/graphics/mac/ImageMac.mm
+++ b/Source/WebCore/platform/graphics/mac/ImageMac.mm
@@ -88,8 +88,8 @@ CFDataRef BitmapImage::getTIFFRepresentation()
unsigned numValidFrames = images.size();
- RetainPtr<CFMutableDataRef> data(AdoptCF, CFDataCreateMutable(0, 0));
- RetainPtr<CGImageDestinationRef> destination(AdoptCF, CGImageDestinationCreateWithData(data.get(), kUTTypeTIFF, numValidFrames, 0));
+ RetainPtr<CFMutableDataRef> data = adoptCF(CFDataCreateMutable(0, 0));
+ RetainPtr<CGImageDestinationRef> destination = adoptCF(CGImageDestinationCreateWithData(data.get(), kUTTypeTIFF, numValidFrames, 0));
if (!destination)
return 0;
@@ -112,7 +112,7 @@ NSImage* BitmapImage::getNSImage()
if (!data)
return 0;
- m_nsImage.adoptNS([[NSImage alloc] initWithData:(NSData*)data]);
+ m_nsImage = adoptNS([[NSImage alloc] initWithData:(NSData*)data]);
return m_nsImage.get();
}
diff --git a/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h b/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h
index 3ee1a4c29..f226cda87 100644
--- a/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h
+++ b/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h
@@ -76,7 +76,7 @@ private:
static PassOwnPtr<MediaPlayerPrivateInterface> create(MediaPlayer*);
static void getSupportedTypes(HashSet<String>& types);
static MediaPlayer::SupportsType supportsType(const String& type, const String& codecs, const KURL&);
-#if ENABLE(ENCRYPTED_MEDIA)
+#if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2)
static MediaPlayer::SupportsType extendedSupportsType(const String& type, const String& codecs, const String& keySystem, const KURL&);
#endif
@@ -86,7 +86,7 @@ private:
static bool isAvailable();
PlatformMedia platformMedia() const;
-#if USE(ACCELERATED_COMPOSITING) && !(PLATFORM(QT) && USE(QTKIT))
+#if USE(ACCELERATED_COMPOSITING)
PlatformLayer* platformLayer() const;
#endif
@@ -139,7 +139,7 @@ private:
virtual void prepareForRendering();
-#if USE(ACCELERATED_COMPOSITING) && !(PLATFORM(QT) && USE(QTKIT))
+#if USE(ACCELERATED_COMPOSITING)
bool supportsAcceleratedRendering() const;
void acceleratedRenderingStateChanged();
#endif
diff --git a/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm b/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm
index 4a7021a05..9998af98a 100644
--- a/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm
+++ b/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm
@@ -44,7 +44,6 @@
#import "WebCoreSystemInterface.h"
#import <QTKit/QTKit.h>
#import <objc/runtime.h>
-#import <wtf/UnusedParam.h>
#if USE(ACCELERATED_COMPOSITING)
#include "PlatformLayer.h"
@@ -190,7 +189,7 @@ PassOwnPtr<MediaPlayerPrivateInterface> MediaPlayerPrivateQTKit::create(MediaPla
void MediaPlayerPrivateQTKit::registerMediaEngine(MediaEngineRegistrar registrar)
{
if (isAvailable())
-#if ENABLE(ENCRYPTED_MEDIA)
+#if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2)
registrar(create, getSupportedTypes, extendedSupportsType, getSitesInMediaCache, clearMediaCache, clearMediaCacheForSite);
#else
registrar(create, getSupportedTypes, supportsType, getSitesInMediaCache, clearMediaCache, clearMediaCacheForSite);
@@ -199,7 +198,7 @@ void MediaPlayerPrivateQTKit::registerMediaEngine(MediaEngineRegistrar registrar
MediaPlayerPrivateQTKit::MediaPlayerPrivateQTKit(MediaPlayer* player)
: m_player(player)
- , m_objcObserver(AdoptNS, [[WebCoreMovieObserver alloc] initWithCallback:this])
+ , m_objcObserver(adoptNS([[WebCoreMovieObserver alloc] initWithCallback:this]))
, m_seekTo(-1)
, m_seekTimer(this, &MediaPlayerPrivateQTKit::seekTimerFired)
, m_networkState(MediaPlayer::Empty)
@@ -271,7 +270,6 @@ void MediaPlayerPrivateQTKit::createQTMovie(const String& url)
NSMutableDictionary *movieAttributes = commonMovieAttributes();
[movieAttributes setValue:cocoaURL forKey:QTMovieURLAttribute];
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
CFDictionaryRef proxySettings = CFNetworkCopySystemProxySettings();
CFArrayRef proxiesForURL = CFNetworkCopyProxiesForURL((CFURLRef)cocoaURL, proxySettings);
BOOL willUseProxy = YES;
@@ -300,8 +298,7 @@ void MediaPlayerPrivateQTKit::createQTMovie(const String& url)
CFRelease(proxiesForURL);
if (proxySettings)
CFRelease(proxySettings);
-#endif
-
+
createQTMovie(cocoaURL, movieAttributes);
}
@@ -355,7 +352,7 @@ void MediaPlayerPrivateQTKit::createQTMovie(NSURL *url, NSDictionary *movieAttri
return;
NSError *error = nil;
- m_qtMovie.adoptNS([[QTMovie alloc] initWithAttributes:movieAttributes error:&error]);
+ m_qtMovie = adoptNS([[QTMovie alloc] initWithAttributes:movieAttributes error:&error]);
if (!m_qtMovie)
return;
@@ -446,7 +443,7 @@ void MediaPlayerPrivateQTKit::createQTMovieView()
// delay callbacks as we *will* get notifications during setup
[m_objcObserver.get() setDelayCallbacks:YES];
- m_qtMovieView.adoptNS([[QTMovieView alloc] init]);
+ m_qtMovieView = adoptNS([[QTMovieView alloc] init]);
setSize(m_player->size());
NSView* parentView = 0;
#if PLATFORM(MAC)
@@ -486,7 +483,7 @@ void MediaPlayerPrivateQTKit::createQTVideoRenderer(QTVideoRendererMode renderer
LOG(Media, "MediaPlayerPrivateQTKit::createQTVideoRenderer(%p)", this);
destroyQTVideoRenderer();
- m_qtVideoRenderer.adoptNS([[QTVideoRendererClass() alloc] init]);
+ m_qtVideoRenderer = adoptNS([[QTVideoRendererClass() alloc] init]);
if (!m_qtVideoRenderer)
return;
@@ -522,14 +519,14 @@ void MediaPlayerPrivateQTKit::destroyQTVideoRenderer()
void MediaPlayerPrivateQTKit::createQTMovieLayer()
{
LOG(Media, "MediaPlayerPrivateQTKit::createQTMovieLayer(%p)", this);
-#if USE(ACCELERATED_COMPOSITING) && !(PLATFORM(QT) && USE(QTKIT))
+#if USE(ACCELERATED_COMPOSITING)
if (!m_qtMovie)
return;
ASSERT(supportsAcceleratedRendering());
if (!m_qtVideoLayer) {
- m_qtVideoLayer.adoptNS([[QTMovieLayer alloc] init]);
+ m_qtVideoLayer = adoptNS([[QTMovieLayer alloc] init]);
if (!m_qtVideoLayer)
return;
@@ -574,7 +571,7 @@ MediaPlayerPrivateQTKit::MediaRenderingMode MediaPlayerPrivateQTKit::preferredRe
if (!m_player->frameView() || !m_qtMovie)
return MediaRenderingNone;
-#if USE(ACCELERATED_COMPOSITING) && !(PLATFORM(QT) && USE(QTKIT))
+#if USE(ACCELERATED_COMPOSITING)
if (supportsAcceleratedRendering() && m_player->mediaPlayerClient()->mediaPlayerRenderingCanBeAccelerated(m_player))
return MediaRenderingMovieLayer;
#endif
@@ -696,7 +693,7 @@ PlatformMedia MediaPlayerPrivateQTKit::platformMedia() const
return pm;
}
-#if USE(ACCELERATED_COMPOSITING) && !(PLATFORM(QT) && USE(QTKIT))
+#if USE(ACCELERATED_COMPOSITING)
PlatformLayer* MediaPlayerPrivateQTKit::platformLayer() const
{
return m_qtVideoLayer.get();
@@ -880,12 +877,7 @@ bool MediaPlayerPrivateQTKit::hasAudio() const
bool MediaPlayerPrivateQTKit::supportsFullscreen() const
{
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
return true;
-#else
- // See <rdar://problem/7389945>
- return false;
-#endif
}
void MediaPlayerPrivateQTKit::setVolume(float volume)
@@ -907,11 +899,11 @@ void MediaPlayerPrivateQTKit::setClosedCaptionsVisible(bool closedCaptionsVisibl
if (metaDataAvailable()) {
wkQTMovieSetShowClosedCaptions(m_qtMovie.get(), closedCaptionsVisible);
-#if USE(ACCELERATED_COMPOSITING) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
- if (closedCaptionsVisible && m_qtVideoLayer) {
- // Captions will be rendered upside down unless we flag the movie as flipped (again). See <rdar://7408440>.
- [m_qtVideoLayer.get() setGeometryFlipped:YES];
- }
+#if USE(ACCELERATED_COMPOSITING)
+ if (closedCaptionsVisible && m_qtVideoLayer) {
+ // Captions will be rendered upside down unless we flag the movie as flipped (again). See <rdar://7408440>.
+ [m_qtVideoLayer.get() setGeometryFlipped:YES];
+ }
#endif
}
}
@@ -934,7 +926,7 @@ void MediaPlayerPrivateQTKit::setPreservesPitch(bool preservesPitch)
if ([[m_qtMovie.get() attributeForKey:QTMovieRateChangesPreservePitchAttribute] boolValue] == preservesPitch)
return;
- RetainPtr<NSDictionary> movieAttributes(AdoptNS, [[m_qtMovie.get() movieAttributes] mutableCopy]);
+ RetainPtr<NSDictionary> movieAttributes = adoptNS([[m_qtMovie.get() movieAttributes] mutableCopy]);
ASSERT(movieAttributes);
[movieAttributes.get() setValue:[NSNumber numberWithBool:preservesPitch] forKey:QTMovieRateChangesPreservePitchAttribute];
m_timeToRestore = currentTime();
@@ -957,7 +949,7 @@ float MediaPlayerPrivateQTKit::maxTimeSeekable() const
return 0;
// infinite duration means live stream
- if (isinf(duration()))
+ if (std::isinf(duration()))
return 0;
return wkQTMovieMaxTimeSeekable(m_qtMovie.get());
@@ -1005,7 +997,6 @@ void MediaPlayerPrivateQTKit::cacheMovieScale()
NSSize initialSize = NSZeroSize;
NSSize naturalSize = [[m_qtMovie.get() attributeForKey:QTMovieNaturalSizeAttribute] sizeValue];
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
// QTMovieCurrentSizeAttribute is not allowed with instances of QTMovie that have been
// opened with QTMovieOpenForPlaybackAttribute, so ask for the display transform attribute instead.
NSAffineTransform *displayTransform = [m_qtMovie.get() attributeForKey:@"QTMoviePreferredTransformAttribute"];
@@ -1015,9 +1006,6 @@ void MediaPlayerPrivateQTKit::cacheMovieScale()
initialSize.width = naturalSize.width;
initialSize.height = naturalSize.height;
}
-#else
- initialSize = [[m_qtMovie.get() attributeForKey:QTMovieCurrentSizeAttribute] sizeValue];
-#endif
if (naturalSize.width)
m_scaleFactor.setWidth(initialSize.width / naturalSize.width);
@@ -1239,7 +1227,7 @@ void MediaPlayerPrivateQTKit::didEnd()
m_player->timeChanged();
}
-#if USE(ACCELERATED_COMPOSITING) && !(PLATFORM(QT) && USE(QTKIT))
+#if USE(ACCELERATED_COMPOSITING)
#if __MAC_OS_X_VERSION_MIN_REQUIRED == 1060
static bool layerIsDescendentOf(PlatformLayer* child, PlatformLayer* descendent)
{
@@ -1343,18 +1331,6 @@ void MediaPlayerPrivateQTKit::paintCurrentFrameInContext(GraphicsContext* contex
paint(context, r);
}
-#if PLATFORM(QT) && USE(QTKIT)
-static inline void swapBgrToRgb(uint32_t* pixel, uint32_t width, uint32_t height)
-{
- uint32_t* end = pixel + (width * height);
-
- while (pixel < end) {
- *pixel = ((*pixel << 16) & 0xff0000) | ((*pixel >> 16) & 0xff) | (*pixel & 0xff00ff00);
- ++pixel;
- }
-}
-#endif
-
void MediaPlayerPrivateQTKit::paint(GraphicsContext* context, const IntRect& r)
{
if (context->paintingDisabled() || m_hasUnsupportedTracks)
@@ -1370,26 +1346,13 @@ void MediaPlayerPrivateQTKit::paint(GraphicsContext* context, const IntRect& r)
FloatSize scaleFactor(1.0f, -1.0f);
IntRect paintRect(IntPoint(0, 0), IntSize(r.width(), r.height()));
-#if PLATFORM(QT) && USE(QTKIT)
- NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes: NULL
- pixelsWide: paintRect.width()
- pixelsHigh: paintRect.height()
- bitsPerSample: 8
- samplesPerPixel: 4
- hasAlpha: YES
- isPlanar: NO
- colorSpaceName: NSCalibratedRGBColorSpace
- bytesPerRow: 4 * paintRect.width() // 32 bit per pixel.
- bitsPerPixel: 32];
- newContext = [NSGraphicsContext graphicsContextWithBitmapImageRep: imageRep];
-#else
GraphicsContextStateSaver stateSaver(*context);
context->translate(r.x(), r.y() + r.height());
context->scale(scaleFactor);
context->setImageInterpolationQuality(InterpolationLow);
newContext = [NSGraphicsContext graphicsContextWithGraphicsPort:context->platformContext() flipped:NO];
-#endif
+
// draw the current video frame
if (qtVideoRenderer) {
[NSGraphicsContext saveGraphicsState];
@@ -1443,27 +1406,28 @@ void MediaPlayerPrivateQTKit::paint(GraphicsContext* context, const IntRect& r)
}
}
#endif
-#if PLATFORM(QT) && USE(QTKIT)
- unsigned char* bitmap = [imageRep bitmapData];
- swapBgrToRgb(reinterpret_cast<uint32_t*>(bitmap), paintRect.width(), paintRect.height());
- QImage videoFrame(bitmap, paintRect.width(), paintRect.height(), QImage::Format_ARGB32);
- QPainter* painter = context->platformContext();
- painter->drawImage(QRect(r), videoFrame);
- [imageRep release];
-#endif
END_BLOCK_OBJC_EXCEPTIONS;
[m_objcObserver.get() setDelayCallbacks:NO];
}
+static bool shouldRejectMIMEType(const String& type)
+{
+ // QTKit will return non-video MIME types which it claims to support, but which we
+ // do not support in the <video> element. Disclaim all non video/ or audio/ types.
+ return !type.startsWith("video/") && !type.startsWith("audio/");
+}
+
static void addFileTypesToCache(NSArray * fileTypes, HashSet<String> &cache)
{
int count = [fileTypes count];
for (int n = 0; n < count; n++) {
CFStringRef ext = reinterpret_cast<CFStringRef>([fileTypes objectAtIndex:n]);
- RetainPtr<CFStringRef> uti(AdoptCF, UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, ext, NULL));
+ RetainPtr<CFStringRef> uti = adoptCF(UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, ext, NULL));
if (!uti)
continue;
- RetainPtr<CFStringRef> mime(AdoptCF, UTTypeCopyPreferredTagWithClass(uti.get(), kUTTagClassMIMEType));
+ RetainPtr<CFStringRef> mime = adoptCF(UTTypeCopyPreferredTagWithClass(uti.get(), kUTTagClassMIMEType));
+ if (shouldRejectMIMEType(mime.get()))
+ continue;
if (mime)
cache.add(mime.get());
@@ -1476,8 +1440,13 @@ static void addFileTypesToCache(NSArray * fileTypes, HashSet<String> &cache)
Vector<String> typesForExtension = MIMETypeRegistry::getMediaMIMETypesForExtension(ext);
unsigned count = typesForExtension.size();
for (unsigned ndx = 0; ndx < count; ++ndx) {
- if (!cache.contains(typesForExtension[ndx]))
- cache.add(typesForExtension[ndx]);
+ String& type = typesForExtension[ndx];
+
+ if (shouldRejectMIMEType(type))
+ continue;
+
+ if (!cache.contains(type))
+ cache.add(type);
}
}
}
@@ -1509,20 +1478,24 @@ static HashSet<String> mimeModernTypesCache()
}
return cache;
-}
+}
+
+static void concatenateHashSets(HashSet<String>& destination, const HashSet<String>& source)
+{
+ HashSet<String>::const_iterator it = source.begin();
+ HashSet<String>::const_iterator end = source.end();
+ for (; it != end; ++it)
+ destination.add(*it);
+}
void MediaPlayerPrivateQTKit::getSupportedTypes(HashSet<String>& supportedTypes)
{
- supportedTypes = mimeModernTypesCache();
-
+ concatenateHashSets(supportedTypes, mimeModernTypesCache());
+
// Note: this method starts QTKitServer if it isn't already running when in 64-bit because it has to return the list
// of every MIME type supported by QTKit.
- HashSet<String> commonTypes = mimeCommonTypesCache();
- HashSet<String>::const_iterator it = commonTypes.begin();
- HashSet<String>::const_iterator end = commonTypes.end();
- for (; it != end; ++it)
- supportedTypes.add(*it);
-}
+ concatenateHashSets(supportedTypes, mimeCommonTypesCache());
+}
MediaPlayer::SupportsType MediaPlayerPrivateQTKit::supportsType(const String& type, const String& codecs, const KURL&)
{
@@ -1531,7 +1504,7 @@ MediaPlayer::SupportsType MediaPlayerPrivateQTKit::supportsType(const String& ty
// Due to <rdar://problem/10777059>, avoid calling the mime types cache functions if at
// all possible:
- if (!type.startsWith("video/") && !type.startsWith("audio/"))
+ if (shouldRejectMIMEType(type))
return MediaPlayer::IsNotSupported;
// We check the "modern" type cache first, as it doesn't require QTKitServer to start.
@@ -1541,7 +1514,7 @@ MediaPlayer::SupportsType MediaPlayerPrivateQTKit::supportsType(const String& ty
return MediaPlayer::IsNotSupported;
}
-#if ENABLE(ENCRYPTED_MEDIA)
+#if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2)
MediaPlayer::SupportsType MediaPlayerPrivateQTKit::extendedSupportsType(const String& type, const String& codecs, const String& keySystem, const KURL& url)
{
// QTKit does not support any encrytped media, so return IsNotSupported if the keySystem is non-NULL:
@@ -1675,7 +1648,7 @@ void MediaPlayerPrivateQTKit::sawUnsupportedTracks()
m_player->mediaPlayerClient()->mediaPlayerSawUnsupportedTracks(m_player);
}
-#if USE(ACCELERATED_COMPOSITING) && !(PLATFORM(QT) && USE(QTKIT))
+#if USE(ACCELERATED_COMPOSITING)
bool MediaPlayerPrivateQTKit::supportsAcceleratedRendering() const
{
return isReadyForVideoSetup() && getQTMovieLayerClass() != Nil;
@@ -1838,7 +1811,7 @@ void MediaPlayerPrivateQTKit::setPrivateBrowsingMode(bool privateBrowsing)
- (void)layerHostChanged:(NSNotification *)notification
{
-#if USE(ACCELERATED_COMPOSITING) && !(PLATFORM(QT) && USE(QTKIT))
+#if USE(ACCELERATED_COMPOSITING)
CALayer* rootLayer = static_cast<CALayer*>([notification object]);
m_callback->layerHostChanged(rootLayer);
#else
diff --git a/Source/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp b/Source/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp
index 6c2c11727..9aaf82511 100644
--- a/Source/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp
+++ b/Source/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp
@@ -39,7 +39,7 @@ CFDictionaryRef SimpleFontData::getCFStringAttributes(TypesettingFeatures typese
if (!addResult.isNewEntry)
return attributesDictionary.get();
- attributesDictionary.adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 4, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+ attributesDictionary = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 4, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
CFMutableDictionaryRef mutableAttributes = (CFMutableDictionaryRef)attributesDictionary.get();
CFDictionarySetValue(mutableAttributes, kCTFontAttributeName, platformData().ctFont());
diff --git a/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm b/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm
index fc23bbd9b..5bf2ad4b9 100644
--- a/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm
+++ b/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm
@@ -42,7 +42,6 @@
#import <wtf/Assertions.h>
#import <wtf/StdLibExtras.h>
#import <wtf/RetainPtr.h>
-#import <wtf/UnusedParam.h>
@interface NSFont (WebAppKitSecretAPI)
- (BOOL)_isFakeFixedPitch;
@@ -55,7 +54,7 @@ namespace WebCore {
static bool fontHasVerticalGlyphs(CTFontRef ctFont)
{
// The check doesn't look neat but this is what AppKit does for vertical writing...
- RetainPtr<CFArrayRef> tableTags(AdoptCF, CTFontCopyAvailableTables(ctFont, kCTFontTableOptionNoOptions));
+ RetainPtr<CFArrayRef> tableTags = adoptCF(CTFontCopyAvailableTables(ctFont, kCTFontTableOptionNoOptions));
CFIndex numTables = CFArrayGetCount(tableTags.get());
for (CFIndex index = 0; index < numTables; ++index) {
CTFontTableTag tag = (CTFontTableTag)(uintptr_t)CFArrayGetValueAtIndex(tableTags.get(), index);
@@ -79,41 +78,13 @@ static NSString *webFallbackFontFamily(void)
return webFallbackFontFamily.get();
}
-#if !ERROR_DISABLED
-#if defined(__LP64__) || PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 || (__MAC_OS_X_VERSION_MAX_ALLOWED >= 107 && __MAC_OS_X_VERSION_MIN_REQUIRED >= 106)
-static NSString* pathFromFont(NSFont*)
-{
- // FMGetATSFontRefFromFont is not available. As pathFromFont is only used for debugging purposes,
- // returning nil is acceptable.
- return nil;
-}
-#else
-static NSString* pathFromFont(NSFont *font)
-{
- ATSFontRef atsFont = FMGetATSFontRefFromFont(CTFontGetPlatformFont(toCTFontRef(font), 0));
- FSRef fileRef;
-
- OSStatus status = ATSFontGetFileReference(atsFont, &fileRef);
- if (status != noErr)
- return nil;
-
- UInt8 filePathBuffer[PATH_MAX];
- status = FSRefMakePath(&fileRef, filePathBuffer, PATH_MAX);
- if (status == noErr)
- return [NSString stringWithUTF8String:(const char*)filePathBuffer];
-
- return nil;
-}
-#endif // __LP64__
-#endif // !ERROR_DISABLED
-
const SimpleFontData* SimpleFontData::getCompositeFontReferenceFontData(NSFont *key) const
{
- if (key && !CFEqual(RetainPtr<CFStringRef>(AdoptCF, CTFontCopyPostScriptName(CTFontRef(key))).get(), CFSTR("LastResort"))) {
+ if (key && !CFEqual(adoptCF(CTFontCopyPostScriptName(CTFontRef(key))).get(), CFSTR("LastResort"))) {
if (!m_derivedFontData)
m_derivedFontData = DerivedFontData::create(isCustomFont());
if (!m_derivedFontData->compositeFontReferences)
- m_derivedFontData->compositeFontReferences.adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 1, &kCFTypeDictionaryKeyCallBacks, NULL));
+ m_derivedFontData->compositeFontReferences = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 1, &kCFTypeDictionaryKeyCallBacks, NULL));
else {
const SimpleFontData* found = static_cast<const SimpleFontData*>(CFDictionaryGetValue(m_derivedFontData->compositeFontReferences.get(), static_cast<const void *>(key)));
if (found)
@@ -127,11 +98,11 @@ const SimpleFontData* SimpleFontData::getCompositeFontReferenceFontData(NSFont *
bool syntheticBold = platformData().syntheticBold() && !(traits & kCTFontBoldTrait);
bool syntheticOblique = platformData().syntheticOblique() && !(traits & kCTFontItalicTrait);
- FontPlatformData substitutePlatform(substituteFont, platformData().size(), isUsingPrinterFont, syntheticBold, syntheticOblique, platformData().orientation(), platformData().textOrientation(), platformData().widthVariant());
- SimpleFontData* value = new SimpleFontData(substitutePlatform, isCustomFont());
- if (value) {
- CFDictionaryAddValue(dictionary, key, value);
- return value;
+ FontPlatformData substitutePlatform(substituteFont, platformData().size(), isUsingPrinterFont, syntheticBold, syntheticOblique, platformData().orientation(), platformData().widthVariant());
+ if (RefPtr<SimpleFontData> value = adoptRef(new SimpleFontData(substitutePlatform, isCustomFont()))) {
+ SimpleFontData* valuePtr = value.get();
+ CFDictionaryAddValue(dictionary, key, value.release().leakRef());
+ return valuePtr;
}
}
}
@@ -166,11 +137,6 @@ void SimpleFontData::platformInit()
m_platformData.setFont([[NSFontManager sharedFontManager] convertFont:m_platformData.font() toFamily:fallbackFontFamily]);
else
m_platformData.setFont([NSFont fontWithName:fallbackFontFamily size:m_platformData.size()]);
-#if !ERROR_DISABLED
- NSString *filePath = pathFromFont(initialFont.get());
- if (!filePath)
- filePath = @"not known";
-#endif
if (!initFontData(this)) {
if ([fallbackFontFamily isEqual:@"Times New Roman"]) {
// OK, couldn't setup Times New Roman as an alternate to Times, fallback
@@ -178,19 +144,19 @@ void SimpleFontData::platformInit()
m_platformData.setFont([[NSFontManager sharedFontManager] convertFont:m_platformData.font() toFamily:webFallbackFontFamily()]);
if (!initFontData(this)) {
// We tried, Times, Times New Roman, and the system font. No joy. We have to give up.
- LOG_ERROR("unable to initialize with font %@ at %@", initialFont.get(), filePath);
+ LOG_ERROR("unable to initialize with font %@", initialFont.get());
failedSetup = true;
}
} else {
// We tried the requested font and the system font. No joy. We have to give up.
- LOG_ERROR("unable to initialize with font %@ at %@", initialFont.get(), filePath);
+ LOG_ERROR("unable to initialize with font %@", initialFont.get());
failedSetup = true;
}
}
// Report the problem.
- LOG_ERROR("Corrupt font detected, using %@ in place of %@ located at \"%@\".",
- [m_platformData.font() familyName], [initialFont.get() familyName], filePath);
+ LOG_ERROR("Corrupt font detected, using %@ in place of %@.",
+ [m_platformData.font() familyName], [initialFont.get() familyName]);
}
// If all else fails, try to set up using the system font.
@@ -225,15 +191,6 @@ void SimpleFontData::platformInit()
NSString *familyName = [m_platformData.font() familyName];
if ([familyName isEqualToString:@"Times"] || [familyName isEqualToString:@"Helvetica"] || [familyName isEqualToString:@"Courier"])
ascent += floorf(((ascent + descent) * 0.15f) + 0.5f);
-#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1050
- else if ([familyName isEqualToString:@"Geeza Pro"]) {
- // Geeza Pro has glyphs that draw slightly above the ascent or far below the descent. Adjust
- // those vertical metrics to better match reality, so that diacritics at the bottom of one line
- // do not overlap diacritics at the top of the next line.
- ascent *= 1.08f;
- descent *= 2.f;
- }
-#endif
// Compute and store line spacing, before the line metrics hacks are applied.
m_fontMetrics.setLineSpacing(lroundf(ascent) + lroundf(descent) + lroundf(lineGap));
@@ -279,14 +236,14 @@ void SimpleFontData::platformCharWidthInit()
m_avgCharWidth = 0;
m_maxCharWidth = 0;
- RetainPtr<CFDataRef> os2Table(AdoptCF, copyFontTableForTag(m_platformData, 'OS/2'));
+ RetainPtr<CFDataRef> os2Table = adoptCF(copyFontTableForTag(m_platformData, 'OS/2'));
if (os2Table && CFDataGetLength(os2Table.get()) >= 4) {
const UInt8* os2 = CFDataGetBytePtr(os2Table.get());
SInt16 os2AvgCharWidth = os2[2] * 256 + os2[3];
m_avgCharWidth = scaleEmToUnits(os2AvgCharWidth, m_fontMetrics.unitsPerEm()) * m_platformData.m_size;
}
- RetainPtr<CFDataRef> headTable(AdoptCF, copyFontTableForTag(m_platformData, 'head'));
+ RetainPtr<CFDataRef> headTable = adoptCF(copyFontTableForTag(m_platformData, 'head'));
if (headTable && CFDataGetLength(headTable.get()) >= 42) {
const UInt8* head = CFDataGetBytePtr(headTable.get());
ushort uxMin = head[36] * 256 + head[37];
@@ -313,7 +270,7 @@ void SimpleFontData::platformDestroy()
}
}
-PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
+PassRefPtr<SimpleFontData> SimpleFontData::platformCreateScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
{
if (isCustomFont()) {
FontPlatformData scaledFontData(m_platformData);
@@ -441,10 +398,10 @@ bool SimpleFontData::canRenderCombiningCharacterSequence(const UChar* characters
if (!addResult.isNewEntry)
return addResult.iterator->value;
- RetainPtr<CGFontRef> cgFont(AdoptCF, CTFontCopyGraphicsFont(platformData().ctFont(), 0));
+ RetainPtr<CGFontRef> cgFont = adoptCF(CTFontCopyGraphicsFont(platformData().ctFont(), 0));
ProviderInfo info = { characters, length, getCFStringAttributes(0, platformData().orientation()) };
- RetainPtr<CTLineRef> line(AdoptCF, wkCreateCTLineWithUniCharProvider(&provideStringAndAttributes, 0, &info));
+ RetainPtr<CTLineRef> line = adoptCF(wkCreateCTLineWithUniCharProvider(&provideStringAndAttributes, 0, &info));
CFArrayRef runArray = CTLineGetGlyphRuns(line.get());
CFIndex runCount = CFArrayGetCount(runArray);
@@ -454,7 +411,7 @@ bool SimpleFontData::canRenderCombiningCharacterSequence(const UChar* characters
ASSERT(CFGetTypeID(ctRun) == CTRunGetTypeID());
CFDictionaryRef runAttributes = CTRunGetAttributes(ctRun);
CTFontRef runFont = static_cast<CTFontRef>(CFDictionaryGetValue(runAttributes, kCTFontAttributeName));
- RetainPtr<CGFontRef> runCGFont(AdoptCF, CTFontCopyGraphicsFont(runFont, 0));
+ RetainPtr<CGFontRef> runCGFont = adoptCF(CTFontCopyGraphicsFont(runFont, 0));
if (!CFEqual(runCGFont.get(), cgFont.get()))
return false;
}
diff --git a/Source/WebCore/platform/graphics/mac/WebGLLayer.mm b/Source/WebCore/platform/graphics/mac/WebGLLayer.mm
index 2000e1270..d510b619d 100644
--- a/Source/WebCore/platform/graphics/mac/WebGLLayer.mm
+++ b/Source/WebCore/platform/graphics/mac/WebGLLayer.mm
@@ -36,7 +36,6 @@
#import <OpenGL/gl.h>
#import <wtf/FastMalloc.h>
#import <wtf/RetainPtr.h>
-#import <wtf/UnusedParam.h>
using namespace WebCore;
@@ -116,7 +115,7 @@ static void freeData(void *, const void *data, size_t /* size */)
RetainPtr<CGColorSpaceRef> imageColorSpace = colorSpace;
if (!imageColorSpace)
- imageColorSpace.adoptCF(CGColorSpaceCreateDeviceRGB());
+ imageColorSpace = adoptCF(CGColorSpaceCreateDeviceRGB());
CGRect layerBounds = CGRectIntegral([self bounds]);
diff --git a/Source/WebCore/platform/graphics/mac/WebLayer.h b/Source/WebCore/platform/graphics/mac/WebLayer.h
index 1266bb749..65569ce5a 100644
--- a/Source/WebCore/platform/graphics/mac/WebLayer.h
+++ b/Source/WebCore/platform/graphics/mac/WebLayer.h
@@ -36,13 +36,6 @@ namespace WebCore {
class PlatformCALayerClient;
}
-#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED == 1050
-@interface CALayer(WebLayerInternal)
-- (CGAffineTransform)contentsTransform;
-- (void)setContentsTransform:(CGAffineTransform)t;
-@end
-#endif
-
@interface WebLayer : CALayer
{
}
diff --git a/Source/WebCore/platform/graphics/mac/WebLayer.mm b/Source/WebCore/platform/graphics/mac/WebLayer.mm
index e4663abaf..58556c145 100644
--- a/Source/WebCore/platform/graphics/mac/WebLayer.mm
+++ b/Source/WebCore/platform/graphics/mac/WebLayer.mm
@@ -33,10 +33,9 @@
#import "GraphicsLayerCA.h"
#import "PlatformCALayer.h"
#import "ThemeMac.h"
+#import "WebCoreSystemInterface.h"
#import <objc/runtime.h>
#import <QuartzCore/QuartzCore.h>
-#import <wtf/UnusedParam.h>
-#import "WebCoreSystemInterface.h"
@interface CALayer(WebCoreCALayerPrivate)
- (void)reloadValueForKeyPath:(NSString *)keyPath;
@@ -80,9 +79,13 @@ void drawLayerContents(CGContextRef context, CALayer *layer, WebCore::PlatformCA
// smaller than the layer bounds (e.g. tiled layers)
FloatRect clipBounds = CGContextGetClipBoundingBox(context);
+ FloatRect focusRingClipRect = clipBounds;
+#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1090
// Set the focus ring clip rect which needs to be in base coordinates.
AffineTransform transform = CGContextGetCTM(context);
- ThemeMac::setFocusRingClipRect(transform.mapRect(clipBounds));
+ focusRingClipRect = transform.mapRect(clipBounds);
+#endif
+ ThemeMac::setFocusRingClipRect(focusRingClipRect);
#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
const float wastedSpaceThreshold = 0.75f;
@@ -128,11 +131,16 @@ void drawLayerContents(CGContextRef context, CALayer *layer, WebCore::PlatformCA
// Re-fetch the layer owner, since <rdar://problem/9125151> indicates that it might have been destroyed during painting.
layerContents = platformLayer->owner();
ASSERT(layerContents);
- if (!platformLayer->usesTileCacheLayer() && layerContents && layerContents->platformCALayerShowRepaintCounter(platformLayer)) {
+
+ // Always update the repain count so that it's accurate even if the count itself is not shown. This will be useful
+ // for the Web Inspector feeding this information through the LayerTreeAgent.
+ int repaintCount = layerContents->platformCALayerIncrementRepaintCount();
+
+ if (!platformLayer->usesTiledBackingLayer() && layerContents && layerContents->platformCALayerShowRepaintCounter(platformLayer)) {
bool isTiledLayer = [layer isKindOfClass:[CATiledLayer class]];
char text[16]; // that's a lot of repaints
- snprintf(text, sizeof(text), "%d", layerContents->platformCALayerIncrementRepaintCount());
+ snprintf(text, sizeof(text), "%d", repaintCount);
CGRect indicatorBox = layerBounds;
indicatorBox.size.width = 12 + 10 * strlen(text);
diff --git a/Source/WebCore/platform/graphics/mac/WebTiledLayer.mm b/Source/WebCore/platform/graphics/mac/WebTiledLayer.mm
index 65fa7d2ee..943a049d5 100644
--- a/Source/WebCore/platform/graphics/mac/WebTiledLayer.mm
+++ b/Source/WebCore/platform/graphics/mac/WebTiledLayer.mm
@@ -32,7 +32,6 @@
#import "GraphicsContext.h"
#import "GraphicsLayerCA.h"
#import "PlatformCALayer.h"
-#import <wtf/UnusedParam.h>
using namespace WebCore;
diff --git a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp
index 6ccf4b26c..0905c9213 100644
--- a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp
+++ b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp
@@ -35,7 +35,7 @@
#if PLATFORM(MAC)
#include "ANGLE/ShaderLang.h"
#include <OpenGL/gl.h>
-#elif PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(QT)
+#elif PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(QT) || PLATFORM(WIN)
#include "OpenGLShims.h"
#endif
@@ -64,22 +64,26 @@ void Extensions3DOpenGL::renderbufferStorageMultisample(unsigned long target, un
Platform3DObject Extensions3DOpenGL::createVertexArrayOES()
{
m_context->makeContextCurrent();
-#if !PLATFORM(GTK) && !PLATFORM(QT) && !PLATFORM(EFL) && defined(GL_APPLE_vertex_array_object) && GL_APPLE_vertex_array_object
GLuint array = 0;
+#if (PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(EFL)) || PLATFORM(WIN)
+ if (isVertexArrayObjectSupported())
+ glGenVertexArrays(1, &array);
+#elif defined(GL_APPLE_vertex_array_object) && GL_APPLE_vertex_array_object
glGenVertexArraysAPPLE(1, &array);
- return array;
-#else
- return 0;
#endif
+ return array;
}
void Extensions3DOpenGL::deleteVertexArrayOES(Platform3DObject array)
{
if (!array)
return;
-
+
m_context->makeContextCurrent();
-#if !PLATFORM(GTK) && !PLATFORM(QT) && !PLATFORM(EFL) && defined(GL_APPLE_vertex_array_object) && GL_APPLE_vertex_array_object
+#if (PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(EFL) || PLATFORM(WIN))
+ if (isVertexArrayObjectSupported())
+ glDeleteVertexArrays(1, &array);
+#elif defined(GL_APPLE_vertex_array_object) && GL_APPLE_vertex_array_object
glDeleteVertexArraysAPPLE(1, &array);
#endif
}
@@ -88,19 +92,24 @@ GC3Dboolean Extensions3DOpenGL::isVertexArrayOES(Platform3DObject array)
{
if (!array)
return GL_FALSE;
-
+
m_context->makeContextCurrent();
-#if !PLATFORM(GTK) && !PLATFORM(QT) && !PLATFORM(EFL) && defined(GL_APPLE_vertex_array_object) && GL_APPLE_vertex_array_object
+#if (PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(EFL) || PLATFORM(WIN))
+ if (isVertexArrayObjectSupported())
+ return glIsVertexArray(array);
+#elif defined(GL_APPLE_vertex_array_object) && GL_APPLE_vertex_array_object
return glIsVertexArrayAPPLE(array);
-#else
- return GL_FALSE;
#endif
+ return GL_FALSE;
}
void Extensions3DOpenGL::bindVertexArrayOES(Platform3DObject array)
{
m_context->makeContextCurrent();
-#if !PLATFORM(GTK) && !PLATFORM(QT) && !PLATFORM(EFL) && defined(GL_APPLE_vertex_array_object) && GL_APPLE_vertex_array_object
+#if (PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(EFL) || PLATFORM(WIN))
+ if (isVertexArrayObjectSupported())
+ glBindVertexArray(array);
+#elif defined(GL_APPLE_vertex_array_object) && GL_APPLE_vertex_array_object
glBindVertexArrayAPPLE(array);
#else
UNUSED_PARAM(array);
@@ -150,8 +159,13 @@ bool Extensions3DOpenGL::supportsExtension(const String& name)
return m_availableExtensions.contains("GL_ARB_texture_float");
// GL_OES_vertex_array_object
- if (name == "GL_OES_vertex_array_object")
+ if (name == "GL_OES_vertex_array_object") {
+#if (PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(EFL))
+ return m_availableExtensions.contains("GL_ARB_vertex_array_object");
+#else
return m_availableExtensions.contains("GL_APPLE_vertex_array_object");
+#endif
+ }
// Desktop GL always supports the standard derivative functions
if (name == "GL_OES_standard_derivatives")
@@ -164,14 +178,41 @@ bool Extensions3DOpenGL::supportsExtension(const String& name)
if (name == "GL_EXT_texture_filter_anisotropic")
return m_availableExtensions.contains("GL_EXT_texture_filter_anisotropic");
+ if (name == "GL_EXT_draw_buffers") {
+#if PLATFORM(MAC)
+ return m_availableExtensions.contains("GL_ARB_draw_buffers");
+#else
+ // FIXME: implement support for other platforms.
+ return false;
+#endif
+ }
return m_availableExtensions.contains(name);
}
+void Extensions3DOpenGL::drawBuffersEXT(GC3Dsizei n, const GC3Denum* bufs)
+{
+ // FIXME: implement support for other platforms.
+#if PLATFORM(MAC)
+ ::glDrawBuffersARB(n, bufs);
+#else
+ UNUSED_PARAM(n);
+ UNUSED_PARAM(bufs);
+#endif
+}
+
String Extensions3DOpenGL::getExtensions()
{
return String(reinterpret_cast<const char*>(::glGetString(GL_EXTENSIONS)));
}
+#if (PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(EFL) || PLATFORM(WIN))
+bool Extensions3DOpenGL::isVertexArrayObjectSupported()
+{
+ static const bool supportsVertexArrayObject = supports("GL_OES_vertex_array_object");
+ return supportsVertexArrayObject;
+}
+#endif
+
} // namespace WebCore
#endif // USE(3D_GRAPHICS)
diff --git a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h
index 3bec89656..f9d69e9f4 100644
--- a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h
+++ b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h
@@ -51,6 +51,7 @@ public:
virtual void insertEventMarkerEXT(const String&);
virtual void pushGroupMarkerEXT(const String&);
virtual void popGroupMarkerEXT(void);
+ virtual void drawBuffersEXT(GC3Dsizei, const GC3Denum*);
protected:
// This class only needs to be instantiated by GraphicsContext3D implementations.
@@ -59,6 +60,10 @@ protected:
virtual bool supportsExtension(const WTF::String&);
virtual String getExtensions();
+#if (PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(EFL) || PLATFORM(WIN))
+private:
+ bool isVertexArrayObjectSupported();
+#endif
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp
index aaf68d8be..f413a675a 100644
--- a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp
+++ b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp
@@ -42,7 +42,7 @@
#include <GLES2/gl2ext.h>
#elif PLATFORM(MAC)
#include <OpenGL/gl.h>
-#elif PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(QT)
+#elif PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(QT) || PLATFORM(WIN)
#include "OpenGLShims.h"
#endif
@@ -91,8 +91,8 @@ Extensions3DOpenGLCommon::Extensions3DOpenGLCommon(GraphicsContext3D* context)
systemSupportsMultisampling = version >= 0x1072;
#endif // SNOW_LEOPARD and LION
- if (m_isNVIDIA || (m_isAMD && systemSupportsMultisampling))
- m_maySupportMultisampling = true;
+ if (m_isAMD && !systemSupportsMultisampling)
+ m_maySupportMultisampling = false;
#endif
}
@@ -118,6 +118,15 @@ void Extensions3DOpenGLCommon::ensureEnabled(const String& name)
ANGLEResources.OES_standard_derivatives = 1;
compiler.setResources(ANGLEResources);
}
+ } else if (name == "GL_EXT_draw_buffers") {
+ // Enable support in ANGLE (if not enabled already)
+ ANGLEWebKitBridge& compiler = m_context->m_compiler;
+ ShBuiltInResources ANGLEResources = compiler.getResources();
+ if (!ANGLEResources.EXT_draw_buffers) {
+ ANGLEResources.EXT_draw_buffers = 1;
+ m_context->getIntegerv(Extensions3D::MAX_DRAW_BUFFERS_EXT, &ANGLEResources.MaxDrawBuffers);
+ compiler.setResources(ANGLEResources);
+ }
}
}
@@ -161,7 +170,7 @@ String Extensions3DOpenGLCommon::getTranslatedShaderSourceANGLE(Platform3DObject
String translatedShaderSource;
String shaderInfoLog;
- int extraCompileOptions = SH_MAP_LONG_VARIABLE_NAMES;
+ int extraCompileOptions = SH_MAP_LONG_VARIABLE_NAMES | SH_CLAMP_INDIRECT_ARRAY_BOUNDS;
if (m_requiresBuiltInFunctionEmulation)
extraCompileOptions |= SH_EMULATE_BUILT_IN_FUNCTIONS;
diff --git a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.h b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.h
index 7092cfaca..4cc8dbac1 100644
--- a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.h
+++ b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.h
@@ -50,6 +50,8 @@ public:
virtual GC3Dboolean isVertexArrayOES(Platform3DObject) = 0;
virtual void bindVertexArrayOES(Platform3DObject) = 0;
+ virtual void drawBuffersEXT(GC3Dsizei, const GC3Denum*) = 0;
+
virtual String getTranslatedShaderSourceANGLE(Platform3DObject);
// EXT Robustness - uses getGraphicsResetStatusARB()
diff --git a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.cpp b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.cpp
index 9d619b6fb..662bb02f6 100644
--- a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.cpp
+++ b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.cpp
@@ -160,6 +160,11 @@ void Extensions3DOpenGLES::bindVertexArrayOES(Platform3DObject array)
m_context->synthesizeGLError(GL_INVALID_OPERATION);
}
+void Extensions3DOpenGLES::drawBuffersEXT(GC3Dsizei n, const GC3Denum* bufs)
+{
+ // FIXME: implement the support.
+}
+
int Extensions3DOpenGLES::getGraphicsResetStatusARB()
{
// FIXME: This does not call getGraphicsResetStatusARB, but instead getGraphicsResetStatusEXT.
@@ -250,6 +255,9 @@ bool Extensions3DOpenGLES::supportsExtension(const String& name)
m_glReadnPixelsEXT = reinterpret_cast<PFNGLREADNPIXELSEXTPROC>(eglGetProcAddress("glReadnPixelsEXT"));
m_glGetnUniformfvEXT = reinterpret_cast<PFNGLGETNUNIFORMFVEXTPROC>(eglGetProcAddress("glGetnUniformfvEXT"));
m_glGetnUniformivEXT = reinterpret_cast<PFNGLGETNUNIFORMIVEXTPROC>(eglGetProcAddress("glGetnUniformivEXT"));
+ } else if (name == "GL_EXT_draw_buffers") {
+ // FIXME: implement the support.
+ return false;
}
return true;
}
diff --git a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.h b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.h
index a70eaa7cd..21ec2e572 100644
--- a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.h
+++ b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.h
@@ -90,6 +90,7 @@ public:
virtual void deleteVertexArrayOES(Platform3DObject);
virtual GC3Dboolean isVertexArrayOES(Platform3DObject);
virtual void bindVertexArrayOES(Platform3DObject);
+ virtual void drawBuffersEXT(GC3Dsizei, const GC3Denum*);
// EXT Robustness - reset
virtual int getGraphicsResetStatusARB();
diff --git a/Source/WebCore/platform/graphics/opengl/GLDefs.h b/Source/WebCore/platform/graphics/opengl/GLDefs.h
index 6e36a1116..659d24974 100644
--- a/Source/WebCore/platform/graphics/opengl/GLDefs.h
+++ b/Source/WebCore/platform/graphics/opengl/GLDefs.h
@@ -28,32 +28,55 @@
#if USE(ACCELERATED_COMPOSITING)
+#define GL_GLEXT_PROTOTYPES 1
+
#if USE(OPENGL_ES_2)
#include "Extensions3DOpenGLES.h"
+#include "OpenGLESShims.h"
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
#else
#include "Extensions3DOpenGL.h"
-#endif
-
#include "OpenGLShims.h"
-
#include <GL/gl.h>
#include <GL/glext.h>
-#if HAVE(GLX)
+#if USE(GLX)
+#define GLX_GLXEXT_PROTOTYPES 1
#include <GL/glx.h>
+#include <GL/glxext.h>
+#endif
+#endif
+
+#if USE(EGL)
+#define EGL_EGLEXT_PROTOTYPES 1
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
#endif
namespace WebCore {
-#if HAVE(GLX)
+typedef uint32_t PlatformBufferHandle;
+
+#if USE(GLX)
typedef GLXContext PlatformContext;
typedef Display* PlatformDisplay;
typedef GLXFBConfig PlatformSurfaceConfig;
-typedef GLXDrawable PlatformSurface;
+typedef GLXDrawable PlatformDrawable;
+#elif USE(EGL)
+#if USE(OPENGL_ES_2)
+static const EGLenum eglAPIVersion = EGL_OPENGL_ES_API;
+#else
+static const EGLenum eglAPIVersion = EGL_OPENGL_API;
+#endif
+typedef EGLContext PlatformContext;
+typedef EGLDisplay PlatformDisplay;
+typedef EGLConfig PlatformSurfaceConfig;
+typedef EGLSurface PlatformDrawable;
#else
typedef void* PlatformContext;
typedef void* PlatformDisplay;
typedef void* PlatformSurfaceConfig;
-typedef void* PlatformSurface;
+typedef void* PlatformDrawable;
#endif
}
diff --git a/Source/WebCore/platform/graphics/opengl/GLPlatformContext.cpp b/Source/WebCore/platform/graphics/opengl/GLPlatformContext.cpp
index 17b30842d..9ab3dea95 100644
--- a/Source/WebCore/platform/graphics/opengl/GLPlatformContext.cpp
+++ b/Source/WebCore/platform/graphics/opengl/GLPlatformContext.cpp
@@ -28,39 +28,95 @@
#if USE(ACCELERATED_COMPOSITING)
-#if HAVE(GLX)
+#if USE(GLX)
#include "GLXContext.h"
+#elif USE(EGL)
+#include "EGLContext.h"
#endif
#include "NotImplemented.h"
namespace WebCore {
-static PFNGLGETGRAPHICSRESETSTATUSARBPROC glGetGraphicsResetStatusARB = 0;
+#if USE(OPENGL_ES_2)
+static PFNGLGETGRAPHICSRESETSTATUSEXTPROC glGetGraphicsResetStatus = 0;
+#else
+static PFNGLGETGRAPHICSRESETSTATUSARBPROC glGetGraphicsResetStatus = 0;
+#endif
static GLPlatformContext* m_currentContext = 0;
-PassOwnPtr<GLPlatformContext> GLPlatformContext::createContext(GraphicsContext3D::RenderStyle renderStyle)
+class GLCurrentContextWrapper : public GLPlatformContext {
+
+public:
+ GLCurrentContextWrapper()
+ : GLPlatformContext()
+ {
+#if USE(GLX)
+ m_contextHandle = glXGetCurrentContext();
+#elif USE(EGL)
+ m_contextHandle = eglGetCurrentContext();
+#endif
+ if (m_contextHandle)
+ m_currentContext = this;
+ }
+
+ virtual ~GLCurrentContextWrapper() { }
+};
+
+static PassOwnPtr<GLPlatformContext> createOffScreenContext()
{
- static bool initializedShims = false;
+#if USE(GLX)
+ return adoptPtr(new GLXOffScreenContext());
+#elif USE(EGL)
+ return adoptPtr(new EGLOffScreenContext());
+#else
+ return nullptr;
+#endif
+}
+
+static HashSet<String> parseExtensions(const String& extensionsString)
+{
+ Vector<String> extNames;
+ extensionsString.split(" ", extNames);
+ HashSet<String> splitExtNames;
+ unsigned size = extNames.size();
+ for (unsigned i = 0; i < size; ++i)
+ splitExtNames.add(extNames[i]);
+ extNames.clear();
+
+ return splitExtNames;
+}
- if (!initializedShims) {
- initializedShims = initializeOpenGLShims();
-#if HAVE(GLX)
- glGetGraphicsResetStatusARB = reinterpret_cast<PFNGLGETGRAPHICSRESETSTATUSARBPROC>(glXGetProcAddressARB(reinterpret_cast<const GLubyte*>("glGetGraphicsResetStatusARB")));
+static void resolveResetStatusExtension()
+{
+ static bool resolvedRobustnessExtension = false;
+ if (!resolvedRobustnessExtension) {
+ resolvedRobustnessExtension = true;
+#if USE(OPENGL_ES_2)
+ glGetGraphicsResetStatus = reinterpret_cast<PFNGLGETGRAPHICSRESETSTATUSEXTPROC>(eglGetProcAddress("glGetGraphicsResetStatusEXT"));
+#elif USE(EGL)
+ glGetGraphicsResetStatus = reinterpret_cast<PFNGLGETGRAPHICSRESETSTATUSARBPROC>(eglGetProcAddress("glGetGraphicsResetStatusARB"));
+#elif USE(GLX)
+ glGetGraphicsResetStatus = reinterpret_cast<PFNGLGETGRAPHICSRESETSTATUSARBPROC>(glXGetProcAddressARB(reinterpret_cast<const GLubyte*>("glGetGraphicsResetStatusARB")));
#endif
}
+}
- if (!initializedShims)
+PassOwnPtr<GLPlatformContext> GLPlatformContext::createContext(GraphicsContext3D::RenderStyle renderStyle)
+{
+#if !USE(OPENGL_ES_2)
+ if (!initializeOpenGLShims())
return nullptr;
+#endif
switch (renderStyle) {
case GraphicsContext3D::RenderOffscreen:
- if (OwnPtr<GLPlatformContext> glxContext = GLPlatformContext::createOffScreenContext())
- return glxContext.release();
+ if (OwnPtr<GLPlatformContext> context = createOffScreenContext())
+ return context.release();
break;
case GraphicsContext3D::RenderToCurrentGLContext:
- if (OwnPtr<GLPlatformContext> glxContext = GLPlatformContext::createCurrentContextWrapper())
- return glxContext.release();
+ if (OwnPtr<GLPlatformContext> context = adoptPtr(new GLCurrentContextWrapper()))
+ return context.release();
break;
case GraphicsContext3D::RenderDirectlyToHostWindow:
ASSERT_NOT_REACHED();
@@ -70,25 +126,60 @@ PassOwnPtr<GLPlatformContext> GLPlatformContext::createContext(GraphicsContext3D
return nullptr;
}
-PassOwnPtr<GLPlatformContext> GLPlatformContext::createOffScreenContext()
+bool GLPlatformContext::supportsGLExtension(const String& name)
{
-#if HAVE(GLX)
- OwnPtr<GLPlatformContext> glxContext = adoptPtr(new GLXOffScreenContext());
- return glxContext.release();
-#endif
+ static HashSet<String> supportedExtensions;
- return nullptr;
+ if (!supportedExtensions.size()) {
+ String rawExtensions = reinterpret_cast<const char*>(::glGetString(GL_EXTENSIONS));
+ supportedExtensions = parseExtensions(rawExtensions);
+ }
+
+ if (supportedExtensions.contains(name))
+ return true;
+
+ return false;
}
-PassOwnPtr<GLPlatformContext> GLPlatformContext::createCurrentContextWrapper()
+#if USE(EGL)
+bool GLPlatformContext::supportsEGLExtension(EGLDisplay display, const String& name)
{
-#if HAVE(GLX)
- OwnPtr<GLPlatformContext> glxContext = adoptPtr(new GLXCurrentContextWrapper());
- return glxContext.release();
+ static HashSet<String> supportedExtensions;
+
+ if (!supportedExtensions.size()) {
+ if (display == EGL_NO_DISPLAY)
+ return false;
+
+ String rawExtensions = reinterpret_cast<const char*>(eglQueryString(display, EGL_EXTENSIONS));
+ supportedExtensions = parseExtensions(rawExtensions);
+ }
+
+ if (supportedExtensions.contains(name))
+ return true;
+
+ return false;
+}
#endif
- return nullptr;
+#if USE(GLX)
+bool GLPlatformContext::supportsGLXExtension(Display* display, const String& name)
+{
+ static HashSet<String> supportedExtensions;
+
+ if (!supportedExtensions.size()) {
+ if (!display)
+ return false;
+
+ String rawExtensions = glXQueryExtensionsString(display, DefaultScreen(display));
+ supportedExtensions = parseExtensions(rawExtensions);
+ }
+
+ if (supportedExtensions.contains(name))
+ return true;
+
+ return false;
}
+#endif
GLPlatformContext::GLPlatformContext()
: m_contextHandle(0)
@@ -106,32 +197,38 @@ bool GLPlatformContext::makeCurrent(GLPlatformSurface* surface)
{
m_contextLost = false;
- if (isCurrentContext())
+ if (m_currentContext == this && (!surface || surface->isCurrentDrawable()))
return true;
m_currentContext = 0;
- if (!surface || (surface && !surface->handle()))
+ if (!surface || (surface && !surface->drawable()))
platformReleaseCurrent();
- else if (platformMakeCurrent(surface))
+ else if (platformMakeCurrent(surface)) {
m_currentContext = this;
+ surface->onMakeCurrent();
+ }
- if (m_resetLostContext && glGetGraphicsResetStatusARB) {
- GLenum status = glGetGraphicsResetStatusARB();
-
- switch (status) {
- case PLATFORMCONTEXT_NO_ERROR:
- break;
- case PLATFORMCONTEXT_GUILTY_CONTEXT_RESET:
- m_contextLost = true;
- break;
- case PLATFORMCONTEXT_INNOCENT_CONTEXT_RESET:
- break;
- case PLATFORMCONTEXT_UNKNOWN_CONTEXT_RESET:
- m_contextLost = true;
- break;
- default:
- break;
+ if (m_resetLostContext) {
+ resolveResetStatusExtension();
+
+ if (glGetGraphicsResetStatus) {
+ GLenum status = glGetGraphicsResetStatus();
+
+ switch (status) {
+ case PLATFORMCONTEXT_NO_ERROR:
+ break;
+ case PLATFORMCONTEXT_GUILTY_CONTEXT_RESET:
+ m_contextLost = true;
+ break;
+ case PLATFORMCONTEXT_INNOCENT_CONTEXT_RESET:
+ break;
+ case PLATFORMCONTEXT_UNKNOWN_CONTEXT_RESET:
+ m_contextLost = true;
+ break;
+ default:
+ break;
+ }
}
}
@@ -145,11 +242,10 @@ bool GLPlatformContext::isValid() const
void GLPlatformContext::releaseCurrent()
{
- if (!isCurrentContext())
- return;
-
- m_currentContext = 0;
- platformReleaseCurrent();
+ if (this == m_currentContext) {
+ m_currentContext = 0;
+ platformReleaseCurrent();
+ }
}
PlatformContext GLPlatformContext::handle() const
@@ -162,7 +258,7 @@ bool GLPlatformContext::isCurrentContext() const
return true;
}
-bool GLPlatformContext::initialize(GLPlatformSurface*)
+bool GLPlatformContext::initialize(GLPlatformSurface*, PlatformContext)
{
return true;
}
@@ -186,9 +282,6 @@ void GLPlatformContext::destroy()
{
m_contextHandle = 0;
m_resetLostContext = false;
-
- if (this == m_currentContext)
- m_currentContext = 0;
}
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/opengl/GLPlatformContext.h b/Source/WebCore/platform/graphics/opengl/GLPlatformContext.h
index 1959b7be8..2e41db3da 100644
--- a/Source/WebCore/platform/graphics/opengl/GLPlatformContext.h
+++ b/Source/WebCore/platform/graphics/opengl/GLPlatformContext.h
@@ -30,6 +30,7 @@
#include "GLDefs.h"
#include "GLPlatformSurface.h"
+#include "GraphicsContext3D.h"
#include <wtf/Noncopyable.h>
#include <wtf/PassOwnPtr.h>
@@ -50,9 +51,19 @@ public:
static PassOwnPtr<GLPlatformContext> createContext(GraphicsContext3D::RenderStyle);
+ static bool supportsGLExtension(const String&);
+
+#if USE(EGL)
+ static bool supportsEGLExtension(EGLDisplay, const String&);
+#endif
+
+#if USE(GLX)
+ static bool supportsGLXExtension(Display*, const String&);
+#endif
+
virtual ~GLPlatformContext();
- virtual bool initialize(GLPlatformSurface*);
+ virtual bool initialize(GLPlatformSurface*, PlatformContext = 0);
// Makes this and surface as current context and drawable.
// Calling this function with no surface is same as calling releaseCurrent.
@@ -63,7 +74,7 @@ public:
// Doesn't have any effect if this is not the current Context.
void releaseCurrent();
- PlatformContext handle() const;
+ virtual PlatformContext handle() const;
virtual bool isCurrentContext() const;
@@ -81,10 +92,6 @@ protected:
PlatformContext m_contextHandle;
bool m_resetLostContext;
bool m_contextLost;
-
-private:
- static PassOwnPtr<GLPlatformContext> createOffScreenContext();
- static PassOwnPtr<GLPlatformContext> createCurrentContextWrapper();
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp b/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp
index 8944dc068..7c354bb55 100644
--- a/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp
+++ b/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.cpp
@@ -28,51 +28,57 @@
#if USE(ACCELERATED_COMPOSITING)
-#if HAVE(GLX)
+#if USE(GLX)
#include "GLXSurface.h"
#endif
+#if USE(EGL)
+#include "EGLSurface.h"
+#endif
+
#include "NotImplemented.h"
namespace WebCore {
-PassOwnPtr<GLPlatformSurface> GLPlatformSurface::createOffscreenSurface()
-{
-#if HAVE(GLX)
- OwnPtr<GLPlatformSurface> surface = adoptPtr(new GLXPBuffer());
-
- if (surface->handle())
- return surface.release();
-#endif
-
- return nullptr;
-}
+static GLPlatformSurface* m_currentDrawable = 0;
-PassOwnPtr<GLPlatformSurface> GLPlatformSurface::createTransportSurface()
+PassOwnPtr<GLPlatformSurface> GLPlatformSurface::createOffScreenSurface(SurfaceAttributes attributes)
{
-#if HAVE(GLX)
- OwnPtr<GLPlatformSurface> surface = adoptPtr(new GLXTransportSurface());
+ OwnPtr<GLPlatformSurface> surface;
+#if USE(GLX)
+ surface = adoptPtr(new GLXOffScreenSurface(attributes));
+#elif USE(EGL)
+ surface = EGLOffScreenSurface::createOffScreenSurface(attributes);
+#else
+ // FIXME: Need WGL implementation for Windows
+ notImplemented();
+#endif
- if (surface->handle())
+ if (surface && surface->drawable())
return surface.release();
-#endif
return nullptr;
}
-GLPlatformSurface::GLPlatformSurface()
- : m_restoreNeeded(true)
- , m_fboId(0)
- , m_sharedDisplay(0)
+GLPlatformSurface::GLPlatformSurface(SurfaceAttributes)
+ : m_sharedDisplay(0)
, m_drawable(0)
+ , m_bufferHandle(0)
{
}
GLPlatformSurface::~GLPlatformSurface()
{
+ if (m_currentDrawable == this)
+ m_currentDrawable = 0;
}
-PlatformSurface GLPlatformSurface::handle() const
+PlatformBufferHandle GLPlatformSurface::handle() const
+{
+ return m_bufferHandle;
+}
+
+PlatformDrawable GLPlatformSurface::drawable() const
{
return m_drawable;
}
@@ -97,74 +103,33 @@ void GLPlatformSurface::swapBuffers()
notImplemented();
}
-void GLPlatformSurface::copyTexture(uint32_t texture, const IntRect& sourceRect)
+bool GLPlatformSurface::isCurrentDrawable() const
{
- if (!m_fboId)
- glGenFramebuffers(1, &m_fboId);
-
- m_restoreNeeded = true;
- int x = sourceRect.x();
- int y = sourceRect.y();
- int width = sourceRect.width();
- int height = sourceRect.height();
-
- glPushAttrib(GL_COLOR_BUFFER_BIT);
-
- GLint previousFBO;
- glGetIntegerv(GL_FRAMEBUFFER_BINDING, &previousFBO);
-
- glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fboId);
-
- glBindTexture(GL_TEXTURE_2D, texture);
- glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
-
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
-
- glBlitFramebuffer(x, y, width, height, x, y, width, height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
-
- glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
- glBindTexture(GL_TEXTURE_2D, 0);
- glBindFramebuffer(GL_FRAMEBUFFER, previousFBO);
-
- glPopAttrib();
+ return m_currentDrawable == this;
}
-void GLPlatformSurface::updateContents(uint32_t texture, const IntRect& sourceRect, const GLuint bindFboId)
+void GLPlatformSurface::onMakeCurrent()
{
- m_restoreNeeded = false;
-
- if (!m_fboId)
- glGenFramebuffers(1, &m_fboId);
-
- int x = sourceRect.x();
- int y = sourceRect.y();
- int width = sourceRect.width();
- int height = sourceRect.height();
+ m_currentDrawable = this;
+}
- glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fboId);
- glBindTexture(GL_TEXTURE_2D, texture);
- glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
- glBlitFramebuffer(x, y, width, height, x, y, width, height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
- swapBuffers();
- glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
- glBindTexture(GL_TEXTURE_2D, 0);
- glBindFramebuffer(GL_FRAMEBUFFER, bindFboId);
+void GLPlatformSurface::updateContents(const uint32_t)
+{
}
-void GLPlatformSurface::setGeometry(const IntRect& newRect)
+void GLPlatformSurface::setGeometry(const IntRect&)
{
- m_rect = newRect;
}
void GLPlatformSurface::destroy()
{
- m_rect = IntRect();
-
- if (m_fboId)
- glDeleteFramebuffers(1, &m_fboId);
+ if (m_currentDrawable == this)
+ m_currentDrawable = 0;
+}
- m_fboId = 0;
+GLPlatformSurface::SurfaceAttributes GLPlatformSurface::attributes() const
+{
+ return GLPlatformSurface::Default;
}
}
diff --git a/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h b/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h
index f1066b7be..d276fa5e8 100644
--- a/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h
+++ b/Source/WebCore/platform/graphics/opengl/GLPlatformSurface.h
@@ -29,8 +29,8 @@
#if USE(ACCELERATED_COMPOSITING)
#include "GLDefs.h"
+#include "IntRect.h"
#include <wtf/Noncopyable.h>
-#include <wtf/PassOwnPtr.h>
// Encapsulates a surface that can be rendered to with GL, hiding platform
// specific management.
@@ -40,46 +40,56 @@ class GLPlatformSurface {
WTF_MAKE_NONCOPYABLE(GLPlatformSurface);
public:
- // Creates a GL surface used for offscreen rendering.
- static PassOwnPtr<GLPlatformSurface> createOffscreenSurface();
+ enum Attributes {
+ Default = 0x00, // No Alpha channel. Only R,G,B values set.
+ SupportAlpha = 0x01,
+ DoubleBuffered = 0x02
+ };
- // Creates a GL surface used for offscreen rendering. The results can be transported
- // to the UI process for display.
- static PassOwnPtr<GLPlatformSurface> createTransportSurface();
+ typedef unsigned SurfaceAttributes;
+ // Creates a GL surface used for offscreen rendering.
+ static PassOwnPtr<GLPlatformSurface> createOffScreenSurface(SurfaceAttributes = GLPlatformSurface::Default);
virtual ~GLPlatformSurface();
const IntRect& geometry() const;
- // Get the underlying platform specific surface handle.
- PlatformSurface handle() const;
+ // Get the underlying platform specific buffer handle.
+ // The handle will be null if surface doesn't support
+ // buffer sharing.
+ PlatformBufferHandle handle() const;
+
+ PlatformDrawable drawable() const;
PlatformDisplay sharedDisplay() const;
+ virtual SurfaceAttributes attributes() const;
+
virtual void swapBuffers();
- virtual void copyTexture(uint32_t texture, const IntRect& sourceRect);
+ virtual bool isCurrentDrawable() const;
+ virtual void onMakeCurrent();
- // Convenience Function to update surface backbuffer with texture contents and restore current FBO.
+ // Convenience Function to update surface backbuffer with texture contents.
+ // Note that the function doesn't track or restore any GL states.
// Function does the following(in order):
- // a)Blits texture contents to back buffer.
- // b)Calls Swap Buffers.
- // c)Sets current FBO as bindFboId.
- virtual void updateContents(uint32_t texture, const IntRect& sourceRect, const GLuint bindFboId);
+ // a) Blits texture contents to back buffer.
+ // b) Calls Swap Buffers.
+ virtual void updateContents(const uint32_t);
- virtual void setGeometry(const IntRect& newRect);
+ virtual void setGeometry(const IntRect&);
virtual PlatformSurfaceConfig configuration();
virtual void destroy();
protected:
- GLPlatformSurface();
- bool m_restoreNeeded;
- IntRect m_rect;
- GLuint m_fboId;
+ GLPlatformSurface(SurfaceAttributes);
+
PlatformDisplay m_sharedDisplay;
- PlatformSurface m_drawable;
+ PlatformDrawable m_drawable;
+ PlatformBufferHandle m_bufferHandle;
+ IntRect m_rect;
};
}
@@ -87,3 +97,4 @@ protected:
#endif
#endif
+
diff --git a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp
index d7c05e627..fbdca0e07 100644
--- a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp
+++ b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp
@@ -38,12 +38,11 @@
#include <algorithm>
#include <cstring>
#include <wtf/MainThread.h>
-#include <wtf/UnusedParam.h>
#include <wtf/text/CString.h>
#if PLATFORM(MAC)
#include <OpenGL/gl.h>
-#elif PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(QT)
+#elif PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(QT) || PLATFORM(WIN)
#include "OpenGLShims.h"
#endif
@@ -62,14 +61,7 @@ void GraphicsContext3D::readPixelsAndConvertToBGRAIfNecessary(int x, int y, int
void GraphicsContext3D::validateAttributes()
{
- Extensions3D* extensions = getExtensions();
validateDepthStencil("GL_EXT_packed_depth_stencil");
- if (m_attrs.antialias) {
- if (!extensions->maySupportMultisampling() || !extensions->supports("GL_ANGLE_framebuffer_multisample") || isGLES2Compliant())
- m_attrs.antialias = false;
- else
- extensions->ensureEnabled("GL_ANGLE_framebuffer_multisample");
- }
}
bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
@@ -105,7 +97,7 @@ bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
GLint sampleCount = std::min(8, maxSampleCount);
if (sampleCount > maxSampleCount)
sampleCount = maxSampleCount;
- if (m_boundFBO != m_multisampleFBO) {
+ if (m_state.boundFBO != m_multisampleFBO) {
::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
mustRestoreFBO = true;
}
@@ -128,7 +120,7 @@ bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
}
// resize regular FBO
- if (m_boundFBO != m_fbo) {
+ if (m_state.boundFBO != m_fbo) {
mustRestoreFBO = true;
::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
}
@@ -154,7 +146,7 @@ bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
if (m_attrs.antialias) {
::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
- if (m_boundFBO == m_multisampleFBO)
+ if (m_state.boundFBO == m_multisampleFBO)
mustRestoreFBO = false;
}
@@ -263,8 +255,19 @@ bool GraphicsContext3D::texImage2D(GC3Denum target, GC3Dint level, GC3Denum inte
openGLInternalFormat = GL_RGBA32F_ARB;
else if (format == GL_RGB)
openGLInternalFormat = GL_RGB32F_ARB;
+ } else if (type == HALF_FLOAT_OES) {
+ if (format == GL_RGBA)
+ openGLInternalFormat = GL_RGBA16F_ARB;
+ else if (format == GL_RGB)
+ openGLInternalFormat = GL_RGB16F_ARB;
+ else if (format == GL_LUMINANCE)
+ openGLInternalFormat = GL_LUMINANCE16F_ARB;
+ else if (format == GL_ALPHA)
+ openGLInternalFormat = GL_ALPHA16F_ARB;
+ else if (format == GL_LUMINANCE_ALPHA)
+ openGLInternalFormat = GL_LUMINANCE_ALPHA16F_ARB;
+ type = GL_HALF_FLOAT_ARB;
}
-
texImage2DDirect(target, level, openGLInternalFormat, width, height, border, format, type, pixels);
return true;
}
@@ -294,13 +297,13 @@ void GraphicsContext3D::readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsi
// all previous rendering calls should be done before reading pixels.
makeContextCurrent();
::glFlush();
- if (m_attrs.antialias && m_boundFBO == m_multisampleFBO) {
+ if (m_attrs.antialias && m_state.boundFBO == m_multisampleFBO) {
resolveMultisamplingIfNecessary(IntRect(x, y, width, height));
::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_fbo);
::glFlush();
}
::glReadPixels(x, y, width, height, format, type, data);
- if (m_attrs.antialias && m_boundFBO == m_multisampleFBO)
+ if (m_attrs.antialias && m_state.boundFBO == m_multisampleFBO)
::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO);
}
diff --git a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp
index 58cfd7f7e..9d46a4c3d 100644
--- a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp
+++ b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp
@@ -32,7 +32,6 @@
#include "GraphicsContext3D.h"
-#include "CanvasRenderingContext.h"
#if USE(OPENGL_ES_2)
#include "Extensions3DOpenGLES.h"
#else
@@ -44,7 +43,6 @@
#include "IntRect.h"
#include "IntSize.h"
#include "NotImplemented.h"
-#include "WebGLObject.h"
#include <cstring>
#include <wtf/ArrayBuffer.h>
#include <wtf/ArrayBufferView.h>
@@ -53,14 +51,13 @@
#include <wtf/MainThread.h>
#include <wtf/OwnArrayPtr.h>
#include <wtf/Uint8Array.h>
-#include <wtf/UnusedParam.h>
#include <wtf/text/CString.h>
#if USE(OPENGL_ES_2)
#include "OpenGLESShims.h"
#elif PLATFORM(MAC)
#include <OpenGL/gl.h>
-#elif PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(QT)
+#elif PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(QT) || PLATFORM(WIN)
#include "OpenGLShims.h"
#endif
@@ -120,7 +117,7 @@ void GraphicsContext3D::paintRenderingResultsToCanvas(ImageBuffer* imageBuffer,
}
}
-#if PLATFORM(BLACKBERRY)
+#if PLATFORM(BLACKBERRY) || USE(CG)
paintToCanvas(pixels.get(), m_currentWidth, m_currentHeight,
imageBuffer->internalSize().width(), imageBuffer->internalSize().height(), imageBuffer->context());
#else
@@ -169,10 +166,10 @@ void GraphicsContext3D::prepareTexture()
::glActiveTexture(GL_TEXTURE0);
::glBindTexture(GL_TEXTURE_2D, m_compositorTexture);
::glCopyTexImage2D(GL_TEXTURE_2D, 0, m_internalColorFormat, 0, 0, m_currentWidth, m_currentHeight, 0);
- ::glBindTexture(GL_TEXTURE_2D, m_boundTexture0);
- ::glActiveTexture(m_activeTexture);
- if (m_boundFBO != m_fbo)
- ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_boundFBO);
+ ::glBindTexture(GL_TEXTURE_2D, m_state.boundTexture0);
+ ::glActiveTexture(m_state.activeTexture);
+ if (m_state.boundFBO != m_fbo)
+ ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_state.boundFBO);
::glFinish();
m_layerComposited = true;
}
@@ -191,7 +188,7 @@ void GraphicsContext3D::readRenderingResults(unsigned char *pixels, int pixelsSi
::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_fbo);
mustRestoreFBO = true;
} else {
- if (m_boundFBO != m_fbo) {
+ if (m_state.boundFBO != m_fbo) {
mustRestoreFBO = true;
::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_fbo);
}
@@ -211,7 +208,7 @@ void GraphicsContext3D::readRenderingResults(unsigned char *pixels, int pixelsSi
::glPixelStorei(GL_PACK_ALIGNMENT, packAlignment);
if (mustRestoreFBO)
- ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_boundFBO);
+ ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_state.boundFBO);
}
void GraphicsContext3D::reshape(int width, int height)
@@ -288,7 +285,7 @@ void GraphicsContext3D::reshape(int width, int height)
::glDisable(GL_DITHER);
if (mustRestoreFBO)
- ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_boundFBO);
+ ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_state.boundFBO);
::glFlush();
}
@@ -301,7 +298,7 @@ IntSize GraphicsContext3D::getInternalFramebufferSize() const
void GraphicsContext3D::activeTexture(GC3Denum texture)
{
makeContextCurrent();
- m_activeTexture = texture;
+ m_state.activeTexture = texture;
::glActiveTexture(texture);
}
@@ -338,9 +335,9 @@ void GraphicsContext3D::bindFramebuffer(GC3Denum target, Platform3DObject buffer
#else
fbo = (m_attrs.antialias ? m_multisampleFBO : m_fbo);
#endif
- if (fbo != m_boundFBO) {
+ if (fbo != m_state.boundFBO) {
::glBindFramebufferEXT(target, fbo);
- m_boundFBO = fbo;
+ m_state.boundFBO = fbo;
}
}
@@ -354,8 +351,8 @@ void GraphicsContext3D::bindRenderbuffer(GC3Denum target, Platform3DObject rende
void GraphicsContext3D::bindTexture(GC3Denum target, Platform3DObject texture)
{
makeContextCurrent();
- if (m_activeTexture == GL_TEXTURE0 && target == GL_TEXTURE_2D)
- m_boundTexture0 = texture;
+ if (m_state.activeTexture == GL_TEXTURE0 && target == GL_TEXTURE_2D)
+ m_state.boundTexture0 = texture;
::glBindTexture(target, texture);
}
@@ -487,14 +484,14 @@ void GraphicsContext3D::copyTexImage2D(GC3Denum target, GC3Dint level, GC3Denum
{
makeContextCurrent();
#if !PLATFORM(BLACKBERRY)
- if (m_attrs.antialias && m_boundFBO == m_multisampleFBO) {
+ if (m_attrs.antialias && m_state.boundFBO == m_multisampleFBO) {
resolveMultisamplingIfNecessary(IntRect(x, y, width, height));
::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_fbo);
}
#endif
::glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
#if !PLATFORM(BLACKBERRY)
- if (m_attrs.antialias && m_boundFBO == m_multisampleFBO)
+ if (m_attrs.antialias && m_state.boundFBO == m_multisampleFBO)
::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO);
#endif
}
@@ -503,14 +500,14 @@ void GraphicsContext3D::copyTexSubImage2D(GC3Denum target, GC3Dint level, GC3Din
{
makeContextCurrent();
#if !PLATFORM(BLACKBERRY)
- if (m_attrs.antialias && m_boundFBO == m_multisampleFBO) {
+ if (m_attrs.antialias && m_state.boundFBO == m_multisampleFBO) {
resolveMultisamplingIfNecessary(IntRect(x, y, width, height));
::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_fbo);
}
#endif
::glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
#if !PLATFORM(BLACKBERRY)
- if (m_attrs.antialias && m_boundFBO == m_multisampleFBO)
+ if (m_attrs.antialias && m_state.boundFBO == m_multisampleFBO)
::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO);
#endif
}
@@ -1377,7 +1374,7 @@ void GraphicsContext3D::deleteBuffer(Platform3DObject buffer)
void GraphicsContext3D::deleteFramebuffer(Platform3DObject framebuffer)
{
makeContextCurrent();
- if (framebuffer == m_boundFBO) {
+ if (framebuffer == m_state.boundFBO) {
// Make sure the framebuffer is not going to be used for drawing
// operations after it gets deleted.
bindFramebuffer(FRAMEBUFFER, 0);
@@ -1406,8 +1403,8 @@ void GraphicsContext3D::deleteShader(Platform3DObject shader)
void GraphicsContext3D::deleteTexture(Platform3DObject texture)
{
makeContextCurrent();
- if (m_boundTexture0 == texture)
- m_boundTexture0 = 0;
+ if (m_state.boundTexture0 == texture)
+ m_state.boundTexture0 = 0;
glDeleteTextures(1, &texture);
}
diff --git a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp
index 991571d42..f3be9237b 100644
--- a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp
+++ b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp
@@ -55,7 +55,7 @@ void GraphicsContext3D::readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsi
// all previous rendering calls should be done before reading pixels.
::glFlush();
#if PLATFORM(BLACKBERRY)
- if (m_isImaginationHardware && m_fbo == m_boundFBO) {
+ if (m_isImaginationHardware && m_fbo == m_state.boundFBO) {
// FIXME: This workaround should always be used until the
// driver alignment bug is fixed, even when we aren't
// drawing to the canvas.
@@ -63,7 +63,7 @@ void GraphicsContext3D::readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsi
} else
::glReadPixels(x, y, width, height, format, type, data);
#else
- if (m_attrs.antialias && m_boundFBO == m_multisampleFBO) {
+ if (m_attrs.antialias && m_state.boundFBO == m_multisampleFBO) {
resolveMultisamplingIfNecessary(IntRect(x, y, width, height));
::glBindFramebuffer(GL_FRAMEBUFFER, m_fbo);
::glFlush();
@@ -71,7 +71,7 @@ void GraphicsContext3D::readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsi
::glReadPixels(x, y, width, height, format, type, data);
- if (m_attrs.antialias && m_boundFBO == m_multisampleFBO)
+ if (m_attrs.antialias && m_state.boundFBO == m_multisampleFBO)
::glBindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO);
#endif
}
@@ -79,7 +79,7 @@ void GraphicsContext3D::readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsi
void GraphicsContext3D::readPixelsAndConvertToBGRAIfNecessary(int x, int y, int width, int height, unsigned char* pixels)
{
#if PLATFORM(BLACKBERRY)
- if (m_isImaginationHardware && m_fbo == m_boundFBO) {
+ if (m_isImaginationHardware && m_fbo == m_state.boundFBO) {
// FIXME: This workaround should always be used until the
// driver alignment bug is fixed, even when we aren't
// drawing to the canvas.
@@ -119,7 +119,7 @@ bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
// Resize regular FBO.
bool mustRestoreFBO = false;
- if (m_boundFBO != m_fbo) {
+ if (m_state.boundFBO != m_fbo) {
mustRestoreFBO = true;
::glBindFramebuffer(GL_FRAMEBUFFER, m_fbo);
}
diff --git a/Source/WebCore/platform/graphics/opentype/OpenTypeVerticalData.cpp b/Source/WebCore/platform/graphics/opentype/OpenTypeVerticalData.cpp
index 67013b1ac..35ae71dd7 100644
--- a/Source/WebCore/platform/graphics/opentype/OpenTypeVerticalData.cpp
+++ b/Source/WebCore/platform/graphics/opentype/OpenTypeVerticalData.cpp
@@ -533,7 +533,7 @@ void OpenTypeVerticalData::getVerticalTranslationsForGlyphs(const SimpleFontData
outXYArray[1] = -vertOriginYFUnit * sizePerUnit;
continue;
}
- if (isnan(defaultVertOriginY))
+ if (std::isnan(defaultVertOriginY))
defaultVertOriginY = -m_defaultVertOriginY * sizePerUnit;
outXYArray[1] = defaultVertOriginY;
continue;
diff --git a/Source/WebCore/platform/graphics/openvg/EGLDisplayOpenVG.cpp b/Source/WebCore/platform/graphics/openvg/EGLDisplayOpenVG.cpp
deleted file mode 100644
index 1a68aeff8..000000000
--- a/Source/WebCore/platform/graphics/openvg/EGLDisplayOpenVG.cpp
+++ /dev/null
@@ -1,455 +0,0 @@
-/*
- * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "EGLDisplayOpenVG.h"
-
-#include "EGLUtils.h"
-#include "IntSize.h"
-#include "SurfaceOpenVG.h"
-
-#include <wtf/Assertions.h>
-#include <wtf/StdLibExtras.h>
-
-namespace WebCore {
-
-// Need to typedef this, otherwise DEFINE_STATIC_LOCAL() doesn't swallow it.
-typedef HashMap<EGLDisplay, EGLDisplayOpenVG*> EGLDisplayManagerMap;
-
-// File-static variables.
-static EGLDisplayManagerMap& displayManagers()
-{
- DEFINE_STATIC_LOCAL(EGLDisplayManagerMap, managers, ());
- return managers;
-}
-
-static EGLDisplayOpenVG* s_current = 0;
-
-// Static class members.
-
-SurfaceOpenVG* EGLDisplayOpenVG::currentSurface()
-{
- EGLDisplayManagerMap& managers = displayManagers();
- EGLDisplay currentDisplay = eglGetCurrentDisplay();
-
- if (currentDisplay == EGL_NO_DISPLAY || !managers.contains(currentDisplay))
- return 0;
-
- EGLDisplayOpenVG* displayManager = managers.get(currentDisplay);
- EGLSurface currentSurface = eglGetCurrentSurface(EGL_DRAW);
-
- if (currentSurface == EGL_NO_SURFACE || !displayManager->m_platformSurfaces.contains(currentSurface))
- return 0;
-
- return displayManager->m_platformSurfaces.get(currentSurface);
-}
-
-void EGLDisplayOpenVG::registerPlatformSurface(SurfaceOpenVG* platformSurface)
-{
- EGLDisplayOpenVG* displayManager = EGLDisplayOpenVG::forDisplay(platformSurface->eglDisplay());
- displayManager->m_platformSurfaces.set(platformSurface->eglSurface(), platformSurface);
-}
-
-void EGLDisplayOpenVG::unregisterPlatformSurface(SurfaceOpenVG* platformSurface)
-{
- EGLDisplayOpenVG* displayManager = EGLDisplayOpenVG::forDisplay(platformSurface->eglDisplay());
- displayManager->m_platformSurfaces.remove(platformSurface->eglSurface());
-}
-
-void EGLDisplayOpenVG::setCurrentDisplay(const EGLDisplay& display)
-{
- s_current = EGLDisplayOpenVG::forDisplay(display);
-}
-
-EGLDisplayOpenVG* EGLDisplayOpenVG::current()
-{
- if (!s_current) {
- EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
- eglInitialize(display, 0, 0);
- ASSERT_EGL_NO_ERROR();
-
- s_current = EGLDisplayOpenVG::forDisplay(display);
- }
- return s_current;
-}
-
-EGLDisplayOpenVG* EGLDisplayOpenVG::forDisplay(const EGLDisplay& display)
-{
- EGLDisplayManagerMap& managers = displayManagers();
-
- if (!managers.contains(display))
- managers.set(display, new EGLDisplayOpenVG(display));
-
- return managers.get(display);
-}
-
-
-// Object/instance members.
-
-EGLDisplayOpenVG::EGLDisplayOpenVG(const EGLDisplay& display)
- : m_display(display)
- , m_sharedPlatformSurface(0)
- , m_pbufferConfigId(0)
- , m_windowConfigId(0)
-{
- eglBindAPI(EGL_OPENVG_API);
- ASSERT_EGL_NO_ERROR();
-}
-
-EGLDisplayOpenVG::~EGLDisplayOpenVG()
-{
- eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
- ASSERT_EGL_NO_ERROR();
-
- delete m_sharedPlatformSurface;
-
- HashMap<EGLSurface, EGLint>::const_iterator end = m_surfaceConfigIds.end();
- for (HashMap<EGLSurface, EGLint>::const_iterator it = m_surfaceConfigIds.begin(); it != end; ++it)
- destroySurface((*it).key);
-
- eglTerminate(m_display);
- ASSERT_EGL_NO_ERROR();
-}
-
-void EGLDisplayOpenVG::setDefaultPbufferConfig(const EGLConfig& config)
-{
- EGLint configId;
- EGLBoolean success = eglGetConfigAttrib(m_display, config, EGL_CONFIG_ID, &configId);
- ASSERT(success == EGL_TRUE);
- ASSERT(configId != EGL_BAD_ATTRIBUTE);
-
- m_pbufferConfigId = configId;
-}
-
-EGLConfig EGLDisplayOpenVG::defaultPbufferConfig()
-{
- EGLConfig config;
- EGLint numConfigs;
-
- // Hopefully the client will have set the pbuffer config of its choice
- // by now - if not, use a 32-bit generic one as default.
- if (!m_pbufferConfigId) {
- static const EGLint configAttribs[] = {
- EGL_RED_SIZE, 8,
- EGL_GREEN_SIZE, 8,
- EGL_BLUE_SIZE, 8,
- EGL_ALPHA_SIZE, 8,
- EGL_ALPHA_MASK_SIZE, 1,
- EGL_LUMINANCE_SIZE, EGL_DONT_CARE,
- EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
- EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
- EGL_NONE
- };
- eglChooseConfig(m_display, configAttribs, &config, 1, &numConfigs);
- } else {
- const EGLint configAttribs[] = {
- EGL_CONFIG_ID, m_pbufferConfigId,
- EGL_NONE
- };
- eglChooseConfig(m_display, configAttribs, &config, 1, &numConfigs);
- }
-
- ASSERT_EGL_NO_ERROR();
- ASSERT(numConfigs == 1);
- return config;
-}
-
-void EGLDisplayOpenVG::setDefaultWindowConfig(const EGLConfig& config)
-{
- EGLint configId;
- EGLBoolean success = eglGetConfigAttrib(m_display, config, EGL_CONFIG_ID, &configId);
- ASSERT(success == EGL_TRUE);
- ASSERT(configId != EGL_BAD_ATTRIBUTE);
-
- m_windowConfigId = configId;
-}
-
-EGLConfig EGLDisplayOpenVG::defaultWindowConfig()
-{
- EGLConfig config;
- EGLint numConfigs;
-
- // Hopefully the client will have set the window config of its choice
- // by now - if not, use a 32-bit generic one as default.
- if (!m_windowConfigId) {
- static const EGLint configAttribs[] = {
- EGL_RED_SIZE, 8,
- EGL_GREEN_SIZE, 8,
- EGL_BLUE_SIZE, 8,
- EGL_ALPHA_SIZE, 8,
- EGL_ALPHA_MASK_SIZE, 1,
- EGL_LUMINANCE_SIZE, EGL_DONT_CARE,
- EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
- EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
- EGL_NONE
- };
- eglChooseConfig(m_display, configAttribs, &config, 1, &numConfigs);
- } else {
- const EGLint configAttribs[] = {
- EGL_CONFIG_ID, m_windowConfigId,
- EGL_NONE
- };
- eglChooseConfig(m_display, configAttribs, &config, 1, &numConfigs);
- }
-
- ASSERT_EGL_NO_ERROR();
- ASSERT(numConfigs == 1);
- return config;
-}
-
-SurfaceOpenVG* EGLDisplayOpenVG::sharedPlatformSurface()
-{
- if (!m_sharedPlatformSurface) {
- // The shared surface doesn't need to be drawn on, it just exists so
- // that we can always make the shared context current (which in turn is
- // the owner of long-living resources such as images, paths and fonts).
- // We'll just make the shared surface as small as possible: 1x1 pixel.
- EGLConfig config = defaultPbufferConfig();
- EGLSurface surface = createPbufferSurface(IntSize(1, 1), config);
-
- EGLContext context = eglCreateContext(m_display, config, EGL_NO_CONTEXT, 0);
- ASSERT_EGL_NO_ERROR();
- m_contexts.set(m_surfaceConfigIds.get(surface), context);
-
- m_sharedPlatformSurface = new SurfaceOpenVG;
- m_sharedPlatformSurface->m_eglDisplay = m_display;
- m_sharedPlatformSurface->m_eglSurface = surface;
- m_sharedPlatformSurface->m_eglContext = context;
- m_platformSurfaces.set(surface, m_sharedPlatformSurface); // a.k.a. registerPlatformSurface()
- }
- return m_sharedPlatformSurface;
-}
-
-EGLSurface EGLDisplayOpenVG::createPbufferSurface(const IntSize& size, const EGLConfig& config, EGLint* errorCode)
-{
- const EGLint attribList[] = {
- EGL_WIDTH, size.width(),
- EGL_HEIGHT, size.height(),
- EGL_NONE
- };
- EGLSurface surface = eglCreatePbufferSurface(m_display, config, attribList);
-
- if (errorCode)
- *errorCode = eglGetError();
- else
- ASSERT_EGL_NO_ERROR();
-
- if (surface == EGL_NO_SURFACE)
- return EGL_NO_SURFACE;
-
- EGLint surfaceConfigId;
- EGLBoolean success = eglGetConfigAttrib(m_display, config, EGL_CONFIG_ID, &surfaceConfigId);
- ASSERT(success == EGL_TRUE);
- ASSERT(surfaceConfigId != EGL_BAD_ATTRIBUTE);
-
- ASSERT(!m_surfaceConfigIds.contains(surface));
- m_surfaceConfigIds.set(surface, surfaceConfigId);
- return surface;
-}
-
-EGLSurface EGLDisplayOpenVG::createPbufferFromClientBuffer(
- EGLClientBuffer clientBuffer, EGLenum bufferType, const EGLConfig& config, EGLint* errorCode)
-{
- EGLSurface surface = eglCreatePbufferFromClientBuffer(m_display,
- bufferType, clientBuffer, config, 0 /* attribList */);
-
- if (errorCode)
- *errorCode = eglGetError();
- else
- ASSERT_EGL_NO_ERROR();
-
- if (surface == EGL_NO_SURFACE)
- return EGL_NO_SURFACE;
-
- EGLint surfaceConfigId;
- EGLBoolean success = eglGetConfigAttrib(m_display, config, EGL_CONFIG_ID, &surfaceConfigId);
- ASSERT(success == EGL_TRUE);
- ASSERT(surfaceConfigId != EGL_BAD_ATTRIBUTE);
-
- ASSERT(!m_surfaceConfigIds.contains(surface));
- m_surfaceConfigIds.set(surface, surfaceConfigId);
- return surface;
-}
-
-EGLSurface EGLDisplayOpenVG::surfaceForWindow(EGLNativeWindowType wId, const EGLConfig& config)
-{
- if (m_windowSurfaces.contains(wId))
- return m_windowSurfaces.get(wId);
-
- EGLSurface surface = eglCreateWindowSurface(m_display, config, wId, 0);
- ASSERT_EGL_NO_ERROR();
-
- EGLint surfaceConfigId;
- EGLBoolean success = eglGetConfigAttrib(m_display, config, EGL_CONFIG_ID, &surfaceConfigId);
- ASSERT(success == EGL_TRUE);
- ASSERT(surfaceConfigId != EGL_BAD_ATTRIBUTE);
-
- ASSERT(!m_surfaceConfigIds.contains(surface));
- m_surfaceConfigIds.set(surface, surfaceConfigId);
- return surface;
-}
-
-bool EGLDisplayOpenVG::surfacesCompatible(const EGLSurface& surface, const EGLSurface& otherSurface)
-{
- if (surface == EGL_NO_SURFACE || otherSurface == EGL_NO_SURFACE)
- return false;
-
- // Currently, we assume that all surfaces known to this object are
- // context-compatible to each other (which is reasonable to assume,
- // otherwise eglCreateContext() would fail with EGL_BAD_MATCH for shared
- // context compatibility anyways.
- return m_surfaceConfigIds.contains(surface) && m_surfaceConfigIds.contains(otherSurface);
-}
-
-void EGLDisplayOpenVG::destroySurface(const EGLSurface& surface)
-{
- ASSERT(surface != EGL_NO_SURFACE);
-
- if (eglGetCurrentSurface(EGL_DRAW) == surface) {
- eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
- ASSERT_EGL_NO_ERROR();
- }
-
- // Destroy the context associated to the surface, if we already created one.
- if (m_surfaceConfigIds.contains(surface)) {
- EGLint surfaceConfigId = m_surfaceConfigIds.take(surface); // take = get and remove
- bool isContextReferenced = false;
-
- if (m_compatibleConfigIds.contains(surfaceConfigId))
- surfaceConfigId = m_compatibleConfigIds.get(surfaceConfigId);
-
- HashMap<EGLSurface, EGLint>::iterator end = m_surfaceConfigIds.end();
-
- // ...but only if there's no other surfaces associated to that context.
- for (HashMap<EGLSurface, EGLint>::iterator it = m_surfaceConfigIds.begin(); it != end; ++it) {
- if ((*it).value == surfaceConfigId) {
- isContextReferenced = true;
- break;
- }
- }
- if (!isContextReferenced && m_contexts.contains(surfaceConfigId)) {
- EGLContext context = m_contexts.take(surfaceConfigId);
- eglDestroyContext(m_display, context);
- ASSERT_EGL_NO_ERROR();
- }
- }
-
- m_platformSurfaces.remove(surface);
-
- HashMap<EGLNativeWindowType, EGLSurface>::iterator end = m_windowSurfaces.end();
- for (HashMap<EGLNativeWindowType, EGLSurface>::iterator it = m_windowSurfaces.begin(); it != end; ++it) {
- if ((*it).value == surface) {
- m_windowSurfaces.remove(it);
- break;
- }
- }
-
- eglDestroySurface(m_display, surface);
- ASSERT_EGL_NO_ERROR();
-}
-
-EGLContext EGLDisplayOpenVG::contextForSurface(const EGLSurface& surface)
-{
- ASSERT(surface != EGL_NO_SURFACE);
-
- if (m_platformSurfaces.contains(surface))
- return m_platformSurfaces.get(surface)->eglContext();
-
- eglBindAPI(EGL_OPENVG_API);
- ASSERT_EGL_NO_ERROR();
-
- EGLint surfaceConfigId;
-
- if (m_surfaceConfigIds.contains(surface))
- surfaceConfigId = m_surfaceConfigIds.get(surface);
- else {
- // Retrieve the same EGL config for context creation that was used to
- // create the the EGL surface.
- EGLBoolean success = eglQuerySurface(m_display, surface, EGL_CONFIG_ID, &surfaceConfigId);
- ASSERT(success == EGL_TRUE);
- ASSERT(surfaceConfigId != EGL_BAD_ATTRIBUTE);
-
- m_surfaceConfigIds.set(surface, surfaceConfigId);
- }
-
- if (m_compatibleConfigIds.contains(surfaceConfigId))
- surfaceConfigId = m_compatibleConfigIds.get(surfaceConfigId);
-
- if (m_contexts.contains(surfaceConfigId))
- return m_contexts.get(surfaceConfigId);
-
- if (!m_sharedPlatformSurface) // shared context has not been created yet
- sharedPlatformSurface(); // creates the shared surface & context
-
- EGLDisplay currentDisplay = eglGetCurrentDisplay();
- EGLSurface currentReadSurface = eglGetCurrentSurface(EGL_READ);
- EGLSurface currentDrawSurface = eglGetCurrentSurface(EGL_DRAW);
- EGLContext currentContext = eglGetCurrentContext();
-
- // Before creating a new context, let's try whether an existing one
- // is compatible with the surface. EGL doesn't give us a different way
- // to check context/surface compatibility than trying it out, so let's
- // do just that.
- HashMap<EGLint, EGLContext>::iterator end = m_contexts.end();
-
- for (HashMap<EGLint, EGLContext>::iterator it = m_contexts.begin(); it != end; ++it) {
- eglMakeCurrent(m_display, surface, surface, (*it).value);
- if (eglGetError() == EGL_SUCCESS) {
- // Restore previous surface/context.
- if (currentContext != EGL_NO_CONTEXT) {
- eglMakeCurrent(currentDisplay, currentReadSurface, currentDrawSurface, currentContext);
- ASSERT_EGL_NO_ERROR();
- }
- // Cool, surface is compatible to one of our existing contexts.
- m_compatibleConfigIds.set(surfaceConfigId, (*it).key);
- return (*it).value;
- }
- }
- // Restore previous surface/context.
- if (currentContext != EGL_NO_CONTEXT) {
- eglMakeCurrent(currentDisplay, currentReadSurface, currentDrawSurface, currentContext);
- ASSERT_EGL_NO_ERROR();
- }
-
- EGLConfig config;
- EGLint numConfigs;
-
- const EGLint configAttribs[] = {
- EGL_CONFIG_ID, surfaceConfigId,
- EGL_NONE
- };
-
- eglChooseConfig(m_display, configAttribs, &config, 1, &numConfigs);
- ASSERT_EGL_NO_ERROR();
- ASSERT(numConfigs == 1);
-
- // We share all of the images and paths amongst the different contexts,
- // so that they can be used in all of them. Resources that are created
- // while m_sharedPlatformSurface->context() is current will be
- // accessible from all other contexts, but are not restricted to the
- // lifetime of those contexts.
- EGLContext context = eglCreateContext(m_display, config, m_sharedPlatformSurface->eglContext(), 0);
- ASSERT_EGL_NO_ERROR();
-
- ASSERT(!m_contexts.contains(surfaceConfigId));
- m_contexts.set(surfaceConfigId, context);
- return context;
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/openvg/EGLDisplayOpenVG.h b/Source/WebCore/platform/graphics/openvg/EGLDisplayOpenVG.h
deleted file mode 100644
index 0dff6c938..000000000
--- a/Source/WebCore/platform/graphics/openvg/EGLDisplayOpenVG.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef EGLDisplayOpenVG_h
-#define EGLDisplayOpenVG_h
-
-#include <egl.h>
-#include <wtf/HashMap.h>
-
-namespace WebCore {
-
-class IntSize;
-class SurfaceOpenVG;
-
-class EGLDisplayOpenVG {
-public:
- friend class SurfaceOpenVG;
-
- static SurfaceOpenVG* currentSurface();
- static void setCurrentDisplay(const EGLDisplay&);
- static EGLDisplayOpenVG* current();
- static EGLDisplayOpenVG* forDisplay(const EGLDisplay&);
-
- void setDefaultPbufferConfig(const EGLConfig&);
- EGLConfig defaultPbufferConfig();
- void setDefaultWindowConfig(const EGLConfig&);
- EGLConfig defaultWindowConfig();
-
- EGLDisplay display() const { return m_display; }
- SurfaceOpenVG* sharedPlatformSurface();
-
- /** Creates a pbuffer surface using the given config. If no surface
- * could be created, EGL_NO_SURFACE is returned and errors can be
- * checked with the value that is written to the errorCode parameter
- * If no surface could be created and errorCode is zero, this method
- * will trigger an assertion by itself. */
- EGLSurface createPbufferSurface(const IntSize&, const EGLConfig&, EGLint* errorCode = 0);
- EGLSurface createPbufferFromClientBuffer(EGLClientBuffer, EGLenum bufferType, const EGLConfig&, EGLint* errorCode = 0);
-
- EGLSurface surfaceForWindow(EGLNativeWindowType, const EGLConfig&);
-
- bool surfacesCompatible(const EGLSurface&, const EGLSurface&);
-
- /** Destroy the surface and its corresponding context (unless another
- * surface is still using the same context, in which case the context
- * is not destroyed). */
- void destroySurface(const EGLSurface&);
-
- /** Return the context corresponding to the surface.
- * If no corresponding context exists, one is created automatically. */
- EGLContext contextForSurface(const EGLSurface&);
-
-private:
- static void registerPlatformSurface(SurfaceOpenVG*);
- static void unregisterPlatformSurface(SurfaceOpenVG*);
-
- EGLDisplayOpenVG(const EGLDisplay& display);
- ~EGLDisplayOpenVG();
-
- EGLDisplay m_display;
- SurfaceOpenVG* m_sharedPlatformSurface;
- EGLint m_pbufferConfigId;
- EGLint m_windowConfigId;
-
- HashMap<EGLSurface, SurfaceOpenVG*> m_platformSurfaces;
- HashMap<EGLNativeWindowType, EGLSurface> m_windowSurfaces;
- HashMap<EGLSurface, EGLint> m_surfaceConfigIds;
- HashMap<EGLint, EGLint> m_compatibleConfigIds;
- HashMap<EGLint, EGLContext> m_contexts;
-};
-
-}
-
-#endif
diff --git a/Source/WebCore/platform/graphics/openvg/EGLUtils.h b/Source/WebCore/platform/graphics/openvg/EGLUtils.h
deleted file mode 100644
index 6f5d793c0..000000000
--- a/Source/WebCore/platform/graphics/openvg/EGLUtils.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef EGLUtils_h
-#define EGLUtils_h
-
-#include <egl.h>
-#include <wtf/Assertions.h>
-
-static inline const char* toEGLErrorConstant(EGLint error)
-{
- switch (error) {
- case EGL_NOT_INITIALIZED:
- return "EGL_NOT_INITIALIZED";
- case EGL_BAD_ACCESS:
- return "EGL_BAD_ACCESS";
- case EGL_BAD_ALLOC:
- return "EGL_BAD_ALLOC";
- case EGL_BAD_ATTRIBUTE:
- return "EGL_BAD_ATTRIBUTE";
- case EGL_BAD_CONTEXT:
- return "EGL_BAD_CONTEXT";
- case EGL_BAD_CONFIG:
- return "EGL_BAD_CONFIG";
- case EGL_BAD_CURRENT_SURFACE:
- return "EGL_BAD_CURRENT_SURFACE";
- case EGL_BAD_DISPLAY:
- return "EGL_BAD_DISPLAY";
- case EGL_BAD_SURFACE:
- return "EGL_BAD_SURFACE";
- case EGL_BAD_MATCH:
- return "EGL_BAD_MATCH";
- case EGL_BAD_PARAMETER:
- return "EGL_BAD_PARAMETER";
- case EGL_BAD_NATIVE_PIXMAP:
- return "EGL_BAD_NATIVE_PIXMAP";
- case EGL_BAD_NATIVE_WINDOW:
- return "EGL_BAD_NATIVE_WINDOW";
- case EGL_CONTEXT_LOST:
- return "EGL_CONTEXT_LOST";
- default:
- return "UNKNOWN_ERROR";
- }
-}
-
-#if ASSERT_DISABLED
-#define ASSERT_EGL_NO_ERROR() ((void)0)
-#else
-#define ASSERT_EGL_NO_ERROR() do { \
- EGLint eglErrorCode = eglGetError(); \
- ASSERT_WITH_MESSAGE(eglErrorCode == EGL_SUCCESS, "Found %s", toEGLErrorConstant(eglErrorCode)); \
-} while (0)
-#endif
-
-#endif
diff --git a/Source/WebCore/platform/graphics/openvg/GraphicsContextOpenVG.cpp b/Source/WebCore/platform/graphics/openvg/GraphicsContextOpenVG.cpp
deleted file mode 100644
index babaa0ff4..000000000
--- a/Source/WebCore/platform/graphics/openvg/GraphicsContextOpenVG.cpp
+++ /dev/null
@@ -1,538 +0,0 @@
-/*
- * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "GraphicsContext.h"
-
-#include "AffineTransform.h"
-#include "KURL.h"
-#include "NotImplemented.h"
-#include "PainterOpenVG.h"
-#include "SurfaceOpenVG.h"
-
-#include <wtf/Assertions.h>
-#include <wtf/MathExtras.h>
-#include <wtf/UnusedParam.h>
-#include <wtf/Vector.h>
-
-#if PLATFORM(EGL)
-#include "EGLDisplayOpenVG.h"
-#include "EGLUtils.h"
-#include <egl.h>
-#endif
-
-namespace WebCore {
-
-// typedef'ing doesn't work, let's inherit from PainterOpenVG instead
-class GraphicsContextPlatformPrivate : public PainterOpenVG {
-public:
- GraphicsContextPlatformPrivate(SurfaceOpenVG* surface)
- : PainterOpenVG(surface)
- {
- }
-};
-
-void GraphicsContext::platformInit(SurfaceOpenVG* surface)
-{
- m_data = surface ? new GraphicsContextPlatformPrivate(surface) : 0;
- setPaintingDisabled(!surface);
-}
-
-void GraphicsContext::platformDestroy()
-{
- delete m_data;
-}
-
-PlatformGraphicsContext* GraphicsContext::platformContext() const
-{
- if (paintingDisabled())
- return 0;
-
- return m_data->baseSurface();
-}
-
-AffineTransform GraphicsContext::getCTM(IncludeDeviceScale) const
-{
- if (paintingDisabled())
- return AffineTransform();
-
- return m_data->transformation();
-}
-
-void GraphicsContext::savePlatformState()
-{
- if (paintingDisabled())
- return;
-
- m_data->save();
-}
-
-void GraphicsContext::restorePlatformState()
-{
- if (paintingDisabled())
- return;
-
- m_data->restore();
-}
-
-void GraphicsContext::drawRect(const IntRect& rect)
-{
- if (paintingDisabled())
- return;
-
- ASSERT(!rect.isEmpty());
-
- m_data->drawRect(rect);
-}
-
-void GraphicsContext::drawLine(const IntPoint& from, const IntPoint& to)
-{
- if (paintingDisabled())
- return;
-
- m_data->drawLine(from, to);
-}
-
-/**
- * Draw the largest ellipse that fits into the given rectangle.
- */
-void GraphicsContext::drawEllipse(const IntRect& rect)
-{
- if (paintingDisabled())
- return;
-
- m_data->drawEllipse(rect);
-}
-
-void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan)
-{
- if (paintingDisabled())
- return;
-
- m_data->drawArc(rect, startAngle, angleSpan, VG_STROKE_PATH);
-}
-
-void GraphicsContext::drawConvexPolygon(size_t numPoints, const FloatPoint* points, bool shouldAntialias)
-{
- if (paintingDisabled())
- return;
-
- m_data->drawPolygon(numPoints, points);
-
- UNUSED_PARAM(shouldAntialias); // FIXME
-}
-
-void GraphicsContext::fillPath(const Path& path)
-{
- if (paintingDisabled())
- return;
-
- m_data->drawPath(path, VG_FILL_PATH, m_state.fillRule);
-}
-
-void GraphicsContext::strokePath(const Path& path)
-{
- if (paintingDisabled())
- return;
-
- m_data->drawPath(path, VG_STROKE_PATH, m_state.fillRule);
-}
-
-void GraphicsContext::fillRect(const FloatRect& rect)
-{
- if (paintingDisabled())
- return;
-
- m_data->drawRect(rect, VG_FILL_PATH);
-}
-
-void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorSpace colorSpace)
-{
- if (paintingDisabled())
- return;
-
- Color oldColor = m_data->fillColor();
- m_data->setFillColor(color);
- m_data->drawRect(rect, VG_FILL_PATH);
- m_data->setFillColor(oldColor);
-
- UNUSED_PARAM(colorSpace); // FIXME
-}
-
-void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color, ColorSpace colorSpace)
-{
- if (paintingDisabled())
- return;
-
- Color oldColor = m_data->fillColor();
- m_data->setFillColor(color);
- m_data->drawRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight, VG_FILL_PATH);
- m_data->setFillColor(oldColor);
-
- UNUSED_PARAM(colorSpace); // FIXME
-}
-
-void GraphicsContext::clip(const FloatRect& rect)
-{
- if (paintingDisabled())
- return;
-
- m_data->intersectClipRect(rect);
-}
-
-void GraphicsContext::clipPath(const Path& path, WindRule clipRule)
-{
- if (paintingDisabled())
- return;
-
- m_data->clipPath(path, PainterOpenVG::IntersectClip, clipRule);
-}
-
-void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int offset, const Color& color)
-{
- if (paintingDisabled())
- return;
-
- if (rects.isEmpty())
- return;
-
- // FIXME: We just unite all focus ring rects into one for now.
- // We should outline the edge of the full region.
- offset += (width - 1) / 2;
- IntRect finalFocusRect;
-
- for (unsigned i = 0; i < rects.size(); i++) {
- IntRect focusRect = rects[i];
- focusRect.inflate(offset);
- finalFocusRect.unite(focusRect);
- }
-
- StrokeStyle oldStyle = m_data->strokeStyle();
- Color oldStrokeColor = m_data->strokeColor();
- m_data->setStrokeStyle(DashedStroke);
- m_data->setStrokeColor(color);
- strokeRect(FloatRect(finalFocusRect), 1.f);
- m_data->setStrokeStyle(oldStyle);
- m_data->setStrokeColor(oldStrokeColor);
-}
-
-void GraphicsContext::drawLineForText(const IntPoint& origin, int width, bool printing)
-{
- if (paintingDisabled())
- return;
-
- if (width <= 0)
- return;
-
- StrokeStyle oldStyle = m_data->strokeStyle();
- m_data->setStrokeStyle(SolidStroke);
- drawLine(origin, origin + IntSize(width, 0));
- m_data->setStrokeStyle(oldStyle);
-
- UNUSED_PARAM(printing);
-}
-
-void GraphicsContext::drawLineForDocumentMarker(const IntPoint& origin, int width, DocumentMarkerLineStyle style)
-{
- if (paintingDisabled())
- return;
-
- notImplemented();
- UNUSED_PARAM(origin);
- UNUSED_PARAM(width);
- UNUSED_PARAM(style);
-}
-
-FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect, RoundingMode)
-{
- if (paintingDisabled())
- return FloatRect();
-
- return FloatRect(enclosingIntRect(m_data->transformation().mapRect(rect)));
-}
-
-void GraphicsContext::setPlatformShadow(const FloatSize& size, float blur, const Color& color, ColorSpace colorSpace)
-{
- if (paintingDisabled())
- return;
-
- notImplemented();
- UNUSED_PARAM(size);
- UNUSED_PARAM(blur);
- UNUSED_PARAM(color);
- UNUSED_PARAM(colorSpace);
-}
-
-void GraphicsContext::clearPlatformShadow()
-{
- if (paintingDisabled())
- return;
-
- notImplemented();
-}
-
-void GraphicsContext::beginPlatformTransparencyLayer(float opacity)
-{
- if (paintingDisabled())
- return;
-
- notImplemented();
- UNUSED_PARAM(opacity);
-}
-
-void GraphicsContext::endPlatformTransparencyLayer()
-{
- if (paintingDisabled())
- return;
-
- notImplemented();
-}
-
-bool GraphicsContext::supportsTransparencyLayers()
-{
- return false;
-}
-
-void GraphicsContext::clearRect(const FloatRect& rect)
-{
- if (paintingDisabled())
- return;
-
- CompositeOperator op = m_data->compositeOperation();
- m_data->setCompositeOperation(CompositeClear);
- m_data->drawRect(rect, VG_FILL_PATH);
- m_data->setCompositeOperation(op);
-}
-
-void GraphicsContext::strokeRect(const FloatRect& rect, float lineWidth)
-{
- if (paintingDisabled())
- return;
-
- float oldThickness = m_data->strokeThickness();
- m_data->setStrokeThickness(lineWidth);
- m_data->drawRect(rect, VG_STROKE_PATH);
- m_data->setStrokeThickness(oldThickness);
-}
-
-void GraphicsContext::setLineCap(LineCap lc)
-{
- if (paintingDisabled())
- return;
-
- m_data->setLineCap(lc);
-}
-
-void GraphicsContext::setLineDash(const DashArray& dashes, float dashOffset)
-{
- if (paintingDisabled())
- return;
-
- m_data->setLineDash(dashes, dashOffset);
-}
-
-void GraphicsContext::setLineJoin(LineJoin lj)
-{
- if (paintingDisabled())
- return;
-
- m_data->setLineJoin(lj);
-}
-
-void GraphicsContext::setMiterLimit(float limit)
-{
- if (paintingDisabled())
- return;
-
- m_data->setMiterLimit(limit);
-}
-
-void GraphicsContext::setAlpha(float opacity)
-{
- if (paintingDisabled())
- return;
-
- m_data->setOpacity(opacity);
-}
-
-void GraphicsContext::setPlatformCompositeOperation(CompositeOperator op)
-{
- if (paintingDisabled())
- return;
-
- m_data->setCompositeOperation(op);
-}
-
-void GraphicsContext::clip(const Path& path)
-{
- if (paintingDisabled())
- return;
-
- m_data->clipPath(path, PainterOpenVG::IntersectClip, m_state.fillRule);
-}
-
-void GraphicsContext::canvasClip(const Path& path)
-{
- clip(path);
-}
-
-void GraphicsContext::clipOut(const Path& path)
-{
- if (paintingDisabled())
- return;
-
- m_data->clipPath(path, PainterOpenVG::SubtractClip, m_state.fillRule);
-}
-
-void GraphicsContext::scale(const FloatSize& scaleFactors)
-{
- if (paintingDisabled())
- return;
-
- m_data->scale(scaleFactors);
-}
-
-void GraphicsContext::rotate(float radians)
-{
- if (paintingDisabled())
- return;
-
- m_data->rotate(radians);
-}
-
-void GraphicsContext::translate(float dx, float dy)
-{
- if (paintingDisabled())
- return;
-
- m_data->translate(dx, dy);
-}
-
-void GraphicsContext::clipOut(const IntRect& rect)
-{
- if (paintingDisabled())
- return;
-
- Path path;
- path.addRect(rect);
- m_data->clipPath(path, PainterOpenVG::SubtractClip, m_state.fillRule);
-}
-
-void GraphicsContext::clipToImageBuffer(const FloatRect& rect, const ImageBuffer* imageBuffer)
-{
- if (paintingDisabled())
- return;
-
- notImplemented();
- UNUSED_PARAM(rect);
- UNUSED_PARAM(imageBuffer);
-}
-
-void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness)
-{
- if (paintingDisabled())
- return;
-
- Path path;
- path.addEllipse(rect);
- path.addEllipse(FloatRect(rect.x() + thickness, rect.y() + thickness,
- rect.width() - (thickness * 2), rect.height() - (thickness * 2)));
-
- m_data->clipPath(path, PainterOpenVG::IntersectClip, m_state.fillRule);
-}
-
-void GraphicsContext::concatCTM(const AffineTransform& transformation)
-{
- if (paintingDisabled())
- return;
-
- m_data->concatTransformation(transformation);
-}
-
-void GraphicsContext::setCTM(const AffineTransform& transformation)
-{
- if (paintingDisabled())
- return;
-
- m_data->setTransformation(transformation);
-}
-
-void GraphicsContext::setURLForRect(const KURL& link, const IntRect& destRect)
-{
- notImplemented();
- UNUSED_PARAM(link);
- UNUSED_PARAM(destRect);
-}
-
-void GraphicsContext::setPlatformStrokeColor(const Color& color, ColorSpace colorSpace)
-{
- if (paintingDisabled())
- return;
-
- m_data->setStrokeColor(color);
-
- UNUSED_PARAM(colorSpace); // FIXME
-}
-
-void GraphicsContext::setPlatformStrokeStyle(StrokeStyle strokeStyle)
-{
- if (paintingDisabled())
- return;
-
- m_data->setStrokeStyle(strokeStyle);
-}
-
-void GraphicsContext::setPlatformStrokeThickness(float thickness)
-{
- if (paintingDisabled())
- return;
-
- m_data->setStrokeThickness(thickness);
-}
-
-void GraphicsContext::setPlatformFillColor(const Color& color, ColorSpace colorSpace)
-{
- if (paintingDisabled())
- return;
-
- m_data->setFillColor(color);
-
- UNUSED_PARAM(colorSpace); // FIXME
-}
-
-void GraphicsContext::setPlatformShouldAntialias(bool enable)
-{
- if (paintingDisabled())
- return;
-
- m_data->setAntialiasingEnabled(enable);
-}
-
-void GraphicsContext::setImageInterpolationQuality(InterpolationQuality)
-{
- notImplemented();
-}
-
-InterpolationQuality GraphicsContext::imageInterpolationQuality() const
-{
- notImplemented();
- return InterpolationDefault;
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/openvg/ImageOpenVG.cpp b/Source/WebCore/platform/graphics/openvg/ImageOpenVG.cpp
deleted file mode 100644
index 9510882cc..000000000
--- a/Source/WebCore/platform/graphics/openvg/ImageOpenVG.cpp
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "Image.h"
-
-#include "AffineTransform.h"
-#include "BitmapImage.h"
-#include "FloatRect.h"
-#include "GraphicsContext.h"
-#include "ImageDecoder.h"
-#include "ImageObserver.h"
-#include "IntSize.h"
-#include "NotImplemented.h"
-#include "PainterOpenVG.h"
-#include "SurfaceOpenVG.h"
-#include "TiledImageOpenVG.h"
-#include "VGUtils.h"
-
-#include <wtf/MathExtras.h>
-
-namespace WebCore {
-
-bool FrameData::clear(bool clearMetadata)
-{
- if (clearMetadata)
- m_haveMetadata = false;
-
- if (m_frame) {
- delete m_frame;
- m_frame = 0;
- return true;
- }
- return false;
-}
-
-BitmapImage::BitmapImage(TiledImageOpenVG* tiledImage, ImageObserver* observer)
- : Image(observer)
- , m_size(tiledImage->size())
- , m_currentFrame(0)
- , m_frames(1)
- , m_frameTimer(0)
- , m_repetitionCount(cAnimationNone)
- , m_repetitionCountStatus(Unknown)
- , m_repetitionsComplete(0)
- , m_desiredFrameStartTime(0)
- , m_frameCount(1)
- , m_isSolidColor(false)
- , m_checkedForSolidColor(false)
- , m_animationFinished(false)
- , m_allDataReceived(false)
- , m_haveSize(true)
- , m_sizeAvailable(true)
- , m_hasUniformFrameSize(true)
- , m_haveFrameCount(true)
-{
- ASSERT(m_size.width() > 0);
- ASSERT(m_size.height() > 0);
-
- m_decodedSize = m_size.width() * m_size.height() * 4;
-
- m_frames[0].m_frame = tiledImage;
- m_frames[0].m_hasAlpha = true;
- m_frames[0].m_isComplete = true;
- m_frames[0].m_haveMetadata = true;
- checkForSolidColor();
-}
-
-void BitmapImage::checkForSolidColor()
-{
- TiledImageOpenVG* tiledImage = 0;
-
- if (m_frameCount == 1 && m_size.width() == 1 && m_size.height() == 1)
- tiledImage = nativeImageForCurrentFrame();
-
- if (tiledImage) {
- m_isSolidColor = true;
- RGBA32 pixel;
- vgGetImageSubData(tiledImage->tile(0, 0), &pixel, 0, VG_sARGB_8888, 0, 0, 1, 1);
- ASSERT_VG_NO_ERROR();
- m_solidColor.setRGB(pixel);
- } else
- m_isSolidColor = false;
-
- m_checkedForSolidColor = true;
-}
-
-void BitmapImage::invalidatePlatformData()
-{
-}
-
-void BitmapImage::draw(GraphicsContext* context, const FloatRect& dst, const FloatRect& src, ColorSpace styleColorSpace, CompositeOperator op)
-{
- if (dst.isEmpty() || src.isEmpty())
- return;
-
- NativeImagePtr image = nativeImageForCurrentFrame();
- if (!image)
- return;
-
- startAnimation();
-
- if (mayFillWithSolidColor()) {
- fillWithSolidColor(context, dst, solidColor(), styleColorSpace, op);
- return;
- }
-
- context->save();
-
- // Set the compositing operation.
- if (op == CompositeSourceOver && !frameHasAlphaAtIndex(m_currentFrame))
- context->setCompositeOperation(CompositeCopy);
- else
- context->setCompositeOperation(op);
-
-#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
- FloatRect srcRectLocal = adjustSourceRectForDownSampling(src, image->size());
-#else
- FloatRect srcRectLocal(src);
-#endif
-
- context->platformContext()->activePainter()->drawImage(image, dst, srcRectLocal);
- context->restore();
-
- if (imageObserver())
- imageObserver()->didDraw(this);
-}
-
-void Image::drawPattern(GraphicsContext* context, const FloatRect& src,
- const AffineTransform& patternTransformation,
- const FloatPoint& phase, ColorSpace styleColorSpace,
- CompositeOperator op, const FloatRect& dst)
-{
- if (dst.isEmpty() || src.isEmpty())
- return;
-
- NativeImagePtr image = nativeImageForCurrentFrame();
- if (!image)
- return;
-
- startAnimation();
-
- if (mayFillWithSolidColor()) {
- fillWithSolidColor(context, dst, solidColor(), styleColorSpace, op);
- return;
- }
-
- notImplemented();
-
- if (imageObserver())
- imageObserver()->didDraw(this);
-}
-
-PassRefPtr<Image> Image::loadPlatformResource(char const* name)
-{
- notImplemented();
- return 0;
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/openvg/PainterOpenVG.cpp b/Source/WebCore/platform/graphics/openvg/PainterOpenVG.cpp
deleted file mode 100644
index 123a2fcbf..000000000
--- a/Source/WebCore/platform/graphics/openvg/PainterOpenVG.cpp
+++ /dev/null
@@ -1,1240 +0,0 @@
-/*
- * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "PainterOpenVG.h"
-
-#include "AffineTransform.h"
-#include "Color.h"
-#include "DashArray.h"
-#include "FloatPoint.h"
-#include "FloatQuad.h"
-#include "FloatRect.h"
-#include "IntRect.h"
-#include "IntSize.h"
-#include "NotImplemented.h"
-#include "PlatformPathOpenVG.h"
-#include "SurfaceOpenVG.h"
-#include "TiledImageOpenVG.h"
-#include "VGUtils.h"
-
-#if PLATFORM(EGL)
-#include "EGLUtils.h"
-#endif
-
-#include <vgu.h>
-
-#include <wtf/Assertions.h>
-#include <wtf/MathExtras.h>
-
-namespace WebCore {
-
-static bool isNonRotatedAffineTransformation(const AffineTransform& t)
-{
- return t.b() <= FLT_EPSILON && t.c() <= FLT_EPSILON;
-}
-
-static VGCapStyle toVGCapStyle(LineCap lineCap)
-{
- switch (lineCap) {
- case RoundCap:
- return VG_CAP_ROUND;
- case SquareCap:
- return VG_CAP_SQUARE;
- case ButtCap:
- default:
- return VG_CAP_BUTT;
- }
-}
-
-static VGJoinStyle toVGJoinStyle(LineJoin lineJoin)
-{
- switch (lineJoin) {
- case RoundJoin:
- return VG_JOIN_ROUND;
- case BevelJoin:
- return VG_JOIN_BEVEL;
- case MiterJoin:
- default:
- return VG_JOIN_MITER;
- }
-}
-
-static VGFillRule toVGFillRule(WindRule fillRule)
-{
- return fillRule == RULE_EVENODD ? VG_EVEN_ODD : VG_NON_ZERO;
-}
-
-static VGuint colorToVGColor(const Color& color)
-{
- VGuint vgColor = color.red();
- vgColor = (vgColor << 8) | color.green();
- vgColor = (vgColor << 8) | color.blue();
- vgColor = (vgColor << 8) | color.alpha();
- return vgColor;
-}
-
-static void setVGSolidColor(VGPaintMode paintMode, const Color& color)
-{
- VGPaint paint = vgCreatePaint();
- vgSetParameteri(paint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
- vgSetColor(paint, colorToVGColor(color));
- vgSetPaint(paint, paintMode);
- vgDestroyPaint(paint);
- ASSERT_VG_NO_ERROR();
-}
-
-
-struct PlatformPainterState {
- AffineTransform surfaceTransformation;
- CompositeOperator compositeOperation;
- float opacity;
-
- bool scissoringEnabled;
- FloatRect scissorRect;
-#ifdef OPENVG_VERSION_1_1
- bool maskingChangedAndEnabled;
- VGMaskLayer mask;
-#endif
-
- Color fillColor;
- StrokeStyle strokeStyle;
- Color strokeColor;
- float strokeThickness;
- LineCap strokeLineCap;
- LineJoin strokeLineJoin;
- float strokeMiterLimit;
- DashArray strokeDashArray;
- float strokeDashOffset;
-
- TextDrawingModeFlags textDrawingMode;
- bool antialiasingEnabled;
-
- PlatformPainterState()
- : compositeOperation(CompositeSourceOver)
- , opacity(1.0)
- , scissoringEnabled(false)
-#ifdef OPENVG_VERSION_1_1
- , maskingChangedAndEnabled(false)
- , mask(VG_INVALID_HANDLE)
-#endif
- , fillColor(Color::black)
- , strokeStyle(NoStroke)
- , strokeThickness(0.0)
- , strokeLineCap(ButtCap)
- , strokeLineJoin(MiterJoin)
- , strokeMiterLimit(4.0)
- , strokeDashOffset(0.0)
- , textDrawingMode(TextModeFill)
- , antialiasingEnabled(true)
- {
- }
-
- ~PlatformPainterState()
- {
-#ifdef OPENVG_VERSION_1_1
- if (maskingChangedAndEnabled && mask != VG_INVALID_HANDLE) {
- vgDestroyMaskLayer(mask);
- ASSERT_VG_NO_ERROR();
- mask = VG_INVALID_HANDLE;
- }
-#endif
- }
-
- PlatformPainterState(const PlatformPainterState& state)
- {
- surfaceTransformation = state.surfaceTransformation;
-
- scissoringEnabled = state.scissoringEnabled;
- scissorRect = state.scissorRect;
-#ifdef OPENVG_VERSION_1_1
- maskingChangedAndEnabled = false;
- mask = state.mask;
-#endif
- copyPaintState(&state);
- }
-
- inline bool maskingEnabled()
- {
- return maskingChangedAndEnabled || mask != VG_INVALID_HANDLE;
- }
-
- void copyPaintState(const PlatformPainterState* other)
- {
- compositeOperation = other->compositeOperation;
- opacity = other->opacity;
-
- fillColor = other->fillColor;
- strokeStyle = other->strokeStyle;
- strokeColor = other->strokeColor;
- strokeThickness = other->strokeThickness;
- strokeLineCap = other->strokeLineCap;
- strokeLineJoin = other->strokeLineJoin;
- strokeMiterLimit = other->strokeMiterLimit;
- strokeDashArray = other->strokeDashArray;
- strokeDashOffset = other->strokeDashOffset;
-
- textDrawingMode = other->textDrawingMode;
- antialiasingEnabled = other->antialiasingEnabled;
- }
-
- void applyState(PainterOpenVG* painter)
- {
- ASSERT(painter);
-
- setVGSolidColor(VG_FILL_PATH, fillColor);
- setVGSolidColor(VG_STROKE_PATH, strokeColor);
-
- vgSetf(VG_STROKE_LINE_WIDTH, strokeThickness);
- vgSeti(VG_STROKE_CAP_STYLE, toVGCapStyle(strokeLineCap));
- vgSeti(VG_STROKE_JOIN_STYLE, toVGJoinStyle(strokeLineJoin));
- vgSetf(VG_STROKE_MITER_LIMIT, strokeMiterLimit);
-
- if (antialiasingEnabled)
- vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_FASTER);
- else
- vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_NONANTIALIASED);
-
- applyBlending(painter);
- applyStrokeStyle();
-
- applyTransformation(painter);
- applyScissorRect();
-
-#ifdef OPENVG_VERSION_1_1
- if (maskingEnabled()) {
- vgSeti(VG_MASKING, VG_TRUE);
- if (mask != VG_INVALID_HANDLE)
- vgMask(mask, VG_SET_MASK, 0, 0, painter->surface()->width(), painter->surface()->height());
- } else
- vgSeti(VG_MASKING, VG_FALSE);
-#endif
- ASSERT_VG_NO_ERROR();
- }
-
- void applyBlending(PainterOpenVG* painter)
- {
- VGBlendMode blendMode = VG_BLEND_SRC_OVER;
-
- switch (compositeOperation) {
- case CompositeClear: {
- // Clear means "set to fully transparent regardless of SRC".
- // We implement that by multiplying DST with white color
- // (= no changes) and an alpha of 1.0 - opacity, so the destination
- // pixels will be fully transparent when opacity == 1.0 and
- // unchanged when opacity == 0.0.
- blendMode = VG_BLEND_DST_IN;
- const VGfloat values[] = { 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 - opacity };
- vgSetfv(VG_COLOR_TRANSFORM_VALUES, 8, values);
- vgSeti(VG_COLOR_TRANSFORM, VG_TRUE);
- ASSERT_VG_NO_ERROR();
- break;
- }
- case CompositeCopy:
- blendMode = VG_BLEND_SRC;
- break;
- case CompositeSourceOver:
- blendMode = VG_BLEND_SRC_OVER;
- break;
- case CompositeSourceIn:
- blendMode = VG_BLEND_SRC_IN;
- break;
- case CompositeSourceOut:
- notImplemented();
- break;
- case CompositeSourceAtop:
- notImplemented();
- break;
- case CompositeDestinationOver:
- blendMode = VG_BLEND_DST_OVER;
- break;
- case CompositeDestinationIn:
- blendMode = VG_BLEND_DST_IN;
- break;
- case CompositeDestinationOut:
- notImplemented();
- break;
- case CompositeDestinationAtop:
- notImplemented();
- break;
- case CompositeXOR:
- notImplemented();
- break;
- case CompositePlusDarker:
- blendMode = VG_BLEND_DARKEN;
- break;
- case CompositePlusLighter:
- blendMode = VG_BLEND_LIGHTEN;
- break;
- }
-
- if (compositeOperation != CompositeClear) {
- if (opacity >= (1.0 - FLT_EPSILON))
- vgSeti(VG_COLOR_TRANSFORM, VG_FALSE);
- else if (blendMode == VG_BLEND_SRC) {
- blendMode = VG_BLEND_SRC_OVER;
- VGfloat values[] = { 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, opacity };
- vgSetfv(VG_COLOR_TRANSFORM_VALUES, 8, values);
- vgSeti(VG_COLOR_TRANSFORM, VG_TRUE);
- } else {
- VGfloat values[] = { 1.0, 1.0, 1.0, opacity, 0.0, 0.0, 0.0, 0.0 };
- vgSetfv(VG_COLOR_TRANSFORM_VALUES, 8, values);
- vgSeti(VG_COLOR_TRANSFORM, VG_TRUE);
- }
- ASSERT_VG_NO_ERROR();
- }
-
- vgSeti(VG_BLEND_MODE, blendMode);
- ASSERT_VG_NO_ERROR();
- }
-
- void applyTransformation(PainterOpenVG* painter)
- {
- // There are *five* separate transforms that can be applied to OpenVG as of 1.1
- // but it is not clear that we need to set them separately. Instead we set them
- // all right here and let this be a call to essentially set the world transformation!
- VGMatrix vgMatrix(surfaceTransformation);
- const VGfloat* vgFloatArray = vgMatrix.toVGfloat();
-
- vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
- vgLoadMatrix(vgFloatArray);
- ASSERT_VG_NO_ERROR();
-
- vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
- vgLoadMatrix(vgFloatArray);
- ASSERT_VG_NO_ERROR();
-
-#ifdef OPENVG_VERSION_1_1
- vgSeti(VG_MATRIX_MODE, VG_MATRIX_GLYPH_USER_TO_SURFACE);
- vgLoadMatrix(vgFloatArray);
- ASSERT_VG_NO_ERROR();
-#endif
- }
-
- void applyScissorRect()
- {
- if (scissoringEnabled) {
- vgSeti(VG_SCISSORING, VG_TRUE);
- vgSetfv(VG_SCISSOR_RECTS, 4, VGRect(scissorRect).toVGfloat());
- } else
- vgSeti(VG_SCISSORING, VG_FALSE);
-
- ASSERT_VG_NO_ERROR();
- }
-
- void applyStrokeStyle()
- {
- if (strokeStyle == DottedStroke) {
- VGfloat vgFloatArray[2] = { 1.0, 1.0 };
- vgSetfv(VG_STROKE_DASH_PATTERN, 2, vgFloatArray);
- vgSetf(VG_STROKE_DASH_PHASE, 0.0);
- } else if (strokeStyle == DashedStroke) {
- if (!strokeDashArray.size()) {
- VGfloat vgFloatArray[2] = { 4.0, 3.0 };
- vgSetfv(VG_STROKE_DASH_PATTERN, 2, vgFloatArray);
- } else {
- Vector<VGfloat> vgFloatArray(strokeDashArray.size());
- for (int i = 0; i < strokeDashArray.size(); ++i)
- vgFloatArray[i] = strokeDashArray[i];
-
- vgSetfv(VG_STROKE_DASH_PATTERN, vgFloatArray.size(), vgFloatArray.data());
- }
- vgSetf(VG_STROKE_DASH_PHASE, strokeDashOffset);
- } else {
- vgSetfv(VG_STROKE_DASH_PATTERN, 0, 0);
- vgSetf(VG_STROKE_DASH_PHASE, 0.0);
- }
-
- ASSERT_VG_NO_ERROR();
- }
-
- inline bool strokeDisabled() const
- {
- return (compositeOperation == CompositeSourceOver
- && (strokeStyle == NoStroke || !strokeColor.alpha()));
- }
-
- inline bool fillDisabled() const
- {
- return (compositeOperation == CompositeSourceOver && !fillColor.alpha());
- }
-
- void saveMaskIfNecessary(PainterOpenVG* painter)
- {
-#ifdef OPENVG_VERSION_1_1
- if (maskingChangedAndEnabled) {
- if (mask != VG_INVALID_HANDLE) {
- vgDestroyMaskLayer(mask);
- ASSERT_VG_NO_ERROR();
- }
- mask = vgCreateMaskLayer(painter->surface()->width(), painter->surface()->height());
- ASSERT(mask != VG_INVALID_HANDLE);
- vgCopyMask(mask, 0, 0, 0, 0, painter->surface()->width(), painter->surface()->height());
- ASSERT_VG_NO_ERROR();
- }
-#endif
- }
-};
-
-
-PainterOpenVG::PainterOpenVG()
- : m_state(0)
- , m_surface(0)
-{
-}
-
-PainterOpenVG::PainterOpenVG(SurfaceOpenVG* surface)
- : m_state(0)
- , m_surface(0)
-{
- ASSERT(surface);
- begin(surface);
-}
-
-PainterOpenVG::~PainterOpenVG()
-{
- end();
-}
-
-void PainterOpenVG::begin(SurfaceOpenVG* surface)
-{
- if (surface == m_surface)
- return;
-
- ASSERT(surface);
- ASSERT(!m_state);
-
- m_surface = surface;
-
- m_stateStack.append(new PlatformPainterState());
- m_state = m_stateStack.last();
-
- m_surface->setActivePainter(this);
- m_surface->makeCurrent();
-}
-
-void PainterOpenVG::end()
-{
- if (!m_surface)
- return;
-
- m_surface->setActivePainter(0);
- m_surface = 0;
-
- destroyPainterStates();
-}
-
-void PainterOpenVG::destroyPainterStates()
-{
- PlatformPainterState* state = 0;
- while (!m_stateStack.isEmpty()) {
- state = m_stateStack.last();
- m_stateStack.removeLast();
- delete state;
- }
- m_state = 0;
-}
-
-// Called by friend SurfaceOpenVG, private otherwise.
-void PainterOpenVG::applyState()
-{
- ASSERT(m_state);
- m_state->applyState(this);
-}
-
-/**
- * Copy the current back buffer image onto the surface.
- *
- * Call this method when all painting operations have been completed,
- * otherwise the surface won't visibly change.
- */
-void PainterOpenVG::blitToSurface()
-{
- ASSERT(m_state); // implies m_surface
- m_surface->flush();
-}
-
-AffineTransform PainterOpenVG::transformation() const
-{
- ASSERT(m_state);
- return m_state->surfaceTransformation;
-}
-
-void PainterOpenVG::concatTransformation(const AffineTransform& transformation)
-{
- ASSERT(m_state);
- m_surface->makeCurrent();
-
- // We do the multiplication ourself using WebCore's AffineTransform rather
- // than offloading this to VG via vgMultMatrix() to keep things simple and
- // so we can maintain state ourselves.
- m_state->surfaceTransformation.multLeft(transformation);
- m_state->applyTransformation(this);
-}
-
-void PainterOpenVG::setTransformation(const AffineTransform& transformation)
-{
- ASSERT(m_state);
- m_surface->makeCurrent();
-
- m_state->surfaceTransformation = transformation;
- m_state->applyTransformation(this);
-}
-
-void PainterOpenVG::transformPath(VGPath dst, VGPath src, const AffineTransform& transformation)
-{
- vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
-
- // Save the transform state
- VGfloat currentMatrix[9];
- vgGetMatrix(currentMatrix);
- ASSERT_VG_NO_ERROR();
-
- // Load the new transform
- vgLoadMatrix(VGMatrix(transformation).toVGfloat());
- ASSERT_VG_NO_ERROR();
-
- // Apply the new transform
- vgTransformPath(dst, src);
- ASSERT_VG_NO_ERROR();
-
- // Restore the transform state
- vgLoadMatrix(currentMatrix);
- ASSERT_VG_NO_ERROR();
-}
-
-CompositeOperator PainterOpenVG::compositeOperation() const
-{
- ASSERT(m_state);
- return m_state->compositeOperation;
-}
-
-void PainterOpenVG::setCompositeOperation(CompositeOperator op)
-{
- ASSERT(m_state);
- m_surface->makeCurrent();
-
- m_state->compositeOperation = op;
- m_state->applyBlending(this);
-}
-
-float PainterOpenVG::opacity() const
-{
- ASSERT(m_state);
- return m_state->opacity;
-}
-
-void PainterOpenVG::setOpacity(float opacity)
-{
- ASSERT(m_state);
- m_surface->makeCurrent();
-
- m_state->opacity = opacity;
- m_state->applyBlending(this);
-}
-
-float PainterOpenVG::strokeThickness() const
-{
- ASSERT(m_state);
- return m_state->strokeThickness;
-}
-
-void PainterOpenVG::setStrokeThickness(float thickness)
-{
- ASSERT(m_state);
- m_surface->makeCurrent();
-
- m_state->strokeThickness = thickness;
- vgSetf(VG_STROKE_LINE_WIDTH, thickness);
- ASSERT_VG_NO_ERROR();
-}
-
-StrokeStyle PainterOpenVG::strokeStyle() const
-{
- ASSERT(m_state);
- return m_state->strokeStyle;
-}
-
-void PainterOpenVG::setStrokeStyle(StrokeStyle style)
-{
- ASSERT(m_state);
- m_surface->makeCurrent();
-
- m_state->strokeStyle = style;
- m_state->applyStrokeStyle();
-}
-
-void PainterOpenVG::setLineDash(const DashArray& dashArray, float dashOffset)
-{
- ASSERT(m_state);
- m_surface->makeCurrent();
-
- m_state->strokeDashArray = dashArray;
- m_state->strokeDashOffset = dashOffset;
- m_state->applyStrokeStyle();
-}
-
-void PainterOpenVG::setLineCap(LineCap lineCap)
-{
- ASSERT(m_state);
- m_surface->makeCurrent();
-
- m_state->strokeLineCap = lineCap;
- vgSeti(VG_STROKE_CAP_STYLE, toVGCapStyle(lineCap));
- ASSERT_VG_NO_ERROR();
-}
-
-void PainterOpenVG::setLineJoin(LineJoin lineJoin)
-{
- ASSERT(m_state);
- m_surface->makeCurrent();
-
- m_state->strokeLineJoin = lineJoin;
- vgSeti(VG_STROKE_JOIN_STYLE, toVGJoinStyle(lineJoin));
- ASSERT_VG_NO_ERROR();
-}
-
-void PainterOpenVG::setMiterLimit(float miterLimit)
-{
- ASSERT(m_state);
- m_surface->makeCurrent();
-
- m_state->strokeMiterLimit = miterLimit;
- vgSetf(VG_STROKE_MITER_LIMIT, miterLimit);
- ASSERT_VG_NO_ERROR();
-}
-
-Color PainterOpenVG::strokeColor() const
-{
- ASSERT(m_state);
- return m_state->strokeColor;
-}
-
-void PainterOpenVG::setStrokeColor(const Color& color)
-{
- ASSERT(m_state);
- m_surface->makeCurrent();
-
- m_state->strokeColor = color;
- setVGSolidColor(VG_STROKE_PATH, color);
-}
-
-Color PainterOpenVG::fillColor() const
-{
- ASSERT(m_state);
- return m_state->fillColor;
-}
-
-void PainterOpenVG::setFillColor(const Color& color)
-{
- ASSERT(m_state);
- m_surface->makeCurrent();
-
- m_state->fillColor = color;
- setVGSolidColor(VG_FILL_PATH, color);
-}
-
-TextDrawingModeFlags PainterOpenVG::textDrawingMode() const
-{
- ASSERT(m_state);
- return m_state->textDrawingMode;
-}
-
-void PainterOpenVG::setTextDrawingMode(TextDrawingModeFlags mode)
-{
- ASSERT(m_state);
- m_state->textDrawingMode = mode;
-}
-
-bool PainterOpenVG::antialiasingEnabled() const
-{
- ASSERT(m_state);
- return m_state->antialiasingEnabled;
-}
-
-void PainterOpenVG::setAntialiasingEnabled(bool enabled)
-{
- ASSERT(m_state);
- m_surface->makeCurrent();
-
- m_state->antialiasingEnabled = enabled;
-
- if (enabled)
- vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_FASTER);
- else
- vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_NONANTIALIASED);
-}
-
-void PainterOpenVG::scale(const FloatSize& scaleFactors)
-{
- ASSERT(m_state);
- m_surface->makeCurrent();
-
- AffineTransform transformation = m_state->surfaceTransformation;
- transformation.scaleNonUniform(scaleFactors.width(), scaleFactors.height());
- setTransformation(transformation);
-}
-
-void PainterOpenVG::rotate(float radians)
-{
- ASSERT(m_state);
- m_surface->makeCurrent();
-
- AffineTransform transformation = m_state->surfaceTransformation;
- transformation.rotate(rad2deg(radians));
- setTransformation(transformation);
-}
-
-void PainterOpenVG::translate(float dx, float dy)
-{
- ASSERT(m_state);
- m_surface->makeCurrent();
-
- AffineTransform transformation = m_state->surfaceTransformation;
- transformation.translate(dx, dy);
- setTransformation(transformation);
-}
-
-void PainterOpenVG::drawPath(const Path& path, VGbitfield specifiedPaintModes, WindRule fillRule)
-{
- if (path.isNull())
- return;
-
- ASSERT(m_state);
-
- VGbitfield paintModes = 0;
- if (!m_state->strokeDisabled())
- paintModes |= VG_STROKE_PATH;
- if (!m_state->fillDisabled())
- paintModes |= VG_FILL_PATH;
-
- paintModes &= specifiedPaintModes;
-
- if (!paintModes)
- return;
-
- m_surface->makeCurrent();
-
- vgSeti(VG_FILL_RULE, toVGFillRule(fillRule));
- vgDrawPath(path.platformPath()->vgPath(), paintModes);
- ASSERT_VG_NO_ERROR();
-}
-
-void PainterOpenVG::intersectScissorRect(const FloatRect& rect)
-{
- // Scissor rectangles are defined by float values, but e.g. painting
- // something red to a float-clipped rectangle and then painting something
- // white to the same rectangle will leave some red remnants as it is
- // rendered to full pixels in between. Also, some OpenVG implementations
- // are likely to clip to integer coordinates anyways because of the above
- // effect. So considering the above (and confirming through tests) the
- // visual result is better if we clip to the enclosing integer rectangle
- // rather than the exact float rectangle for scissoring.
- if (m_state->scissoringEnabled)
- m_state->scissorRect.intersect(FloatRect(enclosingIntRect(rect)));
- else {
- m_state->scissoringEnabled = true;
- m_state->scissorRect = FloatRect(enclosingIntRect(rect));
- }
-
- m_state->applyScissorRect();
-}
-
-void PainterOpenVG::intersectClipRect(const FloatRect& rect)
-{
- ASSERT(m_state);
- m_surface->makeCurrent();
-
- if (m_state->surfaceTransformation.isIdentity()) {
- // No transformation required, skip all the complex stuff.
- intersectScissorRect(rect);
- return;
- }
-
- // Check if the actual destination rectangle is still rectilinear (can be
- // represented as FloatRect) so we could apply scissoring instead of
- // (potentially more expensive) path clipping. Note that scissoring is not
- // subject to transformations, so we need to do the transformation to
- // surface coordinates by ourselves.
- FloatQuad effectiveScissorQuad = m_state->surfaceTransformation.mapQuad(FloatQuad(rect));
-
- if (effectiveScissorQuad.isRectilinear())
- intersectScissorRect(effectiveScissorQuad.boundingBox());
- else {
- // The transformed scissorRect cannot be represented as FloatRect
- // anymore, so we need to perform masking instead.
- Path scissorRectPath;
- scissorRectPath.addRect(rect);
- clipPath(scissorRectPath, PainterOpenVG::IntersectClip);
- }
-}
-
-void PainterOpenVG::clipPath(const Path& path, PainterOpenVG::ClipOperation maskOp, WindRule clipRule)
-{
-#ifdef OPENVG_VERSION_1_1
- ASSERT(m_state);
- m_surface->makeCurrent();
-
- if (m_state->mask != VG_INVALID_HANDLE && !m_state->maskingChangedAndEnabled) {
- // The parent's mask has been inherited - dispose the handle so that
- // it won't be overwritten.
- m_state->maskingChangedAndEnabled = true;
- m_state->mask = VG_INVALID_HANDLE;
- } else if (!m_state->maskingEnabled()) {
- // None of the parent painter states had a mask enabled yet.
- m_state->maskingChangedAndEnabled = true;
- vgSeti(VG_MASKING, VG_TRUE);
- // Make sure not to inherit previous mask state from previously written
- // (but disabled) masks. For VG_FILL_MASK the first argument is ignored,
- // we pass VG_INVALID_HANDLE which is what the OpenVG spec suggests.
- vgMask(VG_INVALID_HANDLE, VG_FILL_MASK, 0, 0, m_surface->width(), m_surface->height());
- }
-
- // Intersect the path from the mask, or subtract it from there.
- // (In either case we always decrease the visible area, never increase it,
- // which means masking never has to modify scissor rectangles.)
- vgSeti(VG_FILL_RULE, toVGFillRule(clipRule));
- vgRenderToMask(path.platformPath()->vgPath(), VG_FILL_PATH, (VGMaskOperation) maskOp);
- ASSERT_VG_NO_ERROR();
-#else
- notImplemented();
-#endif
-}
-
-void PainterOpenVG::drawRect(const FloatRect& rect, VGbitfield specifiedPaintModes)
-{
- ASSERT(m_state);
-
- VGbitfield paintModes = 0;
- if (!m_state->strokeDisabled())
- paintModes |= VG_STROKE_PATH;
- if (!m_state->fillDisabled())
- paintModes |= VG_FILL_PATH;
-
- paintModes &= specifiedPaintModes;
-
- if (!paintModes)
- return;
-
- m_surface->makeCurrent();
-
- VGPath path = vgCreatePath(
- VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
- 1.0 /* scale */, 0.0 /* bias */,
- 5 /* expected number of segments */,
- 5 /* expected number of total coordinates */,
- VG_PATH_CAPABILITY_APPEND_TO);
- ASSERT_VG_NO_ERROR();
-
- if (vguRect(path, rect.x(), rect.y(), rect.width(), rect.height()) == VGU_NO_ERROR) {
- vgDrawPath(path, paintModes);
- ASSERT_VG_NO_ERROR();
- }
-
- vgDestroyPath(path);
- ASSERT_VG_NO_ERROR();
-}
-
-void PainterOpenVG::drawRoundedRect(const FloatRect& rect, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, VGbitfield specifiedPaintModes)
-{
- ASSERT(m_state);
-
- VGbitfield paintModes = 0;
- if (!m_state->strokeDisabled())
- paintModes |= VG_STROKE_PATH;
- if (!m_state->fillDisabled())
- paintModes |= VG_FILL_PATH;
-
- paintModes &= specifiedPaintModes;
-
- if (!paintModes)
- return;
-
- m_surface->makeCurrent();
-
- VGPath path = vgCreatePath(
- VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
- 1.0 /* scale */, 0.0 /* bias */,
- 10 /* expected number of segments */,
- 25 /* expected number of total coordinates */,
- VG_PATH_CAPABILITY_APPEND_TO);
- ASSERT_VG_NO_ERROR();
-
- // clamp corner arc sizes
- FloatSize clampedTopLeft = FloatSize(topLeft).shrunkTo(rect.size()).expandedTo(FloatSize());
- FloatSize clampedTopRight = FloatSize(topRight).shrunkTo(rect.size()).expandedTo(FloatSize());
- FloatSize clampedBottomLeft = FloatSize(bottomLeft).shrunkTo(rect.size()).expandedTo(FloatSize());
- FloatSize clampedBottomRight = FloatSize(bottomRight).shrunkTo(rect.size()).expandedTo(FloatSize());
-
- // As OpenVG's coordinate system is flipped in comparison to WebKit's,
- // we have to specify the opposite value for the "clockwise" value.
- static const VGubyte pathSegments[] = {
- VG_MOVE_TO_ABS,
- VG_HLINE_TO_REL,
- VG_SCCWARC_TO_REL,
- VG_VLINE_TO_REL,
- VG_SCCWARC_TO_REL,
- VG_HLINE_TO_REL,
- VG_SCCWARC_TO_REL,
- VG_VLINE_TO_REL,
- VG_SCCWARC_TO_REL,
- VG_CLOSE_PATH
- };
- // Also, the rounded rectangle path proceeds from the top to the bottom,
- // requiring height distances and clamped radius sizes to be flipped.
- const VGfloat pathData[] = {
- rect.x() + clampedTopLeft.width(), rect.y(),
- rect.width() - clampedTopLeft.width() - clampedTopRight.width(),
- clampedTopRight.width(), clampedTopRight.height(), 0, clampedTopRight.width(), clampedTopRight.height(),
- rect.height() - clampedTopRight.height() - clampedBottomRight.height(),
- clampedBottomRight.width(), clampedBottomRight.height(), 0, -clampedBottomRight.width(), clampedBottomRight.height(),
- -(rect.width() - clampedBottomLeft.width() - clampedBottomRight.width()),
- clampedBottomLeft.width(), clampedBottomLeft.height(), 0, -clampedBottomLeft.width(), -clampedBottomLeft.height(),
- -(rect.height() - clampedTopLeft.height() - clampedBottomLeft.height()),
- clampedTopLeft.width(), clampedTopLeft.height(), 0, clampedTopLeft.width(), -clampedTopLeft.height(),
- };
-
- vgAppendPathData(path, 10, pathSegments, pathData);
- vgDrawPath(path, paintModes);
- vgDestroyPath(path);
- ASSERT_VG_NO_ERROR();
-}
-
-void PainterOpenVG::drawLine(const IntPoint& from, const IntPoint& to)
-{
- ASSERT(m_state);
-
- if (m_state->strokeDisabled())
- return;
-
- m_surface->makeCurrent();
-
- VGPath path = vgCreatePath(
- VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
- 1.0 /* scale */, 0.0 /* bias */,
- 2 /* expected number of segments */,
- 4 /* expected number of total coordinates */,
- VG_PATH_CAPABILITY_APPEND_TO);
- ASSERT_VG_NO_ERROR();
-
- VGUErrorCode errorCode;
-
- // Try to align lines to pixels, centering them between pixels for odd thickness values.
- if (fmod(m_state->strokeThickness + 0.5, 2.0) < 1.0)
- errorCode = vguLine(path, from.x(), from.y(), to.x(), to.y());
- else if ((to.y() - from.y()) > (to.x() - from.x())) // more vertical than horizontal
- errorCode = vguLine(path, from.x() + 0.5, from.y(), to.x() + 0.5, to.y());
- else
- errorCode = vguLine(path, from.x(), from.y() + 0.5, to.x(), to.y() + 0.5);
-
- if (errorCode == VGU_NO_ERROR) {
- vgDrawPath(path, VG_STROKE_PATH);
- ASSERT_VG_NO_ERROR();
- }
-
- vgDestroyPath(path);
- ASSERT_VG_NO_ERROR();
-}
-
-void PainterOpenVG::drawArc(const IntRect& rect, int startAngle, int angleSpan, VGbitfield specifiedPaintModes)
-{
- ASSERT(m_state);
-
- VGbitfield paintModes = 0;
- if (!m_state->strokeDisabled())
- paintModes |= VG_STROKE_PATH;
- if (!m_state->fillDisabled())
- paintModes |= VG_FILL_PATH;
-
- paintModes &= specifiedPaintModes;
-
- if (!paintModes)
- return;
-
- m_surface->makeCurrent();
-
- VGPath path = vgCreatePath(
- VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
- 1.0 /* scale */, 0.0 /* bias */,
- 2 /* expected number of segments */,
- 4 /* expected number of total coordinates */,
- VG_PATH_CAPABILITY_APPEND_TO);
- ASSERT_VG_NO_ERROR();
-
- if (vguArc(path, rect.x() + rect.width() / 2.0, rect.y() + rect.height() / 2.0, rect.width(), rect.height(), -startAngle, -angleSpan, VGU_ARC_OPEN) == VGU_NO_ERROR) {
- vgDrawPath(path, VG_STROKE_PATH);
- ASSERT_VG_NO_ERROR();
- }
-
- vgDestroyPath(path);
- ASSERT_VG_NO_ERROR();
-}
-
-void PainterOpenVG::drawEllipse(const IntRect& rect, VGbitfield specifiedPaintModes)
-{
- ASSERT(m_state);
-
- VGbitfield paintModes = 0;
- if (!m_state->strokeDisabled())
- paintModes |= VG_STROKE_PATH;
- if (!m_state->fillDisabled())
- paintModes |= VG_FILL_PATH;
-
- paintModes &= specifiedPaintModes;
-
- if (!paintModes)
- return;
-
- m_surface->makeCurrent();
-
- VGPath path = vgCreatePath(
- VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
- 1.0 /* scale */, 0.0 /* bias */,
- 4 /* expected number of segments */,
- 12 /* expected number of total coordinates */,
- VG_PATH_CAPABILITY_APPEND_TO);
- ASSERT_VG_NO_ERROR();
-
- if (vguEllipse(path, rect.x() + rect.width() / 2.0, rect.y() + rect.height() / 2.0, rect.width(), rect.height()) == VGU_NO_ERROR) {
- vgDrawPath(path, paintModes);
- ASSERT_VG_NO_ERROR();
- }
-
- vgDestroyPath(path);
- ASSERT_VG_NO_ERROR();
-}
-
-void PainterOpenVG::drawPolygon(size_t numPoints, const FloatPoint* points, VGbitfield specifiedPaintModes)
-{
- ASSERT(m_state);
-
- VGbitfield paintModes = 0;
- if (!m_state->strokeDisabled())
- paintModes |= VG_STROKE_PATH;
- if (!m_state->fillDisabled())
- paintModes |= VG_FILL_PATH;
-
- paintModes &= specifiedPaintModes;
-
- if (!paintModes)
- return;
-
- m_surface->makeCurrent();
-
- // Path segments: all points + "close path".
- const VGint numSegments = numPoints + 1;
- const VGint numCoordinates = numPoints * 2;
-
- VGPath path = vgCreatePath(
- VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
- 1.0 /* scale */, 0.0 /* bias */,
- numSegments /* expected number of segments */,
- numCoordinates /* expected number of total coordinates */,
- VG_PATH_CAPABILITY_APPEND_TO);
- ASSERT_VG_NO_ERROR();
-
- Vector<VGfloat> vgPoints(numCoordinates);
- for (int i = 0; i < numPoints; ++i) {
- vgPoints[i*2] = points[i].x();
- vgPoints[i*2 + 1] = points[i].y();
- }
-
- if (vguPolygon(path, vgPoints.data(), numPoints, VG_TRUE /* closed */) == VGU_NO_ERROR) {
- vgDrawPath(path, paintModes);
- ASSERT_VG_NO_ERROR();
- }
-
- vgDestroyPath(path);
- ASSERT_VG_NO_ERROR();
-}
-
-void PainterOpenVG::drawImage(TiledImageOpenVG* tiledImage, const FloatRect& dst, const FloatRect& src)
-{
- ASSERT(m_state);
- m_surface->makeCurrent();
-
- // If buffers can be larger than the maximum OpenVG image sizes,
- // we split them into tiles.
- IntRect drawnTiles = tiledImage->tilesInRect(src);
- AffineTransform srcToDstTransformation = makeMapBetweenRects(
- FloatRect(FloatPoint(0.0, 0.0), src.size()), dst);
- srcToDstTransformation.translate(-src.x(), -src.y());
-
- for (int yIndex = drawnTiles.y(); yIndex < drawnTiles.bottom(); ++yIndex) {
- for (int xIndex = drawnTiles.x(); xIndex < drawnTiles.right(); ++xIndex) {
- // The srcTile rectangle is an aligned tile cropped by the src rectangle.
- FloatRect tile(tiledImage->tileRect(xIndex, yIndex));
- FloatRect srcTile = intersection(src, tile);
-
- save();
-
- // If the image is drawn in full, all we need is the proper transformation
- // in order to get it drawn at the right spot on the surface.
- concatTransformation(AffineTransform(srcToDstTransformation).translate(tile.x(), tile.y()));
-
- // If only a part of the tile is drawn, we also need to clip the surface.
- if (srcTile != tile) {
- // Put boundaries relative to tile origin, as we already
- // translated to (x, y) with the transformation matrix.
- srcTile.move(-tile.x(), -tile.y());
- intersectClipRect(srcTile);
- }
-
- VGImage image = tiledImage->tile(xIndex, yIndex);
- if (image != VG_INVALID_HANDLE) {
- vgDrawImage(image);
- ASSERT_VG_NO_ERROR();
- }
-
- restore();
- }
- }
-}
-
-#ifdef OPENVG_VERSION_1_1
-void PainterOpenVG::drawText(VGFont vgFont, Vector<VGuint>& characters, VGfloat* adjustmentsX, VGfloat* adjustmentsY, const FloatPoint& point)
-{
- ASSERT(m_state);
-
- VGbitfield paintModes = 0;
-
- if (m_state->textDrawingMode & TextModeFill && !m_state->fillDisabled())
- paintModes |= VG_FILL_PATH;
- if (m_state->textDrawingMode & TextModeStroke && !m_state->strokeDisabled())
- paintModes |= VG_STROKE_PATH;
-
- m_surface->makeCurrent();
-
- FloatPoint effectivePoint = m_state->surfaceTransformation.mapPoint(point);
- FloatPoint p = point;
- AffineTransform* originalTransformation = 0;
-
- // In case the font isn't drawn at a pixel-exact baseline and we can easily
- // fix that (which is the case for non-rotated affine transforms), let's
- // align the starting point to the pixel boundary in order to prevent
- // font rendering issues such as glyphs that appear off by a pixel.
- // This causes us to have inconsistent spacing between baselines in a
- // larger paragraph, but that seems to be the least of all evils.
- if ((fmod(effectivePoint.x() + 0.01, 1.0) > 0.02 || fmod(effectivePoint.y() + 0.01, 1.0) > 0.02)
- && isNonRotatedAffineTransformation(m_state->surfaceTransformation))
- {
- originalTransformation = new AffineTransform(m_state->surfaceTransformation);
- setTransformation(AffineTransform(
- m_state->surfaceTransformation.a(), 0,
- 0, m_state->surfaceTransformation.d(),
- roundf(effectivePoint.x()), roundf(effectivePoint.y())));
- p = FloatPoint();
- }
-
- const VGfloat vgPoint[2] = { p.x(), p.y() };
- vgSetfv(VG_GLYPH_ORIGIN, 2, vgPoint);
- ASSERT_VG_NO_ERROR();
-
- vgDrawGlyphs(vgFont, characters.size(), characters.data(),
- adjustmentsX, adjustmentsY, paintModes, VG_TRUE /* allow autohinting */);
- ASSERT_VG_NO_ERROR();
-
- if (originalTransformation) {
- setTransformation(*originalTransformation);
- delete originalTransformation;
- }
-}
-#endif
-
-TiledImageOpenVG* PainterOpenVG::asNewNativeImage(const IntRect& src, VGImageFormat format)
-{
- ASSERT(m_state);
- m_surface->sharedSurface()->makeCurrent();
-
- const IntSize vgMaxImageSize(vgGeti(VG_MAX_IMAGE_WIDTH), vgGeti(VG_MAX_IMAGE_HEIGHT));
- ASSERT_VG_NO_ERROR();
-
- const IntRect rect = intersection(src, IntRect(0, 0, m_surface->width(), m_surface->height()));
- TiledImageOpenVG* tiledImage = new TiledImageOpenVG(rect.size(), vgMaxImageSize);
-
- const int numColumns = tiledImage->numColumns();
- const int numRows = tiledImage->numRows();
-
- // Create the images as resources of the shared surface/context.
- for (int yIndex = 0; yIndex < numRows; ++yIndex) {
- for (int xIndex = 0; xIndex < numColumns; ++xIndex) {
- IntRect tileRect = tiledImage->tileRect(xIndex, yIndex);
- VGImage image = vgCreateImage(format, tileRect.width(), tileRect.height(), VG_IMAGE_QUALITY_FASTER);
- ASSERT_VG_NO_ERROR();
-
- tiledImage->setTile(xIndex, yIndex, image);
- }
- }
-
- // Fill the image contents with our own surface/context being current.
- m_surface->makeCurrent();
-
- for (int yIndex = 0; yIndex < numRows; ++yIndex) {
- for (int xIndex = 0; xIndex < numColumns; ++xIndex) {
- IntRect tileRect = tiledImage->tileRect(xIndex, yIndex);
-
- vgGetPixels(tiledImage->tile(xIndex, yIndex), 0, 0,
- rect.x() + tileRect.x(), rect.y() + tileRect.y(),
- tileRect.width(), tileRect.height());
- ASSERT_VG_NO_ERROR();
- }
- }
-
- return tiledImage;
-}
-
-void PainterOpenVG::save(PainterOpenVG::SaveMode saveMode)
-{
- ASSERT(m_state);
-
- // If the underlying context/surface was switched away by someone without
- // telling us, it might not correspond to the one assigned to this painter.
- // Switch back so we can save the state properly. (Should happen rarely.)
- // Use DontSaveOrApplyPainterState mode in order to avoid recursion.
- m_surface->makeCurrent(SurfaceOpenVG::DontSaveOrApplyPainterState);
-
- if (saveMode == PainterOpenVG::CreateNewState) {
- m_state->saveMaskIfNecessary(this);
- PlatformPainterState* state = new PlatformPainterState(*m_state);
- m_stateStack.append(state);
- m_state = m_stateStack.last();
- } else if (saveMode == PainterOpenVG::CreateNewStateWithPaintStateOnly) {
- m_state->saveMaskIfNecessary(this);
- PlatformPainterState* state = new PlatformPainterState();
- state->copyPaintState(m_state);
- m_stateStack.append(state);
- m_state = m_stateStack.last();
- } else // if (saveMode == PainterOpenVG::KeepCurrentState)
- m_state->saveMaskIfNecessary(this);
-}
-
-void PainterOpenVG::restore()
-{
- ASSERT(m_stateStack.size() >= 2);
- m_surface->makeCurrent(SurfaceOpenVG::DontApplyPainterState);
-
- PlatformPainterState* state = m_stateStack.last();
- m_stateStack.removeLast();
- delete state;
-
- m_state = m_stateStack.last();
- m_state->applyState(this);
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/openvg/PainterOpenVG.h b/Source/WebCore/platform/graphics/openvg/PainterOpenVG.h
deleted file mode 100644
index 3f1494e5a..000000000
--- a/Source/WebCore/platform/graphics/openvg/PainterOpenVG.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef PainterOpenVG_h
-#define PainterOpenVG_h
-
-#include "Color.h"
-#include "GraphicsContext.h"
-
-#include <openvg.h>
-
-#include <wtf/Noncopyable.h>
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-class AffineTransform;
-class FloatPoint;
-class FloatRect;
-class IntRect;
-class IntSize;
-class Path;
-class SurfaceOpenVG;
-class TiledImageOpenVG;
-
-struct PlatformPainterState;
-
-class PainterOpenVG {
- WTF_MAKE_NONCOPYABLE(PainterOpenVG);
-public:
- friend class SurfaceOpenVG;
- friend struct PlatformPainterState;
-
- enum SaveMode {
- CreateNewState,
- KeepCurrentState,
- CreateNewStateWithPaintStateOnly // internal usage only, do not use outside PainterOpenVG
- };
- enum ClipOperation {
- IntersectClip = VG_INTERSECT_MASK,
- SubtractClip = VG_SUBTRACT_MASK
- };
-
- PainterOpenVG();
- PainterOpenVG(SurfaceOpenVG*);
- ~PainterOpenVG();
-
- void begin(SurfaceOpenVG*);
- void end();
-
- AffineTransform transformation() const;
- void setTransformation(const AffineTransform&);
- void concatTransformation(const AffineTransform&);
-
- static void transformPath(VGPath dst, VGPath src, const AffineTransform&);
-
- CompositeOperator compositeOperation() const;
- void setCompositeOperation(CompositeOperator);
- float opacity() const;
- void setOpacity(float);
-
- float strokeThickness() const;
- void setStrokeThickness(float);
- StrokeStyle strokeStyle() const;
- void setStrokeStyle(StrokeStyle);
-
- void setLineDash(const DashArray&, float dashOffset);
- void setLineCap(LineCap);
- void setLineJoin(LineJoin);
- void setMiterLimit(float);
-
- Color strokeColor() const;
- void setStrokeColor(const Color&);
-
- Color fillColor() const;
- void setFillColor(const Color&);
-
- int textDrawingMode() const;
- void setTextDrawingMode(int mode);
-
- bool antialiasingEnabled() const;
- void setAntialiasingEnabled(bool);
-
- void drawRect(const FloatRect&, VGbitfield paintModes = (VG_STROKE_PATH | VG_FILL_PATH));
- void drawRoundedRect(const FloatRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, VGbitfield paintModes = (VG_STROKE_PATH | VG_FILL_PATH));
- void drawLine(const IntPoint& from, const IntPoint& to);
- void drawArc(const IntRect& ellipseBounds, int startAngle, int angleSpan, VGbitfield paintModes = (VG_STROKE_PATH | VG_FILL_PATH));
- void drawEllipse(const IntRect& bounds, VGbitfield paintModes = (VG_STROKE_PATH | VG_FILL_PATH));
- void drawPolygon(size_t numPoints, const FloatPoint* points, VGbitfield paintModes = (VG_STROKE_PATH | VG_FILL_PATH));
- void drawImage(TiledImageOpenVG*, const FloatRect& dst, const FloatRect& src);
-#ifdef OPENVG_VERSION_1_1
- void drawText(VGFont, Vector<VGuint>& characters, VGfloat* adjustmentsX, VGfloat* adjustmentsY, const FloatPoint&);
-#endif
-
- void scale(const FloatSize& scaleFactors);
- void rotate(float radians);
- void translate(float dx, float dy);
-
- void drawPath(const Path&, VGbitfield paintModes = (VG_STROKE_PATH | VG_FILL_PATH), WindRule fillRule = RULE_NONZERO);
-
- void intersectClipRect(const FloatRect&);
- void clipPath(const Path&, PainterOpenVG::ClipOperation, WindRule clipRule = RULE_NONZERO);
-
- TiledImageOpenVG* asNewNativeImage(const IntRect& src, VGImageFormat);
-
- void save(PainterOpenVG::SaveMode saveMode = CreateNewState);
- void restore();
-
- SurfaceOpenVG* surface() { return m_surface; }
- void blitToSurface();
-
-private:
- void destroyPainterStates();
- void applyState();
-
- void intersectScissorRect(const FloatRect&);
-
-private:
- Vector<PlatformPainterState*> m_stateStack;
- PlatformPainterState* m_state;
- SurfaceOpenVG* m_surface;
-};
-
-}
-
-#endif
diff --git a/Source/WebCore/platform/graphics/openvg/PathOpenVG.cpp b/Source/WebCore/platform/graphics/openvg/PathOpenVG.cpp
deleted file mode 100644
index a1fe36a5d..000000000
--- a/Source/WebCore/platform/graphics/openvg/PathOpenVG.cpp
+++ /dev/null
@@ -1,497 +0,0 @@
-/*
- * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "Path.h"
-
-#include "AffineTransform.h"
-#include "FloatRect.h"
-#include "GraphicsContext.h"
-#include "NotImplemented.h"
-#include "PainterOpenVG.h"
-#include "PlatformPathOpenVG.h"
-#include "StrokeStyleApplier.h"
-#include "VGUtils.h"
-
-#include <openvg.h>
-#include <wtf/MathExtras.h>
-#include <wtf/text/WTFString.h>
-
-#define WEBKIT_VG_PATH_CAPABILITIES VG_PATH_CAPABILITY_ALL
-
-#define FUZZY_COMPARE(number, reference, delta) \
- (number >= (reference - delta) && number <= (reference + delta))
-
-namespace WebCore {
-
-PlatformPathOpenVG::PlatformPathOpenVG()
- : SharedResourceOpenVG()
-{
- createPath();
-}
-
-PlatformPathOpenVG::PlatformPathOpenVG(const PlatformPathOpenVG& other)
- : SharedResourceOpenVG()
- , m_currentPoint(other.m_currentPoint)
- , m_subpathStartPoint(other.m_subpathStartPoint)
-{
- createPath();
- // makeCompatibleContextCurrent() is called by createPath(), so not necessary here.
- vgAppendPath(m_vgPath, other.m_vgPath);
- ASSERT_VG_NO_ERROR();
-}
-
-PlatformPathOpenVG& PlatformPathOpenVG::operator=(const PlatformPathOpenVG& other)
-{
- if (&other != this) {
- clear();
- // makeCompatibleContextCurrent() is called by clear(), so not necessary here.
- vgAppendPath(m_vgPath, other.m_vgPath);
- ASSERT_VG_NO_ERROR();
- }
- return *this;
-}
-
-PlatformPathOpenVG::~PlatformPathOpenVG()
-{
- makeCompatibleContextCurrent();
-
- vgDestroyPath(m_vgPath);
- ASSERT_VG_NO_ERROR();
-}
-
-void PlatformPathOpenVG::clear()
-{
- makeCompatibleContextCurrent();
-
- vgClearPath(m_vgPath, WEBKIT_VG_PATH_CAPABILITIES);
- ASSERT_VG_NO_ERROR();
-
- m_subpathStartPoint.setX(0);
- m_subpathStartPoint.setY(0);
- m_currentPoint = m_subpathStartPoint;
-}
-
-void PlatformPathOpenVG::createPath()
-{
- makeSharedContextCurrent();
-
- m_vgPath = vgCreatePath(
- VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
- 1.0 /* scale */, 0.0 /* bias */,
- 0 /* expected number of segments */,
- 0 /* expected number of total coordinates */,
- WEBKIT_VG_PATH_CAPABILITIES);
- ASSERT_VG_NO_ERROR();
-}
-
-
-Path::Path()
-{
- m_path = new PlatformPathOpenVG();
-}
-
-Path::~Path()
-{
- delete m_path;
-}
-
-Path::Path(const Path& other)
-{
- m_path = new PlatformPathOpenVG(*(other.m_path));
-}
-
-Path& Path::operator=(const Path& other)
-{
- *m_path = *(other.m_path);
- return *this;
-}
-
-FloatPoint Path::currentPoint() const
-{
- // FIXME: is this the way to return the current point of the subpath?
- return m_currentPoint;
-}
-
-
-bool Path::contains(const FloatPoint& point, WindRule rule) const
-{
- notImplemented();
-
- // OpenVG has no path-contains function, so for now we approximate by
- // using the bounding rect of the path.
- return boundingRect().contains(point);
-}
-
-bool Path::strokeContains(StrokeStyleApplier* applier, const FloatPoint& point) const
-{
- notImplemented();
-
- // OpenVG has no path-contains function, so for now we approximate by
- // using the stroke bounding rect of the path.
- return (const_cast<Path*>(this))->strokeBoundingRect().contains(point);
-}
-
-void Path::translate(const FloatSize& size)
-{
- AffineTransform transformation;
- transformation.translate(size.width(), size.height());
- transform(transformation);
-}
-
-FloatRect Path::boundingRect() const
-{
- VGfloat minX;
- VGfloat minY;
- VGfloat width;
- VGfloat height;
-
- m_path->makeCompatibleContextCurrent();
- vgPathBounds(m_path->vgPath(), &minX, &minY, &width, &height);
- ASSERT_VG_NO_ERROR();
-
- return FloatRect(FloatPoint(minX, minY), FloatSize(width, height));
-}
-
-FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier) const
-{
- notImplemented();
-
- // vgPathBounds() ignores stroke parameters, and we don't currently have
- // an approximation that takes stroke parameters into account.
- return boundingRect();
-}
-
-void Path::moveTo(const FloatPoint& point)
-{
- static const VGubyte pathSegments[] = { VG_MOVE_TO_ABS };
- const VGfloat pathData[] = { point.x(), point.y() };
-
- m_path->makeCompatibleContextCurrent();
- vgAppendPathData(m_path->vgPath(), 1, pathSegments, pathData);
- ASSERT_VG_NO_ERROR();
-
- m_path->m_currentPoint = m_path->m_subpathStartPoint = point;
-}
-
-void Path::addLineTo(const FloatPoint& point)
-{
- static const VGubyte pathSegments[] = { VG_LINE_TO_ABS };
- const VGfloat pathData[] = { point.x(), point.y() };
-
- m_path->makeCompatibleContextCurrent();
- vgAppendPathData(m_path->vgPath(), 1, pathSegments, pathData);
- ASSERT_VG_NO_ERROR();
-
- m_path->m_currentPoint = point;
-}
-
-void Path::addQuadCurveTo(const FloatPoint& controlPoint, const FloatPoint& endPoint)
-{
- static const VGubyte pathSegments[] = { VG_QUAD_TO_ABS };
- const VGfloat pathData[] = { controlPoint.x(), controlPoint.y(), endPoint.x(), endPoint.y() };
-
- m_path->makeCompatibleContextCurrent();
- vgAppendPathData(m_path->vgPath(), 1, pathSegments, pathData);
- ASSERT_VG_NO_ERROR();
-
- m_path->m_currentPoint = endPoint;
-}
-
-void Path::addBezierCurveTo(const FloatPoint& controlPoint1, const FloatPoint& controlPoint2, const FloatPoint& endPoint)
-{
- static const VGubyte pathSegments[] = { VG_CUBIC_TO_ABS };
- const VGfloat pathData[] = { controlPoint1.x(), controlPoint1.y(), controlPoint2.x(), controlPoint2.y(), endPoint.x(), endPoint.y() };
-
- m_path->makeCompatibleContextCurrent();
- vgAppendPathData(m_path->vgPath(), 1, pathSegments, pathData);
- ASSERT_VG_NO_ERROR();
-
- m_path->m_currentPoint = endPoint;
-}
-
-void Path::addArcTo(const FloatPoint& point1, const FloatPoint& point2, float radius)
-{
- // See http://philip.html5.org/tests/canvas/suite/tests/spec.html#arcto.
-
- const FloatPoint& point0 = m_path->m_currentPoint;
- if (!radius || point0 == point1 || point1 == point2) {
- addLineTo(point1);
- return;
- }
-
- FloatSize v01 = point0 - point1;
- FloatSize v21 = point2 - point1;
-
- // sin(A - B) = sin(A) * cos(B) - sin(B) * cos(A)
- double cross = v01.width() * v21.height() - v01.height() * v21.width();
-
- if (fabs(cross) < 1E-10) {
- // on one line
- addLineTo(point1);
- return;
- }
-
- double d01 = hypot(v01.width(), v01.height());
- double d21 = hypot(v21.width(), v21.height());
- double angle = (piDouble - fabs(asin(cross / (d01 * d21)))) * 0.5;
- double span = radius * tan(angle);
- double rate = span / d01;
- FloatPoint startPoint = FloatPoint(point1.x() + v01.width() * rate,
- point1.y() + v01.height() * rate);
- rate = span / d21;
- FloatPoint endPoint = FloatPoint(point1.x() + v21.width() * rate,
- point1.y() + v21.height() * rate);
-
- // Fa: large arc flag, makes the difference between SCWARC_TO and LCWARC_TO
- // respectively SCCWARC_TO and LCCWARC_TO arcs. We always use small
- // arcs for arcTo(), as the arc is defined as the "shortest arc" of the
- // circle specified in HTML 5.
-
- // Fs: sweep flag, specifying whether the arc is drawn in increasing (true)
- // or decreasing (0) direction.
- const bool anticlockwise = cross < 0;
-
- // Translate the large arc and sweep flags into an OpenVG segment command.
- const VGubyte segmentCommand = anticlockwise ? VG_SCCWARC_TO_ABS : VG_SCWARC_TO_ABS;
-
- const VGubyte pathSegments[] = {
- VG_LINE_TO_ABS,
- segmentCommand
- };
- const VGfloat pathData[] = {
- startPoint.x(), startPoint.y(),
- radius, radius, 0, endPoint.x(), endPoint.y()
- };
-
- m_path->makeCompatibleContextCurrent();
- vgAppendPathData(m_path->vgPath(), 2, pathSegments, pathData);
- ASSERT_VG_NO_ERROR();
-
- m_path->m_currentPoint = endPoint;
-}
-
-void Path::closeSubpath()
-{
- static const VGubyte pathSegments[] = { VG_CLOSE_PATH };
- // pathData must not be 0, but certain compilers also don't create
- // zero-size arrays. So let's use a random aligned value (sizeof(VGfloat)),
- // it won't be accessed anyways as VG_CLOSE_PATH doesn't take coordinates.
- static const VGfloat* pathData = reinterpret_cast<VGfloat*>(sizeof(VGfloat));
-
- m_path->makeCompatibleContextCurrent();
- vgAppendPathData(m_path->vgPath(), 1, pathSegments, pathData);
- ASSERT_VG_NO_ERROR();
-
- m_path->m_currentPoint = m_path->m_subpathStartPoint;
-}
-
-void Path::addArc(const FloatPoint& center, float radius, float startAngle, float endAngle, bool anticlockwise)
-{
- // The OpenVG spec says nothing about inf as radius or start/end angle.
- // WebKit seems to pass those (e.g. https://bugs.webkit.org/show_bug.cgi?id=16449),
- // so abort instead of risking undefined behavior.
- if (!isfinite(radius) || !isfinite(startAngle) || !isfinite(endAngle))
- return;
-
- // For some reason, the HTML 5 spec defines the angle as going clockwise
- // from the positive X axis instead of going standard anticlockwise.
- // So let's make it a proper angle in order to keep sanity.
- startAngle = fmod((2.0 * piDouble) - startAngle, 2.0 * piDouble);
- endAngle = fmod((2.0 * piDouble) - endAngle, 2.0 * piDouble);
-
- // Make it so that endAngle > startAngle. fmod() above takes care of
- // keeping the difference below 360 degrees.
- if (endAngle <= startAngle)
- endAngle += 2.0 * piDouble;
-
- const VGfloat angleDelta = anticlockwise
- ? (endAngle - startAngle)
- : (startAngle - endAngle + (2.0 * piDouble));
-
- // OpenVG uses endpoint parameterization while this method receives its
- // values in center parameterization. It lacks an ellipse rotation
- // parameter so we use 0 for that, and also the radius is only a single
- // value which makes for rh == rv. In order to convert from endpoint to
- // center parameterization, we use the formulas from the OpenVG/SVG specs:
-
- // (x,y) = (cos rot, -sin rot; sin rot, -cos rot) * (rh * cos angle, rv * sin angle) + (center.x, center.y)
- // rot is 0, which simplifies this a bit:
- // (x,y) = (1, 0; 0, -1) * (rh * cos angle, rv * sin angle) + (center.x, center.y)
- // = (1 * rh * cos angle + 0 * rv * sin angle, 0 * rh * cos angle + -1 * rv * sin angle) + (center.x, center.y)
- // = (rh * cos angle, -rv * sin angle) + (center.x, center.y)
- // (Set angle = {startAngle, endAngle} to retrieve the respective endpoints.)
-
- const VGfloat startX = radius * cos(startAngle) + center.x();
- const VGfloat startY = -radius * sin(startAngle) + center.y();
- const VGfloat endX = radius * cos(endAngle) + center.x();
- const VGfloat endY = -radius * sin(endAngle) + center.y();
-
- // Fa: large arc flag, makes the difference between SCWARC_TO and LCWARC_TO
- // respectively SCCWARC_TO and LCCWARC_TO arcs.
- const bool largeArc = (angleDelta > piDouble);
-
- // Fs: sweep flag, specifying whether the arc is drawn in increasing (true)
- // or decreasing (0) direction. No need to calculate this value, as it
- // we already get it passed as a parameter (Fs == !anticlockwise).
-
- // Translate the large arc and sweep flags into an OpenVG segment command.
- // As OpenVG thinks of everything upside down, we need to reverse the
- // anticlockwise parameter in order to get the specified rotation.
- const VGubyte segmentCommand = !anticlockwise
- ? (largeArc ? VG_LCCWARC_TO_ABS : VG_SCCWARC_TO_ABS)
- : (largeArc ? VG_LCWARC_TO_ABS : VG_SCWARC_TO_ABS);
-
- // So now, we've got all the parameters in endpoint parameterization format
- // as OpenVG requires it. Which means we can just pass it like this.
- const VGubyte pathSegments[] = {
- hasCurrentPoint() ? VG_LINE_TO_ABS : VG_MOVE_TO_ABS,
- segmentCommand
- };
- const VGfloat pathData[] = {
- startX, startY,
- radius, radius, 0, endX, endY
- };
-
- m_path->makeCompatibleContextCurrent();
- vgAppendPathData(m_path->vgPath(), 2, pathSegments, pathData);
- ASSERT_VG_NO_ERROR();
-
- m_path->m_currentPoint.setX(endX);
- m_path->m_currentPoint.setY(endY);
-}
-
-void Path::addRect(const FloatRect& rect)
-{
- static const VGubyte pathSegments[] = {
- VG_MOVE_TO_ABS,
- VG_HLINE_TO_REL,
- VG_VLINE_TO_REL,
- VG_HLINE_TO_REL,
- VG_CLOSE_PATH
- };
- const VGfloat pathData[] = {
- rect.x(), rect.y(),
- rect.width(),
- rect.height(),
- -rect.width()
- };
-
- m_path->makeCompatibleContextCurrent();
- vgAppendPathData(m_path->vgPath(), 5, pathSegments, pathData);
- ASSERT_VG_NO_ERROR();
-
- m_path->m_currentPoint = m_path->m_subpathStartPoint = rect.location();
-}
-
-void Path::addEllipse(const FloatRect& rect)
-{
- static const VGubyte pathSegments[] = {
- VG_MOVE_TO_ABS,
- VG_SCCWARC_TO_REL,
- VG_SCCWARC_TO_REL,
- VG_CLOSE_PATH
- };
- const VGfloat pathData[] = {
- rect.x() + rect.width() / 2.0, rect.y(),
- rect.width() / 2.0, rect.height() / 2.0, 0, 0, rect.height(),
- rect.width() / 2.0, rect.height() / 2.0, 0, 0, -rect.height()
- };
-
- m_path->makeCompatibleContextCurrent();
- vgAppendPathData(m_path->vgPath(), 4, pathSegments, pathData);
- ASSERT_VG_NO_ERROR();
-}
-
-void Path::clear()
-{
- m_path->clear();
-}
-
-bool Path::isEmpty() const
-{
- m_path->makeCompatibleContextCurrent();
- return !vgGetParameteri(m_path->vgPath(), VG_PATH_NUM_SEGMENTS);
-}
-
-bool Path::hasCurrentPoint() const
-{
- m_path->makeCompatibleContextCurrent();
- return vgGetParameteri(m_path->vgPath(), VG_PATH_NUM_SEGMENTS) > 0;
-}
-
-void Path::apply(void* info, PathApplierFunction function) const
-{
- // OpenVG provides no means to retrieve path segment information.
- // This is *very* unfortunate, we might need to store the segments in
- // memory if we want to implement this function properly.
- // See http://www.khronos.org/message_boards/viewtopic.php?f=6&t=1887
- notImplemented();
-}
-
-void Path::transform(const AffineTransform& transformation)
-{
- PlatformPathOpenVG* dst = new PlatformPathOpenVG();
- // dst->makeCompatibleContextCurrent() is called by the platform path
- // constructor, therefore not necessary to call it again here.
- PainterOpenVG::transformPath(dst->vgPath(), m_path->vgPath(), transformation);
- delete m_path;
- m_path = dst;
-
- m_path->m_currentPoint = transformation.mapPoint(m_path->m_currentPoint);
- m_path->m_subpathStartPoint = transformation.mapPoint(m_path->m_subpathStartPoint);
-}
-
-
-// Path::length(), Path::pointAtLength() and Path::normalAngleAtLength() are
-// reimplemented here instead of in Path.cpp, because OpenVG has its own
-// functions and Path::apply() doesn't really work as long as we rely on VGPath
-// as primary path storage.
-
-float Path::length() const
-{
- m_path->makeCompatibleContextCurrent();
- VGfloat length = vgPathLength(m_path->vgPath(), 0, vgGetParameteri(m_path->vgPath(), VG_PATH_NUM_SEGMENTS));
- ASSERT_VG_NO_ERROR();
- return length;
-}
-
-FloatPoint Path::pointAtLength(float length, bool& ok) const
-{
- VGfloat x = 0, y = 0;
- m_path->makeCompatibleContextCurrent();
-
- vgPointAlongPath(m_path->vgPath(), 0, vgGetParameteri(m_path->vgPath(), VG_PATH_NUM_SEGMENTS),
- length, &x, &y, 0, 0);
- ok = (vgGetError() == VG_NO_ERROR);
- return FloatPoint(x, y);
-}
-
-float Path::normalAngleAtLength(float length, bool& ok) const
-{
- VGfloat tangentX, tangentY;
- m_path->makeCompatibleContextCurrent();
-
- vgPointAlongPath(m_path->vgPath(), 0, vgGetParameteri(m_path->vgPath(), VG_PATH_NUM_SEGMENTS),
- length, 0, 0, &tangentX, &tangentY);
- ok = (vgGetError() == VG_NO_ERROR);
- return atan2f(tangentY, tangentX) * 180.0 / piFloat; // convert to degrees
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/openvg/PlatformPathOpenVG.h b/Source/WebCore/platform/graphics/openvg/PlatformPathOpenVG.h
deleted file mode 100644
index 286da53e4..000000000
--- a/Source/WebCore/platform/graphics/openvg/PlatformPathOpenVG.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef PlatformPathOpenVG_h
-#define PlatformPathOpenVG_h
-
-#include "FloatPoint.h"
-#include "SharedResourceOpenVG.h"
-
-#include <openvg.h>
-
-namespace WebCore {
-
-class PlatformPathOpenVG : public SharedResourceOpenVG {
-public:
- PlatformPathOpenVG();
- PlatformPathOpenVG(const PlatformPathOpenVG&);
- ~PlatformPathOpenVG();
-
- PlatformPathOpenVG& operator=(const PlatformPathOpenVG&);
-
- VGPath vgPath() { return m_vgPath; }
- void clear();
-
-public:
- FloatPoint m_currentPoint;
- FloatPoint m_subpathStartPoint;
-
-private:
- void createPath();
-
- VGPath m_vgPath;
-};
-
-}
-
-#endif
diff --git a/Source/WebCore/platform/graphics/openvg/SharedResourceOpenVG.cpp b/Source/WebCore/platform/graphics/openvg/SharedResourceOpenVG.cpp
deleted file mode 100644
index a843db538..000000000
--- a/Source/WebCore/platform/graphics/openvg/SharedResourceOpenVG.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) Research In Motion Limited 2009. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "SharedResourceOpenVG.h"
-
-#include "SurfaceOpenVG.h"
-
-#if PLATFORM(EGL)
-#include "EGLDisplayOpenVG.h"
-#endif
-
-namespace WebCore {
-
-void SharedResourceOpenVG::makeSharedContextCurrent()
-{
-#if PLATFORM(EGL)
- EGLDisplayOpenVG::current()->sharedPlatformSurface()->makeCurrent();
-#endif
-}
-
-void SharedResourceOpenVG::makeCompatibleContextCurrent()
-{
-#if PLATFORM(EGL)
- EGLDisplayOpenVG::current()->sharedPlatformSurface()->makeCompatibleCurrent();
-#endif
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/openvg/SharedResourceOpenVG.h b/Source/WebCore/platform/graphics/openvg/SharedResourceOpenVG.h
deleted file mode 100644
index 436ae90c3..000000000
--- a/Source/WebCore/platform/graphics/openvg/SharedResourceOpenVG.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) Research In Motion Limited 2009. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef SharedResourceOpenVG_h
-#define SharedResourceOpenVG_h
-
-namespace WebCore {
-
-class SharedResourceOpenVG {
-public:
- void makeSharedContextCurrent();
- void makeCompatibleContextCurrent();
-};
-
-}
-
-#endif
diff --git a/Source/WebCore/platform/graphics/openvg/SurfaceOpenVG.cpp b/Source/WebCore/platform/graphics/openvg/SurfaceOpenVG.cpp
deleted file mode 100644
index 6700c6ffa..000000000
--- a/Source/WebCore/platform/graphics/openvg/SurfaceOpenVG.cpp
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "SurfaceOpenVG.h"
-
-#include "IntSize.h"
-#include "PainterOpenVG.h"
-
-#if PLATFORM(EGL)
-#include "EGLDisplayOpenVG.h"
-#include "EGLUtils.h"
-#endif
-
-#include <wtf/Assertions.h>
-
-namespace WebCore {
-
-PainterOpenVG* SurfaceOpenVG::s_currentPainter = 0;
-
-SurfaceOpenVG* SurfaceOpenVG::currentSurface()
-{
-#if PLATFORM(EGL)
- return EGLDisplayOpenVG::currentSurface();
-#else
- ASSERT_NOT_REACHED();
- return 0;
-#endif
-}
-
-#if PLATFORM(EGL)
-SurfaceOpenVG::SurfaceOpenVG(const IntSize& size, const EGLDisplay& display, EGLConfig* confPtr, EGLint* errorCode)
- : m_activePainter(0)
- , m_eglDisplay(display)
- , m_eglSurface(EGL_NO_SURFACE)
- , m_eglContext(EGL_NO_CONTEXT)
-{
- ASSERT(m_eglDisplay != EGL_NO_DISPLAY);
-
- EGLDisplayOpenVG* displayManager = EGLDisplayOpenVG::forDisplay(m_eglDisplay);
- EGLConfig config = confPtr ? (*confPtr) : displayManager->defaultPbufferConfig();
- m_eglSurface = displayManager->createPbufferSurface(size, config, errorCode);
-
- if (m_eglSurface == EGL_NO_SURFACE)
- return;
-
- m_eglContext = displayManager->contextForSurface(m_eglSurface);
- EGLDisplayOpenVG::registerPlatformSurface(this);
-}
-
-SurfaceOpenVG::SurfaceOpenVG(EGLClientBuffer buffer, EGLenum bufferType, const EGLDisplay& display, EGLConfig* confPtr, EGLint* errorCode)
- : m_activePainter(0)
- , m_eglDisplay(display)
- , m_eglSurface(EGL_NO_SURFACE)
- , m_eglContext(EGL_NO_CONTEXT)
-{
- ASSERT(m_eglDisplay != EGL_NO_DISPLAY);
-
- EGLDisplayOpenVG* displayManager = EGLDisplayOpenVG::forDisplay(m_eglDisplay);
- EGLConfig config = confPtr ? (*confPtr) : displayManager->defaultPbufferConfig();
- m_eglSurface = displayManager->createPbufferFromClientBuffer(buffer, bufferType, config, errorCode);
-
- if (m_eglSurface == EGL_NO_SURFACE)
- return;
-
- m_eglContext = displayManager->contextForSurface(m_eglSurface);
- EGLDisplayOpenVG::registerPlatformSurface(this);
-}
-
-SurfaceOpenVG::SurfaceOpenVG(EGLNativeWindowType window, const EGLDisplay& display, EGLConfig* confPtr)
- : m_activePainter(0)
- , m_eglDisplay(display)
- , m_eglSurface(EGL_NO_SURFACE)
- , m_eglContext(EGL_NO_CONTEXT)
-{
- ASSERT(m_eglDisplay != EGL_NO_DISPLAY);
-
- EGLDisplayOpenVG* displayManager = EGLDisplayOpenVG::forDisplay(m_eglDisplay);
- EGLConfig config = confPtr ? (*confPtr) : displayManager->defaultWindowConfig();
- m_eglSurface = displayManager->surfaceForWindow(window, config);
- ASSERT(m_eglSurface != EGL_NO_SURFACE);
-
- m_eglContext = displayManager->contextForSurface(m_eglSurface);
- EGLDisplayOpenVG::registerPlatformSurface(this);
-}
-
-// Constructor only accessible to EGLDisplayOpenVG for shared context
-// initialization. The parameter types might define to void* like in the
-// window surface constructor, so it can't be overloaded with all the required
-// arguments and EGLDisplayOpenVG basically implements the constructor
-// by itself.
-SurfaceOpenVG::SurfaceOpenVG()
- : m_activePainter(0)
- , m_eglDisplay(EGL_NO_DISPLAY)
- , m_eglSurface(EGL_NO_SURFACE)
- , m_eglContext(EGL_NO_CONTEXT)
-{
-}
-#endif
-
-SurfaceOpenVG::~SurfaceOpenVG()
-{
- if (!isValid())
- return;
-
- if (m_activePainter && this == m_activePainter->baseSurface())
- m_activePainter->end();
-
-#if PLATFORM(EGL)
- EGLDisplayOpenVG::forDisplay(m_eglDisplay)->destroySurface(m_eglSurface);
- EGLDisplayOpenVG::unregisterPlatformSurface(this);
-#else
- ASSERT_NOT_REACHED();
-#endif
-}
-
-bool SurfaceOpenVG::isValid() const
-{
-#if PLATFORM(EGL)
- return (m_eglSurface != EGL_NO_SURFACE);
-#else
- ASSERT_NOT_REACHED();
- return false;
-#endif
-}
-
-int SurfaceOpenVG::width() const
-{
-#if PLATFORM(EGL)
- ASSERT(m_eglSurface != EGL_NO_SURFACE);
-
- EGLint width;
- eglQuerySurface(m_eglDisplay, m_eglSurface, EGL_WIDTH, &width);
- ASSERT_EGL_NO_ERROR();
- return width;
-#else
- ASSERT_NOT_REACHED();
- return 0;
-#endif
-}
-
-int SurfaceOpenVG::height() const
-{
-#if PLATFORM(EGL)
- ASSERT(m_eglSurface != EGL_NO_SURFACE);
-
- EGLint height;
- eglQuerySurface(m_eglDisplay, m_eglSurface, EGL_HEIGHT, &height);
- ASSERT_EGL_NO_ERROR();
- return height;
-#else
- ASSERT_NOT_REACHED();
- return 0;
-#endif
-}
-
-SurfaceOpenVG* SurfaceOpenVG::sharedSurface() const
-{
-#if PLATFORM(EGL)
- ASSERT(m_eglSurface != EGL_NO_SURFACE);
- return EGLDisplayOpenVG::forDisplay(m_eglDisplay)->sharedPlatformSurface();
-#else
- ASSERT_NOT_REACHED();
- return 0;
-#endif
-}
-
-void SurfaceOpenVG::makeCurrent(MakeCurrentMode mode)
-{
-#if PLATFORM(EGL)
- ASSERT(m_eglSurface != EGL_NO_SURFACE);
-
- eglBindAPI(EGL_OPENVG_API);
- ASSERT_EGL_NO_ERROR();
- EGLSurface currentSurface = eglGetCurrentSurface(EGL_DRAW);
- ASSERT_EGL_NO_ERROR();
-
- if (currentSurface != m_eglSurface) {
- // Save other context before switching over.
- if (s_currentPainter && mode != DontSaveOrApplyPainterState
- && s_currentPainter->surface()->m_eglSurface == currentSurface)
- s_currentPainter->save(PainterOpenVG::KeepCurrentState);
-
- eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext);
- ASSERT_EGL_NO_ERROR();
- s_currentPainter = 0;
- }
-#endif
-
- if (m_activePainter && mode == ApplyPainterStateOnSurfaceSwitch
- && s_currentPainter != m_activePainter) {
- m_activePainter->applyState();
- s_currentPainter = m_activePainter;
- }
-}
-
-void SurfaceOpenVG::makeCompatibleCurrent()
-{
-#if PLATFORM(EGL)
- ASSERT(m_eglSurface != EGL_NO_SURFACE);
-
- eglBindAPI(EGL_OPENVG_API);
- ASSERT_EGL_NO_ERROR();
- EGLSurface currentSurface = eglGetCurrentSurface(EGL_DRAW);
- ASSERT_EGL_NO_ERROR();
-
- if (currentSurface == m_eglSurface) {
- if (m_activePainter && s_currentPainter != m_activePainter) {
- m_activePainter->applyState();
- s_currentPainter = m_activePainter;
- }
- } else if (!EGLDisplayOpenVG::forDisplay(m_eglDisplay)->surfacesCompatible(currentSurface, m_eglSurface)) {
- // Save other context before switching over.
- if (s_currentPainter && s_currentPainter->surface()->m_eglSurface == currentSurface)
- s_currentPainter->save(PainterOpenVG::KeepCurrentState);
-
- eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext);
- ASSERT_EGL_NO_ERROR();
- s_currentPainter = 0;
- }
- // else: surfaces compatible, no need to switch contexts
-#endif
-}
-
-void SurfaceOpenVG::flush()
-{
-#if PLATFORM(EGL)
- ASSERT(m_eglSurface != EGL_NO_SURFACE);
-
- eglSwapBuffers(m_eglDisplay, m_eglSurface);
- ASSERT_EGL_NO_ERROR();
-#endif
-}
-
-void SurfaceOpenVG::setActivePainter(PainterOpenVG* painter)
-{
- ASSERT(isValid());
-
- // If painter is non-zero, we want to make sure there was no previous painter set.
- ASSERT(!painter || !m_activePainter);
-
- // Make sure a disabled painter isn't marked as global current painter anymore.
- if (!painter && s_currentPainter == m_activePainter)
- s_currentPainter = 0;
-
- m_activePainter = painter;
-}
-
-PainterOpenVG* SurfaceOpenVG::activePainter()
-{
- ASSERT(isValid());
- return m_activePainter;
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/openvg/SurfaceOpenVG.h b/Source/WebCore/platform/graphics/openvg/SurfaceOpenVG.h
deleted file mode 100644
index 19d95d875..000000000
--- a/Source/WebCore/platform/graphics/openvg/SurfaceOpenVG.h
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef SurfaceOpenVG_h
-#define SurfaceOpenVG_h
-
-#if PLATFORM(EGL)
-#include <egl.h>
-#endif
-
-#include <wtf/Noncopyable.h>
-
-namespace WebCore {
-
-#if PLATFORM(EGL)
-class EGLDisplayOpenVG;
-#endif
-class PainterOpenVG;
-class IntSize;
-
-/**
- * SurfaceOpenVG provides the functionality of surfaces and contexts that are
- * underlying the OpenVG implementation. In the vast majority of cases, that
- * underlying technology is EGL, but OpenVG doesn't depend on EGL per se.
- * Wrapping surface/context functionality into a separate class avoids lots
- * of #ifdefs and should make it easy to add different surface/context
- * implementations than EGL.
- */
-class SurfaceOpenVG {
- WTF_MAKE_NONCOPYABLE(SurfaceOpenVG);
-public:
- enum MakeCurrentMode {
- ApplyPainterStateOnSurfaceSwitch,
- DontApplyPainterState,
- DontSaveOrApplyPainterState
- };
-
- static SurfaceOpenVG* currentSurface();
-
-#if PLATFORM(EGL)
- friend class EGLDisplayOpenVG;
-
- /**
- * Create a new EGL pbuffer surface with the specified size and config on
- * the given display. If config is not specified, the display's default
- * pbuffer config is used.
- *
- * This constructor will trigger an assertion if creation of the surface
- * fails, unless you pledge to manually process the error code by passing
- * a non-zero pointer as errorCode parameter. The error code returned by
- * eglGetError() will be written to that variable.
- */
- SurfaceOpenVG(const IntSize& size, const EGLDisplay& display, EGLConfig* config = 0, EGLint* errorCode = 0);
-
- /**
- * Create a new EGL pbuffer surface that will be bound to the given
- * client buffer (read: VGImage), with the specified config on the
- * given display. If config is not specified, the display's default
- * pbuffer config is used.
- *
- * After the surface is created, you will only be able to access the
- * client buffer image if the surface is not current. The recommended way
- * to ensure this is to call surface->sharedSurface()->makeCurrent() if you
- * simply want to access the image's pixel contents, or if you intend to
- * draw the image directly, making the draw target surface current.
- *
- * This constructor will trigger an assertion if creation of the surface
- * fails, unless you pledge to manually process the error code by passing
- * a non-zero pointer as errorCode parameter. The error code returned by
- * eglGetError() will be written to that variable.
- */
- SurfaceOpenVG(EGLClientBuffer buffer, EGLenum bufferType,
- const EGLDisplay& display, EGLConfig* config = 0, EGLint* errorCode = 0);
-
- /**
- * Create a new EGL window surface with the specified native window handle
- * and config on the given display. If config is not specified, the
- * display's default window config is used.
- */
- SurfaceOpenVG(EGLNativeWindowType window, const EGLDisplay& display, EGLConfig* config = 0);
-
- EGLDisplay eglDisplay() const { return m_eglDisplay; }
- EGLSurface eglSurface() const { return m_eglSurface; }
- EGLContext eglContext() const { return m_eglContext; }
-#endif
-
- ~SurfaceOpenVG();
-
- /**
- * If a surface is invalid (could not be created), all method calls will
- * crash horribly.
- */
- bool isValid() const;
-
- int width() const;
- int height() const;
-
- SurfaceOpenVG* sharedSurface() const;
-
- /**
- * Make the associated GL/EGL context the current one, so that subsequent
- * OpenVG commands apply to it.
- */
- void makeCurrent(MakeCurrentMode mode = ApplyPainterStateOnSurfaceSwitch);
-
- /**
- * Make a surface/context combination current that is "compatible"
- * (i.e. can access its shared resources) to the given one. If no
- * surface/context is current, the given one is made current.
- *
- * This method is meant to avoid context changes if they're not
- * necessary, particularly tailored for the case where something
- * compatible to the shared surface is requested while actual painting
- * happens on another surface.
- */
- void makeCompatibleCurrent();
-
- /**
- * Empty the OpenVG pipeline and make sure all the performed paint
- * operations show up on the surface as actual drawn pixels.
- */
- void flush();
-
- void setActivePainter(PainterOpenVG*);
- PainterOpenVG* activePainter();
-
-private:
- PainterOpenVG* m_activePainter;
- static PainterOpenVG* s_currentPainter; // global currently active painter
-
-#if PLATFORM(EGL)
- SurfaceOpenVG(); // for EGLDisplayOpenVG
-
- EGLDisplay m_eglDisplay;
- EGLSurface m_eglSurface;
- EGLContext m_eglContext;
-#endif
-};
-
-}
-
-#endif
diff --git a/Source/WebCore/platform/graphics/openvg/TiledImageOpenVG.cpp b/Source/WebCore/platform/graphics/openvg/TiledImageOpenVG.cpp
deleted file mode 100644
index 64d94c9e7..000000000
--- a/Source/WebCore/platform/graphics/openvg/TiledImageOpenVG.cpp
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "TiledImageOpenVG.h"
-
-#include "FloatRect.h"
-#include "IntRect.h"
-#include "VGUtils.h"
-
-namespace WebCore {
-
-TiledImageOpenVG::TiledImageOpenVG(const IntSize& size, const IntSize& tileSize)
- : SharedResourceOpenVG()
- , m_size(size)
- , m_maxTileSize(tileSize)
- , m_numColumns((m_size.width() - 1) / m_maxTileSize.width() + 1)
- , m_tiles(((m_size.height() - 1) / m_maxTileSize.height() + 1) * m_numColumns, VG_INVALID_HANDLE)
-{
-}
-
-TiledImageOpenVG::TiledImageOpenVG(const TiledImageOpenVG& other)
- : SharedResourceOpenVG()
- , m_size(other.m_size)
- , m_maxTileSize(other.m_maxTileSize)
- , m_numColumns(other.m_numColumns)
- , m_tiles(other.m_tiles)
-{
- detachTiles();
-}
-
-TiledImageOpenVG& TiledImageOpenVG::operator=(const TiledImageOpenVG& other)
-{
- if (&other != this) {
- destroyTiles();
-
- m_size = other.m_size;
- m_maxTileSize = other.m_maxTileSize;
- m_numColumns = other.m_numColumns;
- m_tiles = other.m_tiles;
-
- detachTiles();
- }
- return *this;
-}
-
-TiledImageOpenVG::~TiledImageOpenVG()
-{
- destroyTiles();
-}
-
-int TiledImageOpenVG::numTiles() const
-{
- return m_tiles.size();
-}
-
-int TiledImageOpenVG::numColumns() const
-{
- return m_numColumns;
-}
-
-int TiledImageOpenVG::numRows() const
-{
- return m_tiles.size() / m_numColumns;
-}
-
-void TiledImageOpenVG::setTile(int xIndex, int yIndex, VGImage image)
-{
- ASSERT(xIndex < m_numColumns);
- int i = (yIndex * m_numColumns) + xIndex;
- ASSERT(i < m_tiles.size());
- m_tiles.at(i) = image;
-}
-
-IntRect TiledImageOpenVG::tilesInRect(const FloatRect& rect) const
-{
- int leftIndex = static_cast<int>(rect.x()) / m_maxTileSize.width();
- int topIndex = static_cast<int>(rect.y()) / m_maxTileSize.height();
-
- if (leftIndex < 0)
- leftIndex = 0;
- if (topIndex < 0)
- topIndex = 0;
-
- // Round rect edges up to get the outer pixel boundaries.
- int rightIndex = (static_cast<int>(ceil(rect.right())) - 1) / m_maxTileSize.width();
- int bottomIndex = (static_cast<int>(ceil(rect.bottom())) - 1) / m_maxTileSize.height();
- int columns = (rightIndex - leftIndex) + 1;
- int rows = (bottomIndex - topIndex) + 1;
-
- return IntRect(leftIndex, topIndex,
- (columns <= m_numColumns) ? columns : m_numColumns,
- (rows <= (m_tiles.size() / m_numColumns)) ? rows : (m_tiles.size() / m_numColumns));
-}
-
-VGImage TiledImageOpenVG::tile(int xIndex, int yIndex) const
-{
- ASSERT(xIndex < m_numColumns);
- int i = (yIndex * m_numColumns) + xIndex;
- ASSERT(i < m_tiles.size());
- return m_tiles.at(i);
-}
-
-IntRect TiledImageOpenVG::tileRect(int xIndex, int yIndex) const
-{
- ASSERT(xIndex < m_numColumns);
- ASSERT((yIndex * m_numColumns) + xIndex < m_tiles.size());
-
- int x = xIndex * m_maxTileSize.width();
- int y = yIndex * m_maxTileSize.height();
-
- return IntRect(x, y,
- ((m_maxTileSize.width() < m_size.width() - x) ? m_maxTileSize.width() : (m_size.width() - x)),
- ((m_maxTileSize.height() < m_size.height() - y) ? m_maxTileSize.height() : (m_size.height() - y)));
-}
-
-void TiledImageOpenVG::detachTiles()
-{
- makeSharedContextCurrent(); // because we create new images
-
- int numTiles = m_tiles.size();
- VGImage newTile, originalTile;
-
- for (int i = 0; i < numTiles; ++i) {
- originalTile = m_tiles.at(i);
-
- if (originalTile == VG_INVALID_HANDLE)
- continue;
-
- VGImageFormat format = (VGImageFormat) vgGetParameteri(originalTile, VG_IMAGE_FORMAT);
- VGint width = vgGetParameteri(originalTile, VG_IMAGE_WIDTH);
- VGint height = vgGetParameteri(originalTile, VG_IMAGE_HEIGHT);
- ASSERT_VG_NO_ERROR();
-
- newTile = vgCreateImage(format, width, height, VG_IMAGE_QUALITY_FASTER);
- ASSERT_VG_NO_ERROR();
-
- vgCopyImage(newTile, 0, 0, originalTile, 0, 0, width, height, VG_FALSE /* dither */);
- ASSERT_VG_NO_ERROR();
-
- m_tiles.at(i) = newTile;
- }
-}
-
-void TiledImageOpenVG::destroyTiles()
-{
- makeCompatibleContextCurrent();
-
- Vector<VGImage>::const_iterator it = m_tiles.begin();
- Vector<VGImage>::const_iterator end = m_tiles.end();
-
- for (; it != end; ++it) {
- if (*it != VG_INVALID_HANDLE)
- vgDestroyImage(*it);
- }
- ASSERT_VG_NO_ERROR();
-
- m_tiles.fill(VG_INVALID_HANDLE);
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/openvg/TiledImageOpenVG.h b/Source/WebCore/platform/graphics/openvg/TiledImageOpenVG.h
deleted file mode 100644
index c8f55d283..000000000
--- a/Source/WebCore/platform/graphics/openvg/TiledImageOpenVG.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef TiledImageOpenVG_h
-#define TiledImageOpenVG_h
-
-#include "IntRect.h"
-#include "IntSize.h"
-#include "SharedResourceOpenVG.h"
-
-#include <openvg.h>
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-class FloatRect;
-
-class TiledImageOpenVG : public SharedResourceOpenVG {
-public:
- TiledImageOpenVG(const IntSize& size, const IntSize& tileSize);
- TiledImageOpenVG(const TiledImageOpenVG&);
- ~TiledImageOpenVG();
-
- TiledImageOpenVG& operator=(const TiledImageOpenVG&);
-
- const IntSize& size() const { return m_size; }
- const IntSize& maxTileSize() const { return m_maxTileSize; }
-
- int numTiles() const;
- int numColumns() const;
- int numRows() const;
-
- IntRect tilesInRect(const FloatRect&) const;
-
- void setTile(int xIndex, int yIndex, VGImage);
- VGImage tile(int xIndex, int yIndex) const;
- IntRect tileRect(int xIndex, int yIndex) const;
-
-private:
- void detachTiles();
- void destroyTiles();
-
- IntSize m_size;
- IntSize m_maxTileSize;
-
- int m_numColumns;
-
- Vector<VGImage> m_tiles;
-};
-
-}
-
-#endif
diff --git a/Source/WebCore/platform/graphics/openvg/VGUtils.cpp b/Source/WebCore/platform/graphics/openvg/VGUtils.cpp
deleted file mode 100644
index 2559aafea..000000000
--- a/Source/WebCore/platform/graphics/openvg/VGUtils.cpp
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * Copyright (C) Research In Motion Limited 2009. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "VGUtils.h"
-
-#include "AffineTransform.h"
-#include "FloatRect.h"
-#include "TransformationMatrix.h"
-
-namespace WebCore {
-
-VGMatrix::VGMatrix(const VGfloat data[9])
-{
- m_data[0] = data[0];
- m_data[1] = data[1];
- m_data[2] = data[2];
- m_data[3] = data[3];
- m_data[4] = data[4];
- m_data[5] = data[5];
- m_data[6] = data[6];
- m_data[7] = data[7];
- m_data[8] = data[8];
-}
-
-VGMatrix::VGMatrix(const AffineTransform& transformation)
-{
- m_data[0] = transformation.a();
- m_data[1] = transformation.b();
- m_data[2] = 0;
- m_data[3] = transformation.c();
- m_data[4] = transformation.d();
- m_data[5] = 0;
- m_data[6] = transformation.e();
- m_data[7] = transformation.f();
- m_data[8] = 1;
-}
-
-VGMatrix::VGMatrix(const TransformationMatrix& matrix)
-{
- m_data[0] = matrix.m11();
- m_data[1] = matrix.m12();
- m_data[2] = matrix.m14();
- m_data[3] = matrix.m21();
- m_data[4] = matrix.m22();
- m_data[5] = matrix.m24();
- m_data[6] = matrix.m41();
- m_data[7] = matrix.m42();
- m_data[8] = matrix.m44();
-}
-
-VGMatrix::operator AffineTransform() const
-{
- AffineTransform transformation(
- m_data[0], m_data[1],
- m_data[3], m_data[4],
- m_data[6], m_data[7]);
- return transformation;
-}
-
-VGMatrix::operator TransformationMatrix() const
-{
- TransformationMatrix matrix(
- m_data[0], m_data[1], 0, m_data[2],
- m_data[3], m_data[4], 0, m_data[5],
- 0, 0, 1, 0,
- m_data[6], m_data[7], 0, m_data[8]);
- return matrix;
-}
-
-AffineTransform::operator VGMatrix() const
-{
- return VGMatrix(*this);
-}
-
-TransformationMatrix::operator VGMatrix() const
-{
- return VGMatrix(*this);
-}
-
-VGRect::VGRect(const VGfloat data[4])
-{
- m_data[0] = data[0];
- m_data[1] = data[1];
- m_data[2] = data[2];
- m_data[3] = data[3];
-}
-
-VGRect::VGRect(const FloatRect& rect)
-{
- m_data[0] = rect.x();
- m_data[1] = rect.y();
- m_data[2] = rect.width();
- m_data[3] = rect.height();
-}
-
-VGRect::operator FloatRect() const
-{
- return FloatRect(m_data[0], m_data[1], m_data[2], m_data[3]);
-}
-
-FloatRect::operator VGRect() const
-{
- return VGRect(*this);
-}
-
-int VGUtils::bytesForImage(VGImageFormat format, VGint width, VGint height)
-{
- return width * height * imageFormatBitsPerPixel(format) / 8;
-}
-
-int VGUtils::bytesForImageScanline(VGImageFormat format, VGint width)
-{
- int bits = width * imageFormatBitsPerPixel(format);
- if (bits % 8 > 1) // If unaligned, round up to the next byte.
- bits += 8 - (bits % 8);
-
- return bits / 8;
-}
-
-int VGUtils::imageFormatBitsPerPixel(VGImageFormat format)
-{
- switch (format) {
- case VG_sRGBX_8888:
- case VG_sRGBA_8888:
- case VG_sRGBA_8888_PRE:
- case VG_lRGBX_8888:
- case VG_lRGBA_8888:
- case VG_lRGBA_8888_PRE:
- case VG_sXRGB_8888:
- case VG_sARGB_8888:
- case VG_sARGB_8888_PRE:
- case VG_lXRGB_8888:
- case VG_lARGB_8888:
- case VG_lARGB_8888_PRE:
- case VG_sBGRX_8888:
- case VG_sBGRA_8888:
- case VG_sBGRA_8888_PRE:
- case VG_lBGRX_8888:
- case VG_lBGRA_8888:
- case VG_lBGRA_8888_PRE:
- case VG_sXBGR_8888:
- case VG_sABGR_8888:
- case VG_sABGR_8888_PRE:
- case VG_lXBGR_8888:
- case VG_lABGR_8888:
- case VG_lABGR_8888_PRE:
- return 32;
-
- case VG_sRGB_565:
- case VG_sRGBA_5551:
- case VG_sRGBA_4444:
- case VG_sARGB_1555:
- case VG_sARGB_4444:
- case VG_sBGR_565:
- case VG_sBGRA_5551:
- case VG_sBGRA_4444:
- case VG_sABGR_1555:
- case VG_sABGR_4444:
- return 16;
-
- case VG_sL_8:
- case VG_lL_8:
- case VG_A_8:
- return 8;
-
- case VG_A_4:
- return 4;
-
- case VG_BW_1:
- case VG_A_1:
- return 1;
-
- default: // Will only happen when OpenVG extends the enum and we don't.
- ASSERT(false);
- return 0;
- }
-}
-
-#ifndef WTF_PLATFORM_BIG_ENDIAN
-VGImageFormat VGUtils::endianAwareImageFormat(VGImageFormat bigEndianFormat)
-{
- switch (bigEndianFormat) {
- case VG_sRGBX_8888: return VG_sXBGR_8888;
- case VG_sRGBA_8888: return VG_sABGR_8888;
- case VG_sRGBA_8888_PRE: return VG_sABGR_8888_PRE;
- case VG_lRGBX_8888: return VG_lXBGR_8888;
- case VG_lRGBA_8888: return VG_lABGR_8888;
- case VG_lRGBA_8888_PRE: return VG_lABGR_8888_PRE;
- case VG_sXRGB_8888: return VG_sBGRX_8888;
- case VG_sARGB_8888: return VG_sBGRA_8888;
- case VG_sARGB_8888_PRE: return VG_sBGRA_8888_PRE;
- case VG_lXRGB_8888: return VG_lBGRX_8888;
- case VG_lARGB_8888: return VG_lBGRA_8888;
- case VG_lARGB_8888_PRE: return VG_lBGRA_8888_PRE;
- case VG_sBGRX_8888: return VG_sXRGB_8888;
- case VG_sBGRA_8888: return VG_sARGB_8888;
- case VG_sBGRA_8888_PRE: return VG_sARGB_8888_PRE;
- case VG_lBGRX_8888: return VG_lXRGB_8888;
- case VG_lBGRA_8888: return VG_lARGB_8888;
- case VG_lBGRA_8888_PRE: return VG_lARGB_8888_PRE;
- case VG_sXBGR_8888: return VG_sRGBX_8888;
- case VG_sABGR_8888: return VG_sRGBA_8888;
- case VG_sABGR_8888_PRE: return VG_sRGBA_8888_PRE;
- case VG_lXBGR_8888: return VG_lRGBX_8888;
- case VG_lABGR_8888: return VG_lRGBA_8888;
- case VG_lABGR_8888_PRE: return VG_lRGBA_8888_PRE;
- default: ASSERT(false);
- return (VGImageFormat) 0;
- }
-}
-#else
-VGImageFormat VGUtils::endianAwareImageFormat(VGImageFormat bigEndianFormat)
-{
- return bigEndianFormat;
-}
-#endif
-
-}
diff --git a/Source/WebCore/platform/graphics/openvg/VGUtils.h b/Source/WebCore/platform/graphics/openvg/VGUtils.h
deleted file mode 100644
index 06d5feae1..000000000
--- a/Source/WebCore/platform/graphics/openvg/VGUtils.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef VGUtils_h
-#define VGUtils_h
-
-#include <openvg.h>
-#include <wtf/Assertions.h>
-
-static inline const char* toVGErrorConstant(VGErrorCode error)
-{
- switch (error) {
- case VG_BAD_HANDLE_ERROR:
- return "VG_BAD_HANDLE_ERROR";
- case VG_ILLEGAL_ARGUMENT_ERROR:
- return "VG_ILLEGAL_ARGUMENT_ERROR";
- case VG_OUT_OF_MEMORY_ERROR:
- return "VG_OUT_OF_MEMORY_ERROR";
- case VG_PATH_CAPABILITY_ERROR:
- return "VG_PATH_CAPABILITY_ERROR";
- case VG_UNSUPPORTED_IMAGE_FORMAT_ERROR:
- return "VG_UNSUPPORTED_IMAGE_FORMAT_ERROR";
- case VG_UNSUPPORTED_PATH_FORMAT_ERROR:
- return "VG_UNSUPPORTED_PATH_FORMAT_ERROR";
- case VG_IMAGE_IN_USE_ERROR:
- return "VG_IMAGE_IN_USE_ERROR";
- case VG_NO_CONTEXT_ERROR:
- return "VG_NO_CONTEXT_ERROR";
- default:
- return "UNKNOWN_ERROR";
- }
-}
-
-#if ASSERT_DISABLED
-#define ASSERT_VG_NO_ERROR() ((void)0)
-#else
-#define ASSERT_VG_NO_ERROR() do { \
- VGErrorCode vgErrorCode = vgGetError(); \
- ASSERT_WITH_MESSAGE(vgErrorCode == VG_NO_ERROR, "Found %s", toVGErrorConstant(vgErrorCode)); \
-} while (0)
-#endif
-
-
-namespace WebCore {
-
-class AffineTransform;
-class FloatRect;
-class TransformationMatrix;
-
-class VGMatrix {
-public:
- VGMatrix(const VGfloat data[9]);
- VGMatrix(const AffineTransform&);
- VGMatrix(const TransformationMatrix&);
- const VGfloat* toVGfloat() const { return m_data; }
- operator AffineTransform() const;
- operator TransformationMatrix() const;
-private:
- VGfloat m_data[9];
-};
-
-class VGRect {
-public:
- VGRect(const VGfloat data[4]);
- VGRect(const FloatRect&);
- const VGfloat* toVGfloat() const { return m_data; }
- operator FloatRect() const;
-private:
- VGfloat m_data[4];
-};
-
-class VGUtils {
-public:
- static int bytesForImage(VGImageFormat, VGint width, VGint height);
- static int bytesForImageScanline(VGImageFormat, VGint width);
- static int imageFormatBitsPerPixel(VGImageFormat);
-
- /**
- * Return a flipped VGImageFormat if the platform is little endian
- * (e.g. VG_ABGR_8888 for a given VG_RGBA_8888), or return the image format
- * as is if the platform is big endian.
- *
- * OpenVG itself is indifferent to endianness, it will always work on a
- * single machine word with the bytes going from left to right as specified
- * in the image format, no matter which one of the bytes is most or least
- * significant.
- *
- * However, if you interface with vgImageSubData()/vgGetImageSubData()
- * using a byte array then you want to make sure the byte order is
- * appropriate for the given platform (otherwise the byte indexes need
- * to be swapped depending on endianness). So, use this function when
- * interfacing with byte arrays, and don't use it otherwise.
- */
- static VGImageFormat endianAwareImageFormat(VGImageFormat bigEndianFormat);
-};
-
-}
-
-#endif
diff --git a/Source/WebCore/platform/graphics/pango/FontCachePango.cpp b/Source/WebCore/platform/graphics/pango/FontCachePango.cpp
deleted file mode 100644
index 06d63c50f..000000000
--- a/Source/WebCore/platform/graphics/pango/FontCachePango.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2008 Alp Toker <alp@atoker.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "FontCache.h"
-
-#include "Font.h"
-#include "OwnPtrCairo.h"
-#include "SimpleFontData.h"
-#include <wtf/Assertions.h>
-#include <wtf/text/CString.h>
-
-namespace WebCore {
-
-void FontCache::platformInit()
-{
- if (!FontPlatformData::init())
- ASSERT_NOT_REACHED();
-}
-
-PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
-{
- return 0;
-}
-
-PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font& font)
-{
- return 0;
-}
-
-PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)
-{
- // FIXME: Would be even better to somehow get the user's default font here.
- // For now we'll pick the default that the user would get without changing any prefs.
- static AtomicString timesStr("Times New Roman");
- return getCachedFontData(fontDescription, timesStr, false, shouldRetain);
-}
-
-void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigned>& traitsMasks)
-{
-}
-
-FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
-{
- return new FontPlatformData(fontDescription, family);
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/pango/FontCustomPlatformDataPango.cpp b/Source/WebCore/platform/graphics/pango/FontCustomPlatformDataPango.cpp
deleted file mode 100644
index deff9f775..000000000
--- a/Source/WebCore/platform/graphics/pango/FontCustomPlatformDataPango.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2008 Alp Toker <alp@atoker.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "FontCustomPlatformData.h"
-
-#include "SharedBuffer.h"
-#include "FontPlatformData.h"
-
-namespace WebCore {
-
-FontCustomPlatformData::~FontCustomPlatformData()
-{
-}
-
-FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation, TextOrientation, FontWidthVariant, FontRenderingMode)
-{
- return FontPlatformData(m_fontFace, size, bold, italic);
-}
-
-static void releaseData(void* data)
-{
- static_cast<SharedBuffer*>(data)->deref();
-}
-
-FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
-{
- // FIXME: we need support in pango to read fonts from memory to implement this.y
- return 0;
-}
-
-bool FontCustomPlatformData::supportsFormat(const String& /* format */)
-{
- return false;
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/pango/FontPango.cpp b/Source/WebCore/platform/graphics/pango/FontPango.cpp
deleted file mode 100644
index b91bfc980..000000000
--- a/Source/WebCore/platform/graphics/pango/FontPango.cpp
+++ /dev/null
@@ -1,466 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * Copyright (c) 2007 Hiroyuki Ikezoe
- * Copyright (c) 2007 Kouhei Sutou
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- * Copyright (C) 2008 Xan Lopez <xan@gnome.org>
- * Copyright (C) 2008 Nuanti Ltd.
- * Copyright (C) 2011 ProFUSION embedded systems
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Font.h"
-
-#include "CairoUtilities.h"
-#include <wtf/gobject/GOwnPtr.h>
-#include "GraphicsContext.h"
-#include "NotImplemented.h"
-#include "PlatformContextCairo.h"
-#include "ShadowBlur.h"
-#include "SimpleFontData.h"
-#include "TextRun.h"
-#include <cairo.h>
-#include <pango/pango.h>
-#include <pango/pangocairo.h>
-
-#if PLATFORM(GTK)
-#include <gdk/gdk.h>
-#else
-#include "PangoUtilities.h"
-#endif
-
-#if USE(FREETYPE)
-#include <pango/pangofc-fontmap.h>
-#endif
-
-namespace WebCore {
-
-#ifdef GTK_API_VERSION_2
-typedef GdkRegion* PangoRegionType;
-
-void destroyPangoRegion(PangoRegionType region)
-{
- gdk_region_destroy(region);
-}
-
-IntRect getPangoRegionExtents(PangoRegionType region)
-{
- GdkRectangle rectangle;
- gdk_region_get_clipbox(region, &rectangle);
- return IntRect(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
-}
-#else
-typedef cairo_region_t* PangoRegionType;
-
-void destroyPangoRegion(PangoRegionType region)
-{
- cairo_region_destroy(region);
-}
-
-IntRect getPangoRegionExtents(PangoRegionType region)
-{
- cairo_rectangle_int_t rectangle;
- cairo_region_get_extents(region, &rectangle);
- return IntRect(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
-}
-#endif
-
-#define IS_HIGH_SURROGATE(u) ((UChar)(u) >= (UChar)0xd800 && (UChar)(u) <= (UChar)0xdbff)
-#define IS_LOW_SURROGATE(u) ((UChar)(u) >= (UChar)0xdc00 && (UChar)(u) <= (UChar)0xdfff)
-
-static gchar* utf16ToUtf8(const UChar* aText, gint aLength, gint &length)
-{
- gboolean needCopy = FALSE;
-
- for (int i = 0; i < aLength; i++) {
- if (!aText[i] || IS_LOW_SURROGATE(aText[i])) {
- needCopy = TRUE;
- break;
- }
-
- if (IS_HIGH_SURROGATE(aText[i])) {
- if (i < aLength - 1 && IS_LOW_SURROGATE(aText[i+1]))
- i++;
- else {
- needCopy = TRUE;
- break;
- }
- }
- }
-
- GOwnPtr<UChar> copiedString;
- if (needCopy) {
- /* Pango doesn't correctly handle nuls. We convert them to 0xff. */
- /* Also "validate" UTF-16 text to make sure conversion doesn't fail. */
-
- copiedString.set(static_cast<UChar*>(g_memdup(aText, aLength * sizeof(aText[0]))));
- UChar* p = copiedString.get();
-
- /* don't need to reset i */
- for (int i = 0; i < aLength; i++) {
- if (!p[i] || IS_LOW_SURROGATE(p[i]))
- p[i] = 0xFFFD;
- else if (IS_HIGH_SURROGATE(p[i])) {
- if (i < aLength - 1 && IS_LOW_SURROGATE(aText[i+1]))
- i++;
- else
- p[i] = 0xFFFD;
- }
- }
-
- aText = p;
- }
-
- gchar* utf8Text;
- glong itemsWritten;
- utf8Text = g_utf16_to_utf8(reinterpret_cast<const gunichar2*>(aText), aLength, 0, &itemsWritten, 0);
- length = itemsWritten;
-
- return utf8Text;
-}
-
-static gchar* convertUniCharToUTF8(const UChar* characters, gint length, int from, int to)
-{
- gint newLength = 0;
- GOwnPtr<gchar> utf8Text(utf16ToUtf8(characters, length, newLength));
- if (!utf8Text)
- return 0;
-
- gchar* pos = utf8Text.get();
- if (from > 0) {
- // discard the first 'from' characters
- // FIXME: we should do this before the conversion probably
- pos = g_utf8_offset_to_pointer(utf8Text.get(), from);
- }
-
- gint len = strlen(pos);
- GString* ret = g_string_new_len(NULL, len);
-
- // replace line break by space
- while (len > 0) {
- gint index, start;
- pango_find_paragraph_boundary(pos, len, &index, &start);
- g_string_append_len(ret, pos, index);
- if (index == start)
- break;
- g_string_append_c(ret, ' ');
- pos += start;
- len -= start;
- }
- return g_string_free(ret, FALSE);
-}
-
-static void setPangoAttributes(const Font* font, const TextRun& run, PangoLayout* layout)
-{
-#if USE(FREETYPE)
- if (font->primaryFont()->platformData().m_pattern) {
- PangoFontDescription* desc = pango_fc_font_description_from_pattern(font->primaryFont()->platformData().m_pattern.get(), FALSE);
- pango_layout_set_font_description(layout, desc);
- pango_font_description_free(desc);
- }
-#elif USE(PANGO)
- if (font->primaryFont()->platformData().m_font) {
- PangoFontDescription* desc = pango_font_describe(font->primaryFont()->platformData().m_font);
- pango_layout_set_font_description(layout, desc);
- pango_font_description_free(desc);
- }
-#endif
-
- pango_layout_set_auto_dir(layout, FALSE);
-
- PangoContext* pangoContext = pango_layout_get_context(layout);
- PangoDirection direction = run.rtl() ? PANGO_DIRECTION_RTL : PANGO_DIRECTION_LTR;
- pango_context_set_base_dir(pangoContext, direction);
- PangoAttrList* list = pango_attr_list_new();
- PangoAttribute* attr;
-
- attr = pango_attr_size_new_absolute(font->pixelSize() * PANGO_SCALE);
- attr->end_index = G_MAXUINT;
- pango_attr_list_insert_before(list, attr);
-
- if (!run.spacingDisabled()) {
- attr = pango_attr_letter_spacing_new(font->letterSpacing() * PANGO_SCALE);
- attr->end_index = G_MAXUINT;
- pango_attr_list_insert_before(list, attr);
- }
-
- // Pango does not yet support synthesising small caps
- // See http://bugs.webkit.org/show_bug.cgi?id=15610
-
- pango_layout_set_attributes(layout, list);
- pango_attr_list_unref(list);
-}
-
-bool Font::canReturnFallbackFontsForComplexText()
-{
- return false;
-}
-
-bool Font::canExpandAroundIdeographsInComplexText()
-{
- return false;
-}
-
-static void drawGlyphsShadow(GraphicsContext* graphicsContext, const FloatPoint& point, PangoLayoutLine* layoutLine, PangoRegionType renderRegion)
-{
- ShadowBlur& shadow = graphicsContext->platformContext()->shadowBlur();
-
- if (!(graphicsContext->textDrawingMode() & TextModeFill) || shadow.type() == ShadowBlur::NoShadow)
- return;
-
- FloatPoint totalOffset(point + graphicsContext->state().shadowOffset);
-
- // Optimize non-blurry shadows, by just drawing text without the ShadowBlur.
- if (!shadow.mustUseShadowBlur(graphicsContext)) {
- cairo_t* context = graphicsContext->platformContext()->cr();
- cairo_save(context);
- cairo_translate(context, totalOffset.x(), totalOffset.y());
-
- setSourceRGBAFromColor(context, graphicsContext->state().shadowColor);
-#if PLATFORM(GTK)
- gdk_cairo_region(context, renderRegion);
-#else
- appendRegionToCairoContext(context, renderRegion);
-#endif
- cairo_clip(context);
- pango_cairo_show_layout_line(context, layoutLine);
-
- cairo_restore(context);
- return;
- }
-
- FloatRect extents(getPangoRegionExtents(renderRegion));
- extents.setLocation(FloatPoint(point.x(), point.y() - extents.height()));
- if (GraphicsContext* shadowContext = shadow.beginShadowLayer(graphicsContext, extents)) {
- cairo_t* cairoShadowContext = shadowContext->platformContext()->cr();
- cairo_translate(cairoShadowContext, point.x(), point.y());
- pango_cairo_show_layout_line(cairoShadowContext, layoutLine);
-
- // We need the clipping region to be active when we blit the blurred shadow back,
- // because we don't want any bits and pieces of characters out of range to be
- // drawn. Since ShadowBlur expects a consistent transform, we have to undo the
- // translation before calling endShadowLayer as well.
- cairo_t* context = graphicsContext->platformContext()->cr();
- cairo_save(context);
- cairo_translate(context, totalOffset.x(), totalOffset.y());
-#if PLATFORM(GTK)
- gdk_cairo_region(context, renderRegion);
-#else
- appendRegionToCairoContext(context, renderRegion);
-#endif
- cairo_clip(context);
- cairo_translate(context, -totalOffset.x(), -totalOffset.y());
-
- shadow.endShadowLayer(graphicsContext);
- cairo_restore(context);
- }
-}
-
-void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
-{
-#if USE(FREETYPE)
- if (!primaryFont()->platformData().m_pattern) {
- drawSimpleText(context, run, point, from, to);
- return;
- }
-#endif
-
- cairo_t* cr = context->platformContext()->cr();
- PangoLayout* layout = pango_cairo_create_layout(cr);
- setPangoAttributes(this, run, layout);
-
- gchar* utf8 = convertUniCharToUTF8(run.characters16(), run.length(), 0, run.length());
- pango_layout_set_text(layout, utf8, -1);
-
- // Our layouts are single line
- PangoLayoutLine* layoutLine = pango_layout_get_line_readonly(layout, 0);
-
- // Get the region where this text will be laid out. We will use it to clip
- // the Cairo context, for when we are only painting part of the text run and
- // to calculate the size of the shadow buffer.
- PangoRegionType partialRegion = 0;
- char* start = g_utf8_offset_to_pointer(utf8, from);
- char* end = g_utf8_offset_to_pointer(start, to - from);
- int ranges[] = {start - utf8, end - utf8};
-#if PLATFORM(GTK)
- partialRegion = gdk_pango_layout_line_get_clip_region(layoutLine, 0, 0, ranges, 1);
-#else
- partialRegion = getClipRegionFromPangoLayoutLine(layoutLine, ranges);
-#endif
-
- drawGlyphsShadow(context, point, layoutLine, partialRegion);
-
- cairo_save(cr);
- cairo_translate(cr, point.x(), point.y());
-
- float red, green, blue, alpha;
- context->fillColor().getRGBA(red, green, blue, alpha);
- cairo_set_source_rgba(cr, red, green, blue, alpha);
-#if PLATFORM(GTK)
- gdk_cairo_region(cr, partialRegion);
-#else
- appendRegionToCairoContext(cr, partialRegion);
-#endif
- cairo_clip(cr);
-
- pango_cairo_show_layout_line(cr, layoutLine);
-
- if (context->textDrawingMode() & TextModeStroke) {
- Color strokeColor = context->strokeColor();
- strokeColor.getRGBA(red, green, blue, alpha);
- cairo_set_source_rgba(cr, red, green, blue, alpha);
- pango_cairo_layout_line_path(cr, layoutLine);
- cairo_set_line_width(cr, context->strokeThickness());
- cairo_stroke(cr);
- }
-
- // Pango sometimes leaves behind paths we don't want
- cairo_new_path(cr);
-
- destroyPangoRegion(partialRegion);
- g_free(utf8);
- g_object_unref(layout);
-
- cairo_restore(cr);
-}
-
-void Font::drawEmphasisMarksForComplexText(GraphicsContext* /* context */, const TextRun& /* run */, const AtomicString& /* mark */, const FloatPoint& /* point */, int /* from */, int /* to */) const
-{
- notImplemented();
-}
-
-// We should create the layout with our actual context but we can't access it from here.
-static PangoLayout* getDefaultPangoLayout(const TextRun& run)
-{
- static PangoFontMap* map = pango_cairo_font_map_get_default();
-#if PANGO_VERSION_CHECK(1, 21, 5)
- static PangoContext* pangoContext = pango_font_map_create_context(map);
-#else
- // Deprecated in Pango 1.21.
- static PangoContext* pangoContext = pango_cairo_font_map_create_context(PANGO_CAIRO_FONT_MAP(map));
-#endif
- PangoLayout* layout = pango_layout_new(pangoContext);
-
- return layout;
-}
-
-float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* overflow) const
-{
-#if USE(FREETYPE)
- if (!primaryFont()->platformData().m_pattern)
- return floatWidthForSimpleText(run, fallbackFonts, overflow);
-#endif
-
- if (!run.length())
- return 0.0f;
-
- PangoLayout* layout = getDefaultPangoLayout(run);
- setPangoAttributes(this, run, layout);
-
- gchar* utf8 = convertUniCharToUTF8(run.characters16(), run.length(), 0, run.length());
- pango_layout_set_text(layout, utf8, -1);
-
- int width;
- pango_layout_get_pixel_size(layout, &width, 0);
-
- g_free(utf8);
- g_object_unref(layout);
-
- return width;
-}
-
-int Font::offsetForPositionForComplexText(const TextRun& run, float xFloat, bool includePartialGlyphs) const
-{
-#if USE(FREETYPE)
- if (!primaryFont()->platformData().m_pattern)
- return offsetForPositionForSimpleText(run, xFloat, includePartialGlyphs);
-#endif
- // FIXME: This truncation is not a problem for HTML, but only affects SVG, which passes floating-point numbers
- // to Font::offsetForPosition(). Bug http://webkit.org/b/40673 tracks fixing this problem.
- int x = static_cast<int>(xFloat);
-
- PangoLayout* layout = getDefaultPangoLayout(run);
- setPangoAttributes(this, run, layout);
-
- gchar* utf8 = convertUniCharToUTF8(run.characters16(), run.length(), 0, run.length());
- pango_layout_set_text(layout, utf8, -1);
-
- int index, trailing;
- pango_layout_xy_to_index(layout, x * PANGO_SCALE, 1, &index, &trailing);
- glong offset = g_utf8_pointer_to_offset(utf8, utf8 + index);
- if (includePartialGlyphs)
- offset += trailing;
-
- g_free(utf8);
- g_object_unref(layout);
-
- return offset;
-}
-
-FloatRect Font::selectionRectForComplexText(const TextRun& run, const FloatPoint& point, int h, int from, int to) const
-{
-#if USE(FREETYPE)
- if (!primaryFont()->platformData().m_pattern)
- return selectionRectForSimpleText(run, point, h, from, to);
-#endif
-
- PangoLayout* layout = getDefaultPangoLayout(run);
- setPangoAttributes(this, run, layout);
-
- gchar* utf8 = convertUniCharToUTF8(run.characters16(), run.length(), 0, run.length());
- pango_layout_set_text(layout, utf8, -1);
-
- char* start = g_utf8_offset_to_pointer(utf8, from);
- char* end = g_utf8_offset_to_pointer(start, to - from);
-
- if (run.ltr()) {
- from = start - utf8;
- to = end - utf8;
- } else {
- from = end - utf8;
- to = start - utf8;
- }
-
- PangoLayoutLine* layoutLine = pango_layout_get_line_readonly(layout, 0);
- int xPos;
-
- xPos = 0;
- if (from < layoutLine->length)
- pango_layout_line_index_to_x(layoutLine, from, FALSE, &xPos);
- float beforeWidth = PANGO_PIXELS_FLOOR(xPos);
-
- xPos = 0;
- if (run.ltr() || to < layoutLine->length)
- pango_layout_line_index_to_x(layoutLine, to, FALSE, &xPos);
- float afterWidth = PANGO_PIXELS(xPos);
-
- g_free(utf8);
- g_object_unref(layout);
-
- return FloatRect(point.x() + beforeWidth, point.y(), afterWidth - beforeWidth, h);
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/pango/FontPlatformData.h b/Source/WebCore/platform/graphics/pango/FontPlatformData.h
deleted file mode 100644
index bd9251b73..000000000
--- a/Source/WebCore/platform/graphics/pango/FontPlatformData.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * Copyright (C) 2007 Holger Hans Peter Freyther
- * Copyright (C) 2007 Pioneer Research Center USA, Inc.
- * All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef FontPlatformDataPango_h
-#define FontPlatformDataPango_h
-
-#include "FontDescription.h"
-#include "FontOrientation.h"
-#include "GlyphBuffer.h"
-#include <cairo.h>
-#include <pango/pangocairo.h>
-#include <wtf/Forward.h>
-
-namespace WebCore {
-
-class FontPlatformData {
-public:
- FontPlatformData(WTF::HashTableDeletedValueType)
- : m_context(0)
- , m_font(hashTableDeletedFontValue())
- , m_size(0)
- , m_syntheticBold(false)
- , m_syntheticOblique(false)
- , m_scaledFont(0)
- { }
-
- FontPlatformData()
- : m_context(0)
- , m_font(0)
- , m_size(0)
- , m_syntheticBold(false)
- , m_syntheticOblique(false)
- , m_scaledFont(0)
- { }
-
- FontPlatformData(const FontDescription&, const AtomicString& family);
- FontPlatformData(cairo_font_face_t* fontFace, float size, bool bold, bool italic);
- FontPlatformData(float size, bool bold, bool italic);
- FontPlatformData(const FontPlatformData&);
- ~FontPlatformData();
-
- static bool init();
- bool isFixedPitch();
- float size() const { return m_size; }
- void setSize(float size) { m_size = size; }
- bool syntheticBold() const { return m_syntheticBold; }
- bool syntheticOblique() const { return m_syntheticOblique; }
-
- FontOrientation orientation() const { return Horizontal; } // FIXME: Implement.
- void setOrientation(FontOrientation) { } // FIXME: Implement.
-
- cairo_scaled_font_t* scaledFont() const { return m_scaledFont; }
-
- unsigned hash() const
- {
- uintptr_t hashCodes[1] = { reinterpret_cast<uintptr_t>(m_scaledFont) };
- return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes);
- }
-
- bool operator==(const FontPlatformData&) const;
- FontPlatformData& operator=(const FontPlatformData&);
- bool isHashTableDeletedValue() const
- {
- return m_font == hashTableDeletedFontValue();
- }
-
-#ifndef NDEBUG
- String description() const;
-#endif
-
- static PangoFontMap* m_fontMap;
- static GHashTable* m_hashTable;
- PangoContext* m_context;
- PangoFont* m_font;
- float m_size;
- bool m_syntheticBold;
- bool m_syntheticOblique;
- cairo_scaled_font_t* m_scaledFont;
-private:
- static PangoFont *hashTableDeletedFontValue() { return reinterpret_cast<PangoFont*>(-1); }
-};
-
-}
-
-#endif // FontPlatformDataPango_h
diff --git a/Source/WebCore/platform/graphics/pango/FontPlatformDataPango.cpp b/Source/WebCore/platform/graphics/pango/FontPlatformDataPango.cpp
deleted file mode 100644
index 61cd042ff..000000000
--- a/Source/WebCore/platform/graphics/pango/FontPlatformDataPango.cpp
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * Copyright (C) 2007, 2008 Alp Toker <alp@atoker.com>
- * Copyright (C) 2007 Holger Hans Peter Freyther
- * Copyright (C) 2007 Pioneer Research Center USA, Inc.
- * Copyright (C) 2009 Igalia S.L.
- * All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-#include "config.h"
-#include "FontPlatformData.h"
-
-#include "FontDescription.h"
-#include <assert.h>
-#include <cairo.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/WTFString.h>
-
-#include <pango/pango.h>
-#include <pango/pangocairo.h>
-
-// Use cairo-ft i a recent enough Pango version isn't available
-#if !PANGO_VERSION_CHECK(1,18,0)
-#include <cairo-ft.h>
-#include <pango/pangofc-fontmap.h>
-#endif
-
-namespace WebCore {
-
-PangoFontMap* FontPlatformData::m_fontMap = 0;
-GHashTable* FontPlatformData::m_hashTable = 0;
-
-FontPlatformData::FontPlatformData(const FontDescription& fontDescription, const AtomicString& familyName)
- : m_context(0)
- , m_font(0)
- , m_size(fontDescription.computedSize())
- , m_syntheticBold(false)
- , m_syntheticOblique(false)
- , m_scaledFont(0)
-{
- FontPlatformData::init();
-
- CString stored_family = familyName.string().utf8();
- char const* families[] = {
- stored_family.data(),
- NULL
- };
-
- switch (fontDescription.genericFamily()) {
- case FontDescription::SerifFamily:
- families[1] = "serif";
- break;
- case FontDescription::SansSerifFamily:
- families[1] = "sans";
- break;
- case FontDescription::MonospaceFamily:
- families[1] = "monospace";
- break;
- case FontDescription::NoFamily:
- case FontDescription::StandardFamily:
- default:
- families[1] = "sans";
- break;
- }
-
- PangoFontDescription* description = pango_font_description_new();
- pango_font_description_set_absolute_size(description, fontDescription.computedSize() * PANGO_SCALE);
-
- // FIXME: Map all FontWeight values to Pango font weights.
- if (fontDescription.weight() >= FontWeight600)
- pango_font_description_set_weight(description, PANGO_WEIGHT_BOLD);
- if (fontDescription.italic())
- pango_font_description_set_style(description, PANGO_STYLE_ITALIC);
-
-#if PANGO_VERSION_CHECK(1,21,5) // deprecated in 1.21
- m_context = pango_font_map_create_context(m_fontMap);
-#else
- m_context = pango_cairo_font_map_create_context(PANGO_CAIRO_FONT_MAP(m_fontMap));
-#endif
- for (unsigned int i = 0; !m_font && i < G_N_ELEMENTS(families); i++) {
- pango_font_description_set_family(description, families[i]);
- pango_context_set_font_description(m_context, description);
- m_font = pango_font_map_load_font(m_fontMap, m_context, description);
- }
-
-#if PANGO_VERSION_CHECK(1,18,0)
- if (m_font)
- m_scaledFont = cairo_scaled_font_reference(pango_cairo_font_get_scaled_font(PANGO_CAIRO_FONT(m_font)));
-#else
- // This compatibility code for older versions of Pango is not well-tested.
- if (m_font) {
- PangoFcFont* fcfont = PANGO_FC_FONT(m_font);
- cairo_font_face_t* face = cairo_ft_font_face_create_for_pattern(fcfont->font_pattern);
- double size;
- if (FcPatternGetDouble(fcfont->font_pattern, FC_PIXEL_SIZE, 0, &size) != FcResultMatch)
- size = 12.0;
- cairo_matrix_t fontMatrix;
- cairo_matrix_init_scale(&fontMatrix, size, size);
- cairo_font_options_t* fontOptions;
- if (pango_cairo_context_get_font_options(m_context))
- fontOptions = cairo_font_options_copy(pango_cairo_context_get_font_options(m_context));
- else
- fontOptions = cairo_font_options_create();
- cairo_matrix_t ctm;
- cairo_matrix_init_identity(&ctm);
- m_scaledFont = cairo_scaled_font_create(face, &fontMatrix, &ctm, fontOptions);
- cairo_font_options_destroy(fontOptions);
- cairo_font_face_destroy(face);
- }
-#endif
- pango_font_description_free(description);
-}
-
-FontPlatformData::FontPlatformData(float size, bool bold, bool italic)
- : m_context(0)
- , m_font(0)
- , m_size(size)
- , m_syntheticBold(bold)
- , m_syntheticOblique(italic)
- , m_scaledFont(0)
-{
-}
-
-FontPlatformData::FontPlatformData(cairo_font_face_t* fontFace, float size, bool bold, bool italic)
- : m_context(0)
- , m_font(0)
- , m_size(size)
- , m_syntheticBold(bold)
- , m_syntheticOblique(italic)
- , m_scaledFont(0)
-{
- cairo_matrix_t fontMatrix;
- cairo_matrix_init_scale(&fontMatrix, size, size);
- cairo_matrix_t ctm;
- cairo_matrix_init_identity(&ctm);
- cairo_font_options_t* options = cairo_font_options_create();
-
- // We force antialiasing and disable hinting to provide consistent
- // typographic qualities for custom fonts on all platforms.
- cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE);
- cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_GRAY);
-
- m_scaledFont = cairo_scaled_font_create(fontFace, &fontMatrix, &ctm, options);
- cairo_font_options_destroy(options);
-}
-
-bool FontPlatformData::init()
-{
- static bool initialized = false;
- if (initialized)
- return true;
- initialized = true;
-
- if (!m_fontMap)
- m_fontMap = pango_cairo_font_map_get_default();
- if (!m_hashTable) {
- PangoFontFamily** families = 0;
- int n_families = 0;
-
- m_hashTable = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref);
-
- pango_font_map_list_families(m_fontMap, &families, &n_families);
-
- for (int family = 0; family < n_families; family++)
- g_hash_table_insert(m_hashTable,
- g_strdup(pango_font_family_get_name(families[family])),
- g_object_ref(families[family]));
-
- g_free(families);
- }
-
- return true;
-}
-
-FontPlatformData::~FontPlatformData()
-{
- if (m_font && m_font != reinterpret_cast<PangoFont*>(-1)) {
- g_object_unref(m_font);
- m_font = 0;
- }
-
- if (m_context) {
- g_object_unref(m_context);
- m_context = 0;
- }
-
- if (m_scaledFont) {
- cairo_scaled_font_destroy(m_scaledFont);
- m_scaledFont = 0;
- }
-}
-
-bool FontPlatformData::isFixedPitch()
-{
- PangoFontDescription* description = pango_font_describe_with_absolute_size(m_font);
- PangoFontFamily* family = reinterpret_cast<PangoFontFamily*>(g_hash_table_lookup(m_hashTable, pango_font_description_get_family(description)));
- pango_font_description_free(description);
- return pango_font_family_is_monospace(family);
-}
-
-FontPlatformData& FontPlatformData::operator=(const FontPlatformData& other)
-{
- // Check for self-assignment.
- if (this == &other)
- return *this;
-
- m_size = other.m_size;
- m_syntheticBold = other.m_syntheticBold;
- m_syntheticOblique = other.m_syntheticOblique;
-
- if (other.m_scaledFont)
- cairo_scaled_font_reference(other.m_scaledFont);
- if (m_scaledFont)
- cairo_scaled_font_destroy(m_scaledFont);
- m_scaledFont = other.m_scaledFont;
-
- if (other.m_font)
- g_object_ref(other.m_font);
- if (m_font)
- g_object_unref(m_font);
- m_font = other.m_font;
-
- if (other.m_context)
- g_object_ref(other.m_context);
- if (m_context)
- g_object_unref(m_context);
- m_context = other.m_context;
-
- return *this;
-}
-
-FontPlatformData::FontPlatformData(const FontPlatformData& other)
- : m_context(0)
- , m_font(0)
- , m_scaledFont(0)
-{
- *this = other;
-}
-
-bool FontPlatformData::operator==(const FontPlatformData& other) const
-{
- if (m_font == other.m_font)
- return true;
- if (m_font == 0 || m_font == reinterpret_cast<PangoFont*>(-1)
- || other.m_font == 0 || other.m_font == reinterpret_cast<PangoFont*>(-1))
- return false;
- PangoFontDescription* thisDesc = pango_font_describe(m_font);
- PangoFontDescription* otherDesc = pango_font_describe(other.m_font);
- bool result = pango_font_description_equal(thisDesc, otherDesc);
- pango_font_description_free(otherDesc);
- pango_font_description_free(thisDesc);
- return result;
-}
-
-#ifndef NDEBUG
-String FontPlatformData::description() const
-{
- return String();
-}
-#endif
-
-}
diff --git a/Source/WebCore/platform/graphics/pango/GlyphPageTreeNodePango.cpp b/Source/WebCore/platform/graphics/pango/GlyphPageTreeNodePango.cpp
deleted file mode 100644
index 8d0baa613..000000000
--- a/Source/WebCore/platform/graphics/pango/GlyphPageTreeNodePango.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * Copyright (C) 2007 Alp Toker <alp.toker@collabora.co.uk>
- * Copyright (C) 2007 Pioneer Research Center USA, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "GlyphPageTreeNode.h"
-
-#include "SimpleFontData.h"
-#include <pango/pango-font.h>
-
-namespace WebCore {
-
-static PangoGlyph pango_font_get_glyph(PangoFont* font, PangoContext* context, gunichar wc)
-{
- PangoGlyph result = 0;
- gchar buffer[7];
-
- gint length = g_unichar_to_utf8(wc, buffer);
- g_return_val_if_fail(length, 0);
-
- GList* items = pango_itemize(context, buffer, 0, length, NULL, NULL);
-
- if (g_list_length(items) == 1) {
- PangoItem* item = reinterpret_cast<PangoItem*>(items->data);
- PangoFont* tmpFont = item->analysis.font;
- item->analysis.font = font;
-
- PangoGlyphString* glyphs = pango_glyph_string_new();
- pango_shape(buffer, length, &item->analysis, glyphs);
-
- item->analysis.font = tmpFont;
-
- if (glyphs->num_glyphs == 1)
- result = glyphs->glyphs[0].glyph;
- else
- g_warning("didn't get 1 glyph but %d", glyphs->num_glyphs);
-
- pango_glyph_string_free(glyphs);
- }
-
- g_list_foreach(items, (GFunc)pango_item_free, NULL);
- g_list_free(items);
-
- return result;
-}
-
-bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData)
-{
- // The bufferLength will be greater than the glyph page size if the buffer has Unicode supplementary characters.
- // We won't support this for now.
- if (bufferLength > GlyphPage::size)
- return false;
-
- if (!fontData->platformData().m_font || fontData->platformData().m_font == reinterpret_cast<PangoFont*>(-1))
- return false;
-
- bool haveGlyphs = false;
- for (unsigned i = 0; i < length; i++) {
- Glyph glyph = pango_font_get_glyph(fontData->platformData().m_font, fontData->platformData().m_context, buffer[i]);
- if (!glyph)
- setGlyphDataForIndex(offset + i, 0, 0);
- else {
- setGlyphDataForIndex(offset + i, glyph, fontData);
- haveGlyphs = true;
- }
- }
-
- return haveGlyphs;
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/pango/PangoUtilities.cpp b/Source/WebCore/platform/graphics/pango/PangoUtilities.cpp
deleted file mode 100644
index 98dc11b45..000000000
--- a/Source/WebCore/platform/graphics/pango/PangoUtilities.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * This code was mostly copied from gdk-pango.
- * source: http://git.gnome.org/browse/gtk+/tree/gdk/gdkpango.c
- *
- * Copyright (C) 2000 Red Hat, Inc.
- * Copyright (C) 2011 ProFUSION embedded systems
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include "config.h"
-#include "PangoUtilities.h"
-
-#include <cairo.h>
-#include <pango/pango.h>
-
-namespace WebCore {
-
-static cairo_region_t* getLineClipRegionFromLayoutIter(PangoLayoutIter* iter, const int* indexRange)
-{
- PangoRectangle logicalRect;
- PangoLayoutLine* line = pango_layout_iter_get_line_readonly(iter);
- cairo_region_t* clipRegion = cairo_region_create();
- pango_layout_iter_get_line_extents(iter, 0, &logicalRect);
- int baseline = pango_layout_iter_get_baseline(iter);
-
- int* pixelRanges = 0;
- int pixelRangeCount = 0;
-
- if (indexRange[1] >= line->start_index
- && indexRange[0] < line->start_index + line->length)
- pango_layout_line_get_x_ranges(line,
- indexRange[0],
- indexRange[1],
- &pixelRanges, &pixelRangeCount);
-
- for (int j = 0; j < pixelRangeCount; ++j) {
- int offsetX = PANGO_PIXELS(pixelRanges[2 * j] - logicalRect.x);
- int offsetY = PANGO_PIXELS(baseline - logicalRect.y);
-
- cairo_rectangle_int_t rect;
- rect.x = offsetX;
- rect.y = -offsetY;
- rect.width = PANGO_PIXELS(pixelRanges[2 * j + 1] - logicalRect.x) - offsetX;
- rect.height = PANGO_PIXELS(baseline - logicalRect.y + logicalRect.height) - offsetY;
-
- cairo_region_union_rectangle(clipRegion, &rect);
- }
-
- free(pixelRanges);
-
- return clipRegion;
-}
-
-cairo_region_t* getClipRegionFromPangoLayoutLine(PangoLayoutLine* line, const int* indexRange)
-{
- if (!indexRange)
- return 0;
-
- PangoLayoutIter* iter = pango_layout_get_iter(line->layout);
- while (pango_layout_iter_get_line_readonly(iter) != line)
- pango_layout_iter_next_line(iter);
-
- cairo_region_t* clipRegion = getLineClipRegionFromLayoutIter(iter, indexRange);
-
- pango_layout_iter_free(iter);
-
- return clipRegion;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/pango/PangoUtilities.h b/Source/WebCore/platform/graphics/pango/PangoUtilities.h
deleted file mode 100644
index b80067629..000000000
--- a/Source/WebCore/platform/graphics/pango/PangoUtilities.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2000 Red Hat, Inc.
- * Copyright (C) 2011 ProFUSION embedded systems
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef PangoUtilities_h
-#define PangoUtilities_h
-
-#include "GraphicsTypes.h"
-
-typedef struct _PangoLayoutLine PangoLayoutLine;
-typedef struct _cairo_region cairo_region_t;
-
-namespace WebCore {
-
-cairo_region_t* getClipRegionFromPangoLayoutLine(PangoLayoutLine*, const int* indexRange);
-
-} // namespace WebCore
-
-#endif // PangoUtilities_h
diff --git a/Source/WebCore/platform/graphics/pango/SimpleFontDataPango.cpp b/Source/WebCore/platform/graphics/pango/SimpleFontDataPango.cpp
deleted file mode 100644
index f88cbbb7a..000000000
--- a/Source/WebCore/platform/graphics/pango/SimpleFontDataPango.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * Copyright (C) 2007, 2008 Alp Toker <alp@atoker.com>
- * Copyright (C) 2007 Holger Hans Peter Freyther
- * Copyright (C) 2007 Pioneer Research Center USA, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SimpleFontData.h"
-
-#include "FloatRect.h"
-#include "Font.h"
-#include "FontCache.h"
-#include "FontDescription.h"
-#include "GlyphBuffer.h"
-#include <cairo.h>
-#include <wtf/MathExtras.h>
-
-namespace WebCore {
-
-void SimpleFontData::platformInit()
-{
- cairo_font_extents_t font_extents;
- cairo_text_extents_t text_extents;
- cairo_scaled_font_extents(m_platformData.m_scaledFont, &font_extents);
-
- m_fontMetrics.setAscent(font_extents.ascent);
- m_fontMetrics.setDescent(font_extents.descent);
-
- // There seems to be some rounding error in cairo (or in how we
- // use cairo) with some fonts, like DejaVu Sans Mono, which makes
- // cairo report a height smaller than ascent + descent, which is
- // wrong and confuses WebCore's layout system. Workaround this
- // while we figure out what's going on.
- float lineSpacing = font_extents.height;
- if (lineSpacing < font_extents.ascent + font_extents.descent)
- lineSpacing = font_extents.ascent + font_extents.descent;
- m_fontMetrics.setLineSpacing(lroundf(lineSpacing));
- m_fontMetrics.setLineGap(lineSpacing - font_extents.ascent - font_extents.descent);
-
- cairo_scaled_font_text_extents(m_platformData.m_scaledFont, "x", &text_extents);
- m_fontMetrics.setXHeight(text_extents.height);
-
- cairo_scaled_font_text_extents(m_platformData.m_scaledFont, " ", &text_extents);
- m_spaceWidth = static_cast<float>(text_extents.x_advance);
-
- m_syntheticBoldOffset = m_platformData.syntheticBold() ? 1.0f : 0.f;
-}
-
-void SimpleFontData::platformCharWidthInit()
-{
- m_avgCharWidth = 0.f;
- m_maxCharWidth = 0.f;
- initCharWidths();
-}
-
-void SimpleFontData::platformDestroy()
-{
-}
-
-PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
-{
- FontDescription desc = FontDescription(fontDescription);
- desc.setSpecifiedSize(scaleFactor * fontDescription.computedSize());
- FontPlatformData platformData(desc, desc.family().family());
- return SimpleFontData::create(platformData);
-}
-
-bool SimpleFontData::containsCharacters(const UChar* characters, int length) const
-{
- bool result = true;
-
- PangoCoverage* coverage = pango_font_get_coverage(m_platformData.m_font, pango_language_get_default());
-
- for (int i = 0; i < length; i++) {
- if (PANGO_COVERAGE_NONE == pango_coverage_get(coverage, characters[i])) {
- result = false;
- break;
- }
- }
-
- pango_coverage_unref(coverage);
-
- return result;
-}
-
-void SimpleFontData::determinePitch()
-{
- if (isCustomFont()) {
- m_treatAsFixedPitch = false;
- return;
- }
-
- m_treatAsFixedPitch = m_platformData.isFixedPitch();
-}
-
-FloatRect SimpleFontData::platformBoundsForGlyph(Glyph) const
-{
- return FloatRect();
-}
-
-float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
-{
- ASSERT(m_platformData.m_scaledFont);
-
- cairo_glyph_t cglyph = { glyph, 0, 0 };
- cairo_text_extents_t extents;
- cairo_scaled_font_glyph_extents(m_platformData.m_scaledFont, &cglyph, 1, &extents);
-
- float width = (float)m_spaceWidth;
- if (cairo_scaled_font_status(m_platformData.m_scaledFont) == CAIRO_STATUS_SUCCESS && extents.x_advance != 0)
- width = (float)extents.x_advance;
-
- return width;
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/qt/FontCacheQt.cpp b/Source/WebCore/platform/graphics/qt/FontCacheQt.cpp
index 55a0f821d..8a987c7ee 100644
--- a/Source/WebCore/platform/graphics/qt/FontCacheQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/FontCacheQt.cpp
@@ -63,24 +63,19 @@ static QRawFont rawFontForCharacters(const QString& string, const QRawFont& font
return glyphs.rawFont();
}
-PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
+PassRefPtr<SimpleFontData> FontCache::systemFallbackForCharacters(const FontDescription&, const SimpleFontData* originalFontData, bool, const UChar* characters, int length)
{
QString qstring = QString::fromRawData(reinterpret_cast<const QChar*>(characters), length);
- QRawFont computedFont = rawFontForCharacters(qstring, font.rawFont());
+ QRawFont computedFont = rawFontForCharacters(qstring, originalFontData->getQtRawFont());
if (!computedFont.isValid())
return 0;
FontPlatformData alternateFont(computedFont);
return getCachedFontData(&alternateFont, DoNotRetain);
}
-PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font& font)
-{
- return 0;
-}
-
PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)
{
- const AtomicString fallbackFamily = QFont(fontDescription.family().family()).lastResortFamily();
+ const AtomicString fallbackFamily = QFont(fontDescription.firstFamily()).lastResortFamily();
FontPlatformData platformData(fontDescription, fallbackFamily);
return getCachedFontData(&platformData, shouldRetain);
}
@@ -89,12 +84,12 @@ void FontCache::getTraitsInFamily(const AtomicString&, Vector<unsigned>&)
{
}
-FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& familyName)
+PassOwnPtr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& familyName)
{
QFontDatabase db;
if (!db.hasFamily(familyName))
- return 0;
- return new FontPlatformData(fontDescription, familyName);
+ return nullptr;
+ return adoptPtr(new FontPlatformData(fontDescription, familyName));
}
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/qt/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/qt/FontCustomPlatformData.h
index 8d4efeca2..c73aac075 100644
--- a/Source/WebCore/platform/graphics/qt/FontCustomPlatformData.h
+++ b/Source/WebCore/platform/graphics/qt/FontCustomPlatformData.h
@@ -25,7 +25,6 @@
#include "FontOrientation.h"
#include "FontRenderingMode.h"
#include "FontWidthVariant.h"
-#include "TextOrientation.h"
#include <QRawFont>
#include <wtf/FastAllocBase.h>
#include <wtf/Forward.h>
@@ -41,7 +40,7 @@ struct FontCustomPlatformData {
public:
FontCustomPlatformData() { }
- FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation = Horizontal, TextOrientation = TextOrientationVerticalRight,
+ FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation = Horizontal,
FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode);
static bool supportsFormat(const String&);
diff --git a/Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp b/Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp
index 5c36380d2..957978d0f 100644
--- a/Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp
@@ -31,7 +31,7 @@
namespace WebCore {
-FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation, TextOrientation, FontWidthVariant, FontRenderingMode)
+FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation, FontWidthVariant, FontRenderingMode)
{
Q_ASSERT(m_rawFont.isValid());
m_rawFont.setPixelSize(qreal(size));
diff --git a/Source/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp b/Source/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp
index 99a4e397f..94f3a91b0 100644
--- a/Source/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp
@@ -74,14 +74,9 @@ FontPlatformData::FontPlatformData(const FontDescription& description, const Ato
font.setWeight(toQFontWeight(description.weight()));
font.setWordSpacing(wordSpacing);
font.setLetterSpacing(QFont::AbsoluteSpacing, letterSpacing);
-#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
- // To maintain stable baselines for Qt 5.0, keep force integer metrics enabled and ignore font-smoothing setting.
- font.setStyleStrategy(QFont::ForceIntegerMetrics);
-#else
if (description.fontSmoothing() == NoSmoothing
|| (description.fontSmoothing() == AutoSmoothing && !Font::shouldUseSmoothing()))
font.setStyleStrategy(QFont::NoAntialias);
-#endif
m_data->bold = font.bold();
// WebKit allows font size zero but QFont does not. We will return
diff --git a/Source/WebCore/platform/graphics/qt/FontQt.cpp b/Source/WebCore/platform/graphics/qt/FontQt.cpp
index 3afbb3528..5f0d5ee4f 100644
--- a/Source/WebCore/platform/graphics/qt/FontQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/FontQt.cpp
@@ -24,7 +24,7 @@
#include "AffineTransform.h"
#include "FontDescription.h"
-#include "FontFallbackList.h"
+#include "FontGlyphs.h"
#include "FontSelector.h"
#include "GlyphBuffer.h"
#include "Gradient.h"
@@ -125,43 +125,35 @@ static void drawQtGlyphRun(GraphicsContext* context, const QGlyphRun& qtGlyphRun
if (context->textDrawingMode() & TextModeStroke)
textStrokePath = pathForGlyphs(qtGlyphRun, point);
- ShadowBlur* shadow = context->shadowBlur();
- if (context->hasShadow() && shadow->type() != ShadowBlur::NoShadow) {
- switch (shadow->type()) {
- case ShadowBlur::SolidShadow: {
- QPen previousPen = painter->pen();
- painter->setPen(context->state().shadowColor);
- const QPointF shadowOffset(context->state().shadowOffset.width(), context->state().shadowOffset.height());
- painter->translate(shadowOffset);
- if (context->textDrawingMode() & TextModeFill)
- painter->drawGlyphRun(point, qtGlyphRun);
- else if (context->textDrawingMode() & TextModeStroke)
- painter->strokePath(textStrokePath, painter->pen());
- painter->translate(-shadowOffset);
- painter->setPen(previousPen);
- break;
- }
- case ShadowBlur::BlurShadow: {
+ if (context->hasShadow()) {
+ const GraphicsContextState& state = context->state();
+ if (context->mustUseShadowBlur()) {
+ ShadowBlur shadow(state);
const int width = qtGlyphRun.boundingRect().width();
const QRawFont& font = qtGlyphRun.rawFont();
const int height = font.ascent() + font.descent();
const QRectF boundingRect(point.x(), point.y() - font.ascent() + baseLineOffset, width, height);
- GraphicsContext* shadowContext = shadow->beginShadowLayer(context, boundingRect);
+ GraphicsContext* shadowContext = shadow.beginShadowLayer(context, boundingRect);
if (shadowContext) {
QPainter* shadowPainter = shadowContext->platformContext();
- shadowPainter->setPen(shadowContext->state().shadowColor);
+ shadowPainter->setPen(state.shadowColor);
if (shadowContext->textDrawingMode() & TextModeFill)
shadowPainter->drawGlyphRun(point, qtGlyphRun);
else if (shadowContext->textDrawingMode() & TextModeStroke)
shadowPainter->strokePath(textStrokePath, shadowPainter->pen());
- shadow->endShadowLayer(context);
+ shadow.endShadowLayer(context);
}
- break;
- }
- case ShadowBlur::NoShadow:
- default:
- ASSERT_NOT_REACHED();
- break;
+ } else {
+ QPen previousPen = painter->pen();
+ painter->setPen(state.shadowColor);
+ const QPointF shadowOffset(state.shadowOffset.width(), state.shadowOffset.height());
+ painter->translate(shadowOffset);
+ if (context->textDrawingMode() & TextModeFill)
+ painter->drawGlyphRun(point, qtGlyphRun);
+ else if (context->textDrawingMode() & TextModeStroke)
+ painter->strokePath(textStrokePath, painter->pen());
+ painter->translate(-shadowOffset);
+ painter->setPen(previousPen);
}
}
@@ -304,7 +296,7 @@ void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* fontData,
for (int i = 0; i < numGlyphs; ++i) {
Glyph glyph = glyphBuffer.glyphAt(from + i);
- float advance = glyphBuffer.advanceAt(from + i);
+ float advance = glyphBuffer.advanceAt(from + i).width();
if (!glyph)
continue;
glyphIndexes.append(glyph);
diff --git a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp b/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
index 8a8c77074..1c7289cec 100644
--- a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
@@ -34,8 +34,8 @@
#include "OpenGLShims.h"
#include "QWebPageClient.h"
#include "SharedBuffer.h"
+#include "TextureMapperPlatformLayer.h"
#include <qpa/qplatformpixmap.h>
-#include <wtf/UnusedParam.h>
#include <wtf/text/CString.h>
#if QT_VERSION >= 0x050100
@@ -70,7 +70,7 @@ public:
~GraphicsContext3DPrivate();
#if USE(ACCELERATED_COMPOSITING)
- virtual void paintToTextureMapper(TextureMapper*, const FloatRect& target, const TransformationMatrix&, float opacity, BitmapTexture* mask);
+ virtual void paintToTextureMapper(TextureMapper*, const FloatRect& target, const TransformationMatrix&, float opacity);
#endif
#if USE(GRAPHICS_SURFACE)
virtual IntSize platformLayerSize() const;
@@ -173,14 +173,14 @@ void GraphicsContext3DPrivate::createOffscreenBuffers()
if (m_context->m_attrs.antialias) {
glGenFramebuffers(1, &m_context->m_multisampleFBO);
glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_multisampleFBO);
- m_context->m_boundFBO = m_context->m_multisampleFBO;
+ m_context->m_state.boundFBO = m_context->m_multisampleFBO;
glGenRenderbuffers(1, &m_context->m_multisampleColorBuffer);
if (m_context->m_attrs.stencil || m_context->m_attrs.depth)
glGenRenderbuffers(1, &m_context->m_multisampleDepthStencilBuffer);
} else {
// Bind canvas FBO.
glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_fbo);
- m_context->m_boundFBO = m_context->m_fbo;
+ m_context->m_state.boundFBO = m_context->m_fbo;
#if USE(OPENGL_ES_2)
if (m_context->m_attrs.depth)
glGenRenderbuffers(1, &m_context->m_depthBuffer);
@@ -212,6 +212,10 @@ void GraphicsContext3DPrivate::initializeANGLE()
if (extensions->supports("GL_ARB_texture_rectangle"))
ANGLEResources.ARB_texture_rectangle = 1;
+ GC3Dint range[2], precision;
+ m_context->getShaderPrecisionFormat(GraphicsContext3D::FRAGMENT_SHADER, GraphicsContext3D::HIGH_FLOAT, range, &precision);
+ ANGLEResources.FragmentPrecisionHigh = (range[0] || range[1] || precision);
+
m_context->m_compiler.setResources(ANGLEResources);
}
@@ -223,12 +227,13 @@ GraphicsContext3DPrivate::~GraphicsContext3DPrivate()
static inline quint32 swapBgrToRgb(quint32 pixel)
{
- return ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff) | (pixel & 0xff00ff00);
+ return (((pixel << 16) | (pixel >> 16)) & 0x00ff00ff) | (pixel & 0xff00ff00);
}
#if USE(ACCELERATED_COMPOSITING)
-void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity, BitmapTexture* mask)
+void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity)
{
+ m_context->markLayerComposited();
blitMultisampleFramebufferAndRestoreContext();
if (textureMapper->accelerationMode() == TextureMapper::OpenGLMode) {
@@ -249,11 +254,11 @@ void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper* textureMapper
// FIXME: Remove this code as soon as GraphicsSurfaceMac makes use of NSOpenGL.
currentContext->makeCurrent(currentSurface);
- m_graphicsSurface->paintToTextureMapper(texmapGL, targetRect, matrix, opacity, mask);
+ m_graphicsSurface->paintToTextureMapper(texmapGL, targetRect, matrix, opacity);
#else
- TextureMapperGL::Flags flags = TextureMapperGL::ShouldFlipTexture | (m_context->m_attrs.alpha ? TextureMapperGL::SupportsBlending : 0);
+ TextureMapperGL::Flags flags = TextureMapperGL::ShouldFlipTexture | (m_context->m_attrs.alpha ? TextureMapperGL::ShouldBlend : 0);
IntSize textureSize(m_context->m_currentWidth, m_context->m_currentHeight);
- texmapGL->drawTexture(m_context->m_texture, flags, textureSize, targetRect, matrix, opacity, mask);
+ texmapGL->drawTexture(m_context->m_texture, flags, textureSize, targetRect, matrix, opacity);
#endif
return;
}
@@ -274,7 +279,7 @@ void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper* textureMapper
makeCurrentIfNeeded();
glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_fbo);
glReadPixels(/* x */ 0, /* y */ 0, width, height, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, imagePixels);
- glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_boundFBO);
+ glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_state.boundFBO);
// OpenGL gives us ABGR on 32 bits, and with the origin at the bottom left
// We need RGB32 or ARGB32_PM, with the origin at the top left.
@@ -314,6 +319,7 @@ uint32_t GraphicsContext3DPrivate::copyToGraphicsSurface()
if (!m_graphicsSurface)
return 0;
+ m_context->markLayerComposited();
blitMultisampleFramebufferAndRestoreContext();
m_graphicsSurface->copyFromTexture(m_context->m_texture, IntRect(0, 0, m_context->m_currentWidth, m_context->m_currentHeight));
return m_graphicsSurface->frontBuffer();
@@ -339,21 +345,25 @@ void GraphicsContext3DPrivate::blitMultisampleFramebuffer() const
glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, m_context->m_fbo);
glBlitFramebuffer(0, 0, m_context->m_currentWidth, m_context->m_currentHeight, 0, 0, m_context->m_currentWidth, m_context->m_currentHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR);
#endif
- glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_boundFBO);
+ glBindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_context->m_state.boundFBO);
}
void GraphicsContext3DPrivate::blitMultisampleFramebufferAndRestoreContext() const
{
- if (!m_context->m_attrs.antialias)
- return;
-
const QOpenGLContext* currentContext = QOpenGLContext::currentContext();
QSurface* currentSurface = 0;
if (currentContext && currentContext != m_platformContext) {
currentSurface = currentContext->surface();
m_platformContext->makeCurrent(m_surface);
}
- blitMultisampleFramebuffer();
+
+ if (m_context->m_attrs.antialias)
+ blitMultisampleFramebuffer();
+
+ // While the context is still bound, make sure all the Framebuffer content is in finished state.
+ // This is necessary as we are doing our own double buffering instead of using a drawable that provides swapBuffers.
+ glFinish();
+
if (currentContext && currentContext != m_platformContext)
const_cast<QOpenGLContext*>(currentContext)->makeCurrent(currentSurface);
}
@@ -401,9 +411,6 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi
, m_depthStencilBuffer(0)
, m_layerComposited(false)
, m_internalColorFormat(0)
- , m_boundFBO(0)
- , m_activeTexture(GL_TEXTURE0)
- , m_boundTexture0(0)
, m_multisampleFBO(0)
, m_multisampleDepthStencilBuffer(0)
, m_multisampleColorBuffer(0)
@@ -510,57 +517,56 @@ void GraphicsContext3D::createGraphicsSurfaces(const IntSize& size)
}
#endif
-bool GraphicsContext3D::getImageData(Image* image,
- GC3Denum format,
- GC3Denum type,
- bool premultiplyAlpha,
- bool ignoreGammaAndColorProfile,
- Vector<uint8_t>& outputVector)
+GraphicsContext3D::ImageExtractor::~ImageExtractor()
+{
+}
+
+bool GraphicsContext3D::ImageExtractor::extractImage(bool premultiplyAlpha, bool ignoreGammaAndColorProfile)
{
UNUSED_PARAM(ignoreGammaAndColorProfile);
- if (!image)
+ if (!m_image)
return false;
- QImage qtImage;
// Is image already loaded? If not, load it.
- if (image->data())
- qtImage = QImage::fromData(reinterpret_cast<const uchar*>(image->data()->data()), image->data()->size());
+ if (m_image->data())
+ m_qtImage = QImage::fromData(reinterpret_cast<const uchar*>(m_image->data()->data()), m_image->data()->size());
else {
- QPixmap* nativePixmap = image->nativeImageForCurrentFrame();
+ QPixmap* nativePixmap = m_image->nativeImageForCurrentFrame();
if (!nativePixmap)
return false;
// With QPA, we can avoid a deep copy.
- qtImage = *nativePixmap->handle()->buffer();
+ m_qtImage = *nativePixmap->handle()->buffer();
}
- AlphaOp alphaOp = AlphaDoNothing;
- switch (qtImage.format()) {
+ m_alphaOp = AlphaDoNothing;
+ switch (m_qtImage.format()) {
case QImage::Format_RGB32:
// For opaque images, we should not premultiply or unmultiply alpha.
break;
case QImage::Format_ARGB32:
if (premultiplyAlpha)
- alphaOp = AlphaDoPremultiply;
+ m_alphaOp = AlphaDoPremultiply;
break;
case QImage::Format_ARGB32_Premultiplied:
if (!premultiplyAlpha)
- alphaOp = AlphaDoUnmultiply;
+ m_alphaOp = AlphaDoUnmultiply;
break;
default:
// The image has a format that is not supported in packPixels. We have to convert it here.
- qtImage = qtImage.convertToFormat(premultiplyAlpha ? QImage::Format_ARGB32_Premultiplied : QImage::Format_ARGB32);
+ m_qtImage = m_qtImage.convertToFormat(premultiplyAlpha ? QImage::Format_ARGB32_Premultiplied : QImage::Format_ARGB32);
break;
}
- unsigned int packedSize;
- // Output data is tightly packed (alignment == 1).
- if (computeImageSizeInBytes(format, type, image->width(), image->height(), 1, &packedSize, 0) != GraphicsContext3D::NO_ERROR)
+ m_imageWidth = m_image->width();
+ m_imageHeight = m_image->height();
+ if (!m_imageWidth || !m_imageHeight)
return false;
+ m_imagePixelData = m_qtImage.constBits();
+ m_imageSourceFormat = DataFormatBGRA8;
+ m_imageSourceUnpackAlignment = 0;
- outputVector.resize(packedSize);
-
- return packPixels(qtImage.constBits(), SourceFormatBGRA8, image->width(), image->height(), 0, format, type, alphaOp, outputVector.data());
+ return true;
}
void GraphicsContext3D::setContextLostCallback(PassOwnPtr<ContextLostCallback>)
diff --git a/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
index ec992d648..17dc4142c 100644
--- a/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
@@ -10,6 +10,7 @@
* Copyright (C) 2008 Dirk Schulze <vbs85@gmx.de>
* Copyright (C) 2010, 2011 Sencha, Inc.
* Copyright (C) 2011 Andreas Kling <kling@webkit.org>
+ * Copyright (C) 2013 Digia Plc. and/or its subsidiary(-ies).
*
* All rights reserved.
*
@@ -51,6 +52,7 @@
#include "Path.h"
#include "Pattern.h"
#include "ShadowBlur.h"
+#include "TransformationMatrix.h"
#include "TransparencyLayer.h"
#include <QBrush>
@@ -119,6 +121,46 @@ static inline QPainter::CompositionMode toQtCompositionMode(CompositeOperator op
return QPainter::CompositionMode_SourceOver;
}
+static inline QPainter::CompositionMode toQtCompositionMode(BlendMode op)
+{
+ switch (op) {
+ case BlendModeNormal:
+ return QPainter::CompositionMode_SourceOver;
+ case BlendModeMultiply:
+ return QPainter::CompositionMode_Multiply;
+ case BlendModeScreen:
+ return QPainter::CompositionMode_Screen;
+ case BlendModeOverlay:
+ return QPainter::CompositionMode_Overlay;
+ case BlendModeDarken:
+ return QPainter::CompositionMode_Darken;
+ case BlendModeLighten:
+ return QPainter::CompositionMode_Lighten;
+ case BlendModeColorDodge:
+ return QPainter::CompositionMode_ColorDodge;
+ case BlendModeColorBurn:
+ return QPainter::CompositionMode_ColorBurn;
+ case BlendModeHardLight:
+ return QPainter::CompositionMode_HardLight;
+ case BlendModeSoftLight:
+ return QPainter::CompositionMode_SoftLight;
+ case BlendModeDifference:
+ return QPainter::CompositionMode_Difference;
+ case BlendModeExclusion:
+ return QPainter::CompositionMode_Exclusion;
+ case BlendModeHue:
+ case BlendModeSaturation:
+ case BlendModeColor:
+ case BlendModeLuminosity:
+ // Not supported.
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+
+ return QPainter::CompositionMode_SourceOver;
+}
+
static inline Qt::PenCapStyle toQtLineCap(LineCap lc)
{
switch (lc) {
@@ -160,7 +202,7 @@ static Qt::PenStyle toQPenStyle(StrokeStyle style)
case SolidStroke:
#if ENABLE(CSS3_TEXT)
case DoubleStroke:
- case WavyStroke: // FIXME: https://bugs.webkit.org/show_bug.cgi?id=93507 - Needs platform support.
+ case WavyStroke:
#endif
return Qt::SolidLine;
break;
@@ -250,8 +292,6 @@ public:
InterpolationQuality imageInterpolationQuality;
bool initialSmoothPixmapTransformHint;
- ShadowBlur* shadow;
-
QRectF clipBoundingRect() const
{
return p()->clipBoundingRect();
@@ -270,7 +310,6 @@ GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate(QPainter* p, cons
, solidColor(initialSolidColor)
, imageInterpolationQuality(InterpolationDefault)
, initialSmoothPixmapTransformHint(false)
- , shadow(new ShadowBlur())
, painter(p)
, platformContextIsOwned(false)
{
@@ -289,8 +328,6 @@ GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate(QPainter* p, cons
GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate()
{
- delete shadow;
-
if (!platformContextIsOwned)
return;
@@ -355,8 +392,6 @@ void GraphicsContext::restorePlatformState()
endPlatformTransparencyLayer();
m_data->p()->restore();
-
- m_data->shadow->setShadowValues(FloatSize(m_state.shadowBlur, m_state.shadowBlur), m_state.shadowOffset, m_state.shadowColor, m_state.shadowColorSpace, m_state.shadowsIgnoreTransforms);
}
// Draws a filled rectangle with a stroked border.
@@ -410,7 +445,7 @@ void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2)
case SolidStroke:
#if ENABLE(CSS3_TEXT)
case DoubleStroke:
- case WavyStroke: // FIXME: https://bugs.webkit.org/show_bug.cgi?id=93507 - Needs platform support.
+ case WavyStroke:
#endif
break;
case DottedStroke: {
@@ -474,12 +509,85 @@ void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2)
p->setPen(pen);
}
+#if ENABLE(CSS3_TEXT)
+ if (style == WavyStroke) {
+ const float step = 2 * width; // Make wave height equal to two times strokeThickness().
+ const float flat = width; // Set size of flat lines between diagonal lines.
+ short signal = -1;
+ QPainterPath path;
+ float x1, y1, x2, y2;
+
+ if (isVerticalLine) {
+ x1 = x2 = p1.x();
+
+ // Make sure (x1, y1) < (x2, y2)
+ if (p1.y() < p2.y()) {
+ y1 = p1.y();
+ y2 = p2.y();
+ } else {
+ y1 = p2.y();
+ y2 = p1.y();
+ }
+
+ // Qt interprets geometric units as end-point inclusive, while WebCore interprets geometric units as endpoint exclusive.
+ // This means we need to subtract one from the endpoint, or the line will be painted one pixel too long.
+ y2 -= 1;
+ path.moveTo(x1 + signal * step, y1);
+ float y = y1 + 2 * step;
+
+ while (y <= y2) {
+ signal = -signal;
+ path.lineTo(x1 + signal * step, y);
+ path.lineTo(x1 + signal * step, y + flat); // Draw flat line between diagonal lines.
+ y += 2 * step + flat;
+ }
+ } else {
+ y1 = y2 = p1.y();
+
+ // Make sure (x1, y1) < (x2, y2)
+ if (p1.x() < p2.x()) {
+ x1 = p1.x();
+ x2 = p2.x();
+ } else {
+ x1 = p2.x();
+ x2 = p1.x();
+ }
+
+ // Qt interprets geometric units as end-point inclusive, while WebCore interprets geometric units as endpoint exclusive.
+ // This means we need to subtract one from the endpoint, or the line will be painted one pixel too long.
+ x2 -= 1;
+ path.moveTo(x1, y1 + signal * step);
+ float x = x1 + 2 * step;
+
+ while (x <= x2) {
+ signal = -signal;
+ path.lineTo(x, y1 + signal * step);
+ path.lineTo(x + flat, y1 + signal * step); // Draw flat line between diagonal lines.
+ x += 2 * step + flat;
+ }
+ }
+
+ // The last point created by the while loops above may not be the end
+ // point, so complete the wave by connecting the end point.
+ path.lineTo(x2, y2);
+ QPen pen = p->pen();
+ pen.setJoinStyle(Qt::BevelJoin); // A bevelled line join is more suitable for wavy than miter or round.
+ pen.setWidth(width);
+ const bool oldAntiAliasing = p->testRenderHint(QPainter::Antialiasing);
+ p->setRenderHint(QPainter::Antialiasing, true); // AntiAliasing is needed for diagonal lines of wavy stroke
+ p->strokePath(path, pen);
+ p->setRenderHint(QPainter::Antialiasing, oldAntiAliasing);
+ } else {
+#endif // CSS3_TEXT
// Qt interprets geometric units as end-point inclusive, while WebCore interprets geomtric units as endpoint exclusive.
// This means we need to subtract one from the endpoint, or the line will be painted one pixel too long.
if (p1.x() == p2.x())
p->drawLine(p1, p2 - FloatSize(0, 1));
else
p->drawLine(p1, p2 - FloatSize(1, 0));
+#if ENABLE(CSS3_TEXT)
+ }
+#endif // CSS3_TEXT
if (patWidth)
p->restore();
@@ -555,10 +663,10 @@ void GraphicsContext::fillPath(const Path& path)
platformPath.setFillRule(toQtFillRule(fillRule()));
if (hasShadow()) {
- ShadowBlur* shadow = shadowBlur();
- if (shadow->mustUseShadowBlur(this) || m_state.fillPattern || m_state.fillGradient)
+ if (mustUseShadowBlur() || m_state.fillPattern || m_state.fillGradient)
{
- GraphicsContext* shadowContext = shadow->beginShadowLayer(this, platformPath.controlPointRect());
+ ShadowBlur shadow(m_state);
+ GraphicsContext* shadowContext = shadow.beginShadowLayer(this, platformPath.controlPointRect());
if (shadowContext) {
QPainter* shadowPainter = shadowContext->platformContext();
if (m_state.fillPattern) {
@@ -570,7 +678,7 @@ void GraphicsContext::fillPath(const Path& path)
} else {
shadowPainter->fillPath(platformPath, p->brush());
}
- shadow->endShadowLayer(this);
+ shadow.endShadowLayer(this);
}
} else {
QPointF offset(m_state.shadowOffset.width(), m_state.shadowOffset.height());
@@ -614,12 +722,12 @@ void GraphicsContext::strokePath(const Path& path)
pathStroker.setWidth(pen.widthF());
if (hasShadow()) {
- ShadowBlur* shadow = shadowBlur();
- if (shadow->mustUseShadowBlur(this) || m_state.strokePattern || m_state.strokeGradient)
+ if (mustUseShadowBlur() || m_state.strokePattern || m_state.strokeGradient)
{
+ ShadowBlur shadow(m_state);
FloatRect boundingRect = platformPath.controlPointRect();
boundingRect.inflate(pen.miterLimit() + pen.widthF());
- GraphicsContext* shadowContext = shadow->beginShadowLayer(this, boundingRect);
+ GraphicsContext* shadowContext = shadow.beginShadowLayer(this, boundingRect);
if (shadowContext) {
QPainter* shadowPainter = shadowContext->platformContext();
if (m_state.strokeGradient) {
@@ -628,7 +736,7 @@ void GraphicsContext::strokePath(const Path& path)
fillPathStroke(shadowPainter, pathStroker, platformPath, brush);
} else
fillPathStroke(shadowPainter, pathStroker, platformPath, pen.brush());
- shadow->endShadowLayer(this);
+ shadow.endShadowLayer(this);
}
} else {
QPointF offset(m_state.shadowOffset.width(), m_state.shadowOffset.height());
@@ -706,35 +814,46 @@ void GraphicsContext::fillRect(const FloatRect& rect)
QPainter* p = m_data->p();
QRectF normalizedRect = rect.normalized();
- ShadowBlur* shadow = shadowBlur();
if (m_state.fillPattern) {
- GraphicsContext* shadowContext = hasShadow() ? shadow->beginShadowLayer(this, normalizedRect) : 0;
- if (shadowContext) {
- QPainter* shadowPainter = shadowContext->platformContext();
- drawRepeatPattern(shadowPainter, m_state.fillPattern, normalizedRect);
- shadow->endShadowLayer(this);
+ if (hasShadow()) {
+ ShadowBlur shadow(m_state);
+ GraphicsContext* shadowContext = shadow.beginShadowLayer(this, normalizedRect);
+ if (shadowContext) {
+ QPainter* shadowPainter = shadowContext->platformContext();
+ drawRepeatPattern(shadowPainter, m_state.fillPattern, normalizedRect);
+ shadow.endShadowLayer(this);
+ }
}
drawRepeatPattern(p, m_state.fillPattern, normalizedRect);
} else if (m_state.fillGradient) {
QBrush brush(*m_state.fillGradient->platformGradient());
brush.setTransform(m_state.fillGradient->gradientSpaceTransform());
- GraphicsContext* shadowContext = hasShadow() ? shadow->beginShadowLayer(this, normalizedRect) : 0;
- if (shadowContext) {
- QPainter* shadowPainter = shadowContext->platformContext();
- shadowPainter->fillRect(normalizedRect, brush);
- shadow->endShadowLayer(this);
+ if (hasShadow()) {
+ ShadowBlur shadow(m_state);
+ GraphicsContext* shadowContext = shadow.beginShadowLayer(this, normalizedRect);
+ if (shadowContext) {
+ QPainter* shadowPainter = shadowContext->platformContext();
+ shadowPainter->fillRect(normalizedRect, brush);
+ shadow.endShadowLayer(this);
+ }
}
p->fillRect(normalizedRect, brush);
} else {
if (hasShadow()) {
- if (shadow->mustUseShadowBlur(this)) {
- GraphicsContext* shadowContext = shadow->beginShadowLayer(this, normalizedRect);
- if (shadowContext) {
- QPainter* shadowPainter = shadowContext->platformContext();
- shadowPainter->fillRect(normalizedRect, p->brush());
- shadow->endShadowLayer(this);
- }
+ if (mustUseShadowBlur()) {
+ ShadowBlur shadow(m_state);
+ // drawRectShadowWithTiling does not work with rotations, and the fallback of
+ // drawing though clipToImageBuffer() produces scaling artifacts for us.
+ if (!getCTM().preservesAxisAlignment()) {
+ GraphicsContext* shadowContext = shadow.beginShadowLayer(this, normalizedRect);
+ if (shadowContext) {
+ QPainter* shadowPainter = shadowContext->platformContext();
+ shadowPainter->fillRect(normalizedRect, p->brush());
+ shadow.endShadowLayer(this);
+ }
+ } else
+ shadow.drawRectShadow(this, rect, RoundedRect::Radii());
} else {
// Solid rectangle fill with no blur shadow or transformations applied can be done
// faster without using the shadow layer at all.
@@ -757,9 +876,9 @@ void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorS
QRectF platformRect(rect);
QPainter* p = m_data->p();
if (hasShadow()) {
- ShadowBlur* shadow = shadowBlur();
- if (shadow->mustUseShadowBlur(this)) {
- shadow->drawRectShadow(this, platformRect, RoundedRect::Radii());
+ if (mustUseShadowBlur()) {
+ ShadowBlur shadow(m_state);
+ shadow.drawRectShadow(this, platformRect, RoundedRect::Radii());
} else {
QColor shadowColor = m_state.shadowColor;
shadowColor.setAlphaF(shadowColor.alphaF() * p->brush().color().alphaF());
@@ -778,9 +897,9 @@ void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLef
path.addRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight);
QPainter* p = m_data->p();
if (hasShadow()) {
- ShadowBlur* shadow = shadowBlur();
- if (shadow->mustUseShadowBlur(this)) {
- shadow->drawRectShadow(this, rect, RoundedRect::Radii(topLeft, topRight, bottomLeft, bottomRight));
+ if (mustUseShadowBlur()) {
+ ShadowBlur shadow(m_state);
+ shadow.drawRectShadow(this, rect, RoundedRect::Radii(topLeft, topRight, bottomLeft, bottomRight));
} else {
const QPointF shadowOffset(m_state.shadowOffset.width(), m_state.shadowOffset.height());
p->translate(shadowOffset);
@@ -808,10 +927,10 @@ void GraphicsContext::fillRectWithRoundedHole(const IntRect& rect, const Rounded
QPainter* p = m_data->p();
if (hasShadow()) {
- ShadowBlur* shadow = shadowBlur();
- if (shadow->mustUseShadowBlur(this))
- shadow->drawInsetShadow(this, rect, roundedHoleRect.rect(), roundedHoleRect.radii());
- else {
+ if (mustUseShadowBlur()) {
+ ShadowBlur shadow(m_state);
+ shadow.drawInsetShadow(this, rect, roundedHoleRect.rect(), roundedHoleRect.radii());
+ } else {
const QPointF shadowOffset(m_state.shadowOffset.width(), m_state.shadowOffset.height());
p->translate(shadowOffset);
p->fillPath(platformPath, QColor(m_state.shadowColor));
@@ -827,11 +946,6 @@ bool GraphicsContext::isInTransparencyLayer() const
return m_data->layerCount;
}
-ShadowBlur* GraphicsContext::shadowBlur()
-{
- return m_data->shadow;
-}
-
void GraphicsContext::clip(const IntRect& rect)
{
if (paintingDisabled())
@@ -955,8 +1069,7 @@ void GraphicsContext::drawLineForText(const FloatPoint& origin, float width, boo
}
#endif // defined(Q_WS_X11)
- // FIXME: Loss of precision here. Might consider rounding.
- drawLine(IntPoint(startPoint.x(), startPoint.y()), IntPoint(endPoint.x(), endPoint.y()));
+ drawLine(roundedIntPoint(startPoint), roundedIntPoint(endPoint));
}
@@ -1093,19 +1206,15 @@ void GraphicsContext::setPlatformShadow(const FloatSize& size, float blur, const
{
// Qt doesn't support shadows natively, they are drawn manually in the draw*
// functions
-
if (m_state.shadowsIgnoreTransforms) {
// Meaning that this graphics context is associated with a CanvasRenderingContext
// We flip the height since CG and HTML5 Canvas have opposite Y axis
m_state.shadowOffset = FloatSize(size.width(), -size.height());
}
-
- m_data->shadow->setShadowValues(FloatSize(m_state.shadowBlur, m_state.shadowBlur), m_state.shadowOffset, color, colorSpace, m_state.shadowsIgnoreTransforms);
}
void GraphicsContext::clearPlatformShadow()
{
- m_data->shadow->clear();
}
void GraphicsContext::pushTransparencyLayerInternal(const QRect &rect, qreal opacity, QPixmap& alphaMask)
@@ -1274,27 +1383,32 @@ void GraphicsContext::setAlpha(float opacity)
p->setOpacity(opacity);
}
-void GraphicsContext::setPlatformCompositeOperation(CompositeOperator op)
+void GraphicsContext::setPlatformCompositeOperation(CompositeOperator op, BlendMode blendMode)
{
if (paintingDisabled())
return;
- m_data->p()->setCompositionMode(toQtCompositionMode(op));
+ ASSERT(op == WebCore::CompositeSourceOver || blendMode == WebCore::BlendModeNormal);
+
+ if (op == WebCore::CompositeSourceOver)
+ m_data->p()->setCompositionMode(toQtCompositionMode(blendMode));
+ else
+ m_data->p()->setCompositionMode(toQtCompositionMode(op));
}
-void GraphicsContext::clip(const Path& path)
+void GraphicsContext::clip(const Path& path, WindRule windRule)
{
if (paintingDisabled())
return;
QPainterPath clipPath = path.platformPath();
- clipPath.setFillRule(Qt::WindingFill);
+ clipPath.setFillRule(toQtFillRule(windRule));
m_data->p()->setClipPath(clipPath, Qt::IntersectClip);
}
-void GraphicsContext::canvasClip(const Path& path)
+void GraphicsContext::canvasClip(const Path& path, WindRule windRule)
{
- clip(path);
+ clip(path, windRule);
}
void GraphicsContext::clipOut(const Path& path)
@@ -1365,32 +1479,6 @@ void GraphicsContext::clipOut(const IntRect& rect)
}
}
-void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect,
- int thickness)
-{
- if (paintingDisabled())
- return;
-
- clip(rect);
- QPainterPath path;
-
- // Add outer ellipse
- path.addEllipse(QRectF(rect.x(), rect.y(), rect.width(), rect.height()));
-
- // Add inner ellipse.
- path.addEllipse(QRectF(rect.x() + thickness, rect.y() + thickness,
- rect.width() - (thickness * 2), rect.height() - (thickness * 2)));
-
- path.setFillRule(Qt::OddEvenFill);
-
- QPainter* p = m_data->p();
-
- const bool antiAlias = p->testRenderHint(QPainter::Antialiasing);
- p->setRenderHint(QPainter::Antialiasing, true);
- p->setClipPath(path, Qt::IntersectClip);
- p->setRenderHint(QPainter::Antialiasing, antiAlias);
-}
-
void GraphicsContext::concatCTM(const AffineTransform& transform)
{
if (paintingDisabled())
diff --git a/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp b/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp
index 3fa8c2985..5a6136cc0 100644
--- a/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp
@@ -94,7 +94,7 @@ QImage ImageBufferData::toQImage() const
return image;
}
-ImageBuffer::ImageBuffer(const IntSize& size, float /* resolutionScale */, ColorSpace, RenderingMode, DeferralMode, bool& success)
+ImageBuffer::ImageBuffer(const IntSize& size, float /* resolutionScale */, ColorSpace, RenderingMode, bool& success)
: m_data(size)
, m_size(size)
, m_logicalSize(size)
@@ -125,15 +125,20 @@ PassRefPtr<Image> ImageBuffer::copyImage(BackingStoreCopy copyBehavior, ScaleBeh
return StillImage::createForRendering(&m_data.m_pixmap);
}
+BackingStoreCopy ImageBuffer::fastCopyImageMode()
+{
+ return DontCopyBackingStore;
+}
+
void ImageBuffer::draw(GraphicsContext* destContext, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect,
- CompositeOperator op, bool useLowQualityScale)
+ CompositeOperator op, BlendMode blendMode, bool useLowQualityScale)
{
if (destContext == context()) {
// We're drawing into our own buffer. In order for this to work, we need to copy the source buffer first.
RefPtr<Image> copy = copyImage(CopyBackingStore);
- destContext->drawImage(copy.get(), ColorSpaceDeviceRGB, destRect, srcRect, op, DoNotRespectImageOrientation, useLowQualityScale);
+ destContext->drawImage(copy.get(), ColorSpaceDeviceRGB, destRect, srcRect, op, blendMode, DoNotRespectImageOrientation, useLowQualityScale);
} else
- destContext->drawImage(m_data.m_image.get(), styleColorSpace, destRect, srcRect, op, DoNotRespectImageOrientation, useLowQualityScale);
+ destContext->drawImage(m_data.m_image.get(), styleColorSpace, destRect, srcRect, op, blendMode, DoNotRespectImageOrientation, useLowQualityScale);
}
void ImageBuffer::drawPattern(GraphicsContext* destContext, const FloatRect& srcRect, const AffineTransform& patternTransform,
diff --git a/Source/WebCore/platform/graphics/qt/ImageDecoderQt.cpp b/Source/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
index a7d9f7523..a3f44650f 100644
--- a/Source/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
@@ -264,7 +264,7 @@ void ImageDecoderQt::clearPointers()
m_buffer.clear();
}
-NativeImagePtr ImageFrame::asNewNativeImage() const
+PassNativeImagePtr ImageFrame::asNewNativeImage() const
{
QImage::Format format;
if (m_hasAlpha)
diff --git a/Source/WebCore/platform/graphics/qt/ImageQt.cpp b/Source/WebCore/platform/graphics/qt/ImageQt.cpp
index 4fb3090fc..ac47fcbd0 100644
--- a/Source/WebCore/platform/graphics/qt/ImageQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/ImageQt.cpp
@@ -133,7 +133,7 @@ void Image::setPlatformResource(const char* name, const QPixmap& pixmap)
}
void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const AffineTransform& patternTransform,
- const FloatPoint& phase, ColorSpace, CompositeOperator op, const FloatRect& destRect)
+ const FloatPoint& phase, ColorSpace, CompositeOperator op, const FloatRect& destRect, BlendMode)
{
QPixmap* framePixmap = nativeImageForCurrentFrame();
if (!framePixmap) // If it's too early we won't have an image yet.
@@ -276,7 +276,7 @@ QPixmap* prescaleImageIfRequired(QPainter* painter, QPixmap* image, QPixmap* buf
// Drawing Routines
void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
- const FloatRect& src, ColorSpace styleColorSpace, CompositeOperator op)
+ const FloatRect& src, ColorSpace styleColorSpace, CompositeOperator op, BlendMode blendMode)
{
QRectF normalizedDst = dst.normalized();
QRectF normalizedSrc = src.normalized();
@@ -303,21 +303,22 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
image = prescaleImageIfRequired(ctxt->platformContext(), image, &prescaledBuffer, normalizedDst, &normalizedSrc);
CompositeOperator previousOperator = ctxt->compositeOperation();
- ctxt->setCompositeOperation(!image->hasAlpha() && op == CompositeSourceOver ? CompositeCopy : op);
+ BlendMode previousBlendMode = ctxt->blendModeOperation();
+ ctxt->setCompositeOperation(!image->hasAlpha() && op == CompositeSourceOver && blendMode == BlendModeNormal ? CompositeCopy : op, blendMode);
if (ctxt->hasShadow()) {
- ShadowBlur* shadow = ctxt->shadowBlur();
- GraphicsContext* shadowContext = shadow->beginShadowLayer(ctxt, normalizedDst);
+ ShadowBlur shadow(ctxt->state());
+ GraphicsContext* shadowContext = shadow.beginShadowLayer(ctxt, normalizedDst);
if (shadowContext) {
QPainter* shadowPainter = shadowContext->platformContext();
shadowPainter->drawPixmap(normalizedDst, *image, normalizedSrc);
- shadow->endShadowLayer(ctxt);
+ shadow.endShadowLayer(ctxt);
}
}
ctxt->platformContext()->drawPixmap(normalizedDst, *image, normalizedSrc);
- ctxt->setCompositeOperation(previousOperator);
+ ctxt->setCompositeOperation(previousOperator, previousBlendMode);
if (imageObserver())
imageObserver()->didDraw(this);
diff --git a/Source/WebCore/platform/graphics/qt/LayoutPointQt.cpp b/Source/WebCore/platform/graphics/qt/LayoutPointQt.cpp
deleted file mode 100644
index 9f814a909..000000000
--- a/Source/WebCore/platform/graphics/qt/LayoutPointQt.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-#include "LayoutPoint.h"
-
-#include <QPoint>
-#include <QPointF>
-
-namespace WebCore {
-
-LayoutPoint::LayoutPoint(const QPoint& point)
- : m_x(point.x())
- , m_y(point.y())
-{
-}
-
-LayoutPoint::LayoutPoint(const QPointF& point)
- : m_x(point.x())
- , m_y(point.y())
-{
-}
-
-LayoutPoint::operator QPointF() const
-{
- return QPointF(m_x, m_y);
-}
-
-} // namespace
diff --git a/Source/WebCore/platform/graphics/qt/LayoutRectQt.cpp b/Source/WebCore/platform/graphics/qt/LayoutRectQt.cpp
deleted file mode 100644
index 4e794c907..000000000
--- a/Source/WebCore/platform/graphics/qt/LayoutRectQt.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-#include "LayoutRect.h"
-
-#include <QRect>
-#include <QRectF>
-
-namespace WebCore {
-
-LayoutRect::LayoutRect(const QRect& r)
- : m_location(r.topLeft())
- , m_size(r.width(), r.height())
-{
-}
-
-LayoutRect::LayoutRect(const QRectF& r)
- : m_location(r.topLeft())
- , m_size(r.width(), r.height())
-{
-}
-
-LayoutRect::operator QRectF() const
-{
- return QRectF(x(), y(), width(), height());
-}
-
-} // namespace
diff --git a/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp b/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp
index e083e2973..5d078b0ba 100644
--- a/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp
@@ -26,6 +26,7 @@
#include "GraphicsLayer.h"
#include "HTMLMediaElement.h"
#include "HTMLVideoElement.h"
+#include "Logging.h"
#include "NetworkingContext.h"
#include "NotImplemented.h"
#include "RenderVideo.h"
@@ -194,17 +195,12 @@ void MediaPlayerPrivateQt::commitLoad(const String& url)
const QUrl rUrl = kUrl;
const QString scheme = rUrl.scheme().toLower();
- // Grab the client media element
- HTMLMediaElement* element = static_cast<HTMLMediaElement*>(m_webCorePlayer->mediaPlayerClient());
-
// Construct the media content with a network request if the resource is http[s]
if (scheme == QString::fromLatin1("http") || scheme == QString::fromLatin1("https")) {
QNetworkRequest request = QNetworkRequest(rUrl);
// Grab the current document
- Document* document = element->document();
- if (!document)
- document = element->ownerDocument();
+ Document* document = m_webCorePlayer->mediaPlayerClient()->mediaPlayerOwningDocument();
// Grab the frame and network manager
Frame* frame = document ? document->frame() : 0;
@@ -240,15 +236,15 @@ void MediaPlayerPrivateQt::commitLoad(const String& url)
// We get these from the element, rather than the player, in case we have
// transitioned from a media engine which doesn't support muting, to a media
// engine which does.
- m_mediaPlayer->setMuted(element->muted());
- m_mediaPlayer->setVolume(static_cast<int>(element->volume() * 100.0));
+ m_mediaPlayer->setMuted(m_webCorePlayer->muted());
+ m_mediaPlayer->setVolume(static_cast<int>(m_webCorePlayer->volume() * 100.0));
// Don't send PlaybackChanged notification for pre-roll.
m_suppressNextPlaybackChanged = true;
// Setting a media source will start loading the media, but we need
// to pre-roll as well to get video size-hints and buffer-status
- if (element->paused())
+ if (m_webCorePlayer->paused())
m_mediaPlayer->pause();
else
m_mediaPlayer->play();
@@ -645,7 +641,7 @@ void MediaPlayerPrivateQt::paintCurrentFrameInContext(GraphicsContext* context,
}
#if USE(ACCELERATED_COMPOSITING)
-void MediaPlayerPrivateQt::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity, BitmapTexture*)
+void MediaPlayerPrivateQt::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity)
{
}
#endif
diff --git a/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.h b/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.h
index 8e31c9d6d..7e388c408 100644
--- a/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.h
+++ b/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.h
@@ -34,7 +34,7 @@ class QGraphicsScene;
QT_END_NAMESPACE
#if USE(ACCELERATED_COMPOSITING)
-#include "TextureMapper.h"
+#include "TextureMapperPlatformLayer.h"
#endif
namespace WebCore {
@@ -109,7 +109,7 @@ public:
virtual void acceleratedRenderingStateChanged() { }
// Const-casting here is safe, since all of TextureMapperPlatformLayer's functions are const.g
virtual PlatformLayer* platformLayer() const { return 0; }
- virtual void paintToTextureMapper(TextureMapper*, const FloatRect& targetRect, const TransformationMatrix&, float opacity, BitmapTexture* mask);
+ virtual void paintToTextureMapper(TextureMapper*, const FloatRect& targetRect, const TransformationMatrix&, float opacity);
#endif
virtual PlatformMedia platformMedia() const;
diff --git a/Source/WebCore/platform/graphics/qt/SimpleFontDataQt.cpp b/Source/WebCore/platform/graphics/qt/SimpleFontDataQt.cpp
index 44099b3eb..63def22b6 100644
--- a/Source/WebCore/platform/graphics/qt/SimpleFontDataQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/SimpleFontDataQt.cpp
@@ -58,7 +58,7 @@ float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
return advances.at(0).x();
}
-PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
+PassRefPtr<SimpleFontData> SimpleFontData::platformCreateScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
{
const float scaledSize = lroundf(fontDescription.computedSize() * scaleFactor);
return SimpleFontData::create(FontPlatformData(m_platformData, scaledSize), isCustomFont(), false);
@@ -88,6 +88,10 @@ void SimpleFontData::platformInit()
QVector<QPointF> advances = rawFont.advancesForGlyphIndexes(indexes);
float spaceWidth = advances.at(0).x();
+ indexes = rawFont.glyphIndexesForString(QLatin1String("0"));
+ advances = rawFont.advancesForGlyphIndexes(indexes);
+ float zeroWidth = advances.at(0).x();
+
// The line spacing should always be >= (ascent + descent), but this
// may be false in some cases due to misbehaving platform libraries.
// Workaround from SimpleFontPango.cpp and SimpleFontFreeType.cpp
@@ -104,6 +108,7 @@ void SimpleFontData::platformInit()
m_fontMetrics.setLineSpacing(lineSpacing);
m_fontMetrics.setXHeight(xHeight);
m_fontMetrics.setLineGap(lineGap);
+ m_fontMetrics.setZeroWidth(zeroWidth);
m_spaceWidth = spaceWidth;
}
diff --git a/Source/WebCore/platform/graphics/qt/StillImageQt.cpp b/Source/WebCore/platform/graphics/qt/StillImageQt.cpp
index 80666ba46..e8d3bce94 100644
--- a/Source/WebCore/platform/graphics/qt/StillImageQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/StillImageQt.cpp
@@ -52,9 +52,9 @@ StillImage::~StillImage()
delete m_pixmap;
}
-bool StillImage::currentFrameHasAlpha()
+bool StillImage::currentFrameKnownToBeOpaque()
{
- return m_pixmap->hasAlpha();
+ return !m_pixmap->hasAlpha();
}
IntSize StillImage::size() const
@@ -62,13 +62,13 @@ IntSize StillImage::size() const
return IntSize(m_pixmap->width(), m_pixmap->height());
}
-NativeImagePtr StillImage::nativeImageForCurrentFrame()
+PassNativeImagePtr StillImage::nativeImageForCurrentFrame()
{
- return const_cast<NativeImagePtr>(m_pixmap);
+ return const_cast<PassNativeImagePtr>(m_pixmap);
}
void StillImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
- const FloatRect& src, ColorSpace, CompositeOperator op)
+ const FloatRect& src, ColorSpace, CompositeOperator op, BlendMode blendMode)
{
if (m_pixmap->isNull())
return;
@@ -77,20 +77,21 @@ void StillImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
FloatRect normalizedDst = dst.normalized();
CompositeOperator previousOperator = ctxt->compositeOperation();
- ctxt->setCompositeOperation(op);
+ BlendMode previousBlendMode = ctxt->blendModeOperation();
+ ctxt->setCompositeOperation(op, blendMode);
if (ctxt->hasShadow()) {
- ShadowBlur* shadow = ctxt->shadowBlur();
- GraphicsContext* shadowContext = shadow->beginShadowLayer(ctxt, normalizedDst);
+ ShadowBlur shadow(ctxt->state());
+ GraphicsContext* shadowContext = shadow.beginShadowLayer(ctxt, normalizedDst);
if (shadowContext) {
QPainter* shadowPainter = shadowContext->platformContext();
shadowPainter->drawPixmap(normalizedDst, *m_pixmap, normalizedSrc);
- shadow->endShadowLayer(ctxt);
+ shadow.endShadowLayer(ctxt);
}
}
ctxt->platformContext()->drawPixmap(normalizedDst, *m_pixmap, normalizedSrc);
- ctxt->setCompositeOperation(previousOperator);
+ ctxt->setCompositeOperation(previousOperator, previousBlendMode);
}
}
diff --git a/Source/WebCore/platform/graphics/qt/StillImageQt.h b/Source/WebCore/platform/graphics/qt/StillImageQt.h
index 0609b5458..1e9e2197d 100644
--- a/Source/WebCore/platform/graphics/qt/StillImageQt.h
+++ b/Source/WebCore/platform/graphics/qt/StillImageQt.h
@@ -44,7 +44,7 @@ namespace WebCore {
return adoptRef(new StillImage(pixmap));
}
- virtual bool currentFrameHasAlpha();
+ virtual bool currentFrameKnownToBeOpaque();
// FIXME: StillImages are underreporting decoded sizes and will be unable
// to prune because these functions are not implemented yet.
@@ -52,8 +52,8 @@ namespace WebCore {
virtual unsigned decodedSize() const { return 0; }
virtual IntSize size() const;
- virtual NativeImagePtr nativeImageForCurrentFrame();
- virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator);
+ virtual PassNativeImagePtr nativeImageForCurrentFrame();
+ virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode);
private:
StillImage(const QPixmap&);
diff --git a/Source/WebCore/platform/graphics/skia/BitmapImageSingleFrameSkia.cpp b/Source/WebCore/platform/graphics/skia/BitmapImageSingleFrameSkia.cpp
deleted file mode 100644
index 28ead8fba..000000000
--- a/Source/WebCore/platform/graphics/skia/BitmapImageSingleFrameSkia.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-#include "config.h"
-
-#include "BitmapImageSingleFrameSkia.h"
-
-namespace WebCore {
-
-bool BitmapImageSingleFrameSkia::isBitmapImage() const
-{
- return true;
-}
-
-bool BitmapImageSingleFrameSkia::currentFrameHasAlpha()
-{
- return !m_nativeImage.bitmap().isOpaque();
-}
-
-IntSize BitmapImageSingleFrameSkia::size() const
-{
- return IntSize(m_nativeImage.bitmap().width(), m_nativeImage.bitmap().height());
-}
-
-// Do nothing, as we only have the one representation of data (decoded).
-void BitmapImageSingleFrameSkia::destroyDecodedData(bool destroyAll)
-{
-
-}
-
-unsigned BitmapImageSingleFrameSkia::decodedSize() const
-{
- return m_nativeImage.decodedSize();
-}
-
-// We only have a single frame.
-NativeImagePtr BitmapImageSingleFrameSkia::nativeImageForCurrentFrame()
-{
- return &m_nativeImage;
-}
-
-#if !ASSERT_DISABLED
-bool BitmapImageSingleFrameSkia::notSolidColor()
-{
- return m_nativeImage.bitmap().width() != 1 || m_nativeImage.bitmap().height() != 1;
-}
-#endif
-
-} // namespace WebCore
-
diff --git a/Source/WebCore/platform/graphics/skia/BitmapImageSingleFrameSkia.h b/Source/WebCore/platform/graphics/skia/BitmapImageSingleFrameSkia.h
deleted file mode 100644
index f0d1192a3..000000000
--- a/Source/WebCore/platform/graphics/skia/BitmapImageSingleFrameSkia.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2006,2007,2008, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef BitmapImageSingleFrameSkia_h
-#define BitmapImageSingleFrameSkia_h
-
-#include "Image.h"
-#include "NativeImageSkia.h"
-
-namespace WebCore {
-
-// This image class can be used in places which need an Image, but have
-// raw pixel data rather than undecoded image data.
-// The Image is simpler than a BitmapImage, as it does not have image
-// observers, animation, multiple frames, or non-decoded data.
-// Therefore trimming the decoded data (destroyDecodedData()) has no effect.
-//
-// The difficulty with putting this in BitmapImage::create(NativeImagePtr)
-// is that NativeImagePtr = NativeImageSkia, yet callers have SkBitmap.
-class BitmapImageSingleFrameSkia : public Image {
-public:
- // Creates a new Image from the given SkBitmap. If "copyPixels" is true, a
- // deep copy is done. Otherwise, a shallow copy is done (pixel data is
- // ref'ed).
- static PassRefPtr<BitmapImageSingleFrameSkia> create(const SkBitmap&, bool copyPixels, float resolutionScale = 1);
-
- virtual bool isBitmapImage() const;
-
- virtual bool currentFrameHasAlpha();
-
- virtual IntSize size() const;
-
- // Do nothing, as we only have the one representation of data (decoded).
- virtual void destroyDecodedData(bool destroyAll = true);
-
- virtual unsigned decodedSize() const;
-
- // We only have a single frame.
- virtual NativeImagePtr nativeImageForCurrentFrame();
-
-#if !ASSERT_DISABLED
- virtual bool notSolidColor();
-#endif
-
-protected:
- virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator);
-
-private:
- NativeImageSkia m_nativeImage;
-
- // Creates a new Image from the given SkBitmap, using a shallow copy.
- BitmapImageSingleFrameSkia(const SkBitmap&, float resolutionScale);
-};
-
-FloatRect normalizeRect(const FloatRect&);
-
-} // namespace WebCore
-
-#endif // BitmapImageSingleFrameSkia_h
diff --git a/Source/WebCore/platform/graphics/skia/FloatPointSkia.cpp b/Source/WebCore/platform/graphics/skia/FloatPointSkia.cpp
deleted file mode 100644
index 054a7720b..000000000
--- a/Source/WebCore/platform/graphics/skia/FloatPointSkia.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2008, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FloatPoint.h"
-
-#include "SkPoint.h"
-#include "SkiaUtils.h"
-
-namespace WebCore {
-
-FloatPoint::FloatPoint(const SkPoint& p)
- : m_x(p.fX)
- , m_y(p.fY)
-{
-}
-
-FloatPoint::operator SkPoint() const
-{
- SkPoint p = { WebCoreFloatToSkScalar(m_x), WebCoreFloatToSkScalar(m_y) };
- return p;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/skia/FloatRectSkia.cpp b/Source/WebCore/platform/graphics/skia/FloatRectSkia.cpp
deleted file mode 100644
index 23045ba95..000000000
--- a/Source/WebCore/platform/graphics/skia/FloatRectSkia.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2008, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FloatRect.h"
-
-#include "SkRect.h"
-
-namespace WebCore {
-
-FloatRect::FloatRect(const SkRect& r)
- : m_location(r.fLeft, r.fTop)
- , m_size(r.width(), r.height())
-{
-}
-
-FloatRect::operator SkRect() const
-{
- SkRect rect = { x(), y(), maxX(), maxY() };
- return rect;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/skia/FontCacheSkia.cpp b/Source/WebCore/platform/graphics/skia/FontCacheSkia.cpp
deleted file mode 100644
index e59efa5d9..000000000
--- a/Source/WebCore/platform/graphics/skia/FontCacheSkia.cpp
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright (c) 2006, 2007, 2008, 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FontCache.h"
-#include "Font.h"
-#include "FontDescription.h"
-#include "FontFamily.h"
-#include "FontPlatformData.h"
-#include "Logging.h"
-#include "NotImplemented.h"
-#include "SimpleFontData.h"
-#include "SkPaint.h"
-#include "SkTypeface.h"
-#include "SkUtils.h"
-#include <unicode/locid.h>
-#include <wtf/Assertions.h>
-#include <wtf/text/AtomicString.h>
-#include <wtf/text/CString.h>
-
-namespace WebCore {
-
-void FontCache::platformInit()
-{
-}
-
-PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
-{
- icu::Locale locale = icu::Locale::getDefault();
- FontCache::SimpleFontFamily family;
- FontCache::getFontFamilyForCharacters(characters, length, locale.getLanguage(), &family);
- if (family.name.isEmpty())
- return 0;
-
- AtomicString atomicFamily(family.name);
- // Changes weight and/or italic of given FontDescription depends on
- // the result of fontconfig so that keeping the correct font mapping
- // of the given characters. See http://crbug.com/32109 for details.
- bool shouldSetFakeBold = false;
- bool shouldSetFakeItalic = false;
- FontDescription description(font.fontDescription());
- if (family.isBold && description.weight() < FontWeightBold)
- description.setWeight(FontWeightBold);
- if (!family.isBold && description.weight() >= FontWeightBold) {
- shouldSetFakeBold = true;
- description.setWeight(FontWeightNormal);
- }
- if (family.isItalic && description.italic() == FontItalicOff)
- description.setItalic(FontItalicOn);
- if (!family.isItalic && description.italic() == FontItalicOn) {
- shouldSetFakeItalic = true;
- description.setItalic(FontItalicOff);
- }
-
- FontPlatformData* substitutePlatformData = getCachedFontPlatformData(description, atomicFamily, DoNotRetain);
- if (!substitutePlatformData)
- return 0;
- FontPlatformData platformData = FontPlatformData(*substitutePlatformData);
- platformData.setFakeBold(shouldSetFakeBold);
- platformData.setFakeItalic(shouldSetFakeItalic);
- return getCachedFontData(&platformData, DoNotRetain);
-}
-
-PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font& font)
-{
- return 0;
-}
-
-PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& description, ShouldRetain shouldRetain)
-{
- DEFINE_STATIC_LOCAL(const AtomicString, sansStr, ("Sans", AtomicString::ConstructFromLiteral));
- DEFINE_STATIC_LOCAL(const AtomicString, serifStr, ("Serif", AtomicString::ConstructFromLiteral));
- DEFINE_STATIC_LOCAL(const AtomicString, monospaceStr, ("Monospace", AtomicString::ConstructFromLiteral));
-
- FontPlatformData* fontPlatformData = 0;
- switch (description.genericFamily()) {
- case FontDescription::SerifFamily:
- fontPlatformData = getCachedFontPlatformData(description, serifStr);
- break;
- case FontDescription::MonospaceFamily:
- fontPlatformData = getCachedFontPlatformData(description, monospaceStr);
- break;
- case FontDescription::SansSerifFamily:
- default:
- fontPlatformData = getCachedFontPlatformData(description, sansStr);
- break;
- }
-
- if (!fontPlatformData) {
- // we should at least have Arial; this is the SkFontHost_fontconfig last resort fallback
- DEFINE_STATIC_LOCAL(const AtomicString, arialStr, ("Arial", AtomicString::ConstructFromLiteral));
- fontPlatformData = getCachedFontPlatformData(description, arialStr);
- }
-
- ASSERT(fontPlatformData);
- return getCachedFontData(fontPlatformData, shouldRetain);
-}
-
-void FontCache::getTraitsInFamily(const AtomicString& familyName,
- Vector<unsigned>& traitsMasks)
-{
- notImplemented();
-}
-
-FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription,
- const AtomicString& family)
-{
- const char* name = 0;
- CString s;
-
- // If we're creating a fallback font (e.g. "-webkit-monospace"), convert the name into
- // the fallback name (like "monospace") that fontconfig understands.
- if (!family.length() || family.startsWith("-webkit-")) {
- static const struct {
- FontDescription::GenericFamilyType mType;
- const char* mName;
- } fontDescriptions[] = {
- { FontDescription::SerifFamily, "serif" },
- { FontDescription::SansSerifFamily, "sans-serif" },
- { FontDescription::MonospaceFamily, "monospace" },
- { FontDescription::CursiveFamily, "cursive" },
- { FontDescription::FantasyFamily, "fantasy" }
- };
-
- FontDescription::GenericFamilyType type = fontDescription.genericFamily();
- for (unsigned i = 0; i < SK_ARRAY_COUNT(fontDescriptions); i++) {
- if (type == fontDescriptions[i].mType) {
- name = fontDescriptions[i].mName;
- break;
- }
- }
- if (!name)
- name = "";
- } else {
- // convert the name to utf8
- s = family.string().utf8();
- name = s.data();
- }
-
- int style = SkTypeface::kNormal;
- if (fontDescription.weight() >= FontWeightBold)
- style |= SkTypeface::kBold;
- if (fontDescription.italic())
- style |= SkTypeface::kItalic;
-
- SkTypeface* tf = SkTypeface::CreateFromName(name, static_cast<SkTypeface::Style>(style));
- if (!tf)
- return 0;
-
- FontPlatformData* result =
- new FontPlatformData(tf,
- name,
- fontDescription.computedSize(),
- (style & SkTypeface::kBold) && !tf->isBold(),
- (style & SkTypeface::kItalic) && !tf->isItalic(),
- fontDescription.orientation(),
- fontDescription.textOrientation());
- tf->unref();
- return result;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/skia/FontCustomPlatformData.cpp b/Source/WebCore/platform/graphics/skia/FontCustomPlatformData.cpp
deleted file mode 100644
index 3e1b99221..000000000
--- a/Source/WebCore/platform/graphics/skia/FontCustomPlatformData.cpp
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Computer, Inc.
- * Copyright (c) 2007, 2008, 2009, Google Inc. All rights reserved.
- * Copyright (C) 2010 Company 100, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FontCustomPlatformData.h"
-
-#if OS(WINDOWS)
-#include "OpenTypeUtilities.h"
-#elif OS(UNIX)
-#include "SkStream.h"
-#endif
-
-#include "FontPlatformData.h"
-#include "LayoutTestSupport.h"
-#include "NotImplemented.h"
-#include "OpenTypeSanitizer.h"
-#include "SharedBuffer.h"
-
-#if OS(WINDOWS)
-#include <objbase.h>
-#include <wtf/text/Base64.h>
-#elif OS(UNIX)
-#include <cstring>
-#endif
-
-namespace WebCore {
-
-FontCustomPlatformData::~FontCustomPlatformData()
-{
-#if OS(WINDOWS)
- if (m_fontReference)
- RemoveFontMemResourceEx(m_fontReference);
-#elif OS(UNIX)
- if (m_fontReference)
- m_fontReference->unref();
-#endif
-}
-
-FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation orientation,
- TextOrientation textOrientation, FontWidthVariant, FontRenderingMode mode)
-{
-#if OS(WINDOWS)
- ASSERT(m_fontReference);
-
- LOGFONT logFont;
- // m_name comes from createUniqueFontName, which, in turn, gets
- // it from base64-encoded uuid (128-bit). So, m_name
- // can never be longer than LF_FACESIZE (32).
- if (m_name.length() + 1 >= LF_FACESIZE) {
- ASSERT_NOT_REACHED();
- return FontPlatformData();
- }
- memcpy(logFont.lfFaceName, m_name.charactersWithNullTermination(),
- sizeof(logFont.lfFaceName[0]) * (1 + m_name.length()));
-
- // FIXME: almost identical to FillLogFont in FontCacheWin.cpp.
- // Need to refactor.
- logFont.lfHeight = -size;
- logFont.lfWidth = 0;
- logFont.lfEscapement = 0;
- logFont.lfOrientation = 0;
- logFont.lfUnderline = false;
- logFont.lfStrikeOut = false;
- logFont.lfCharSet = DEFAULT_CHARSET;
- logFont.lfOutPrecision = OUT_TT_ONLY_PRECIS;
- logFont.lfQuality = isRunningLayoutTest() ?
- NONANTIALIASED_QUALITY :
- DEFAULT_QUALITY; // Honor user's desktop settings.
- logFont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
- logFont.lfItalic = italic;
- logFont.lfWeight = bold ? FW_BOLD : FW_DONTCARE;
-
- HFONT hfont = CreateFontIndirect(&logFont);
- return FontPlatformData(hfont, size, orientation);
-#elif OS(UNIX)
- ASSERT(m_fontReference);
- return FontPlatformData(m_fontReference, "", size, bold && !m_fontReference->isBold(), italic && !m_fontReference->isItalic(), orientation, textOrientation);
-#else
- notImplemented();
- return FontPlatformData();
-#endif
-}
-
-#if OS(WINDOWS)
-// Creates a unique and unpredictable font name, in order to avoid collisions and to
-// not allow access from CSS.
-static String createUniqueFontName()
-{
- GUID fontUuid;
- CoCreateGuid(&fontUuid);
-
- String fontName = base64Encode(reinterpret_cast<char*>(&fontUuid), sizeof(fontUuid));
- ASSERT(fontName.length() < LF_FACESIZE);
- return fontName;
-}
-#endif
-
-#if OS(UNIX)
-class RemoteFontStream : public SkStream {
-public:
- explicit RemoteFontStream(PassRefPtr<SharedBuffer> buffer)
- : m_buffer(buffer)
- , m_offset(0)
- {
- }
-
- virtual ~RemoteFontStream()
- {
- }
-
- virtual bool rewind()
- {
- m_offset = 0;
- return true;
- }
-
- virtual size_t read(void* buffer, size_t size)
- {
- if (!buffer && !size) {
- // This is request for the length of the stream.
- return m_buffer->size();
- }
- // This is a request to read bytes or skip bytes (when buffer is 0).
- if (!m_buffer->data() || !m_buffer->size())
- return 0;
- size_t left = m_buffer->size() - m_offset;
- size_t bytesToConsume = std::min(left, size);
- if (buffer)
- std::memcpy(buffer, m_buffer->data() + m_offset, bytesToConsume);
- m_offset += bytesToConsume;
- return bytesToConsume;
- }
-
-private:
- RefPtr<SharedBuffer> m_buffer;
- size_t m_offset;
-};
-#endif
-
-FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
-{
- ASSERT_ARG(buffer, buffer);
-
-#if USE(OPENTYPE_SANITIZER)
- OpenTypeSanitizer sanitizer(buffer);
- RefPtr<SharedBuffer> transcodeBuffer = sanitizer.sanitize();
- if (!transcodeBuffer)
- return 0; // validation failed.
- buffer = transcodeBuffer.get();
-#endif
-
-#if OS(WINDOWS)
- // Introduce the font to GDI. AddFontMemResourceEx should be used with care, because it will pollute the process's
- // font namespace (Windows has no API for creating an HFONT from data without exposing the font to the
- // entire process first).
- String fontName = createUniqueFontName();
- HANDLE fontReference = renameAndActivateFont(buffer, fontName);
- if (!fontReference)
- return 0;
- return new FontCustomPlatformData(fontReference, fontName);
-#elif OS(UNIX)
- RemoteFontStream* stream = new RemoteFontStream(buffer);
- SkTypeface* typeface = SkTypeface::CreateFromStream(stream);
- stream->unref();
- if (!typeface)
- return 0;
- return new FontCustomPlatformData(typeface);
-#else
- notImplemented();
- return 0;
-#endif
-}
-
-bool FontCustomPlatformData::supportsFormat(const String& format)
-{
- return equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "opentype")
-#if USE(OPENTYPE_SANITIZER)
- || equalIgnoringCase(format, "woff")
-#endif
- ;
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/skia/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/skia/FontCustomPlatformData.h
deleted file mode 100644
index 371baee44..000000000
--- a/Source/WebCore/platform/graphics/skia/FontCustomPlatformData.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Computer, Inc.
- * Copyright (c) 2007, 2008, 2009, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef FontCustomPlatformData_h
-#define FontCustomPlatformData_h
-
-#include "FontOrientation.h"
-#include "FontRenderingMode.h"
-#include "FontWidthVariant.h"
-#include "TextOrientation.h"
-#include <wtf/Forward.h>
-#include <wtf/Noncopyable.h>
-
-#if OS(WINDOWS)
-#include <windows.h>
-#include <wtf/text/WTFString.h>
-#elif OS(UNIX)
-#include "SkTypeface.h"
-#endif
-
-namespace WebCore {
-
-class FontPlatformData;
-class SharedBuffer;
-
-struct FontCustomPlatformData {
- WTF_MAKE_NONCOPYABLE(FontCustomPlatformData);
-public:
-#if OS(WINDOWS)
- FontCustomPlatformData(HANDLE fontReference, const String& name)
- : m_fontReference(fontReference)
- , m_name(name)
- {}
-#elif OS(UNIX)
- explicit FontCustomPlatformData(SkTypeface* typeface)
- : m_fontReference(typeface)
- {}
-#endif
-
- ~FontCustomPlatformData();
-
- FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation = Horizontal, TextOrientation = TextOrientationVerticalRight,
- FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode);
-
- static bool supportsFormat(const String&);
-
-#if OS(WINDOWS)
- HANDLE m_fontReference;
- String m_name;
-#elif OS(UNIX)
- SkTypeface* m_fontReference;
-#endif
-};
-
-FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer*);
-}
-
-#endif // FontCustomPlatformData_h
diff --git a/Source/WebCore/platform/graphics/skia/FontSkia.cpp b/Source/WebCore/platform/graphics/skia/FontSkia.cpp
deleted file mode 100644
index 655a74bb8..000000000
--- a/Source/WebCore/platform/graphics/skia/FontSkia.cpp
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright (c) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Font.h"
-
-#include "FontSmoothingMode.h"
-#include "GlyphBuffer.h"
-#include "GraphicsContext.h"
-#include "LayoutTestSupport.h"
-#include "PlatformContextSkia.h"
-#include "SimpleFontData.h"
-
-#include "SkCanvas.h"
-#include "SkPaint.h"
-#include "SkTypeface.h"
-#include "SkTypeface_mac.h"
-
-namespace WebCore {
-
-bool Font::canReturnFallbackFontsForComplexText()
-{
- return true;
-}
-
-bool Font::canExpandAroundIdeographsInComplexText()
-{
- return true;
-}
-
-static void setupPaint(SkPaint* paint, const SimpleFontData* fontData, const Font* font, bool shouldAntialias, bool shouldSmoothFonts)
-{
- const FontPlatformData& platformData = fontData->platformData();
- const float textSize = platformData.m_size >= 0 ? platformData.m_size : 12;
-
- paint->setAntiAlias(shouldAntialias);
- paint->setEmbeddedBitmapText(false);
- paint->setTextSize(SkFloatToScalar(textSize));
- paint->setVerticalText(platformData.orientation() == Vertical);
- SkTypeface* typeface = SkCreateTypefaceFromCTFont(platformData.ctFont());
- SkAutoUnref autoUnref(typeface);
- paint->setTypeface(typeface);
- paint->setFakeBoldText(platformData.m_syntheticBold);
- paint->setTextSkewX(platformData.m_syntheticOblique ? -SK_Scalar1 / 4 : 0);
- paint->setAutohinted(false); // freetype specific
- paint->setLCDRenderText(shouldSmoothFonts);
- paint->setSubpixelText(true);
-
-#if OS(DARWIN)
- // When using CoreGraphics, disable hinting when webkit-font-smoothing:antialiased is used.
- // See crbug.com/152304
- if (font->fontDescription().fontSmoothing() == Antialiased)
- paint->setHinting(SkPaint::kNo_Hinting);
-#endif
-
- if (font->fontDescription().textRenderingMode() == GeometricPrecision)
- paint->setHinting(SkPaint::kNo_Hinting);
-}
-
-// TODO: This needs to be split into helper functions to better scope the
-// inputs/outputs, and reduce duplicate code.
-// This issue is tracked in https://bugs.webkit.org/show_bug.cgi?id=62989
-void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
- const GlyphBuffer& glyphBuffer, int from, int numGlyphs,
- const FloatPoint& point) const {
- COMPILE_ASSERT(sizeof(GlyphBufferGlyph) == sizeof(uint16_t), GlyphBufferGlyphSize_equals_uint16_t);
-
- bool shouldSmoothFonts = true;
- bool shouldAntialias = true;
-
- switch (fontDescription().fontSmoothing()) {
- case Antialiased:
- shouldSmoothFonts = false;
- break;
- case SubpixelAntialiased:
- break;
- case NoSmoothing:
- shouldAntialias = false;
- shouldSmoothFonts = false;
- break;
- case AutoSmoothing:
- // For the AutoSmooth case, don't do anything! Keep the default settings.
- break;
- }
-
- if (!shouldUseSmoothing() || isRunningLayoutTest())
- shouldSmoothFonts = false;
-
- const GlyphBufferGlyph* glyphs = glyphBuffer.glyphs(from);
- SkScalar x = SkFloatToScalar(point.x());
- SkScalar y = SkFloatToScalar(point.y());
-
- if (font->platformData().orientation() == Vertical)
- y += SkFloatToScalar(font->fontMetrics().floatAscent(IdeographicBaseline) - font->fontMetrics().floatAscent());
- // FIXME: text rendering speed:
- // Android has code in their WebCore fork to special case when the
- // GlyphBuffer has no advances other than the defaults. In that case the
- // text drawing can proceed faster. However, it's unclear when those
- // patches may be upstreamed to WebKit so we always use the slower path
- // here.
- const GlyphBufferAdvance* adv = glyphBuffer.advances(from);
- SkAutoSTMalloc<32, SkPoint> storage(numGlyphs);
- SkPoint* pos = storage.get();
-
- for (int i = 0; i < numGlyphs; i++) {
- pos[i].set(x, y);
- x += SkFloatToScalar(adv[i].width());
- y += SkFloatToScalar(adv[i].height());
- }
-
- PlatformContextSkia* platformContext = gc->platformContext();
- if (font->platformData().orientation() == Vertical) {
- platformContext->save();
- platformContext->rotate(-90);
- SkMatrix rotator;
- rotator.reset();
- rotator.setRotate(90);
- rotator.mapPoints(pos, numGlyphs);
- }
- TextDrawingModeFlags textMode = gc->platformContext()->getTextDrawingMode();
-
- // We draw text up to two times (once for fill, once for stroke).
- if (textMode & TextModeFill) {
- SkPaint paint;
- gc->platformContext()->setupPaintForFilling(&paint);
- setupPaint(&paint, font, this, shouldAntialias, shouldSmoothFonts);
- gc->platformContext()->adjustTextRenderMode(&paint);
- paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
-
- platformContext->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, paint);
- }
-
- if ((textMode & TextModeStroke)
- && gc->platformContext()->getStrokeStyle() != NoStroke
- && gc->platformContext()->getStrokeThickness() > 0) {
-
- SkPaint paint;
- gc->platformContext()->setupPaintForStroking(&paint, 0, 0);
- setupPaint(&paint, font, this, shouldAntialias, shouldSmoothFonts);
- gc->platformContext()->adjustTextRenderMode(&paint);
- paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
-
- if (textMode & TextModeFill) {
- // If we also filled, we don't want to draw shadows twice.
- // See comment in FontChromiumWin.cpp::paintSkiaText() for more details.
- paint.setLooper(0);
- }
-
- platformContext->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, paint);
- }
- if (font->platformData().orientation() == Vertical)
- platformContext->restore();
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/skia/GlyphPageTreeNodeSkia.cpp b/Source/WebCore/platform/graphics/skia/GlyphPageTreeNodeSkia.cpp
deleted file mode 100644
index 6024d43df..000000000
--- a/Source/WebCore/platform/graphics/skia/GlyphPageTreeNodeSkia.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2008, 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "GlyphPageTreeNode.h"
-
-#include "Font.h"
-#include "SimpleFontData.h"
-
-#include "SkTemplates.h"
-#include "SkPaint.h"
-#include "SkUtils.h"
-
-namespace WebCore {
-
-bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData)
-{
- if (SkUTF16_IsHighSurrogate(buffer[bufferLength-1])) {
- SkDebugf("%s last char is high-surrogate", __FUNCTION__);
- return false;
- }
-
- SkPaint paint;
- fontData->platformData().setupPaint(&paint);
- paint.setTextEncoding(SkPaint::kUTF16_TextEncoding);
-
- SkAutoSTMalloc <GlyphPage::size, uint16_t> glyphStorage(length);
- uint16_t* glyphs = glyphStorage.get();
- // textToGlyphs takes a byte count, not a glyph count so we multiply by two.
- unsigned count = paint.textToGlyphs(buffer, bufferLength * 2, glyphs);
- if (count != length) {
- SkDebugf("%s count != length\n", __FUNCTION__);
- return false;
- }
-
- unsigned allGlyphs = 0; // track if any of the glyphIDs are non-zero
- for (unsigned i = 0; i < length; i++) {
- setGlyphDataForIndex(offset + i, glyphs[i], glyphs[i] ? fontData : NULL);
- allGlyphs |= glyphs[i];
- }
-
- return allGlyphs != 0;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/skia/GradientSkia.cpp b/Source/WebCore/platform/graphics/skia/GradientSkia.cpp
deleted file mode 100644
index e7008e015..000000000
--- a/Source/WebCore/platform/graphics/skia/GradientSkia.cpp
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright (c) 2008, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Gradient.h"
-
-#include "CSSParser.h"
-#include "GraphicsContext.h"
-
-#include "SkColorShader.h"
-#include "SkGradientShader.h"
-#include "SkiaUtils.h"
-
-namespace WebCore {
-
-void Gradient::platformDestroy()
-{
- SkSafeUnref(m_gradient);
- m_gradient = 0;
-}
-
-static inline U8CPU F2B(float x)
-{
- return static_cast<int>(x * 255);
-}
-
-static SkColor makeSkColor(float a, float r, float g, float b)
-{
- return SkColorSetARGB(F2B(a), F2B(r), F2B(g), F2B(b));
-}
-
-// Determine the total number of stops needed, including pseudo-stops at the
-// ends as necessary.
-static size_t totalStopsNeeded(const Gradient::ColorStop* stopData, size_t count)
-{
- // N.B.: The tests in this function should kept in sync with the ones in
- // fillStops(), or badness happens.
- const Gradient::ColorStop* stop = stopData;
- size_t countUsed = count;
- if (count < 1 || stop->stop > 0.0)
- countUsed++;
- stop += count - 1;
- if (count < 1 || stop->stop < 1.0)
- countUsed++;
- return countUsed;
-}
-
-// Collect sorted stop position and color information into the pos and colors
-// buffers, ensuring stops at both 0.0 and 1.0. The buffers must be large
-// enough to hold information for all stops, including the new endpoints if
-// stops at 0.0 and 1.0 aren't already included.
-static void fillStops(const Gradient::ColorStop* stopData,
- size_t count, SkScalar* pos, SkColor* colors)
-{
- const Gradient::ColorStop* stop = stopData;
- size_t start = 0;
- if (count < 1) {
- // A gradient with no stops must be transparent black.
- pos[0] = WebCoreFloatToSkScalar(0.0);
- colors[0] = makeSkColor(0.0, 0.0, 0.0, 0.0);
- start = 1;
- } else if (stop->stop > 0.0) {
- // Copy the first stop to 0.0. The first stop position may have a slight
- // rounding error, but we don't care in this float comparison, since
- // 0.0 comes through cleanly and people aren't likely to want a gradient
- // with a stop at (0 + epsilon).
- pos[0] = WebCoreFloatToSkScalar(0.0);
- colors[0] = makeSkColor(stop->alpha, stop->red, stop->green, stop->blue);
- start = 1;
- }
-
- for (size_t i = start; i < start + count; i++) {
- pos[i] = WebCoreFloatToSkScalar(stop->stop);
- colors[i] = makeSkColor(stop->alpha, stop->red, stop->green, stop->blue);
- ++stop;
- }
-
- // Copy the last stop to 1.0 if needed. See comment above about this float
- // comparison.
- if (count < 1 || (--stop)->stop < 1.0) {
- pos[start + count] = WebCoreFloatToSkScalar(1.0);
- colors[start + count] = colors[start + count - 1];
- }
-}
-
-SkShader* Gradient::platformGradient()
-{
- if (m_gradient)
- return m_gradient;
-
- sortStopsIfNecessary();
- ASSERT(m_stopsSorted);
-
- size_t countUsed = totalStopsNeeded(m_stops.data(), m_stops.size());
- ASSERT(countUsed >= 2);
- ASSERT(countUsed >= m_stops.size());
-
- // FIXME: Why is all this manual pointer math needed?!
- SkAutoMalloc storage(countUsed * (sizeof(SkColor) + sizeof(SkScalar)));
- SkColor* colors = (SkColor*)storage.get();
- SkScalar* pos = (SkScalar*)(colors + countUsed);
-
- fillStops(m_stops.data(), m_stops.size(), pos, colors);
-
- SkShader::TileMode tile = SkShader::kClamp_TileMode;
- switch (m_spreadMethod) {
- case SpreadMethodReflect:
- tile = SkShader::kMirror_TileMode;
- break;
- case SpreadMethodRepeat:
- tile = SkShader::kRepeat_TileMode;
- break;
- case SpreadMethodPad:
- tile = SkShader::kClamp_TileMode;
- break;
- }
-
- if (m_radial) {
- // Since the two-point radial gradient is slower than the plain radial,
- // only use it if we have to.
- if (m_p0 == m_p1 && m_r0 <= 0.0f) {
- m_gradient = SkGradientShader::CreateRadial(m_p1, m_r1, colors, pos, static_cast<int>(countUsed), tile);
- } else {
- // The radii we give to Skia must be positive. If we're given a
- // negative radius, ask for zero instead.
- SkScalar radius0 = m_r0 >= 0.0f ? WebCoreFloatToSkScalar(m_r0) : 0;
- SkScalar radius1 = m_r1 >= 0.0f ? WebCoreFloatToSkScalar(m_r1) : 0;
- m_gradient = SkGradientShader::CreateTwoPointConical(m_p0, radius0, m_p1, radius1, colors, pos, static_cast<int>(countUsed), tile);
- }
-
- if (aspectRatio() != 1) {
- // CSS3 elliptical gradients: apply the elliptical scaling at the
- // gradient center point.
- m_gradientSpaceTransformation.translate(m_p0.x(), m_p0.y());
- m_gradientSpaceTransformation.scale(1, 1 / aspectRatio());
- m_gradientSpaceTransformation.translate(-m_p0.x(), -m_p0.y());
- ASSERT(m_p0 == m_p1);
- }
- } else {
- SkPoint pts[2] = { m_p0, m_p1 };
- m_gradient = SkGradientShader::CreateLinear(pts, colors, pos, static_cast<int>(countUsed), tile);
- }
-
- if (!m_gradient)
- // use last color, since our "geometry" was degenerate (e.g. radius==0)
- m_gradient = new SkColorShader(colors[countUsed - 1]);
- else
- m_gradient->setLocalMatrix(m_gradientSpaceTransformation);
- return m_gradient;
-}
-
-void Gradient::fill(GraphicsContext* context, const FloatRect& rect)
-{
- context->setFillGradient(this);
- context->fillRect(rect);
-}
-
-void Gradient::setPlatformGradientSpaceTransform(const AffineTransform& matrix)
-{
- if (m_gradient)
- m_gradient->setLocalMatrix(m_gradientSpaceTransformation);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/skia/GraphicsContext3DSkia.cpp b/Source/WebCore/platform/graphics/skia/GraphicsContext3DSkia.cpp
deleted file mode 100644
index fea6adce3..000000000
--- a/Source/WebCore/platform/graphics/skia/GraphicsContext3DSkia.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
- * Copyright (C) 2010 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if USE(3D_GRAPHICS)
-
-#include "GraphicsContext3D.h"
-
-#include "BitmapImage.h"
-#include "Image.h"
-#include "ImageDecoder.h"
-#include "NativeImageSkia.h"
-#include "SkColorPriv.h"
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-
-#include <algorithm>
-
-namespace WebCore {
-
-bool GraphicsContext3D::getImageData(Image* image,
- GC3Denum format,
- GC3Denum type,
- bool premultiplyAlpha,
- bool ignoreGammaAndColorProfile,
- Vector<uint8_t>& outputVector)
-{
- if (!image)
- return false;
- OwnPtr<NativeImageSkia> pixels;
- NativeImageSkia* skiaImage = image->nativeImageForCurrentFrame();
- AlphaOp neededAlphaOp = AlphaDoNothing;
- bool hasAlpha = skiaImage ? !skiaImage->bitmap().isOpaque() : true;
- if ((!skiaImage || ignoreGammaAndColorProfile || (hasAlpha && !premultiplyAlpha)) && image->data()) {
- // Attempt to get raw unpremultiplied image data.
- OwnPtr<ImageDecoder> decoder(adoptPtr(ImageDecoder::create(
- *(image->data()), ImageSource::AlphaNotPremultiplied,
- ignoreGammaAndColorProfile ? ImageSource::GammaAndColorProfileIgnored : ImageSource::GammaAndColorProfileApplied)));
- if (!decoder)
- return false;
- decoder->setData(image->data(), true);
- if (!decoder->frameCount())
- return false;
- ImageFrame* frame = decoder->frameBufferAtIndex(0);
- if (!frame || frame->status() != ImageFrame::FrameComplete)
- return false;
- hasAlpha = frame->hasAlpha();
- pixels = adoptPtr(frame->asNewNativeImage());
- if (!pixels.get() || !pixels->isDataComplete() || !pixels->bitmap().width() || !pixels->bitmap().height())
- return false;
- SkBitmap::Config skiaConfig = pixels->bitmap().config();
- if (skiaConfig != SkBitmap::kARGB_8888_Config)
- return false;
- skiaImage = pixels.get();
- if (hasAlpha && premultiplyAlpha)
- neededAlphaOp = AlphaDoPremultiply;
- } else if (!premultiplyAlpha && hasAlpha)
- neededAlphaOp = AlphaDoUnmultiply;
- if (!skiaImage)
- return false;
- const SkBitmap& skiaImageRef = skiaImage->bitmap();
- SkAutoLockPixels lock(skiaImageRef);
- ASSERT(skiaImageRef.rowBytes() == skiaImageRef.width() * 4);
- unsigned int packedSize;
- // Output data is tightly packed (alignment == 1).
- if (computeImageSizeInBytes(format, type, skiaImageRef.width(), skiaImageRef.height(), 1, &packedSize, 0) != GraphicsContext3D::NO_ERROR)
- return false;
- outputVector.resize(packedSize);
- return packPixels(reinterpret_cast<const uint8_t*>(skiaImageRef.getPixels()),
- SK_B32_SHIFT ? SourceFormatRGBA8 : SourceFormatBGRA8,
- skiaImageRef.width(), skiaImageRef.height(), 0,
- format, type, neededAlphaOp, outputVector.data());
-}
-
-} // namespace WebCore
-
-#endif // USE(3D_GRAPHICS)
diff --git a/Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp b/Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp
deleted file mode 100644
index ad4898336..000000000
--- a/Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp
+++ /dev/null
@@ -1,1217 +0,0 @@
-/*
- * Copyright (c) 2006, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "GraphicsContext.h"
-
-#include "AffineTransform.h"
-#include "Color.h"
-#include "FloatRect.h"
-#include "Gradient.h"
-#include "ImageBuffer.h"
-#include "IntRect.h"
-#include "KURL.h"
-#include "NativeImageSkia.h"
-#include "NotImplemented.h"
-#include "PlatformContextSkia.h"
-
-#include "SkAnnotation.h"
-#include "SkBitmap.h"
-#include "SkBlurMaskFilter.h"
-#include "SkColorFilter.h"
-#include "SkCornerPathEffect.h"
-#include "SkData.h"
-#include "SkLayerDrawLooper.h"
-#include "SkShader.h"
-#include "SkiaUtils.h"
-#include "skia/ext/platform_canvas.h"
-
-#include <math.h>
-#include <wtf/Assertions.h>
-#include <wtf/MathExtras.h>
-#include <wtf/UnusedParam.h>
-
-#if PLATFORM(CHROMIUM) && OS(DARWIN)
-#include <ApplicationServices/ApplicationServices.h>
-#endif
-
-using namespace std;
-
-namespace WebCore {
-
-namespace {
-
-// Return value % max, but account for value possibly being negative.
-inline int fastMod(int value, int max)
-{
- bool isNeg = false;
- if (value < 0) {
- value = -value;
- isNeg = true;
- }
- if (value >= max)
- value %= max;
- if (isNeg)
- value = -value;
- return value;
-}
-
-} // namespace
-
-// Local helper functions ------------------------------------------------------
-
-void addCornerArc(SkPath* path, const SkRect& rect, const IntSize& size, int startAngle)
-{
- SkIRect ir;
- int rx = SkMin32(SkScalarRound(rect.width()), size.width());
- int ry = SkMin32(SkScalarRound(rect.height()), size.height());
-
- ir.set(-rx, -ry, rx, ry);
- switch (startAngle) {
- case 0:
- ir.offset(rect.fRight - ir.fRight, rect.fBottom - ir.fBottom);
- break;
- case 90:
- ir.offset(rect.fLeft - ir.fLeft, rect.fBottom - ir.fBottom);
- break;
- case 180:
- ir.offset(rect.fLeft - ir.fLeft, rect.fTop - ir.fTop);
- break;
- case 270:
- ir.offset(rect.fRight - ir.fRight, rect.fTop - ir.fTop);
- break;
- default:
- ASSERT(0);
- }
-
- SkRect r;
- r.set(ir);
- path->arcTo(r, SkIntToScalar(startAngle), SkIntToScalar(90), false);
-}
-
-void draw2xMarker(SkBitmap* bitmap, int index)
-{
-
- static const SkPMColor lineColors[2] = {
- SkPreMultiplyARGB(0xFF, 0xFF, 0x00, 0x00), // Opaque red.
- SkPreMultiplyARGB(0xFF, 0xC0, 0xC0, 0xC0), // Opaque gray.
- };
- static const SkPMColor antiColors1[2] = {
- SkPreMultiplyARGB(0xB0, 0xFF, 0x00, 0x00), // Semitransparent red
- SkPreMultiplyARGB(0xB0, 0xC0, 0xC0, 0xC0), // Semitransparent gray
- };
- static const SkPMColor antiColors2[2] = {
- SkPreMultiplyARGB(0x60, 0xFF, 0x00, 0x00), // More transparent red
- SkPreMultiplyARGB(0x60, 0xC0, 0xC0, 0xC0), // More transparent gray
- };
-
- const SkPMColor lineColor = lineColors[index];
- const SkPMColor antiColor1 = antiColors1[index];
- const SkPMColor antiColor2 = antiColors2[index];
-
- uint32_t* row1 = bitmap->getAddr32(0, 0);
- uint32_t* row2 = bitmap->getAddr32(0, 1);
- uint32_t* row3 = bitmap->getAddr32(0, 2);
- uint32_t* row4 = bitmap->getAddr32(0, 3);
-
- // Pattern: X0o o0X0o o0
- // XX0o o0XXX0o o0X
- // o0XXX0o o0XXX0o
- // o0X0o o0X0o
- const SkPMColor row1Color[] = { lineColor, antiColor1, antiColor2, 0, 0, 0, antiColor2, antiColor1 };
- const SkPMColor row2Color[] = { lineColor, lineColor, antiColor1, antiColor2, 0, antiColor2, antiColor1, lineColor };
- const SkPMColor row3Color[] = { 0, antiColor2, antiColor1, lineColor, lineColor, lineColor, antiColor1, antiColor2 };
- const SkPMColor row4Color[] = { 0, 0, antiColor2, antiColor1, lineColor, antiColor1, antiColor2, 0 };
-
- for (int x = 0; x < bitmap->width() + 8; x += 8) {
- int count = min(bitmap->width() - x, 8);
- if (count > 0) {
- memcpy(row1 + x, row1Color, count * sizeof(SkPMColor));
- memcpy(row2 + x, row2Color, count * sizeof(SkPMColor));
- memcpy(row3 + x, row3Color, count * sizeof(SkPMColor));
- memcpy(row4 + x, row4Color, count * sizeof(SkPMColor));
- }
- }
-}
-
-void draw1xMarker(SkBitmap* bitmap, int index)
-{
- static const uint32_t lineColors[2] = {
- 0xFF << SK_A32_SHIFT | 0xFF << SK_R32_SHIFT, // Opaque red.
- 0xFF << SK_A32_SHIFT | 0xC0 << SK_R32_SHIFT | 0xC0 << SK_G32_SHIFT | 0xC0 << SK_B32_SHIFT, // Opaque gray.
- };
- static const uint32_t antiColors[2] = {
- 0x60 << SK_A32_SHIFT | 0x60 << SK_R32_SHIFT, // Semitransparent red
- 0xFF << SK_A32_SHIFT | 0xC0 << SK_R32_SHIFT | 0xC0 << SK_G32_SHIFT | 0xC0 << SK_B32_SHIFT, // Semitransparent gray
- };
-
- const uint32_t lineColor = lineColors[index];
- const uint32_t antiColor = antiColors[index];
-
- // Pattern: X o o X o o X
- // o X o o X o
- uint32_t* row1 = bitmap->getAddr32(0, 0);
- uint32_t* row2 = bitmap->getAddr32(0, 1);
- for (int x = 0; x < bitmap->width(); x++) {
- switch (x % 4) {
- case 0:
- row1[x] = lineColor;
- break;
- case 1:
- row1[x] = antiColor;
- row2[x] = antiColor;
- break;
- case 2:
- row2[x] = lineColor;
- break;
- case 3:
- row1[x] = antiColor;
- row2[x] = antiColor;
- break;
- }
- }
-}
-
-// -----------------------------------------------------------------------------
-
-// This may be called with a NULL pointer to create a graphics context that has
-// no painting.
-void GraphicsContext::platformInit(PlatformGraphicsContext* gc)
-{
- if (gc)
- gc->setGraphicsContext(this);
-
- // the caller owns the gc
- m_data = gc;
- setPaintingDisabled(!gc || !gc->canvas());
-}
-
-void GraphicsContext::platformDestroy()
-{
-}
-
-PlatformGraphicsContext* GraphicsContext::platformContext() const
-{
- ASSERT(!paintingDisabled());
- return m_data;
-}
-
-// State saving ----------------------------------------------------------------
-
-void GraphicsContext::savePlatformState()
-{
- if (paintingDisabled())
- return;
-
- // Save our private State.
- platformContext()->save();
-}
-
-void GraphicsContext::restorePlatformState()
-{
- if (paintingDisabled())
- return;
-
- // Restore our private State.
- platformContext()->restore();
-}
-
-void GraphicsContext::beginPlatformTransparencyLayer(float opacity)
-{
- if (paintingDisabled())
- return;
-
- // We need the "alpha" layer flag here because the base layer is opaque
- // (the surface of the page) but layers on top may have transparent parts.
- // Without explicitly setting the alpha flag, the layer will inherit the
- // opaque setting of the base and some things won't work properly.
- SkCanvas::SaveFlags saveFlags = static_cast<SkCanvas::SaveFlags>(SkCanvas::kHasAlphaLayer_SaveFlag | SkCanvas::kFullColorLayer_SaveFlag);
-
- SkPaint layerPaint;
- layerPaint.setAlpha(static_cast<unsigned char>(opacity * 255));
- layerPaint.setXfermodeMode(platformContext()->getXfermodeMode());
-
- platformContext()->saveLayer(0, &layerPaint, saveFlags);
-}
-
-void GraphicsContext::endPlatformTransparencyLayer()
-{
- if (paintingDisabled())
- return;
- platformContext()->restoreLayer();
-}
-
-bool GraphicsContext::supportsTransparencyLayers()
-{
- return true;
-}
-
-// Graphics primitives ---------------------------------------------------------
-
-void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness)
-{
- if (paintingDisabled())
- return;
-
- SkRect r(rect);
- SkPath path;
- path.addOval(r, SkPath::kCW_Direction);
- // only perform the inset if we won't invert r
- if (2 * thickness < rect.width() && 2 * thickness < rect.height()) {
- // Adding one to the thickness doesn't make the border too thick as
- // it's painted over afterwards. But without this adjustment the
- // border appears a little anemic after anti-aliasing.
- r.inset(SkIntToScalar(thickness + 1), SkIntToScalar(thickness + 1));
- path.addOval(r, SkPath::kCCW_Direction);
- }
- platformContext()->clipPath(path, PlatformContextSkia::AntiAliased);
-}
-
-void GraphicsContext::clearPlatformShadow()
-{
- if (paintingDisabled())
- return;
- platformContext()->setDrawLooper(0);
-}
-
-void GraphicsContext::clearRect(const FloatRect& rect)
-{
- if (paintingDisabled())
- return;
-
- SkRect r = rect;
- SkPaint paint;
- platformContext()->setupPaintForFilling(&paint);
- paint.setXfermodeMode(SkXfermode::kClear_Mode);
- platformContext()->drawRect(r, paint);
-}
-
-void GraphicsContext::clip(const FloatRect& rect)
-{
- if (paintingDisabled())
- return;
-
- platformContext()->clipRect(rect);
-}
-
-void GraphicsContext::clip(const Path& path)
-{
- if (paintingDisabled() || path.isEmpty())
- return;
-
- platformContext()->clipPath(*path.platformPath(), PlatformContextSkia::AntiAliased);
-}
-
-void GraphicsContext::canvasClip(const Path& path)
-{
- if (paintingDisabled())
- return;
-
- platformContext()->canvasClipPath(path.isNull() ? SkPath() : *path.platformPath());
-}
-
-void GraphicsContext::clipOut(const IntRect& rect)
-{
- if (paintingDisabled())
- return;
-
- platformContext()->clipRect(rect, PlatformContextSkia::NotAntiAliased, SkRegion::kDifference_Op);
-}
-
-void GraphicsContext::clipOut(const Path& p)
-{
- if (paintingDisabled())
- return;
-
- // We must make a copy of the path, to mark it as inverse-filled.
- SkPath path(p.isNull() ? SkPath() : *p.platformPath());
- path.toggleInverseFillType();
- platformContext()->clipPath(path, PlatformContextSkia::AntiAliased);
-}
-
-void GraphicsContext::clipPath(const Path& pathToClip, WindRule clipRule)
-{
- if (paintingDisabled())
- return;
-
- const SkPath* path = pathToClip.platformPath();
- SkPath::FillType ftype = (clipRule == RULE_EVENODD) ? SkPath::kEvenOdd_FillType : SkPath::kWinding_FillType;
- SkPath storage;
- if (!path)
- path = &storage;
- else if (path->getFillType() != ftype) {
- storage = *path;
- storage.setFillType(ftype);
- path = &storage;
- }
- platformContext()->clipPath(*path, PlatformContextSkia::AntiAliased);
-}
-
-void GraphicsContext::concatCTM(const AffineTransform& affine)
-{
- if (paintingDisabled())
- return;
-
- platformContext()->concat(affine);
-}
-
-void GraphicsContext::setCTM(const AffineTransform& affine)
-{
- if (paintingDisabled())
- return;
-
- platformContext()->setMatrix(affine);
-}
-
-static void setPathFromConvexPoints(SkPath* path, size_t numPoints, const FloatPoint* points)
-{
- path->incReserve(numPoints);
- path->moveTo(WebCoreFloatToSkScalar(points[0].x()),
- WebCoreFloatToSkScalar(points[0].y()));
- for (size_t i = 1; i < numPoints; ++i) {
- path->lineTo(WebCoreFloatToSkScalar(points[i].x()),
- WebCoreFloatToSkScalar(points[i].y()));
- }
-
- /* The code used to just blindly call this
- path->setIsConvex(true);
- But webkit can sometimes send us non-convex 4-point values, so we mark the path's
- convexity as unknown, so it will get computed by skia at draw time.
- See crbug.com 108605
- */
- SkPath::Convexity convexity = SkPath::kConvex_Convexity;
- if (numPoints == 4)
- convexity = SkPath::kUnknown_Convexity;
- path->setConvexity(convexity);
-}
-
-void GraphicsContext::drawConvexPolygon(size_t numPoints,
- const FloatPoint* points,
- bool shouldAntialias)
-{
- if (paintingDisabled())
- return;
-
- if (numPoints <= 1)
- return;
-
- SkPath path;
- setPathFromConvexPoints(&path, numPoints, points);
-
- SkPaint paint;
- platformContext()->setupPaintForFilling(&paint);
- paint.setAntiAlias(shouldAntialias);
- platformContext()->drawPath(path, paint);
-
- if (strokeStyle() != NoStroke) {
- paint.reset();
- platformContext()->setupPaintForStroking(&paint, 0, 0);
- platformContext()->drawPath(path, paint);
- }
-}
-
-void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* points, bool antialiased)
-{
- if (paintingDisabled())
- return;
-
- if (numPoints <= 1)
- return;
-
- SkPath path;
- setPathFromConvexPoints(&path, numPoints, points);
- platformContext()->clipPath(path, antialiased
- ? PlatformContextSkia::AntiAliased
- : PlatformContextSkia::NotAntiAliased);
-}
-
-// This method is only used to draw the little circles used in lists.
-void GraphicsContext::drawEllipse(const IntRect& elipseRect)
-{
- if (paintingDisabled())
- return;
-
- SkRect rect = elipseRect;
- SkPaint paint;
- platformContext()->setupPaintForFilling(&paint);
- platformContext()->drawOval(rect, paint);
-
- if (strokeStyle() != NoStroke) {
- paint.reset();
- platformContext()->setupPaintForStroking(&paint, &rect, 0);
- platformContext()->drawOval(rect, paint);
- }
-}
-
-void GraphicsContext::drawFocusRing(const Path& path, int width, int offset, const Color& color)
-{
- // FIXME: implement
-}
-
-static inline void drawOuterPath(PlatformContextSkia* context, const SkPath& path, SkPaint& paint, int width)
-{
-#if PLATFORM(CHROMIUM) && OS(DARWIN)
- paint.setAlpha(64);
- paint.setStrokeWidth(width);
- paint.setPathEffect(new SkCornerPathEffect((width - 1) * 0.5f))->unref();
-#else
- paint.setStrokeWidth(1);
- paint.setPathEffect(new SkCornerPathEffect(1))->unref();
-#endif
- context->drawPath(path, paint);
-}
-
-static inline void drawInnerPath(PlatformContextSkia* context, const SkPath& path, SkPaint& paint, int width)
-{
-#if PLATFORM(CHROMIUM) && OS(DARWIN)
- paint.setAlpha(128);
- paint.setStrokeWidth(width * 0.5f);
- context->drawPath(path, paint);
-#endif
-}
-
-static inline int getFocusRingOutset(int offset)
-{
-#if PLATFORM(CHROMIUM) && OS(DARWIN)
- return offset + 2;
-#else
- return 0;
-#endif
-}
-
-void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int offset, const Color& color)
-{
- if (paintingDisabled())
- return;
-
- unsigned rectCount = rects.size();
- if (!rectCount)
- return;
-
- SkRegion focusRingRegion;
- const int focusRingOutset = getFocusRingOutset(offset);
- for (unsigned i = 0; i < rectCount; i++) {
- SkIRect r = rects[i];
- r.inset(-focusRingOutset, -focusRingOutset);
- focusRingRegion.op(r, SkRegion::kUnion_Op);
- }
-
- SkPath path;
- SkPaint paint;
- paint.setAntiAlias(true);
- paint.setStyle(SkPaint::kStroke_Style);
-
- paint.setColor(color.rgb());
- focusRingRegion.getBoundaryPath(&path);
- drawOuterPath(platformContext(), path, paint, width);
- drawInnerPath(platformContext(), path, paint, width);
-}
-
-// This is only used to draw borders.
-void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2)
-{
- if (paintingDisabled())
- return;
-
- StrokeStyle penStyle = strokeStyle();
- if (penStyle == NoStroke)
- return;
-
- SkPaint paint;
- FloatPoint p1 = point1;
- FloatPoint p2 = point2;
- bool isVerticalLine = (p1.x() == p2.x());
- int width = roundf(strokeThickness());
-
- // We know these are vertical or horizontal lines, so the length will just
- // be the sum of the displacement component vectors give or take 1 -
- // probably worth the speed up of no square root, which also won't be exact.
- FloatSize disp = p2 - p1;
- int length = SkScalarRound(disp.width() + disp.height());
- platformContext()->setupPaintForStroking(&paint, 0, length);
-
- if (strokeStyle() == DottedStroke || strokeStyle() == DashedStroke) {
- // Do a rect fill of our endpoints. This ensures we always have the
- // appearance of being a border. We then draw the actual dotted/dashed line.
-
- SkRect r1, r2;
- r1.set(p1.x(), p1.y(), p1.x() + width, p1.y() + width);
- r2.set(p2.x(), p2.y(), p2.x() + width, p2.y() + width);
-
- if (isVerticalLine) {
- r1.offset(-width / 2, 0);
- r2.offset(-width / 2, -width);
- } else {
- r1.offset(0, -width / 2);
- r2.offset(-width, -width / 2);
- }
- SkPaint fillPaint;
- fillPaint.setColor(paint.getColor());
- platformContext()->drawRect(r1, fillPaint);
- platformContext()->drawRect(r2, fillPaint);
- }
-
- adjustLineToPixelBoundaries(p1, p2, width, penStyle);
- SkPoint pts[2] = { (SkPoint)p1, (SkPoint)p2 };
-
- platformContext()->drawPoints(SkCanvas::kLines_PointMode, 2, pts, paint);
-}
-
-void GraphicsContext::drawLineForDocumentMarker(const FloatPoint& pt, float width, DocumentMarkerLineStyle style)
-{
- if (paintingDisabled())
- return;
-
- int deviceScaleFactor = SkScalarRoundToInt(WebCoreFloatToSkScalar(platformContext()->deviceScaleFactor()));
- ASSERT(deviceScaleFactor == 1 || deviceScaleFactor == 2);
-
- // Create the pattern we'll use to draw the underline.
- int index = style == DocumentMarkerGrammarLineStyle ? 1 : 0;
- static SkBitmap* misspellBitmap1x[2] = { 0, 0 };
- static SkBitmap* misspellBitmap2x[2] = { 0, 0 };
- SkBitmap** misspellBitmap = deviceScaleFactor == 2 ? misspellBitmap2x : misspellBitmap1x;
- if (!misspellBitmap[index]) {
-#if PLATFORM(CHROMIUM) && OS(DARWIN)
- // Match the artwork used by the Mac.
- const int rowPixels = 4 * deviceScaleFactor;
- const int colPixels = 3 * deviceScaleFactor;
- misspellBitmap[index] = new SkBitmap;
- misspellBitmap[index]->setConfig(SkBitmap::kARGB_8888_Config,
- rowPixels, colPixels);
- misspellBitmap[index]->allocPixels();
-
- misspellBitmap[index]->eraseARGB(0, 0, 0, 0);
- const uint32_t transparentColor = 0x00000000;
-
- if (deviceScaleFactor == 1) {
- const uint32_t colors[2][6] = {
- { 0x2A2A0600, 0x57571000, 0xA8A81B00, 0xBFBF1F00, 0x70701200, 0xE0E02400 },
- { 0x2A001503, 0x57002A08, 0xA800540D, 0xBF005F0F, 0x70003809, 0xE0007012 }
- };
-
- // Pattern: a b a a b a
- // c d c c d c
- // e f e e f e
- for (int x = 0; x < colPixels; ++x) {
- uint32_t* row = misspellBitmap[index]->getAddr32(0, x);
- row[0] = colors[index][x * 2];
- row[1] = colors[index][x * 2 + 1];
- row[2] = colors[index][x * 2];
- row[3] = transparentColor;
- }
- } else if (deviceScaleFactor == 2) {
- const uint32_t colors[2][18] = {
- { 0x0a090101, 0x33320806, 0x55540f0a, 0x37360906, 0x6e6c120c, 0x6e6c120c, 0x7674140d, 0x8d8b1810, 0x8d8b1810,
- 0x96941a11, 0xb3b01f15, 0xb3b01f15, 0x6d6b130c, 0xd9d62619, 0xd9d62619, 0x19180402, 0x7c7a150e, 0xcecb2418 },
- { 0x0a000400, 0x33031b06, 0x55062f0b, 0x37041e06, 0x6e083d0d, 0x6e083d0d, 0x7608410e, 0x8d094e11, 0x8d094e11,
- 0x960a5313, 0xb30d6417, 0xb30d6417, 0x6d073c0d, 0xd90f781c, 0xd90f781c, 0x19010d03, 0x7c094510, 0xce0f731a }
- };
-
- // Pattern: a b c c b a
- // d e f f e d
- // g h j j h g
- // k l m m l k
- // n o p p o n
- // q r s s r q
- for (int x = 0; x < colPixels; ++x) {
- uint32_t* row = misspellBitmap[index]->getAddr32(0, x);
- row[0] = colors[index][x * 3];
- row[1] = colors[index][x * 3 + 1];
- row[2] = colors[index][x * 3 + 2];
- row[3] = colors[index][x * 3 + 2];
- row[4] = colors[index][x * 3 + 1];
- row[5] = colors[index][x * 3];
- row[6] = transparentColor;
- row[7] = transparentColor;
- }
- } else
- ASSERT_NOT_REACHED();
-#else
- // We use a 2-pixel-high misspelling indicator because that seems to be
- // what WebKit is designed for, and how much room there is in a typical
- // page for it.
- const int rowPixels = 32 * deviceScaleFactor; // Must be multiple of 4 for pattern below.
- const int colPixels = 2 * deviceScaleFactor;
- misspellBitmap[index] = new SkBitmap;
- misspellBitmap[index]->setConfig(SkBitmap::kARGB_8888_Config, rowPixels, colPixels);
- misspellBitmap[index]->allocPixels();
-
- misspellBitmap[index]->eraseARGB(0, 0, 0, 0);
- if (deviceScaleFactor == 1)
- draw1xMarker(misspellBitmap[index], index);
- else if (deviceScaleFactor == 2)
- draw2xMarker(misspellBitmap[index], index);
- else
- ASSERT_NOT_REACHED();
-#endif
- }
-
-#if PLATFORM(CHROMIUM) && OS(DARWIN)
- SkScalar originX = WebCoreFloatToSkScalar(pt.x()) * deviceScaleFactor;
- SkScalar originY = WebCoreFloatToSkScalar(pt.y()) * deviceScaleFactor;
-
- // Make sure to draw only complete dots.
- int rowPixels = misspellBitmap[index]->width();
- float widthMod = fmodf(width * deviceScaleFactor, rowPixels);
- if (rowPixels - widthMod > deviceScaleFactor)
- width -= widthMod / deviceScaleFactor;
-#else
- SkScalar originX = WebCoreFloatToSkScalar(pt.x());
-
- // Offset it vertically by 1 so that there's some space under the text.
- SkScalar originY = WebCoreFloatToSkScalar(pt.y()) + 1;
- originX *= deviceScaleFactor;
- originY *= deviceScaleFactor;
-#endif
-
- // Make a shader for the bitmap with an origin of the box we'll draw. This
- // shader is refcounted and will have an initial refcount of 1.
- SkShader* shader = SkShader::CreateBitmapShader(
- *misspellBitmap[index], SkShader::kRepeat_TileMode,
- SkShader::kRepeat_TileMode);
- SkMatrix matrix;
- matrix.setTranslate(originX, originY);
- shader->setLocalMatrix(matrix);
-
- // Assign the shader to the paint & release our reference. The paint will
- // now own the shader and the shader will be destroyed when the paint goes
- // out of scope.
- SkPaint paint;
- paint.setShader(shader)->unref();
-
- SkRect rect;
- rect.set(originX, originY, originX + WebCoreFloatToSkScalar(width) * deviceScaleFactor, originY + SkIntToScalar(misspellBitmap[index]->height()));
-
- if (deviceScaleFactor == 2) {
- platformContext()->save();
- platformContext()->scale(SK_ScalarHalf, SK_ScalarHalf);
- }
- platformContext()->drawRect(rect, paint);
- if (deviceScaleFactor == 2)
- platformContext()->restore();
-}
-
-void GraphicsContext::drawLineForText(const FloatPoint& pt,
- float width,
- bool printing)
-{
- if (paintingDisabled())
- return;
-
- if (width <= 0)
- return;
-
- int thickness = SkMax32(static_cast<int>(strokeThickness()), 1);
- SkRect r;
- r.fLeft = WebCoreFloatToSkScalar(pt.x());
- // Avoid anti-aliasing lines. Currently, these are always horizontal.
- r.fTop = WebCoreFloatToSkScalar(floorf(pt.y()));
- r.fRight = r.fLeft + WebCoreFloatToSkScalar(width);
- r.fBottom = r.fTop + SkIntToScalar(thickness);
-
- SkPaint paint;
- platformContext()->setupPaintForFilling(&paint);
- // Text lines are drawn using the stroke color.
- paint.setColor(platformContext()->effectiveStrokeColor());
- platformContext()->drawRect(r, paint);
-}
-
-// Draws a filled rectangle with a stroked border.
-void GraphicsContext::drawRect(const IntRect& rect)
-{
- if (paintingDisabled())
- return;
-
- ASSERT(!rect.isEmpty());
- if (rect.isEmpty())
- return;
-
- platformContext()->drawRect(rect);
-}
-
-void GraphicsContext::fillPath(const Path& pathToFill)
-{
- if (paintingDisabled() || pathToFill.isEmpty())
- return;
-
- const GraphicsContextState& state = m_state;
- SkPath::FillType ftype = state.fillRule == RULE_EVENODD ?
- SkPath::kEvenOdd_FillType : SkPath::kWinding_FillType;
-
- const SkPath* path = pathToFill.platformPath();
- SkPath storage;
- if (path->getFillType() != ftype) {
- storage = *path;
- storage.setFillType(ftype);
- path = &storage;
- }
-
- SkPaint paint;
- platformContext()->setupPaintForFilling(&paint);
-
- platformContext()->drawPath(*path, paint);
-}
-
-void GraphicsContext::fillRect(const FloatRect& rect)
-{
- if (paintingDisabled())
- return;
-
- SkRect r = rect;
-
- SkPaint paint;
- platformContext()->setupPaintForFilling(&paint);
- platformContext()->drawRect(r, paint);
-}
-
-void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorSpace colorSpace)
-{
- if (paintingDisabled())
- return;
-
- SkRect r = rect;
- SkPaint paint;
- platformContext()->setupPaintCommon(&paint);
- paint.setColor(color.rgb());
- platformContext()->drawRect(r, paint);
-}
-
-void GraphicsContext::fillRoundedRect(const IntRect& rect,
- const IntSize& topLeft,
- const IntSize& topRight,
- const IntSize& bottomLeft,
- const IntSize& bottomRight,
- const Color& color,
- ColorSpace colorSpace)
-{
- if (paintingDisabled())
- return;
-
- if (topLeft.width() + topRight.width() > rect.width()
- || bottomLeft.width() + bottomRight.width() > rect.width()
- || topLeft.height() + bottomLeft.height() > rect.height()
- || topRight.height() + bottomRight.height() > rect.height()) {
- // Not all the radii fit, return a rect. This matches the behavior of
- // Path::createRoundedRectangle. Without this we attempt to draw a round
- // shadow for a square box.
- fillRect(rect, color, colorSpace);
- return;
- }
-
- SkRect r = rect;
- SkPath path;
- addCornerArc(&path, r, topRight, 270);
- addCornerArc(&path, r, bottomRight, 0);
- addCornerArc(&path, r, bottomLeft, 90);
- addCornerArc(&path, r, topLeft, 180);
-
- SkPaint paint;
- platformContext()->setupPaintForFilling(&paint);
- paint.setColor(color.rgb());
- platformContext()->drawPath(path, paint);
-}
-
-AffineTransform GraphicsContext::getCTM(IncludeDeviceScale) const
-{
- if (paintingDisabled())
- return AffineTransform();
-
- const SkMatrix& m = platformContext()->getTotalMatrix();
- return AffineTransform(SkScalarToDouble(m.getScaleX()),
- SkScalarToDouble(m.getSkewY()),
- SkScalarToDouble(m.getSkewX()),
- SkScalarToDouble(m.getScaleY()),
- SkScalarToDouble(m.getTranslateX()),
- SkScalarToDouble(m.getTranslateY()));
-}
-
-FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect, RoundingMode)
-{
- return rect;
-}
-
-void GraphicsContext::scale(const FloatSize& size)
-{
- if (paintingDisabled())
- return;
-
- platformContext()->scale(WebCoreFloatToSkScalar(size.width()),
- WebCoreFloatToSkScalar(size.height()));
-}
-
-void GraphicsContext::setAlpha(float alpha)
-{
- if (paintingDisabled())
- return;
-
- platformContext()->setAlpha(alpha);
-}
-
-void GraphicsContext::setPlatformCompositeOperation(CompositeOperator op)
-{
- if (paintingDisabled())
- return;
-
- platformContext()->setXfermodeMode(WebCoreCompositeToSkiaComposite(op));
-}
-
-InterpolationQuality GraphicsContext::imageInterpolationQuality() const
-{
- return platformContext()->interpolationQuality();
-}
-
-void GraphicsContext::setImageInterpolationQuality(InterpolationQuality q)
-{
- platformContext()->setInterpolationQuality(q);
-}
-
-void GraphicsContext::setLineCap(LineCap cap)
-{
- if (paintingDisabled())
- return;
- switch (cap) {
- case ButtCap:
- platformContext()->setLineCap(SkPaint::kButt_Cap);
- break;
- case RoundCap:
- platformContext()->setLineCap(SkPaint::kRound_Cap);
- break;
- case SquareCap:
- platformContext()->setLineCap(SkPaint::kSquare_Cap);
- break;
- default:
- ASSERT(0);
- break;
- }
-}
-
-void GraphicsContext::setLineDash(const DashArray& dashes, float dashOffset)
-{
- if (paintingDisabled())
- return;
-
- // FIXME: This is lifted directly off SkiaSupport, lines 49-74
- // so it is not guaranteed to work correctly.
- size_t dashLength = dashes.size();
- if (!dashLength) {
- // If no dash is set, revert to solid stroke
- // FIXME: do we need to set NoStroke in some cases?
- platformContext()->setStrokeStyle(SolidStroke);
- platformContext()->setDashPathEffect(0);
- return;
- }
-
- size_t count = !(dashLength % 2) ? dashLength : dashLength * 2;
- SkScalar* intervals = new SkScalar[count];
-
- for (unsigned int i = 0; i < count; i++)
- intervals[i] = dashes[i % dashLength];
-
- platformContext()->setDashPathEffect(new SkDashPathEffect(intervals, count, dashOffset));
-
- delete[] intervals;
-}
-
-void GraphicsContext::setLineJoin(LineJoin join)
-{
- if (paintingDisabled())
- return;
- switch (join) {
- case MiterJoin:
- platformContext()->setLineJoin(SkPaint::kMiter_Join);
- break;
- case RoundJoin:
- platformContext()->setLineJoin(SkPaint::kRound_Join);
- break;
- case BevelJoin:
- platformContext()->setLineJoin(SkPaint::kBevel_Join);
- break;
- default:
- ASSERT(0);
- break;
- }
-}
-
-void GraphicsContext::setMiterLimit(float limit)
-{
- if (paintingDisabled())
- return;
- platformContext()->setMiterLimit(limit);
-}
-
-void GraphicsContext::setPlatformFillColor(const Color& color, ColorSpace colorSpace)
-{
- if (paintingDisabled())
- return;
-
- platformContext()->setFillColor(color.rgb());
-}
-
-void GraphicsContext::setPlatformShadow(const FloatSize& size,
- float blurFloat,
- const Color& color,
- ColorSpace colorSpace)
-{
- if (paintingDisabled())
- return;
-
- // Detect when there's no effective shadow and clear the looper.
- if (!size.width() && !size.height() && !blurFloat) {
- platformContext()->setDrawLooper(0);
- return;
- }
-
- double width = size.width();
- double height = size.height();
- double blur = blurFloat;
-
- uint32_t mfFlags = SkBlurMaskFilter::kHighQuality_BlurFlag;
- SkXfermode::Mode colorMode = SkXfermode::kSrc_Mode;
-
- if (m_state.shadowsIgnoreTransforms) {
- // Currently only the GraphicsContext associated with the
- // CanvasRenderingContext for HTMLCanvasElement have shadows ignore
- // Transforms. So with this flag set, we know this state is associated
- // with a CanvasRenderingContext.
- mfFlags |= SkBlurMaskFilter::kIgnoreTransform_BlurFlag;
-
- // CSS wants us to ignore the original's alpha, but Canvas wants us to
- // modulate with it. Using shadowsIgnoreTransforms to tell us that we're
- // in a Canvas, we change the colormode to kDst_Mode, so we don't overwrite
- // it with our layer's (default opaque-black) color.
- colorMode = SkXfermode::kDst_Mode;
-
- // CG uses natural orientation for Y axis, but the HTML5 canvas spec
- // does not.
- // So we now flip the height since it was flipped in
- // CanvasRenderingContext in order to work with CG.
- height = -height;
- }
-
- SkColor c;
- if (color.isValid())
- c = color.rgb();
- else
- c = SkColorSetARGB(0xFF/3, 0, 0, 0); // "std" apple shadow color.
-
- // TODO(tc): Should we have a max value for the blur? CG clamps at 1000.0
- // for perf reasons.
-
- SkLayerDrawLooper* dl = new SkLayerDrawLooper;
- SkAutoUnref aur(dl);
-
- // top layer, we just draw unchanged
- dl->addLayer();
-
- // lower layer contains our offset, blur, and colorfilter
- SkLayerDrawLooper::LayerInfo info;
-
- info.fPaintBits |= SkLayerDrawLooper::kMaskFilter_Bit; // our blur
- info.fPaintBits |= SkLayerDrawLooper::kColorFilter_Bit;
- info.fColorMode = colorMode;
- info.fOffset.set(width, height);
- info.fPostTranslate = m_state.shadowsIgnoreTransforms;
-
- SkMaskFilter* mf = SkBlurMaskFilter::Create(blur / 2, SkBlurMaskFilter::kNormal_BlurStyle, mfFlags);
-
- SkColorFilter* cf = SkColorFilter::CreateModeFilter(c, SkXfermode::kSrcIn_Mode);
-
- SkPaint* paint = dl->addLayer(info);
- SkSafeUnref(paint->setMaskFilter(mf));
- SkSafeUnref(paint->setColorFilter(cf));
-
- // dl is now built, just install it
- platformContext()->setDrawLooper(dl);
-}
-
-void GraphicsContext::setPlatformStrokeColor(const Color& strokecolor, ColorSpace colorSpace)
-{
- if (paintingDisabled())
- return;
-
- platformContext()->setStrokeColor(strokecolor.rgb());
-}
-
-void GraphicsContext::setPlatformStrokeStyle(StrokeStyle stroke)
-{
- if (paintingDisabled())
- return;
-
- platformContext()->setStrokeStyle(stroke);
-}
-
-void GraphicsContext::setPlatformStrokeThickness(float thickness)
-{
- if (paintingDisabled())
- return;
-
- platformContext()->setStrokeThickness(thickness);
-}
-
-void GraphicsContext::setPlatformTextDrawingMode(TextDrawingModeFlags mode)
-{
- if (paintingDisabled())
- return;
-
- platformContext()->setTextDrawingMode(mode);
-}
-
-void GraphicsContext::setURLForRect(const KURL& link, const IntRect& destRect)
-{
- if (paintingDisabled())
- return;
-
- SkAutoDataUnref url(SkData::NewWithCString(link.string().utf8().data()));
- SkAnnotateRectWithURL(platformContext()->canvas(), destRect, url.get());
-}
-
-void GraphicsContext::setPlatformShouldAntialias(bool enable)
-{
- if (paintingDisabled())
- return;
-
- platformContext()->setUseAntialiasing(enable);
-}
-
-void GraphicsContext::strokeArc(const IntRect& r, int startAngle, int angleSpan)
-{
- if (paintingDisabled())
- return;
-
- SkPaint paint;
- SkRect oval = r;
- if (strokeStyle() == NoStroke) {
- // Stroke using the fill color.
- // TODO(brettw) is this really correct? It seems unreasonable.
- platformContext()->setupPaintForFilling(&paint);
- paint.setStyle(SkPaint::kStroke_Style);
- paint.setStrokeWidth(WebCoreFloatToSkScalar(strokeThickness()));
- } else
- platformContext()->setupPaintForStroking(&paint, 0, 0);
-
- // We do this before converting to scalar, so we don't overflow SkFixed.
- startAngle = fastMod(startAngle, 360);
- angleSpan = fastMod(angleSpan, 360);
-
- SkPath path;
- path.addArc(oval, SkIntToScalar(-startAngle), SkIntToScalar(-angleSpan));
- platformContext()->drawPath(path, paint);
-}
-
-void GraphicsContext::strokePath(const Path& pathToStroke)
-{
- if (paintingDisabled() || pathToStroke.isEmpty())
- return;
-
- const SkPath& path = *pathToStroke.platformPath();
- SkPaint paint;
- platformContext()->setupPaintForStroking(&paint, 0, 0);
- platformContext()->drawPath(path, paint);
-}
-
-void GraphicsContext::strokeRect(const FloatRect& rect, float lineWidth)
-{
- if (paintingDisabled())
- return;
-
- SkPaint paint;
- platformContext()->setupPaintForStroking(&paint, 0, 0);
- paint.setStrokeWidth(WebCoreFloatToSkScalar(lineWidth));
- // strokerect has special rules for CSS when the rect is degenerate:
- // if width==0 && height==0, do nothing
- // if width==0 || height==0, then just draw line for the other dimension
- SkRect r(rect);
- bool validW = r.width() > 0;
- bool validH = r.height() > 0;
- if (validW && validH) {
- platformContext()->drawRect(r, paint);
- } else if (validW || validH) {
- // we are expected to respect the lineJoin, so we can't just call
- // drawLine -- we have to create a path that doubles back on itself.
- SkPath path;
- path.moveTo(r.fLeft, r.fTop);
- path.lineTo(r.fRight, r.fBottom);
- path.close();
- platformContext()->drawPath(path, paint);
- }
-}
-
-void GraphicsContext::rotate(float angleInRadians)
-{
- if (paintingDisabled())
- return;
-
- platformContext()->rotate(WebCoreFloatToSkScalar(angleInRadians * (180.0f / 3.14159265f)));
-}
-
-void GraphicsContext::translate(float w, float h)
-{
- if (paintingDisabled())
- return;
-
- platformContext()->translate(WebCoreFloatToSkScalar(w), WebCoreFloatToSkScalar(h));
-}
-
-bool GraphicsContext::isAcceleratedContext() const
-{
- return platformContext()->isAccelerated();
-}
-
-#if PLATFORM(CHROMIUM) && OS(DARWIN)
-CGColorSpaceRef deviceRGBColorSpaceRef()
-{
- static CGColorSpaceRef deviceSpace = CGColorSpaceCreateDeviceRGB();
- return deviceSpace;
-}
-#endif
-
-void GraphicsContext::platformFillEllipse(const FloatRect& ellipse)
-{
- if (paintingDisabled())
- return;
-
- SkRect rect = ellipse;
- SkPaint paint;
- platformContext()->setupPaintForFilling(&paint);
- platformContext()->drawOval(rect, paint);
-}
-
-void GraphicsContext::platformStrokeEllipse(const FloatRect& ellipse)
-{
- if (paintingDisabled())
- return;
-
- SkRect rect(ellipse);
- SkPaint paint;
- platformContext()->setupPaintForStroking(&paint, 0, 0);
- platformContext()->drawOval(rect, paint);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp b/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
deleted file mode 100644
index 8b788650d..000000000
--- a/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
+++ /dev/null
@@ -1,400 +0,0 @@
-/*
- * Copyright (c) 2008, Google Inc. All rights reserved.
- * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
- * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ImageBuffer.h"
-
-#include "BitmapImage.h"
-#include "BitmapImageSingleFrameSkia.h"
-#include "Extensions3D.h"
-#include "GrContext.h"
-#include "GraphicsContext.h"
-#include "GraphicsContext3D.h"
-#include "ImageData.h"
-#include "JPEGImageEncoder.h"
-#include "MIMETypeRegistry.h"
-#include "MemoryInstrumentationSkia.h"
-#include "PNGImageEncoder.h"
-#include "PlatformContextSkia.h"
-#include "SharedGraphicsContext3D.h"
-#include "SkColorPriv.h"
-#include "SkGpuDevice.h"
-#include "SkiaUtils.h"
-#include "WEBPImageEncoder.h"
-
-#if USE(ACCELERATED_COMPOSITING)
-#include "Canvas2DLayerBridge.h"
-#endif
-
-#include <wtf/text/Base64.h>
-#include <wtf/text/WTFString.h>
-
-using namespace std;
-
-namespace WebCore {
-
-// We pass a technically-uninitialized canvas to the platform context here since
-// the canvas initialization completes in ImageBuffer::ImageBuffer. But
-// PlatformContext doesn't actually need to use the object, and this makes all
-// the ownership easier to manage.
-ImageBufferData::ImageBufferData(const IntSize& size)
- : m_platformContext(0) // Canvas is set in ImageBuffer constructor.
-{
-}
-
-static SkCanvas* createAcceleratedCanvas(const IntSize& size, ImageBufferData* data, DeferralMode deferralMode)
-{
- RefPtr<GraphicsContext3D> context3D = SharedGraphicsContext3D::get();
- if (!context3D)
- return 0;
- GrContext* gr = context3D->grContext();
- if (!gr)
- return 0;
- gr->resetContext();
- GrTextureDesc desc;
- desc.fFlags = kRenderTarget_GrTextureFlagBit;
- desc.fSampleCnt = 0;
- desc.fWidth = size.width();
- desc.fHeight = size.height();
- desc.fConfig = kSkia8888_GrPixelConfig;
- SkAutoTUnref<GrTexture> texture(gr->createUncachedTexture(desc, 0, 0));
- if (!texture.get())
- return 0;
- SkCanvas* canvas;
- SkAutoTUnref<SkDevice> device(new SkGpuDevice(gr, texture.get()));
-#if USE(ACCELERATED_COMPOSITING)
- data->m_layerBridge = Canvas2DLayerBridge::create(context3D.release(), size, deferralMode, texture.get()->getTextureHandle());
- canvas = data->m_layerBridge->skCanvas(device.get());
-#else
- canvas = new SkCanvas(device.get());
-#endif
- data->m_platformContext.setAccelerated(true);
- return canvas;
-}
-
-static SkCanvas* createNonPlatformCanvas(const IntSize& size)
-{
- SkAutoTUnref<SkDevice> device(new SkDevice(SkBitmap::kARGB_8888_Config, size.width(), size.height()));
- SkPixelRef* pixelRef = device->accessBitmap(false).pixelRef();
- return pixelRef ? new SkCanvas(device) : 0;
-}
-
-ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace, RenderingMode renderingMode, DeferralMode deferralMode, bool& success)
- : m_data(size)
- , m_size(size)
- , m_logicalSize(size)
- , m_resolutionScale(resolutionScale)
-{
- OwnPtr<SkCanvas> canvas;
-
- if (renderingMode == Accelerated)
- canvas = adoptPtr(createAcceleratedCanvas(size, &m_data, deferralMode));
- else if (renderingMode == UnacceleratedNonPlatformBuffer)
- canvas = adoptPtr(createNonPlatformCanvas(size));
-
- if (!canvas)
- canvas = adoptPtr(skia::TryCreateBitmapCanvas(size.width(), size.height(), false));
-
- if (!canvas) {
- success = false;
- return;
- }
-
- m_data.m_canvas = canvas.release();
- m_data.m_platformContext.setCanvas(m_data.m_canvas.get());
- m_context = adoptPtr(new GraphicsContext(&m_data.m_platformContext));
- m_context->platformContext()->setDrawingToImageBuffer(true);
- m_context->scale(FloatSize(m_resolutionScale, m_resolutionScale));
-
- // Make the background transparent. It would be nice if this wasn't
- // required, but the canvas is currently filled with the magic transparency
- // color. Can we have another way to manage this?
- m_data.m_canvas->drawARGB(0, 0, 0, 0, SkXfermode::kClear_Mode);
-
- success = true;
-}
-
-ImageBuffer::~ImageBuffer()
-{
-}
-
-GraphicsContext* ImageBuffer::context() const
-{
-#if USE(ACCELERATED_COMPOSITING)
- if (m_data.m_layerBridge) {
- // We're using context acquisition as a signal that someone is about to render into our buffer and we need
- // to be ready. This isn't logically const-correct, hence the cast.
- const_cast<Canvas2DLayerBridge*>(m_data.m_layerBridge.get())->contextAcquired();
- }
-#endif
- return m_context.get();
-}
-
-PassRefPtr<Image> ImageBuffer::copyImage(BackingStoreCopy copyBehavior, ScaleBehavior) const
-{
- // FIXME: Start honoring ScaleBehavior to scale 2x buffers down to 1x.
- return BitmapImageSingleFrameSkia::create(*m_data.m_platformContext.bitmap(), copyBehavior == CopyBackingStore, m_resolutionScale);
-}
-
-PlatformLayer* ImageBuffer::platformLayer() const
-{
- return m_data.m_layerBridge ? m_data.m_layerBridge->layer() : 0;
-}
-
-bool ImageBuffer::copyToPlatformTexture(GraphicsContext3D& context, Platform3DObject texture, GC3Denum internalFormat, bool premultiplyAlpha, bool flipY)
-{
- if (!m_data.m_layerBridge || !platformLayer())
- return false;
-
- Platform3DObject sourceTexture = m_data.m_layerBridge->backBufferTexture();
-
- if (!context.makeContextCurrent())
- return false;
-
- Extensions3D* extensions = context.getExtensions();
- if (!extensions->supports("GL_CHROMIUM_copy_texture") || !extensions->supports("GL_CHROMIUM_flipy"))
- return false;
-
- // The canvas is stored in a premultiplied format, so unpremultiply if necessary.
- context.pixelStorei(Extensions3D::UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, !premultiplyAlpha);
-
- // The canvas is stored in an inverted position, so the flip semantics are reversed.
- context.pixelStorei(Extensions3D::UNPACK_FLIP_Y_CHROMIUM, !flipY);
-
- extensions->copyTextureCHROMIUM(GraphicsContext3D::TEXTURE_2D, sourceTexture, texture, 0, internalFormat);
-
- context.pixelStorei(Extensions3D::UNPACK_FLIP_Y_CHROMIUM, false);
- context.pixelStorei(Extensions3D::UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, false);
- context.flush();
- return true;
-}
-
-void ImageBuffer::clip(GraphicsContext* context, const FloatRect& rect) const
-{
- context->platformContext()->beginLayerClippedToImage(rect, this);
-}
-
-static bool drawNeedsCopy(GraphicsContext* src, GraphicsContext* dst)
-{
- return dst->platformContext()->isDeferred() || src == dst;
-}
-
-void ImageBuffer::draw(GraphicsContext* context, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect,
- CompositeOperator op, bool useLowQualityScale)
-{
- RefPtr<Image> image = BitmapImageSingleFrameSkia::create(*m_data.m_platformContext.bitmap(), drawNeedsCopy(m_context.get(), context));
- context->drawImage(image.get(), styleColorSpace, destRect, srcRect, op, DoNotRespectImageOrientation, useLowQualityScale);
-}
-
-void ImageBuffer::drawPattern(GraphicsContext* context, const FloatRect& srcRect, const AffineTransform& patternTransform,
- const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect)
-{
- RefPtr<Image> image = BitmapImageSingleFrameSkia::create(*m_data.m_platformContext.bitmap(), drawNeedsCopy(m_context.get(), context));
- image->drawPattern(context, srcRect, patternTransform, phase, styleColorSpace, op, destRect);
-}
-
-void ImageBuffer::platformTransformColorSpace(const Vector<int>& lookUpTable)
-{
- // FIXME: Disable color space conversions on accelerated canvases (for now).
- if (m_data.m_platformContext.isAccelerated())
- return;
-
- const SkBitmap& bitmap = *context()->platformContext()->bitmap();
- if (bitmap.isNull())
- return;
-
- ASSERT(bitmap.config() == SkBitmap::kARGB_8888_Config);
- SkAutoLockPixels bitmapLock(bitmap);
- for (int y = 0; y < m_size.height(); ++y) {
- uint32_t* srcRow = bitmap.getAddr32(0, y);
- for (int x = 0; x < m_size.width(); ++x) {
- SkColor color = SkPMColorToColor(srcRow[x]);
- srcRow[x] = SkPreMultiplyARGB(SkColorGetA(color),
- lookUpTable[SkColorGetR(color)],
- lookUpTable[SkColorGetG(color)],
- lookUpTable[SkColorGetB(color)]);
- }
- }
-}
-
-template <Multiply multiplied>
-PassRefPtr<Uint8ClampedArray> getImageData(const IntRect& rect, PlatformContextSkia* context,
- const IntSize& size)
-{
- float area = 4.0f * rect.width() * rect.height();
- if (area > static_cast<float>(std::numeric_limits<int>::max()))
- return 0;
-
- RefPtr<Uint8ClampedArray> result = Uint8ClampedArray::createUninitialized(rect.width() * rect.height() * 4);
-
- unsigned char* data = result->data();
-
- if (rect.x() < 0
- || rect.y() < 0
- || rect.maxX() > size.width()
- || rect.maxY() > size.height())
- result->zeroFill();
-
- unsigned destBytesPerRow = 4 * rect.width();
- SkBitmap destBitmap;
- destBitmap.setConfig(SkBitmap::kARGB_8888_Config, rect.width(), rect.height(), destBytesPerRow);
- destBitmap.setPixels(data);
-
- SkCanvas::Config8888 config8888;
- if (multiplied == Premultiplied)
- config8888 = SkCanvas::kRGBA_Premul_Config8888;
- else
- config8888 = SkCanvas::kRGBA_Unpremul_Config8888;
-
- context->readPixels(&destBitmap, rect.x(), rect.y(), config8888);
- return result.release();
-}
-
-PassRefPtr<Uint8ClampedArray> ImageBuffer::getUnmultipliedImageData(const IntRect& rect, CoordinateSystem) const
-{
- return getImageData<Unmultiplied>(rect, context()->platformContext(), m_size);
-}
-
-PassRefPtr<Uint8ClampedArray> ImageBuffer::getPremultipliedImageData(const IntRect& rect, CoordinateSystem) const
-{
- return getImageData<Premultiplied>(rect, context()->platformContext(), m_size);
-}
-
-void ImageBuffer::putByteArray(Multiply multiplied, Uint8ClampedArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, CoordinateSystem)
-{
- ASSERT(sourceRect.width() > 0);
- ASSERT(sourceRect.height() > 0);
-
- int originX = sourceRect.x();
- int destX = destPoint.x() + sourceRect.x();
- ASSERT(destX >= 0);
- ASSERT(destX < m_size.width());
- ASSERT(originX >= 0);
- ASSERT(originX < sourceRect.maxX());
-
- int endX = destPoint.x() + sourceRect.maxX();
- ASSERT(endX <= m_size.width());
-
- int numColumns = endX - destX;
-
- int originY = sourceRect.y();
- int destY = destPoint.y() + sourceRect.y();
- ASSERT(destY >= 0);
- ASSERT(destY < m_size.height());
- ASSERT(originY >= 0);
- ASSERT(originY < sourceRect.maxY());
-
- int endY = destPoint.y() + sourceRect.maxY();
- ASSERT(endY <= m_size.height());
- int numRows = endY - destY;
-
- unsigned srcBytesPerRow = 4 * sourceSize.width();
- SkBitmap srcBitmap;
- srcBitmap.setConfig(SkBitmap::kARGB_8888_Config, numColumns, numRows, srcBytesPerRow);
- srcBitmap.setPixels(source->data() + originY * srcBytesPerRow + originX * 4);
-
- SkCanvas::Config8888 config8888;
- if (multiplied == Premultiplied)
- config8888 = SkCanvas::kRGBA_Premul_Config8888;
- else
- config8888 = SkCanvas::kRGBA_Unpremul_Config8888;
-
- context()->platformContext()->writePixels(srcBitmap, destX, destY, config8888);
-}
-
-template <typename T>
-static bool encodeImage(T& source, const String& mimeType, const double* quality, Vector<char>* output)
-{
- Vector<unsigned char>* encodedImage = reinterpret_cast<Vector<unsigned char>*>(output);
-
- if (mimeType == "image/jpeg") {
- int compressionQuality = JPEGImageEncoder::DefaultCompressionQuality;
- if (quality && *quality >= 0.0 && *quality <= 1.0)
- compressionQuality = static_cast<int>(*quality * 100 + 0.5);
- if (!JPEGImageEncoder::encode(source, compressionQuality, encodedImage))
- return false;
-#if USE(WEBP)
- } else if (mimeType == "image/webp") {
- int compressionQuality = WEBPImageEncoder::DefaultCompressionQuality;
- if (quality && *quality >= 0.0 && *quality <= 1.0)
- compressionQuality = static_cast<int>(*quality * 100 + 0.5);
- if (!WEBPImageEncoder::encode(source, compressionQuality, encodedImage))
- return false;
-#endif
- } else {
- if (!PNGImageEncoder::encode(source, encodedImage))
- return false;
- ASSERT(mimeType == "image/png");
- }
-
- return true;
-}
-
-String ImageBuffer::toDataURL(const String& mimeType, const double* quality, CoordinateSystem) const
-{
- ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType));
-
- Vector<char> encodedImage;
- if (!encodeImage(*context()->platformContext()->bitmap(), mimeType, quality, &encodedImage))
- return "data:,";
-
- Vector<char> base64Data;
- base64Encode(encodedImage, base64Data);
-
- return "data:" + mimeType + ";base64," + base64Data;
-}
-
-void ImageBufferData::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
-{
- MemoryClassInfo info(memoryObjectInfo, this);
- info.addMember(m_canvas);
- info.addMember(m_platformContext);
-#if USE(ACCELERATED_COMPOSITING)
- info.addMember(m_layerBridge);
-#endif
-}
-
-String ImageDataToDataURL(const ImageData& imageData, const String& mimeType, const double* quality)
-{
- ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType));
-
- Vector<char> encodedImage;
- if (!encodeImage(imageData, mimeType, quality, &encodedImage))
- return "data:,";
-
- Vector<char> base64Data;
- base64Encode(encodedImage, base64Data);
-
- return "data:" + mimeType + ";base64," + base64Data;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/skia/ImageSkia.cpp b/Source/WebCore/platform/graphics/skia/ImageSkia.cpp
deleted file mode 100644
index cccbd9007..000000000
--- a/Source/WebCore/platform/graphics/skia/ImageSkia.cpp
+++ /dev/null
@@ -1,684 +0,0 @@
-/*
- * Copyright (c) 2008, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "AffineTransform.h"
-#include "BitmapImage.h"
-#include "BitmapImageSingleFrameSkia.h"
-#include "FloatConversion.h"
-#include "FloatRect.h"
-#include "GraphicsContext.h"
-#include "ImageObserver.h"
-#include "Logging.h"
-#include "NativeImageSkia.h"
-#include "PlatformContextSkia.h"
-#include "SkBitmap.h"
-#include "SkPixelRef.h"
-#include "SkRect.h"
-#include "SkShader.h"
-#include "SkiaUtils.h"
-#include "Texture.h"
-#include <wtf/text/WTFString.h>
-
-#include "skia/ext/image_operations.h"
-#include "skia/ext/platform_canvas.h"
-
-#include <limits>
-#include <math.h>
-
-#if PLATFORM(CHROMIUM)
-#include "TraceEvent.h"
-#endif
-
-namespace WebCore {
-
-// Used by computeResamplingMode to tell how bitmaps should be resampled.
-enum ResamplingMode {
- // Nearest neighbor resampling. Used when we detect that the page is
- // trying to make a pattern by stretching a small bitmap very large.
- RESAMPLE_NONE,
-
- // Default skia resampling. Used for large growing of images where high
- // quality resampling doesn't get us very much except a slowdown.
- RESAMPLE_LINEAR,
-
- // High quality resampling.
- RESAMPLE_AWESOME,
-};
-
-static ResamplingMode computeResamplingMode(const SkMatrix& matrix, const NativeImageSkia& bitmap, float srcWidth, float srcHeight, float destWidth, float destHeight)
-{
- // The percent change below which we will not resample. This usually means
- // an off-by-one error on the web page, and just doing nearest neighbor
- // sampling is usually good enough.
- const float kFractionalChangeThreshold = 0.025f;
-
- // Images smaller than this in either direction are considered "small" and
- // are not resampled ever (see below).
- const int kSmallImageSizeThreshold = 8;
-
- // The amount an image can be stretched in a single direction before we
- // say that it is being stretched so much that it must be a line or
- // background that doesn't need resampling.
- const float kLargeStretch = 3.0f;
-
- // Figure out if we should resample this image. We try to prune out some
- // common cases where resampling won't give us anything, since it is much
- // slower than drawing stretched.
- float diffWidth = fabs(destWidth - srcWidth);
- float diffHeight = fabs(destHeight - srcHeight);
- bool widthNearlyEqual = diffWidth < std::numeric_limits<float>::epsilon();
- bool heightNearlyEqual = diffHeight < std::numeric_limits<float>::epsilon();
- // We don't need to resample if the source and destination are the same.
- if (widthNearlyEqual && heightNearlyEqual)
- return RESAMPLE_NONE;
-
- if (srcWidth <= kSmallImageSizeThreshold
- || srcHeight <= kSmallImageSizeThreshold
- || destWidth <= kSmallImageSizeThreshold
- || destHeight <= kSmallImageSizeThreshold) {
- // Never resample small images. These are often used for borders and
- // rules (think 1x1 images used to make lines).
- return RESAMPLE_NONE;
- }
-
- if (srcHeight * kLargeStretch <= destHeight || srcWidth * kLargeStretch <= destWidth) {
- // Large image detected.
-
- // Don't resample if it is being stretched a lot in only one direction.
- // This is trying to catch cases where somebody has created a border
- // (which might be large) and then is stretching it to fill some part
- // of the page.
- if (widthNearlyEqual || heightNearlyEqual)
- return RESAMPLE_NONE;
-
- // The image is growing a lot and in more than one direction. Resampling
- // is slow and doesn't give us very much when growing a lot.
- return RESAMPLE_LINEAR;
- }
-
- if ((diffWidth / srcWidth < kFractionalChangeThreshold)
- && (diffHeight / srcHeight < kFractionalChangeThreshold)) {
- // It is disappointingly common on the web for image sizes to be off by
- // one or two pixels. We don't bother resampling if the size difference
- // is a small fraction of the original size.
- return RESAMPLE_NONE;
- }
-
- // When the image is not yet done loading, use linear. We don't cache the
- // partially resampled images, and as they come in incrementally, it causes
- // us to have to resample the whole thing every time.
- if (!bitmap.isDataComplete())
- return RESAMPLE_LINEAR;
-
- // Everything else gets resampled.
- // High quality interpolation only enabled for scaling and translation.
- if (!(matrix.getType() & (SkMatrix::kAffine_Mask | SkMatrix::kPerspective_Mask)))
- return RESAMPLE_AWESOME;
-
- return RESAMPLE_LINEAR;
-}
-
-static ResamplingMode limitResamplingMode(PlatformContextSkia* platformContext, ResamplingMode resampling)
-{
- switch (platformContext->interpolationQuality()) {
- case InterpolationNone:
- return RESAMPLE_NONE;
- case InterpolationMedium:
- // For now we treat InterpolationMedium and InterpolationLow the same.
- case InterpolationLow:
- if (resampling == RESAMPLE_AWESOME)
- return RESAMPLE_LINEAR;
- break;
- case InterpolationHigh:
- case InterpolationDefault:
- break;
- }
-
- return resampling;
-}
-
-// Return true if the rectangle is aligned to integer boundaries.
-// See comments for computeBitmapDrawRects() for how this is used.
-static bool areBoundariesIntegerAligned(const SkRect& rect)
-{
- // Value is 1.19209e-007. This is the tolerance threshold.
- const float epsilon = std::numeric_limits<float>::epsilon();
- SkIRect roundedRect = roundedIntRect(rect);
-
- return fabs(rect.x() - roundedRect.x()) < epsilon
- && fabs(rect.y() - roundedRect.y()) < epsilon
- && fabs(rect.right() - roundedRect.right()) < epsilon
- && fabs(rect.bottom() - roundedRect.bottom()) < epsilon;
-}
-
-// FIXME: Remove this code when SkCanvas accepts SkRect as source rectangle.
-// See crbug.com/117597 for background.
-//
-// WebKit wants to draw a sub-rectangle (FloatRect) in a bitmap and scale it to
-// another FloatRect. However Skia only allows bitmap to be addressed by a
-// IntRect. This function computes the appropriate IntRect that encloses the
-// source rectangle and the corresponding enclosing destination rectangle,
-// while maintaining the scale factor.
-//
-// |srcRect| is the source rectangle in the bitmap. Return true if fancy
-// alignment is required. User of this function needs to clip to |dstRect|.
-// Return false if clipping is not needed.
-//
-// |dstRect| is the input rectangle that |srcRect| is scaled to.
-//
-// |outSrcRect| and |outDstRect| are the corresponding output rectangles.
-//
-// ALGORITHM
-//
-// The objective is to (a) find an enclosing IntRect for the source rectangle
-// and (b) the corresponding FloatRect in destination space.
-//
-// These are the steps performed:
-//
-// 1. IntRect enclosingSrcRect = enclosingIntRect(srcRect)
-//
-// Compute the enclosing IntRect for |srcRect|. This ensures the bitmap
-// image is addressed with integer boundaries.
-//
-// 2. FloatRect enclosingDestRect = mapSrcToDest(enclosingSrcRect)
-//
-// Map the enclosing source rectangle to destination coordinate space.
-//
-// The output will be enclosingSrcRect and enclosingDestRect from the
-// algorithm above.
-static bool computeBitmapDrawRects(const SkISize& bitmapSize, const SkRect& srcRect, const SkRect& dstRect, SkIRect* outSrcRect, SkRect* outDstRect)
-{
- if (areBoundariesIntegerAligned(srcRect)) {
- *outSrcRect = roundedIntRect(srcRect);
- *outDstRect = dstRect;
- return false;
- }
-
- SkIRect bitmapRect = SkIRect::MakeSize(bitmapSize);
- SkIRect enclosingSrcRect = enclosingIntRect(srcRect);
- enclosingSrcRect.intersect(bitmapRect); // Clip to bitmap rectangle.
- SkRect enclosingDstRect;
- enclosingDstRect.set(enclosingSrcRect);
- SkMatrix transform;
- transform.setRectToRect(srcRect, dstRect, SkMatrix::kFill_ScaleToFit);
- transform.mapRect(&enclosingDstRect);
- *outSrcRect = enclosingSrcRect;
- *outDstRect = enclosingDstRect;
- return true;
-}
-
-// This function is used to scale an image and extract a scaled fragment.
-//
-// ALGORITHM
-//
-// Because the scaled image size has to be integers, we approximate the real
-// scale with the following formula (only X direction is shown):
-//
-// scaledImageWidth = round(scaleX * imageRect.width())
-// approximateScaleX = scaledImageWidth / imageRect.width()
-//
-// With this method we maintain a constant scale factor among fragments in
-// the scaled image. This allows fragments to stitch together to form the
-// full scaled image. The downside is there will be a small difference
-// between |scaleX| and |approximateScaleX|.
-//
-// A scaled image fragment is identified by:
-//
-// - Scaled image size
-// - Scaled image fragment rectangle (IntRect)
-//
-// Scaled image size has been determined and the next step is to compute the
-// rectangle for the scaled image fragment which needs to be an IntRect.
-//
-// scaledSrcRect = srcRect * (approximateScaleX, approximateScaleY)
-// enclosingScaledSrcRect = enclosingIntRect(scaledSrcRect)
-//
-// Finally we extract the scaled image fragment using
-// (scaledImageSize, enclosingScaledSrcRect).
-//
-static SkBitmap extractScaledImageFragment(const NativeImageSkia& bitmap, const SkRect& srcRect, float scaleX, float scaleY, SkRect* scaledSrcRect, SkIRect* enclosingScaledSrcRect)
-{
- SkISize imageSize = SkISize::Make(bitmap.bitmap().width(), bitmap.bitmap().height());
- SkISize scaledImageSize = SkISize::Make(clampToInteger(roundf(imageSize.width() * scaleX)),
- clampToInteger(roundf(imageSize.height() * scaleY)));
-
- SkRect imageRect = SkRect::MakeWH(imageSize.width(), imageSize.height());
- SkRect scaledImageRect = SkRect::MakeWH(scaledImageSize.width(), scaledImageSize.height());
-
- SkMatrix scaleTransform;
- scaleTransform.setRectToRect(imageRect, scaledImageRect, SkMatrix::kFill_ScaleToFit);
- scaleTransform.mapRect(scaledSrcRect, srcRect);
-
- scaledSrcRect->intersect(scaledImageRect);
- *enclosingScaledSrcRect = enclosingIntRect(*scaledSrcRect);
-
- // |enclosingScaledSrcRect| can be larger than |scaledImageSize| because
- // of float inaccuracy so clip to get inside.
- enclosingScaledSrcRect->intersect(SkIRect::MakeSize(scaledImageSize));
- return bitmap.resizedBitmap(scaledImageSize, *enclosingScaledSrcRect);
-}
-
-// This does a lot of computation to resample only the portion of the bitmap
-// that will only be drawn. This is critical for performance since when we are
-// scrolling, for example, we are only drawing a small strip of the image.
-// Resampling the whole image every time is very slow, so this speeds up things
-// dramatically.
-//
-// Note: this code is only used when the canvas transformation is limited to
-// scaling or translation.
-static void drawResampledBitmap(PlatformContextSkia* context, SkPaint& paint, const NativeImageSkia& bitmap, const SkRect& srcRect, const SkRect& destRect)
-{
-#if PLATFORM(CHROMIUM)
- TRACE_EVENT0("skia", "drawResampledBitmap");
-#endif
- // We want to scale |destRect| with transformation in the canvas to obtain
- // the final scale. The final scale is a combination of scale transform
- // in canvas and explicit scaling (srcRect and destRect).
- SkRect screenRect;
- context->getTotalMatrix().mapRect(&screenRect, destRect);
- float realScaleX = screenRect.width() / srcRect.width();
- float realScaleY = screenRect.height() / srcRect.height();
-
- // This part of code limits scaling only to visible portion in the
- SkRect destRectVisibleSubset;
- ClipRectToCanvas(context, destRect, &destRectVisibleSubset);
-
- // ClipRectToCanvas often overshoots, resulting in a larger region than our
- // original destRect. Intersecting gets us back inside.
- if (!destRectVisibleSubset.intersect(destRect))
- return; // Nothing visible in destRect.
-
- // Find the corresponding rect in the source image.
- SkMatrix destToSrcTransform;
- SkRect srcRectVisibleSubset;
- destToSrcTransform.setRectToRect(destRect, srcRect, SkMatrix::kFill_ScaleToFit);
- destToSrcTransform.mapRect(&srcRectVisibleSubset, destRectVisibleSubset);
-
- SkRect scaledSrcRect;
- SkIRect enclosingScaledSrcRect;
- SkBitmap scaledImageFragment = extractScaledImageFragment(bitmap, srcRectVisibleSubset, realScaleX, realScaleY, &scaledSrcRect, &enclosingScaledSrcRect);
-
- // Expand the destination rectangle because the source rectangle was
- // expanded to fit to integer boundaries.
- SkMatrix scaledSrcToDestTransform;
- scaledSrcToDestTransform.setRectToRect(scaledSrcRect, destRectVisibleSubset, SkMatrix::kFill_ScaleToFit);
- SkRect enclosingDestRect;
- enclosingDestRect.set(enclosingScaledSrcRect);
- scaledSrcToDestTransform.mapRect(&enclosingDestRect);
-
- // The reason we do clipping is because Skia doesn't support SkRect as
- // source rect. See http://crbug.com/145540.
- // When Skia supports then use this as the source rect to replace 0.
- //
- // scaledSrcRect.offset(-enclosingScaledSrcRect.x(), -enclosingScaledSrcRect.y());
- context->save();
- context->clipRect(destRectVisibleSubset);
-
- // Because the image fragment is generated with an approxmiated scaling
- // factor. This draw will perform a close to 1 scaling.
- //
- // NOTE: For future optimization. If the difference in scale is so small
- // that Skia doesn't produce a difference then we can just blit it directly
- // to enhance performance.
- context->drawBitmapRect(scaledImageFragment, 0, enclosingDestRect, &paint);
- context->restore();
-}
-
-static bool hasNon90rotation(PlatformContextSkia* context)
-{
- return !context->getTotalMatrix().rectStaysRect();
-}
-
-static void paintSkBitmap(PlatformContextSkia* platformContext, const NativeImageSkia& bitmap, const SkRect& srcRect, const SkRect& destRect, const SkXfermode::Mode& compOp)
-{
-#if PLATFORM(CHROMIUM)
- TRACE_EVENT0("skia", "paintSkBitmap");
-#endif
- SkPaint paint;
- paint.setXfermodeMode(compOp);
- paint.setAlpha(platformContext->getNormalizedAlpha());
- paint.setLooper(platformContext->getDrawLooper());
- // only antialias if we're rotated or skewed
- paint.setAntiAlias(hasNon90rotation(platformContext));
-
- ResamplingMode resampling;
- if (platformContext->isAccelerated())
- resampling = RESAMPLE_LINEAR;
- else if (platformContext->printing())
- resampling = RESAMPLE_NONE;
- else {
- // Take into account scale applied to the canvas when computing sampling mode (e.g. CSS scale or page scale).
- SkRect destRectTarget = destRect;
- if (!(platformContext->getTotalMatrix().getType() & (SkMatrix::kAffine_Mask | SkMatrix::kPerspective_Mask)))
- platformContext->getTotalMatrix().mapRect(&destRectTarget, destRect);
-
- resampling = computeResamplingMode(platformContext->getTotalMatrix(), bitmap,
- SkScalarToFloat(srcRect.width()), SkScalarToFloat(srcRect.height()),
- SkScalarToFloat(destRectTarget.width()), SkScalarToFloat(destRectTarget.height()));
- }
-
- if (resampling == RESAMPLE_NONE) {
- // FIXME: This is to not break tests (it results in the filter bitmap flag
- // being set to true). We need to decide if we respect RESAMPLE_NONE
- // being returned from computeResamplingMode.
- resampling = RESAMPLE_LINEAR;
- }
- resampling = limitResamplingMode(platformContext, resampling);
- paint.setFilterBitmap(resampling == RESAMPLE_LINEAR);
- if (resampling == RESAMPLE_AWESOME)
- drawResampledBitmap(platformContext, paint, bitmap, srcRect, destRect);
- else {
- // No resampling necessary, we can just draw the bitmap. We want to
- // filter it if we decided to do linear interpolation above, or if there
- // is something interesting going on with the matrix (like a rotation).
- // Note: for serialization, we will want to subset the bitmap first so
- // we don't send extra pixels.
- SkIRect enclosingSrcRect;
- SkRect enclosingDestRect;
- SkISize bitmapSize = SkISize::Make(bitmap.bitmap().width(), bitmap.bitmap().height());
- bool needsClipping = computeBitmapDrawRects(bitmapSize, srcRect, destRect, &enclosingSrcRect, &enclosingDestRect);
-
- if (enclosingSrcRect.isEmpty() || enclosingDestRect.isEmpty())
- return;
-
- // If destination is enlarged because source rectangle didn't align to
- // integer boundaries then we draw a slightly larger rectangle and clip
- // to the original destination rectangle.
- // See http://crbug.com/145540.
- if (needsClipping) {
- platformContext->save();
- platformContext->clipRect(destRect);
- }
-
- platformContext->drawBitmapRect(bitmap.bitmap(), &enclosingSrcRect, enclosingDestRect, &paint);
-
- if (needsClipping)
- platformContext->restore();
- }
- platformContext->didDrawRect(destRect, paint, &bitmap.bitmap());
-}
-
-// A helper method for translating negative width and height values.
-FloatRect normalizeRect(const FloatRect& rect)
-{
- FloatRect norm = rect;
- if (norm.width() < 0) {
- norm.setX(norm.x() + norm.width());
- norm.setWidth(-norm.width());
- }
- if (norm.height() < 0) {
- norm.setY(norm.y() + norm.height());
- norm.setHeight(-norm.height());
- }
- return norm;
-}
-
-bool FrameData::clear(bool clearMetadata)
-{
- if (clearMetadata)
- m_haveMetadata = false;
-
- m_orientation = DefaultImageOrientation;
-
- if (m_frame) {
- // ImageSource::createFrameAtIndex() allocated |m_frame| and passed
- // ownership to BitmapImage; we must delete it here.
- delete m_frame;
- m_frame = 0;
- return true;
- }
- return false;
-}
-
-void Image::drawPattern(GraphicsContext* context,
- const FloatRect& floatSrcRect,
- const AffineTransform& patternTransform,
- const FloatPoint& phase,
- ColorSpace styleColorSpace,
- CompositeOperator compositeOp,
- const FloatRect& destRect)
-{
-#if PLATFORM(CHROMIUM)
- TRACE_EVENT0("skia", "Image::drawPattern");
-#endif
- NativeImageSkia* bitmap = nativeImageForCurrentFrame();
- if (!bitmap)
- return;
-
- FloatRect normSrcRect = normalizeRect(floatSrcRect);
- normSrcRect.intersect(FloatRect(0, 0, bitmap->bitmap().width(), bitmap->bitmap().height()));
- if (destRect.isEmpty() || normSrcRect.isEmpty())
- return; // nothing to draw
-
- SkMatrix ctm = context->platformContext()->getTotalMatrix();
- SkMatrix totalMatrix;
- totalMatrix.setConcat(ctm, patternTransform);
-
- // Figure out what size the bitmap will be in the destination. The
- // destination rect is the bounds of the pattern, we need to use the
- // matrix to see how big it will be.
- SkRect destRectTarget;
- totalMatrix.mapRect(&destRectTarget, normSrcRect);
-
- float destBitmapWidth = SkScalarToFloat(destRectTarget.width());
- float destBitmapHeight = SkScalarToFloat(destRectTarget.height());
-
- // Compute the resampling mode.
- ResamplingMode resampling;
- if (context->platformContext()->isAccelerated() || context->platformContext()->printing())
- resampling = RESAMPLE_LINEAR;
- else
- resampling = computeResamplingMode(totalMatrix, *bitmap, normSrcRect.width(), normSrcRect.height(), destBitmapWidth, destBitmapHeight);
- resampling = limitResamplingMode(context->platformContext(), resampling);
-
- // Load the transform WebKit requested.
- SkMatrix matrix(patternTransform);
-
- SkShader* shader;
- if (resampling == RESAMPLE_AWESOME) {
- // Do nice resampling.
- float scaleX = destBitmapWidth / normSrcRect.width();
- float scaleY = destBitmapHeight / normSrcRect.height();
- SkRect scaledSrcRect;
- SkIRect enclosingScaledSrcRect;
-
- // The image fragment generated here is not exactly what is
- // requested. The scale factor used is approximated and image
- // fragment is slightly larger to align to integer
- // boundaries.
- SkBitmap resampled = extractScaledImageFragment(*bitmap, normSrcRect, scaleX, scaleY, &scaledSrcRect, &enclosingScaledSrcRect);
- shader = SkShader::CreateBitmapShader(resampled, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);
-
- // Since we just resized the bitmap, we need to remove the scale
- // applied to the pixels in the bitmap shader. This means we need
- // CTM * patternTransform to have identity scale. Since we
- // can't modify CTM (or the rectangle will be drawn in the wrong
- // place), we must set patternTransform's scale to the inverse of
- // CTM scale.
- matrix.setScaleX(ctm.getScaleX() ? 1 / ctm.getScaleX() : 1);
- matrix.setScaleY(ctm.getScaleY() ? 1 / ctm.getScaleY() : 1);
- } else {
- // No need to do nice resampling.
- SkBitmap srcSubset;
- bitmap->bitmap().extractSubset(&srcSubset, enclosingIntRect(normSrcRect));
- shader = SkShader::CreateBitmapShader(srcSubset, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);
- }
-
- // We also need to translate it such that the origin of the pattern is the
- // origin of the destination rect, which is what WebKit expects. Skia uses
- // the coordinate system origin as the base for the patter. If WebKit wants
- // a shifted image, it will shift it from there using the patternTransform.
- float adjustedX = phase.x() + normSrcRect.x() *
- narrowPrecisionToFloat(patternTransform.a());
- float adjustedY = phase.y() + normSrcRect.y() *
- narrowPrecisionToFloat(patternTransform.d());
- matrix.postTranslate(SkFloatToScalar(adjustedX),
- SkFloatToScalar(adjustedY));
- shader->setLocalMatrix(matrix);
-
- SkPaint paint;
- paint.setShader(shader)->unref();
- paint.setXfermodeMode(WebCoreCompositeToSkiaComposite(compositeOp));
- paint.setFilterBitmap(resampling == RESAMPLE_LINEAR);
-
- context->platformContext()->drawRect(destRect, paint);
-}
-
-// ================================================
-// BitmapImage Class
-// ================================================
-
-// FIXME: These should go to BitmapImageSkia.cpp
-
-void BitmapImage::invalidatePlatformData()
-{
-}
-
-void BitmapImage::checkForSolidColor()
-{
- m_isSolidColor = false;
- m_checkedForSolidColor = true;
-
- if (frameCount() > 1)
- return;
-
- WebCore::NativeImageSkia* frame = frameAtIndex(0);
-
- if (frame && size().width() == 1 && size().height() == 1) {
- SkAutoLockPixels lock(frame->bitmap());
- if (!frame->bitmap().getPixels())
- return;
-
- m_isSolidColor = true;
- m_solidColor = Color(frame->bitmap().getColor(0, 0));
- }
-}
-
-void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace colorSpace, CompositeOperator compositeOp)
-{
- draw(ctxt, dstRect, srcRect, colorSpace, compositeOp, DoNotRespectImageOrientation);
-}
-
-void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace colorSpace, CompositeOperator compositeOp, RespectImageOrientationEnum shouldRespectImageOrientation)
-{
- if (!m_source.initialized())
- return;
-
- // Spin the animation to the correct frame before we try to draw it, so we
- // don't draw an old frame and then immediately need to draw a newer one,
- // causing flicker and wasting CPU.
- startAnimation();
-
- NativeImageSkia* bm = nativeImageForCurrentFrame();
- if (!bm)
- return; // It's too early and we don't have an image yet.
-
- FloatRect normDstRect = normalizeRect(dstRect);
- FloatRect normSrcRect = normalizeRect(srcRect);
- normSrcRect.intersect(FloatRect(0, 0, bm->bitmap().width(), bm->bitmap().height()));
-
- if (normSrcRect.isEmpty() || normDstRect.isEmpty())
- return; // Nothing to draw.
-
- ImageOrientation orientation = DefaultImageOrientation;
- if (shouldRespectImageOrientation == RespectImageOrientation)
- orientation = frameOrientationAtIndex(m_currentFrame);
-
- GraphicsContextStateSaver saveContext(*ctxt, false);
- if (orientation != DefaultImageOrientation) {
- saveContext.save();
-
- // ImageOrientation expects the origin to be at (0, 0)
- ctxt->translate(normDstRect.x(), normDstRect.y());
- normDstRect.setLocation(FloatPoint());
-
- ctxt->concatCTM(orientation.transformFromDefault(normDstRect.size()));
-
- if (orientation.usesWidthAsHeight()) {
- // The destination rect will have it's width and height already reversed for the orientation of
- // the image, as it was needed for page layout, so we need to reverse it back here.
- normDstRect = FloatRect(normDstRect.x(), normDstRect.y(), normDstRect.height(), normDstRect.width());
- }
- }
-
- paintSkBitmap(ctxt->platformContext(),
- *bm,
- normSrcRect,
- normDstRect,
- WebCoreCompositeToSkiaComposite(compositeOp));
-
- if (ImageObserver* observer = imageObserver())
- observer->didDraw(this);
-}
-
-// FIXME: These should go into BitmapImageSingleFrameSkia.cpp
-
-void BitmapImageSingleFrameSkia::draw(GraphicsContext* ctxt,
- const FloatRect& dstRect,
- const FloatRect& srcRect,
- ColorSpace styleColorSpace,
- CompositeOperator compositeOp)
-{
- FloatRect normDstRect = normalizeRect(dstRect);
- FloatRect normSrcRect = normalizeRect(srcRect);
- normSrcRect.intersect(FloatRect(0, 0, m_nativeImage.bitmap().width(), m_nativeImage.bitmap().height()));
-
- if (normSrcRect.isEmpty() || normDstRect.isEmpty())
- return; // Nothing to draw.
-
- paintSkBitmap(ctxt->platformContext(),
- m_nativeImage,
- normSrcRect,
- normDstRect,
- WebCoreCompositeToSkiaComposite(compositeOp));
-
- if (ImageObserver* observer = imageObserver())
- observer->didDraw(this);
-}
-
-BitmapImageSingleFrameSkia::BitmapImageSingleFrameSkia(const SkBitmap& bitmap, float resolutionScale)
- : m_nativeImage(bitmap, resolutionScale)
-{
-}
-
-PassRefPtr<BitmapImageSingleFrameSkia> BitmapImageSingleFrameSkia::create(const SkBitmap& bitmap, bool copyPixels, float resolutionScale)
-{
- if (copyPixels) {
- SkBitmap temp;
- if (!bitmap.deepCopyTo(&temp, bitmap.config()))
- bitmap.copyTo(&temp, bitmap.config());
- return adoptRef(new BitmapImageSingleFrameSkia(temp, resolutionScale));
- }
- return adoptRef(new BitmapImageSingleFrameSkia(bitmap, resolutionScale));
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/skia/IntPointSkia.cpp b/Source/WebCore/platform/graphics/skia/IntPointSkia.cpp
deleted file mode 100644
index fd9a6fd05..000000000
--- a/Source/WebCore/platform/graphics/skia/IntPointSkia.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2008, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "IntPoint.h"
-
-#include "SkPoint.h"
-
-namespace WebCore {
-
-IntPoint::IntPoint(const SkIPoint& p)
- : m_x(p.fX)
- , m_y(p.fY)
-{
-}
-
-IntPoint::operator SkIPoint() const
-{
- SkIPoint p = { m_x, m_y };
- return p;
-}
-
-IntPoint::operator SkPoint() const
-{
- SkPoint p = { SkIntToScalar(m_x), SkIntToScalar(m_y) };
- return p;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/skia/IntRectSkia.cpp b/Source/WebCore/platform/graphics/skia/IntRectSkia.cpp
deleted file mode 100644
index 002408675..000000000
--- a/Source/WebCore/platform/graphics/skia/IntRectSkia.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2008, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "IntRect.h"
-
-#include "SkRect.h"
-
-namespace WebCore {
-
-IntRect::operator SkIRect() const
-{
- SkIRect rect = { x(), y(), maxX(), maxY() };
- return rect;
-}
-
-IntRect::operator SkRect() const
-{
- SkRect rect;
- rect.set(SkIntToScalar(x()), SkIntToScalar(y()), SkIntToScalar(maxX()), SkIntToScalar(maxY()));
- return rect;
-}
-
-IntRect::IntRect(const SkIRect& r)
- : m_location(r.fLeft, r.fTop)
- , m_size(r.width(), r.height())
-{
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/skia/MemoryInstrumentationSkia.cpp b/Source/WebCore/platform/graphics/skia/MemoryInstrumentationSkia.cpp
deleted file mode 100644
index 0793c3569..000000000
--- a/Source/WebCore/platform/graphics/skia/MemoryInstrumentationSkia.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "MemoryInstrumentationSkia.h"
-
-#include "PlatformMemoryInstrumentation.h"
-#include "SkBitmap.h"
-#include "SkCanvas.h"
-#include "SkDevice.h"
-#include "SkPixelRef.h"
-
-void reportMemoryUsage(const SkBitmap* const& image, WTF::MemoryObjectInfo* memoryObjectInfo)
-{
- WTF::MemoryClassInfo info(memoryObjectInfo, image);
- SkPixelRef* pixelRef = image->pixelRef();
- info.addMember(pixelRef);
- if (pixelRef)
- info.addRawBuffer(pixelRef->pixels(), image->getSize());
-}
-
-void reportMemoryUsage(const SkDevice* const& device, WTF::MemoryObjectInfo* memoryObjectInfo)
-{
- WTF::MemoryClassInfo info(memoryObjectInfo, device);
- info.addMember(const_cast<SkDevice*>(device)->accessBitmap(false));
-}
-
-void reportMemoryUsage(const SkCanvas* const& canvas, WTF::MemoryObjectInfo* memoryObjectInfo)
-{
- WTF::MemoryClassInfo info(memoryObjectInfo, canvas);
- info.addMember(canvas->getDevice());
-}
diff --git a/Source/WebCore/platform/graphics/skia/MemoryInstrumentationSkia.h b/Source/WebCore/platform/graphics/skia/MemoryInstrumentationSkia.h
deleted file mode 100644
index e6f81b0d2..000000000
--- a/Source/WebCore/platform/graphics/skia/MemoryInstrumentationSkia.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef MemoryInstrumentationSkia_h
-#define MemoryInstrumentationSkia_h
-
-#include "PlatformMemoryInstrumentation.h"
-
-class SkBitmap;
-class SkDevice;
-class SkCanvas;
-
-void reportMemoryUsage(const SkBitmap* const&, WTF::MemoryObjectInfo*);
-void reportMemoryUsage(const SkDevice* const&, WTF::MemoryObjectInfo*);
-void reportMemoryUsage(const SkCanvas* const&, WTF::MemoryObjectInfo*);
-
-#endif // !defined(MemoryInstrumentationSkia_h)
diff --git a/Source/WebCore/platform/graphics/skia/NativeImageSkia.cpp b/Source/WebCore/platform/graphics/skia/NativeImageSkia.cpp
deleted file mode 100644
index 6f5dbc818..000000000
--- a/Source/WebCore/platform/graphics/skia/NativeImageSkia.cpp
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright (c) 2008, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "skia/ext/image_operations.h"
-
-#include "NativeImageSkia.h"
-#include "GraphicsContext3D.h"
-#include "MemoryInstrumentationSkia.h"
-#include "PlatformInstrumentation.h"
-#include "PlatformMemoryInstrumentation.h"
-#include "SkPixelRef.h"
-#include "SkiaUtils.h"
-
-#if PLATFORM(CHROMIUM)
-#include "DeferredImageDecoder.h"
-#include "TraceEvent.h"
-#endif
-
-namespace WebCore {
-
-NativeImageSkia::NativeImageSkia()
- : m_resolutionScale(1),
- m_resizeRequests(0)
-{
-}
-
-NativeImageSkia::NativeImageSkia(const SkBitmap& other, float resolutionScale)
- : m_image(other),
- m_resolutionScale(resolutionScale),
- m_resizeRequests(0)
-{
-}
-
-NativeImageSkia::~NativeImageSkia()
-{
-}
-
-int NativeImageSkia::decodedSize() const
-{
- return m_image.getSize() + m_resizedImage.getSize();
-}
-
-bool NativeImageSkia::hasResizedBitmap(const SkISize& scaledImageSize, const SkIRect& scaledImageSubset) const
-{
- bool imageScaleEqual = m_cachedImageInfo.scaledImageSize == scaledImageSize;
- bool scaledImageSubsetAvailable = m_cachedImageInfo.scaledImageSubset.contains(scaledImageSubset);
- return imageScaleEqual && scaledImageSubsetAvailable && !m_resizedImage.empty();
-}
-
-SkBitmap NativeImageSkia::resizedBitmap(const SkISize& scaledImageSize, const SkIRect& scaledImageSubset) const
-{
-#if PLATFORM(CHROMIUM)
- if (DeferredImageDecoder::isLazyDecoded(m_image))
- return DeferredImageDecoder::createResizedLazyDecodingBitmap(m_image, scaledImageSize, scaledImageSubset);
-#endif
-
- if (!hasResizedBitmap(scaledImageSize, scaledImageSubset)) {
- bool shouldCache = isDataComplete()
- && shouldCacheResampling(scaledImageSize, scaledImageSubset);
-
- PlatformInstrumentation::willResizeImage(shouldCache);
- SkBitmap resizedImage = skia::ImageOperations::Resize(m_image, skia::ImageOperations::RESIZE_LANCZOS3, scaledImageSize.width(), scaledImageSize.height(), scaledImageSubset);
- resizedImage.setImmutable();
- PlatformInstrumentation::didResizeImage();
-
- if (!shouldCache)
- return resizedImage;
-
- m_resizedImage = resizedImage;
- }
-
- SkBitmap resizedSubset;
- SkIRect resizedSubsetRect = m_cachedImageInfo.rectInSubset(scaledImageSubset);
- m_resizedImage.extractSubset(&resizedSubset, resizedSubsetRect);
- return resizedSubset;
-}
-
-bool NativeImageSkia::shouldCacheResampling(const SkISize& scaledImageSize, const SkIRect& scaledImageSubset) const
-{
- // Check whether the requested dimensions match previous request.
- bool matchesPreviousRequest = m_cachedImageInfo.isEqual(scaledImageSize, scaledImageSubset);
- if (matchesPreviousRequest)
- ++m_resizeRequests;
- else {
- m_cachedImageInfo.set(scaledImageSize, scaledImageSubset);
- m_resizeRequests = 0;
- // Reset m_resizedImage now, because we don't distinguish
- // between the last requested resize info and m_resizedImage's
- // resize info.
- m_resizedImage.reset();
- }
-
- // We can not cache incomplete frames. This might be a good optimization in
- // the future, were we know how much of the frame has been decoded, so when
- // we incrementally draw more of the image, we only have to resample the
- // parts that are changed.
- if (!isDataComplete())
- return false;
-
- // If the destination bitmap is excessively large, we'll never allow caching.
- static const unsigned long long kLargeBitmapSize = 4096ULL * 4096ULL;
- unsigned long long fullSize = static_cast<unsigned long long>(scaledImageSize.width()) * static_cast<unsigned long long>(scaledImageSize.height());
- unsigned long long fragmentSize = static_cast<unsigned long long>(scaledImageSubset.width()) * static_cast<unsigned long long>(scaledImageSubset.height());
-
- if (fragmentSize > kLargeBitmapSize)
- return false;
-
- // If the destination bitmap is small, we'll always allow caching, since
- // there is not very much penalty for computing it and it may come in handy.
- static const unsigned kSmallBitmapSize = 4096;
- if (fragmentSize <= kSmallBitmapSize)
- return true;
-
- // If "too many" requests have been made for this bitmap, we assume that
- // many more will be made as well, and we'll go ahead and cache it.
- static const int kManyRequestThreshold = 4;
- if (m_resizeRequests >= kManyRequestThreshold)
- return true;
-
- // If more than 1/4 of the resized image is requested, it's worth caching.
- return fragmentSize > fullSize / 4;
-}
-
-NativeImageSkia::CachedImageInfo::CachedImageInfo()
-{
- scaledImageSize.setEmpty();
- scaledImageSubset.setEmpty();
-}
-
-bool NativeImageSkia::CachedImageInfo::isEqual(const SkISize& otherScaledImageSize, const SkIRect& otherScaledImageSubset) const
-{
- return scaledImageSize == otherScaledImageSize && scaledImageSubset == otherScaledImageSubset;
-}
-
-void NativeImageSkia::CachedImageInfo::set(const SkISize& otherScaledImageSize, const SkIRect& otherScaledImageSubset)
-{
- scaledImageSize = otherScaledImageSize;
- scaledImageSubset = otherScaledImageSubset;
-}
-
-SkIRect NativeImageSkia::CachedImageInfo::rectInSubset(const SkIRect& otherScaledImageSubset)
-{
- if (!scaledImageSubset.contains(otherScaledImageSubset))
- return SkIRect::MakeEmpty();
- SkIRect subsetRect = otherScaledImageSubset;
- subsetRect.offset(-scaledImageSubset.x(), -scaledImageSubset.y());
- return subsetRect;
-}
-
-void NativeImageSkia::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
-{
- MemoryClassInfo info(memoryObjectInfo, this);
- info.addMember(m_image);
- info.addMember(m_resizedImage);
-}
-
-void reportMemoryUsage(const NativeImageSkia* const& image, MemoryObjectInfo* memoryObjectInfo)
-{
- image->reportMemoryUsage(memoryObjectInfo);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/skia/NativeImageSkia.h b/Source/WebCore/platform/graphics/skia/NativeImageSkia.h
deleted file mode 100644
index 8b795e2a5..000000000
--- a/Source/WebCore/platform/graphics/skia/NativeImageSkia.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright (c) 2008, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef NativeImageSkia_h
-#define NativeImageSkia_h
-
-#include "SkBitmap.h"
-#include "SkRect.h"
-#include "SkSize.h"
-#include <wtf/Forward.h>
-
-namespace WebCore {
-
-// This object is used as the "native image" in our port. When WebKit uses
-// "NativeImagePtr", it is a pointer to this type. It has an SkBitmap, and also
-// stores a cached resized image.
-class NativeImageSkia {
-public:
- NativeImageSkia();
- ~NativeImageSkia();
-
- // This constructor does a shallow copy of the passed-in SkBitmap (ie., it
- // references the same pixel data and bumps the refcount). Use only when
- // you want sharing semantics.
- NativeImageSkia(const SkBitmap&, float resolutionScale);
-
- // Returns the number of bytes of image data. This includes the cached
- // resized version if there is one.
- int decodedSize() const;
-
- // Sets the immutable flag on the bitmap, indicating that the image data
- // will not be modified any further. This is called by the image decoder
- // when all data is complete, used by us to know whether we can cache
- // resized images, and used by Skia for various optimizations.
- void setDataComplete() { m_image.setImmutable(); }
-
- // Returns true if the entire image has been decoded.
- bool isDataComplete() const { return m_image.isImmutable(); }
-
- // Get reference to the internal SkBitmap representing this image.
- const SkBitmap& bitmap() const { return m_image; }
- SkBitmap& bitmap() { return m_image; }
-
- float resolutionScale() const { return m_resolutionScale; }
-
- // We can keep a resized version of the bitmap cached on this object.
- // This function will return true if there is a cached version of the given
- // scale and subset.
- bool hasResizedBitmap(const SkISize& scaledImageSize, const SkIRect& scaledImageSubset) const;
-
- // This will return an existing resized image subset, or generate a new one
- // of the specified size and subset and possibly cache it.
- //
- // scaledImageSize
- // Dimensions of the scaled full image.
- //
- // scaledImageSubset
- // Rectangle of the subset in the scaled image.
- SkBitmap resizedBitmap(const SkISize& scaledImageSize, const SkIRect& scaledImageSubset) const;
-
- void reportMemoryUsage(MemoryObjectInfo*) const;
-
-private:
- // CachedImageInfo is used to uniquely identify cached or requested image
- // resizes.
- // Image resize is identified by the scaled image size and scaled image subset.
- struct CachedImageInfo {
- SkISize scaledImageSize;
- SkIRect scaledImageSubset;
-
- CachedImageInfo();
-
- bool isEqual(const SkISize& otherScaledImageSize, const SkIRect& otherScaledImageSubset) const;
- void set(const SkISize& otherScaledImageSize, const SkIRect& otherScaledImageSubset);
- SkIRect rectInSubset(const SkIRect& otherScaledImageRect);
- };
-
- // Returns true if the given resize operation should either resize the whole
- // image and cache it, or resize just the part it needs and throw the result
- // away.
- //
- // Calling this function may increment a request count that can change the
- // result of subsequent calls.
- //
- // On the one hand, if only a small subset is desired, then we will waste a
- // lot of time resampling the entire thing, so we only want to do exactly
- // what's required. On the other hand, resampling the entire bitmap is
- // better if we're going to be using it more than once (like a bitmap
- // scrolling on and off the screen. Since we only cache when doing the
- // entire thing, it's best to just do it up front.
- bool shouldCacheResampling(const SkISize& scaledImageSize, const SkIRect& scaledImageSubset) const;
-
- // The original image.
- SkBitmap m_image;
- float m_resolutionScale;
-
- // The cached bitmap fragment. This is a subset of the scaled version of
- // |m_image|. empty() returns true if there is no cached image.
- mutable SkBitmap m_resizedImage;
-
- // References how many times that the image size has been requested for
- // the last size.
- //
- // Every time we get a call to shouldCacheResampling, if it matches the
- // m_cachedImageInfo, we'll increment the counter, and if not, we'll reset
- // the counter and save the dimensions.
- //
- // This allows us to see if many requests have been made for the same
- // resized image, we know that we should probably cache it, even if all of
- // those requests individually are small and would not otherwise be cached.
- //
- // We also track scaling information and destination subset for the scaled
- // image. See comments for CachedImageInfo.
- mutable CachedImageInfo m_cachedImageInfo;
- mutable int m_resizeRequests;
-};
-
-}
-#endif // NativeImageSkia_h
diff --git a/Source/WebCore/platform/graphics/skia/OpaqueRegionSkia.cpp b/Source/WebCore/platform/graphics/skia/OpaqueRegionSkia.cpp
deleted file mode 100644
index be4bfbc43..000000000
--- a/Source/WebCore/platform/graphics/skia/OpaqueRegionSkia.cpp
+++ /dev/null
@@ -1,439 +0,0 @@
-/*
- * Copyright (c) 2012, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "OpaqueRegionSkia.h"
-
-#include "PlatformContextSkia.h"
-
-#include "SkCanvas.h"
-#include "SkColorFilter.h"
-#include "SkShader.h"
-
-namespace WebCore {
-
-OpaqueRegionSkia::OpaqueRegionSkia()
- : m_opaqueRect(SkRect::MakeEmpty())
-{
-}
-
-OpaqueRegionSkia::~OpaqueRegionSkia()
-{
-}
-
-IntRect OpaqueRegionSkia::asRect() const
-{
- // Returns the largest enclosed rect.
- int left = SkScalarCeil(m_opaqueRect.fLeft);
- int top = SkScalarCeil(m_opaqueRect.fTop);
- int right = SkScalarFloor(m_opaqueRect.fRight);
- int bottom = SkScalarFloor(m_opaqueRect.fBottom);
- return IntRect(left, top, right-left, bottom-top);
-}
-
-// Returns true if the xfermode will force the dst to be opaque, regardless of the current dst.
-static inline bool xfermodeIsOpaque(const SkPaint& paint, bool srcIsOpaque)
-{
- if (!srcIsOpaque)
- return false;
-
- SkXfermode* xfermode = paint.getXfermode();
- if (!xfermode)
- return true; // default to kSrcOver_Mode
- SkXfermode::Mode mode;
- if (!xfermode->asMode(&mode))
- return false;
-
- switch (mode) {
- case SkXfermode::kSrc_Mode: // source
- case SkXfermode::kSrcOver_Mode: // source + dest - source*dest
- case SkXfermode::kDstOver_Mode: // source + dest - source*dest
- case SkXfermode::kDstATop_Mode: // source
- case SkXfermode::kPlus_Mode: // source+dest
- default: // the rest are all source + dest - source*dest
- return true;
- case SkXfermode::kClear_Mode: // 0
- case SkXfermode::kDst_Mode: // dest
- case SkXfermode::kSrcIn_Mode: // source * dest
- case SkXfermode::kDstIn_Mode: // dest * source
- case SkXfermode::kSrcOut_Mode: // source * (1-dest)
- case SkXfermode::kDstOut_Mode: // dest * (1-source)
- case SkXfermode::kSrcATop_Mode: // dest
- case SkXfermode::kXor_Mode: // source + dest - 2*(source*dest)
- return false;
- }
-}
-
-// Returns true if the xfermode will keep the dst opaque, assuming the dst is already opaque.
-static inline bool xfermodePreservesOpaque(const SkPaint& paint, bool srcIsOpaque)
-{
- SkXfermode* xfermode = paint.getXfermode();
- if (!xfermode)
- return true; // default to kSrcOver_Mode
- SkXfermode::Mode mode;
- if (!xfermode->asMode(&mode))
- return false;
-
- switch (mode) {
- case SkXfermode::kDst_Mode: // dest
- case SkXfermode::kSrcOver_Mode: // source + dest - source*dest
- case SkXfermode::kDstOver_Mode: // source + dest - source*dest
- case SkXfermode::kSrcATop_Mode: // dest
- case SkXfermode::kPlus_Mode: // source+dest
- default: // the rest are all source + dest - source*dest
- return true;
- case SkXfermode::kClear_Mode: // 0
- case SkXfermode::kSrcOut_Mode: // source * (1-dest)
- case SkXfermode::kDstOut_Mode: // dest * (1-source)
- case SkXfermode::kXor_Mode: // source + dest - 2*(source*dest)
- return false;
- case SkXfermode::kSrc_Mode: // source
- case SkXfermode::kSrcIn_Mode: // source * dest
- case SkXfermode::kDstIn_Mode: // dest * source
- case SkXfermode::kDstATop_Mode: // source
- return srcIsOpaque;
- }
-}
-
-// Returns true if all pixels painted will be opaque.
-static inline bool paintIsOpaque(const SkPaint& paint, OpaqueRegionSkia::DrawType drawType, const SkBitmap* bitmap)
-{
- if (paint.getAlpha() < 0xFF)
- return false;
- bool checkFillOnly = drawType != OpaqueRegionSkia::FillOrStroke;
- if (!checkFillOnly && paint.getStyle() != SkPaint::kFill_Style && paint.isAntiAlias())
- return false;
- SkShader* shader = paint.getShader();
- if (shader && !shader->isOpaque())
- return false;
- if (bitmap && !bitmap->isOpaque())
- return false;
- if (paint.getLooper())
- return false;
- if (paint.getImageFilter())
- return false;
- if (paint.getMaskFilter())
- return false;
- SkColorFilter* colorFilter = paint.getColorFilter();
- if (colorFilter && !(colorFilter->getFlags() & SkColorFilter::kAlphaUnchanged_Flag))
- return false;
- return true;
-}
-
-// Returns true if there is a rectangular clip, with the result in |deviceClipRect|.
-static inline bool getDeviceClipAsRect(const PlatformContextSkia* context, SkRect& deviceClipRect)
-{
- // Get the current clip in device coordinate space.
- if (context->canvas()->getClipType() != SkCanvas::kRect_ClipType)
- return false;
-
- SkIRect deviceClipIRect;
- if (context->canvas()->getClipDeviceBounds(&deviceClipIRect))
- deviceClipRect.set(deviceClipIRect);
- else
- deviceClipRect.setEmpty();
-
- return true;
-}
-
-static inline SkRect& currentTrackingOpaqueRect(SkRect& rootOpaqueRect, Vector<OpaqueRegionSkia::CanvasLayerState, 3>& canvasLayerStack)
-{
- // If we are drawing into a canvas layer, then track the opaque rect in that layer.
- if (!canvasLayerStack.isEmpty())
- return canvasLayerStack.last().opaqueRect;
- return rootOpaqueRect;
-}
-
-void OpaqueRegionSkia::pushCanvasLayer(const SkPaint* paint)
-{
- CanvasLayerState state;
- if (paint)
- state.paint = *paint;
- m_canvasLayerStack.append(state);
-}
-
-void OpaqueRegionSkia::popCanvasLayer(const PlatformContextSkia* context)
-{
- ASSERT(!m_canvasLayerStack.isEmpty());
- if (m_canvasLayerStack.isEmpty())
- return;
-
- const CanvasLayerState& canvasLayer = m_canvasLayerStack.last();
- SkRect layerOpaqueRect = canvasLayer.opaqueRect;
- SkPaint layerPaint = canvasLayer.paint;
-
- // Apply the image mask.
- if (canvasLayer.hasImageMask && !layerOpaqueRect.intersect(canvasLayer.imageOpaqueRect))
- layerOpaqueRect.setEmpty();
-
- m_canvasLayerStack.removeLast();
-
- applyOpaqueRegionFromLayer(context, layerOpaqueRect, layerPaint);
-}
-
-void OpaqueRegionSkia::setImageMask(const SkRect& imageOpaqueRect)
-{
- ASSERT(!m_canvasLayerStack.isEmpty());
- m_canvasLayerStack.last().hasImageMask = true;
- m_canvasLayerStack.last().imageOpaqueRect = imageOpaqueRect;
-}
-
-void OpaqueRegionSkia::didDrawRect(const PlatformContextSkia* context, const SkRect& fillRect, const SkPaint& paint, const SkBitmap* sourceBitmap)
-{
- // Any stroking may put alpha in pixels even if the filling part does not.
- if (paint.getStyle() != SkPaint::kFill_Style) {
- bool fillsBounds = false;
-
- if (!paint.canComputeFastBounds())
- didDrawUnbounded(context, paint, FillOrStroke);
- else {
- SkRect strokeRect;
- strokeRect = paint.computeFastBounds(fillRect, &strokeRect);
- didDraw(context, strokeRect, paint, sourceBitmap, fillsBounds, FillOrStroke);
- }
- }
-
- bool fillsBounds = paint.getStyle() != SkPaint::kStroke_Style;
- didDraw(context, fillRect, paint, sourceBitmap, fillsBounds, FillOnly);
-}
-
-void OpaqueRegionSkia::didDrawPath(const PlatformContextSkia* context, const SkPath& path, const SkPaint& paint)
-{
- SkRect rect;
- if (path.isRect(&rect)) {
- didDrawRect(context, rect, paint, 0);
- return;
- }
-
- bool fillsBounds = false;
-
- if (!paint.canComputeFastBounds())
- didDrawUnbounded(context, paint, FillOrStroke);
- else {
- rect = paint.computeFastBounds(path.getBounds(), &rect);
- didDraw(context, rect, paint, 0, fillsBounds, FillOrStroke);
- }
-}
-
-void OpaqueRegionSkia::didDrawPoints(const PlatformContextSkia* context, SkCanvas::PointMode mode, int numPoints, const SkPoint points[], const SkPaint& paint)
-{
- if (!numPoints)
- return;
-
- SkRect rect;
- rect.fLeft = points[0].fX;
- rect.fRight = points[0].fX + 1;
- rect.fTop = points[0].fY;
- rect.fBottom = points[0].fY + 1;
-
- for (int i = 1; i < numPoints; ++i) {
- rect.fLeft = std::min(rect.fLeft, points[i].fX);
- rect.fRight = std::max(rect.fRight, points[i].fX + 1);
- rect.fTop = std::min(rect.fTop, points[i].fY);
- rect.fBottom = std::max(rect.fBottom, points[i].fY + 1);
- }
-
- bool fillsBounds = false;
-
- if (!paint.canComputeFastBounds())
- didDrawUnbounded(context, paint, FillOrStroke);
- else {
- rect = paint.computeFastBounds(rect, &rect);
- didDraw(context, rect, paint, 0, fillsBounds, FillOrStroke);
- }
-}
-
-void OpaqueRegionSkia::didDrawBounded(const PlatformContextSkia* context, const SkRect& bounds, const SkPaint& paint)
-{
- bool fillsBounds = false;
-
- if (!paint.canComputeFastBounds())
- didDrawUnbounded(context, paint, FillOrStroke);
- else {
- SkRect rect;
- rect = paint.computeFastBounds(bounds, &rect);
- didDraw(context, rect, paint, 0, fillsBounds, FillOrStroke);
- }
-}
-
-void OpaqueRegionSkia::didDraw(const PlatformContextSkia* context, const SkRect& rect, const SkPaint& paint, const SkBitmap* sourceBitmap, bool fillsBounds, DrawType drawType)
-{
- SkRect targetRect = rect;
-
- // Apply the transform to device coordinate space.
- SkMatrix canvasTransform = context->canvas()->getTotalMatrix();
- if (!canvasTransform.mapRect(&targetRect))
- fillsBounds = false;
-
- // Apply the current clip.
- SkRect deviceClipRect;
- if (!getDeviceClipAsRect(context, deviceClipRect))
- fillsBounds = false;
- else if (!targetRect.intersect(deviceClipRect))
- return;
-
- bool drawsOpaque = paintIsOpaque(paint, drawType, sourceBitmap);
- bool xfersOpaque = xfermodeIsOpaque(paint, drawsOpaque);
- bool preservesOpaque = xfermodePreservesOpaque(paint, drawsOpaque);
-
- if (fillsBounds && xfersOpaque)
- markRectAsOpaque(targetRect);
- else if (!preservesOpaque)
- markRectAsNonOpaque(targetRect);
-}
-
-void OpaqueRegionSkia::didDrawUnbounded(const PlatformContextSkia* context, const SkPaint& paint, DrawType drawType)
-{
- bool drawsOpaque = paintIsOpaque(paint, drawType, 0);
- bool preservesOpaque = xfermodePreservesOpaque(paint, drawsOpaque);
-
- if (preservesOpaque)
- return;
-
- SkRect deviceClipRect;
- getDeviceClipAsRect(context, deviceClipRect);
- markRectAsNonOpaque(deviceClipRect);
-}
-
-void OpaqueRegionSkia::applyOpaqueRegionFromLayer(const PlatformContextSkia* context, const SkRect& layerOpaqueRect, const SkPaint& paint)
-{
- SkRect deviceClipRect;
- bool deviceClipIsARect = getDeviceClipAsRect(context, deviceClipRect);
-
- if (deviceClipRect.isEmpty())
- return;
-
- SkRect sourceOpaqueRect = layerOpaqueRect;
- // Save the opaque area in the destination, so we can preserve the parts of it under the source opaque area if possible.
- SkRect destinationOpaqueRect = currentTrackingOpaqueRect(m_opaqueRect, m_canvasLayerStack);
-
- bool outsideSourceOpaqueRectPreservesOpaque = xfermodePreservesOpaque(paint, false);
- if (!outsideSourceOpaqueRectPreservesOpaque)
- markRectAsNonOpaque(deviceClipRect);
-
- if (!deviceClipIsARect)
- return;
- if (!sourceOpaqueRect.intersect(deviceClipRect))
- return;
-
- bool sourceOpaqueRectDrawsOpaque = paintIsOpaque(paint, FillOnly, 0);
- bool sourceOpaqueRectXfersOpaque = xfermodeIsOpaque(paint, sourceOpaqueRectDrawsOpaque);
- bool sourceOpaqueRectPreservesOpaque = xfermodePreservesOpaque(paint, sourceOpaqueRectDrawsOpaque);
-
- // If the layer's opaque area is being drawn opaque in the layer below, then mark it opaque. Otherwise,
- // if it preserves opaque then keep the intersection of the two.
- if (sourceOpaqueRectXfersOpaque)
- markRectAsOpaque(sourceOpaqueRect);
- else if (sourceOpaqueRectPreservesOpaque && sourceOpaqueRect.intersect(destinationOpaqueRect))
- markRectAsOpaque(sourceOpaqueRect);
-}
-
-void OpaqueRegionSkia::markRectAsOpaque(const SkRect& rect)
-{
- // We want to keep track of an opaque region but bound its complexity at a constant size.
- // We keep track of the largest rectangle seen by area. If we can add the new rect to this
- // rectangle then we do that, as that is the cheapest way to increase the area returned
- // without increasing the complexity.
-
- SkRect& opaqueRect = currentTrackingOpaqueRect(m_opaqueRect, m_canvasLayerStack);
-
- if (rect.isEmpty())
- return;
- if (opaqueRect.contains(rect))
- return;
- if (rect.contains(opaqueRect)) {
- opaqueRect = rect;
- return;
- }
-
- if (rect.fTop <= opaqueRect.fTop && rect.fBottom >= opaqueRect.fBottom) {
- if (rect.fLeft < opaqueRect.fLeft && rect.fRight >= opaqueRect.fLeft)
- opaqueRect.fLeft = rect.fLeft;
- if (rect.fRight > opaqueRect.fRight && rect.fLeft <= opaqueRect.fRight)
- opaqueRect.fRight = rect.fRight;
- } else if (rect.fLeft <= opaqueRect.fLeft && rect.fRight >= opaqueRect.fRight) {
- if (rect.fTop < opaqueRect.fTop && rect.fBottom >= opaqueRect.fTop)
- opaqueRect.fTop = rect.fTop;
- if (rect.fBottom > opaqueRect.fBottom && rect.fTop <= opaqueRect.fBottom)
- opaqueRect.fBottom = rect.fBottom;
- }
-
- long opaqueArea = (long)opaqueRect.width() * (long)opaqueRect.height();
- long area = (long)rect.width() * (long)rect.height();
- if (area > opaqueArea)
- opaqueRect = rect;
-}
-
-void OpaqueRegionSkia::markRectAsNonOpaque(const SkRect& rect)
-{
- // We want to keep as much of the current opaque rectangle as we can, so find the one largest
- // rectangle inside m_opaqueRect that does not intersect with |rect|.
-
- SkRect& opaqueRect = currentTrackingOpaqueRect(m_opaqueRect, m_canvasLayerStack);
-
- if (!SkRect::Intersects(rect, opaqueRect))
- return;
- if (rect.contains(opaqueRect)) {
- markAllAsNonOpaque();
- return;
- }
-
- int deltaLeft = rect.fLeft - opaqueRect.fLeft;
- int deltaRight = opaqueRect.fRight - rect.fRight;
- int deltaTop = rect.fTop - opaqueRect.fTop;
- int deltaBottom = opaqueRect.fBottom - rect.fBottom;
-
- // horizontal is the larger of the two rectangles to the left or to the right of |rect| and inside opaqueRect.
- // vertical is the larger of the two rectangles above or below |rect| and inside opaqueRect.
- SkRect horizontal = opaqueRect;
- if (deltaTop > deltaBottom)
- horizontal.fBottom = rect.fTop;
- else
- horizontal.fTop = rect.fBottom;
- SkRect vertical = opaqueRect;
- if (deltaLeft > deltaRight)
- vertical.fRight = rect.fLeft;
- else
- vertical.fLeft = rect.fRight;
-
- if ((long)horizontal.width() * (long)horizontal.height() > (long)vertical.width() * (long)vertical.height())
- opaqueRect = horizontal;
- else
- opaqueRect = vertical;
-}
-
-void OpaqueRegionSkia::markAllAsNonOpaque()
-{
- SkRect& opaqueRect = currentTrackingOpaqueRect(m_opaqueRect, m_canvasLayerStack);
- opaqueRect.setEmpty();
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/skia/OpaqueRegionSkia.h b/Source/WebCore/platform/graphics/skia/OpaqueRegionSkia.h
deleted file mode 100644
index dcc1fcb97..000000000
--- a/Source/WebCore/platform/graphics/skia/OpaqueRegionSkia.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2012, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef OpaqueRegionSkia_h
-#define OpaqueRegionSkia_h
-
-#include "IntRect.h"
-
-#include "SkBitmap.h"
-#include "SkCanvas.h"
-#include "SkPaint.h"
-#include "SkPoint.h"
-#include "SkRect.h"
-
-namespace WebCore {
-class PlatformContextSkia;
-
-// This class is an encapsulation of functionality for PlatformContextSkia, and its methods are mirrored
-// there for the outside world. It tracks paints and computes what area will be opaque.
-class OpaqueRegionSkia {
-public:
- OpaqueRegionSkia();
- virtual ~OpaqueRegionSkia();
-
- // The resulting opaque region as a single rect.
- IntRect asRect() const;
-
- void pushCanvasLayer(const SkPaint*);
- void popCanvasLayer(const PlatformContextSkia*);
-
- void setImageMask(const SkRect& imageOpaqueRect);
-
- enum DrawType {
- FillOnly,
- FillOrStroke
- };
-
- void didDrawRect(const PlatformContextSkia*, const SkRect&, const SkPaint&, const SkBitmap* sourceBitmap);
- void didDrawPath(const PlatformContextSkia*, const SkPath&, const SkPaint&);
- void didDrawPoints(const PlatformContextSkia*, SkCanvas::PointMode, int numPoints, const SkPoint[], const SkPaint&);
- void didDrawBounded(const PlatformContextSkia*, const SkRect&, const SkPaint&);
- void didDrawUnbounded(const PlatformContextSkia*, const SkPaint&, DrawType);
-
- struct CanvasLayerState {
- CanvasLayerState()
- : hasImageMask(false)
- , opaqueRect(SkRect::MakeEmpty())
- { }
-
- SkPaint paint;
-
- // An image mask is being applied to the layer.
- bool hasImageMask;
- // The opaque area in the image mask.
- SkRect imageOpaqueRect;
-
- SkRect opaqueRect;
- };
-
-private:
- void didDraw(const PlatformContextSkia*, const SkRect&, const SkPaint&, const SkBitmap* sourceBitmap, bool fillsBounds, DrawType);
- void applyOpaqueRegionFromLayer(const PlatformContextSkia*, const SkRect& layerOpaqueRect, const SkPaint&);
- void markRectAsOpaque(const SkRect&);
- void markRectAsNonOpaque(const SkRect&);
- void markAllAsNonOpaque();
-
- SkRect m_opaqueRect;
-
- Vector<CanvasLayerState, 3> m_canvasLayerStack;
-};
-
-}
-#endif // OpaqueRegionSkia_h
diff --git a/Source/WebCore/platform/graphics/skia/PathSkia.cpp b/Source/WebCore/platform/graphics/skia/PathSkia.cpp
deleted file mode 100644
index 47587525d..000000000
--- a/Source/WebCore/platform/graphics/skia/PathSkia.cpp
+++ /dev/null
@@ -1,313 +0,0 @@
-// Copyright (c) 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#include "config.h"
-#include "Path.h"
-
-#include "AffineTransform.h"
-#include "FloatRect.h"
-#include "ImageBuffer.h"
-#include "StrokeStyleApplier.h"
-
-#include "SkPath.h"
-#include "SkRegion.h"
-#include "SkiaUtils.h"
-
-#include <wtf/MathExtras.h>
-
-namespace WebCore {
-
-Path::Path()
- : m_path(0)
-{
-}
-
-Path::Path(const Path& other)
-{
- m_path = other.m_path ? new SkPath(*other.m_path) : 0;
-}
-
-#if PLATFORM(BLACKBERRY)
-Path::Path(const SkPath& path)
-{
- m_path = new SkPath(path);
-}
-#endif
-
-Path::~Path()
-{
- if (m_path)
- delete m_path;
-}
-
-PlatformPathPtr Path::ensurePlatformPath()
-{
- if (!m_path)
- m_path = new SkPath();
- return m_path;
-}
-
-Path& Path::operator=(const Path& other)
-{
- if (other.isNull()) {
- if (m_path)
- delete m_path;
- m_path = 0;
- } else
- *ensurePlatformPath() = *other.m_path;
- return *this;
-}
-
-bool Path::isEmpty() const
-{
- return isNull() || m_path->isEmpty();
-}
-
-bool Path::hasCurrentPoint() const
-{
- return !isNull() && m_path->getPoints(0, 0);
-}
-
-FloatPoint Path::currentPoint() const
-{
- if (!isNull() && m_path->countPoints() > 0) {
- SkPoint skResult;
- m_path->getLastPt(&skResult);
- FloatPoint result;
- result.setX(SkScalarToFloat(skResult.fX));
- result.setY(SkScalarToFloat(skResult.fY));
- return result;
- }
-
- // FIXME: Why does this return quietNaN? Other ports return 0,0.
- float quietNaN = std::numeric_limits<float>::quiet_NaN();
- return FloatPoint(quietNaN, quietNaN);
-}
-
-bool Path::contains(const FloatPoint& point, WindRule rule) const
-{
- if (isNull())
- return false;
- return SkPathContainsPoint(m_path, point, rule == RULE_NONZERO ? SkPath::kWinding_FillType : SkPath::kEvenOdd_FillType);
-}
-
-void Path::translate(const FloatSize& size)
-{
- ensurePlatformPath()->offset(WebCoreFloatToSkScalar(size.width()), WebCoreFloatToSkScalar(size.height()));
-}
-
-FloatRect Path::boundingRect() const
-{
- if (isNull())
- return FloatRect();
- return m_path->getBounds();
-}
-
-void Path::moveTo(const FloatPoint& point)
-{
- ensurePlatformPath()->moveTo(point);
-}
-
-void Path::addLineTo(const FloatPoint& point)
-{
- ensurePlatformPath()->lineTo(point);
-}
-
-void Path::addQuadCurveTo(const FloatPoint& cp, const FloatPoint& ep)
-{
- ensurePlatformPath()->quadTo(cp, ep);
-}
-
-void Path::addBezierCurveTo(const FloatPoint& p1, const FloatPoint& p2, const FloatPoint& ep)
-{
- ensurePlatformPath()->cubicTo(p1, p2, ep);
-}
-
-void Path::addArcTo(const FloatPoint& p1, const FloatPoint& p2, float radius)
-{
- ensurePlatformPath()->arcTo(p1, p2, WebCoreFloatToSkScalar(radius));
-}
-
-void Path::closeSubpath()
-{
- ensurePlatformPath()->close();
-}
-
-void Path::addArc(const FloatPoint& p, float r, float sa, float ea, bool anticlockwise)
-{
- ensurePlatformPath(); // Make sure m_path is not null.
-
- SkScalar cx = WebCoreFloatToSkScalar(p.x());
- SkScalar cy = WebCoreFloatToSkScalar(p.y());
- SkScalar radius = WebCoreFloatToSkScalar(r);
- SkScalar s360 = SkIntToScalar(360);
-
- SkRect oval;
- oval.set(cx - radius, cy - radius, cx + radius, cy + radius);
-
- float sweep = ea - sa;
- SkScalar startDegrees = WebCoreFloatToSkScalar(sa * 180 / piFloat);
- SkScalar sweepDegrees = WebCoreFloatToSkScalar(sweep * 180 / piFloat);
- // Check for a circle.
- if (sweepDegrees >= s360 || sweepDegrees <= -s360) {
- // Move to the start position (0 sweep means we add a single point).
- m_path->arcTo(oval, startDegrees, 0, false);
- // Draw the circle.
- m_path->addOval(oval, anticlockwise ?
- SkPath::kCCW_Direction : SkPath::kCW_Direction);
- // Force a moveTo the end position.
- m_path->arcTo(oval, startDegrees + sweepDegrees, 0, true);
- } else {
- // Counterclockwise arcs should be drawn with negative sweeps, while
- // clockwise arcs should be drawn with positive sweeps. Check to see
- // if the situation is reversed and correct it by adding or subtracting
- // a full circle
- if (anticlockwise && sweepDegrees > 0) {
- sweepDegrees -= s360;
- } else if (!anticlockwise && sweepDegrees < 0) {
- sweepDegrees += s360;
- }
-
- m_path->arcTo(oval, startDegrees, sweepDegrees, false);
- }
-}
-
-void Path::addRect(const FloatRect& rect)
-{
- ensurePlatformPath()->addRect(rect);
-}
-
-void Path::addEllipse(const FloatRect& rect)
-{
- ensurePlatformPath()->addOval(rect);
-}
-
-void Path::clear()
-{
- if (isNull())
- return;
- m_path->reset();
-}
-
-static FloatPoint* convertPathPoints(FloatPoint dst[], const SkPoint src[], int count)
-{
- for (int i = 0; i < count; i++) {
- dst[i].setX(SkScalarToFloat(src[i].fX));
- dst[i].setY(SkScalarToFloat(src[i].fY));
- }
- return dst;
-}
-
-void Path::apply(void* info, PathApplierFunction function) const
-{
- if (isNull())
- return;
-
- SkPath::RawIter iter(*m_path);
- SkPoint pts[4];
- PathElement pathElement;
- FloatPoint pathPoints[3];
-
- for (;;) {
- switch (iter.next(pts)) {
- case SkPath::kMove_Verb:
- pathElement.type = PathElementMoveToPoint;
- pathElement.points = convertPathPoints(pathPoints, &pts[0], 1);
- break;
- case SkPath::kLine_Verb:
- pathElement.type = PathElementAddLineToPoint;
- pathElement.points = convertPathPoints(pathPoints, &pts[1], 1);
- break;
- case SkPath::kQuad_Verb:
- pathElement.type = PathElementAddQuadCurveToPoint;
- pathElement.points = convertPathPoints(pathPoints, &pts[1], 2);
- break;
- case SkPath::kCubic_Verb:
- pathElement.type = PathElementAddCurveToPoint;
- pathElement.points = convertPathPoints(pathPoints, &pts[1], 3);
- break;
- case SkPath::kClose_Verb:
- pathElement.type = PathElementCloseSubpath;
- pathElement.points = convertPathPoints(pathPoints, 0, 0);
- break;
- case SkPath::kDone_Verb:
- return;
- }
- function(info, &pathElement);
- }
-}
-
-void Path::transform(const AffineTransform& xform)
-{
- ensurePlatformPath()->transform(xform);
-}
-
-FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier) const
-{
- if (isNull())
- return FloatRect();
-
- GraphicsContext* scratch = scratchContext();
- scratch->save();
-
- if (applier)
- applier->strokeStyle(scratch);
-
- SkPaint paint;
- scratch->platformContext()->setupPaintForStroking(&paint, 0, 0);
- SkPath boundingPath;
- paint.getFillPath(*platformPath(), &boundingPath);
-
- FloatRect r = boundingPath.getBounds();
- scratch->restore();
- return r;
-}
-
-bool Path::strokeContains(StrokeStyleApplier* applier, const FloatPoint& point) const
-{
- if (isNull())
- return false;
-
- ASSERT(applier);
- GraphicsContext* scratch = scratchContext();
- scratch->save();
-
- applier->strokeStyle(scratch);
-
- SkPaint paint;
- scratch->platformContext()->setupPaintForStroking(&paint, 0, 0);
- SkPath strokePath;
- paint.getFillPath(*platformPath(), &strokePath);
- bool contains = SkPathContainsPoint(&strokePath, point, SkPath::kWinding_FillType);
-
- scratch->restore();
- return contains;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/skia/PatternSkia.cpp b/Source/WebCore/platform/graphics/skia/PatternSkia.cpp
deleted file mode 100644
index 2ae4dd681..000000000
--- a/Source/WebCore/platform/graphics/skia/PatternSkia.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2008 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Pattern.h"
-
-#include "AffineTransform.h"
-#include "Image.h"
-#include "NativeImageSkia.h"
-
-#include "SkCanvas.h"
-#include "SkColor.h"
-#include "SkColorShader.h"
-#include "SkShader.h"
-
-#if USE(V8)
-#include <v8.h>
-#endif
-
-using namespace std;
-
-namespace WebCore {
-
-void Pattern::platformDestroy()
-{
- SkSafeUnref(m_pattern);
- m_pattern = 0;
- if (m_externalMemoryAllocated) {
-#if USE(V8)
- v8::V8::AdjustAmountOfExternalAllocatedMemory(-m_externalMemoryAllocated);
-#endif
- m_externalMemoryAllocated = 0;
- }
-}
-
-PlatformPatternPtr Pattern::platformPattern(const AffineTransform& patternTransform)
-{
- if (m_pattern)
- return m_pattern;
-
- // Note: patternTransform is ignored since it seems to be applied elsewhere
- // (when the pattern is used?). Applying it to the pattern (i.e.
- // shader->setLocalMatrix) results in a double transformation. This can be
- // seen, for instance, as an extra offset in:
- // LayoutTests/fast/canvas/patternfill-repeat.html
- // and expanded scale and skew in:
- // LayoutTests/svg/W3C-SVG-1.1/pservers-grad-06-b.svg
-
- const NativeImageSkia* image = m_tileImage->nativeImageForCurrentFrame();
- // If we don't have a bitmap, return a transparent shader.
- if (!image)
- m_pattern = new SkColorShader(SkColorSetARGB(0, 0, 0, 0));
-
- else if (m_repeatX && m_repeatY)
- m_pattern = SkShader::CreateBitmapShader(image->bitmap(), SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);
-
- else {
-
- // Skia does not have a "draw the tile only once" option. Clamp_TileMode
- // repeats the last line of the image after drawing one tile. To avoid
- // filling the space with arbitrary pixels, this workaround forces the
- // image to have a line of transparent pixels on the "repeated" edge(s),
- // thus causing extra space to be transparent filled.
- SkShader::TileMode tileModeX = m_repeatX ? SkShader::kRepeat_TileMode : SkShader::kClamp_TileMode;
- SkShader::TileMode tileModeY = m_repeatY ? SkShader::kRepeat_TileMode : SkShader::kClamp_TileMode;
- int expandW = m_repeatX ? 0 : 1;
- int expandH = m_repeatY ? 0 : 1;
-
- // Create a transparent bitmap 1 pixel wider and/or taller than the
- // original, then copy the orignal into it.
- // FIXME: Is there a better way to pad (not scale) an image in skia?
- SkBitmap bm2;
- bm2.setConfig(image->bitmap().config(), image->bitmap().width() + expandW, image->bitmap().height() + expandH);
- bm2.allocPixels();
- bm2.eraseARGB(0x00, 0x00, 0x00, 0x00);
- SkCanvas canvas(bm2);
- canvas.drawBitmap(image->bitmap(), 0, 0);
- bm2.setImmutable();
- m_pattern = SkShader::CreateBitmapShader(bm2, tileModeX, tileModeY);
-
- // Clamp to int, since that's what the adjust function takes.
- m_externalMemoryAllocated = static_cast<int>(min(static_cast<size_t>(INT_MAX), bm2.getSafeSize()));
-#if USE(V8)
- v8::V8::AdjustAmountOfExternalAllocatedMemory(m_externalMemoryAllocated);
-#endif
- }
- m_pattern->setLocalMatrix(m_patternSpaceTransformation);
- return m_pattern;
-}
-
-void Pattern::setPlatformPatternSpaceTransform()
-{
- if (m_pattern)
- m_pattern->setLocalMatrix(m_patternSpaceTransformation);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp b/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp
deleted file mode 100644
index b466469cf..000000000
--- a/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp
+++ /dev/null
@@ -1,633 +0,0 @@
-/*
- * Copyright (c) 2008, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "PlatformContextSkia.h"
-
-#include "Extensions3D.h"
-#include "GraphicsContext.h"
-#include "GraphicsContext3D.h"
-#include "ImageBuffer.h"
-#include "NativeImageSkia.h"
-#include "SkiaUtils.h"
-#include "Texture.h"
-#include "TilingData.h"
-
-#include "skia/ext/image_operations.h"
-#include "skia/ext/platform_canvas.h"
-
-#include "SkBitmap.h"
-#include "SkColorPriv.h"
-#include "SkDashPathEffect.h"
-#include "SkShader.h"
-
-#include <wtf/MathExtras.h>
-#include <wtf/Vector.h>
-
-#if PLATFORM(CHROMIUM)
-#include "TraceEvent.h"
-#endif
-
-namespace WebCore {
-
-// State -----------------------------------------------------------------------
-
-// Encapsulates the additional painting state information we store for each
-// pushed graphics state.
-struct PlatformContextSkia::State {
- State();
- State(const State&);
- ~State();
-
- // Common shader state.
- float m_alpha;
- SkXfermode::Mode m_xferMode;
- bool m_useAntialiasing;
- SkDrawLooper* m_looper;
-
- // Fill.
- SkColor m_fillColor;
-
- // Stroke.
- StrokeStyle m_strokeStyle;
- SkColor m_strokeColor;
- float m_strokeThickness;
- int m_dashRatio; // Ratio of the length of a dash to its width.
- float m_miterLimit;
- SkPaint::Cap m_lineCap;
- SkPaint::Join m_lineJoin;
- SkDashPathEffect* m_dash;
-
- // Text. (See TextModeFill & friends in GraphicsContext.h.)
- TextDrawingModeFlags m_textDrawingMode;
-
- // Helper function for applying the state's alpha value to the given input
- // color to produce a new output color.
- SkColor applyAlpha(SkColor) const;
-
- // If non-empty, the current State is clipped to this image.
- SkBitmap m_imageBufferClip;
- // If m_imageBufferClip is non-empty, this is the region the image is clipped to.
- SkRect m_clip;
-
- InterpolationQuality m_interpolationQuality;
-
- PlatformContextSkia::State cloneInheritedProperties();
-private:
- // Not supported.
- void operator=(const State&);
-};
-
-// Note: Keep theses default values in sync with GraphicsContextState.
-PlatformContextSkia::State::State()
- : m_alpha(1)
- , m_xferMode(SkXfermode::kSrcOver_Mode)
- , m_useAntialiasing(true)
- , m_looper(0)
- , m_fillColor(0xFF000000)
- , m_strokeStyle(SolidStroke)
- , m_strokeColor(Color::black)
- , m_strokeThickness(0)
- , m_dashRatio(3)
- , m_miterLimit(4)
- , m_lineCap(SkPaint::kDefault_Cap)
- , m_lineJoin(SkPaint::kDefault_Join)
- , m_dash(0)
- , m_textDrawingMode(TextModeFill)
-#if USE(LOW_QUALITY_IMAGE_INTERPOLATION)
- , m_interpolationQuality(InterpolationLow)
-#else
- , m_interpolationQuality(InterpolationHigh)
-#endif
-{
-}
-
-PlatformContextSkia::State::State(const State& other)
- : m_alpha(other.m_alpha)
- , m_xferMode(other.m_xferMode)
- , m_useAntialiasing(other.m_useAntialiasing)
- , m_looper(other.m_looper)
- , m_fillColor(other.m_fillColor)
- , m_strokeStyle(other.m_strokeStyle)
- , m_strokeColor(other.m_strokeColor)
- , m_strokeThickness(other.m_strokeThickness)
- , m_dashRatio(other.m_dashRatio)
- , m_miterLimit(other.m_miterLimit)
- , m_lineCap(other.m_lineCap)
- , m_lineJoin(other.m_lineJoin)
- , m_dash(other.m_dash)
- , m_textDrawingMode(other.m_textDrawingMode)
- , m_imageBufferClip(other.m_imageBufferClip)
- , m_clip(other.m_clip)
- , m_interpolationQuality(other.m_interpolationQuality)
-{
- // Up the ref count of these. SkSafeRef does nothing if its argument is 0.
- SkSafeRef(m_looper);
- SkSafeRef(m_dash);
-}
-
-PlatformContextSkia::State::~State()
-{
- SkSafeUnref(m_looper);
- SkSafeUnref(m_dash);
-}
-
-// Returns a new State with all of this object's inherited properties copied.
-PlatformContextSkia::State PlatformContextSkia::State::cloneInheritedProperties()
-{
- return PlatformContextSkia::State(*this);
-}
-
-SkColor PlatformContextSkia::State::applyAlpha(SkColor c) const
-{
- int s = roundf(m_alpha * 256);
- if (s >= 256)
- return c;
- if (s < 0)
- return 0;
-
- int a = SkAlphaMul(SkColorGetA(c), s);
- return (c & 0x00FFFFFF) | (a << 24);
-}
-
-// PlatformContextSkia ---------------------------------------------------------
-
-// Danger: canvas can be NULL.
-PlatformContextSkia::PlatformContextSkia(SkCanvas* canvas)
- : m_canvas(canvas)
- , m_trackOpaqueRegion(false)
- , m_printing(false)
- , m_accelerated(false)
- , m_deferred(false)
- , m_drawingToImageBuffer(false)
- , m_deviceScaleFactor(1)
-#if defined(SK_SUPPORT_HINTING_SCALE_FACTOR)
- , m_hintingScaleFactor(SK_Scalar1)
-#endif
-{
- m_stateStack.append(State());
- m_state = &m_stateStack.last();
-
- // will be assigned in setGraphicsContext()
- m_gc = 0;
-}
-
-PlatformContextSkia::~PlatformContextSkia()
-{
-}
-
-void PlatformContextSkia::setCanvas(SkCanvas* canvas)
-{
- m_canvas = canvas;
-}
-
-void PlatformContextSkia::setDrawingToImageBuffer(bool value)
-{
- m_drawingToImageBuffer = value;
-}
-
-bool PlatformContextSkia::isDrawingToImageBuffer() const
-{
- return m_drawingToImageBuffer;
-}
-
-void PlatformContextSkia::save()
-{
- m_stateStack.append(m_state->cloneInheritedProperties());
- m_state = &m_stateStack.last();
-
- // The clip image only needs to be applied once. Reset the image so that we
- // don't attempt to clip multiple times.
- m_state->m_imageBufferClip.reset();
-
- // Save our native canvas.
- m_canvas->save();
-}
-
-void PlatformContextSkia::saveLayer(const SkRect* bounds, const SkPaint* paint)
-{
- m_canvas->saveLayer(bounds, paint);
- if (bounds)
- m_canvas->clipRect(*bounds);
- if (m_trackOpaqueRegion)
- m_opaqueRegion.pushCanvasLayer(paint);
-}
-
-void PlatformContextSkia::saveLayer(const SkRect* bounds, const SkPaint* paint, SkCanvas::SaveFlags saveFlags)
-{
- m_canvas->saveLayer(bounds, paint, saveFlags);
- if (bounds)
- m_canvas->clipRect(*bounds);
- if (m_trackOpaqueRegion)
- m_opaqueRegion.pushCanvasLayer(paint);
-}
-
-void PlatformContextSkia::restoreLayer()
-{
- m_canvas->restore();
- if (m_trackOpaqueRegion)
- m_opaqueRegion.popCanvasLayer(this);
-}
-
-void PlatformContextSkia::beginLayerClippedToImage(const FloatRect& rect,
- const ImageBuffer* imageBuffer)
-{
- SkRect bounds = { SkFloatToScalar(rect.x()), SkFloatToScalar(rect.y()),
- SkFloatToScalar(rect.maxX()), SkFloatToScalar(rect.maxY()) };
-
- if (imageBuffer->internalSize().isEmpty()) {
- m_canvas->clipRect(bounds);
- return;
- }
-
- // Skia doesn't support clipping to an image, so we create a layer. The next
- // time restore is invoked the layer and |imageBuffer| are combined to
- // create the resulting image.
-
- m_state->m_clip = bounds;
- // Get the absolute coordinates of the stored clipping rectangle to make it
- // independent of any transform changes.
- getTotalMatrix().mapRect(&m_state->m_clip);
-
- SkCanvas::SaveFlags saveFlags = static_cast<SkCanvas::SaveFlags>(SkCanvas::kHasAlphaLayer_SaveFlag | SkCanvas::kFullColorLayer_SaveFlag);
- saveLayer(&bounds, 0, saveFlags);
-
- const SkBitmap* bitmap = imageBuffer->context()->platformContext()->bitmap();
-
- if (m_trackOpaqueRegion) {
- SkRect opaqueRect = bitmap->isOpaque() ? m_state->m_clip : SkRect::MakeEmpty();
- m_opaqueRegion.setImageMask(opaqueRect);
- }
-
- // Copy off the image as |imageBuffer| may be deleted before restore is invoked.
- if (bitmap->isImmutable())
- m_state->m_imageBufferClip = *bitmap;
- else {
- // We need to make a deep-copy of the pixels themselves, so they don't
- // change on us between now and when we want to apply them in restore()
- bitmap->copyTo(&m_state->m_imageBufferClip, SkBitmap::kARGB_8888_Config);
- }
-}
-
-void PlatformContextSkia::restore()
-{
- if (!m_state->m_imageBufferClip.empty()) {
- applyClipFromImage(m_state->m_clip, m_state->m_imageBufferClip);
- m_canvas->restore();
- }
-
- m_stateStack.removeLast();
- m_state = &m_stateStack.last();
-
- // Restore our native canvas.
- m_canvas->restore();
-}
-
-void PlatformContextSkia::drawRect(SkRect rect)
-{
- SkPaint paint;
- int fillcolorNotTransparent = m_state->m_fillColor & 0xFF000000;
- if (fillcolorNotTransparent) {
- setupPaintForFilling(&paint);
- drawRect(rect, paint);
- }
-
- if (m_state->m_strokeStyle != NoStroke
- && (m_state->m_strokeColor & 0xFF000000)) {
- // We do a fill of four rects to simulate the stroke of a border.
- paint.reset();
- setupPaintForFilling(&paint);
- // need to jam in the strokeColor
- paint.setColor(this->effectiveStrokeColor());
-
- SkRect topBorder = { rect.fLeft, rect.fTop, rect.fRight, rect.fTop + 1 };
- drawRect(topBorder, paint);
- SkRect bottomBorder = { rect.fLeft, rect.fBottom - 1, rect.fRight, rect.fBottom };
- drawRect(bottomBorder, paint);
- SkRect leftBorder = { rect.fLeft, rect.fTop + 1, rect.fLeft + 1, rect.fBottom - 1 };
- drawRect(leftBorder, paint);
- SkRect rightBorder = { rect.fRight - 1, rect.fTop + 1, rect.fRight, rect.fBottom - 1 };
- drawRect(rightBorder, paint);
- }
-}
-
-void PlatformContextSkia::setupPaintCommon(SkPaint* paint) const
-{
-#if defined(SK_DEBUG)
- {
- SkPaint defaultPaint;
- SkASSERT(*paint == defaultPaint);
- }
-#endif
-
- paint->setAntiAlias(m_state->m_useAntialiasing);
- paint->setXfermodeMode(m_state->m_xferMode);
- paint->setLooper(m_state->m_looper);
-#if defined(SK_SUPPORT_HINTING_SCALE_FACTOR)
- paint->setHintingScaleFactor(m_hintingScaleFactor);
-#endif
-}
-
-void PlatformContextSkia::setupShader(SkPaint* paint, Gradient* grad, Pattern* pat, SkColor color) const
-{
- SkShader* shader = 0;
-
- if (grad) {
- shader = grad->platformGradient();
- color = SK_ColorBLACK;
- } else if (pat) {
- shader = pat->platformPattern(m_gc->getCTM());
- color = SK_ColorBLACK;
- paint->setFilterBitmap(interpolationQuality() != InterpolationNone);
- }
-
- paint->setColor(m_state->applyAlpha(color));
- paint->setShader(shader);
-}
-
-void PlatformContextSkia::setupPaintForFilling(SkPaint* paint) const
-{
- setupPaintCommon(paint);
-
- const GraphicsContextState& state = m_gc->state();
- setupShader(paint, state.fillGradient.get(), state.fillPattern.get(), m_state->m_fillColor);
-}
-
-float PlatformContextSkia::setupPaintForStroking(SkPaint* paint, SkRect* rect, int length) const
-{
- setupPaintCommon(paint);
-
- const GraphicsContextState& state = m_gc->state();
- setupShader(paint, state.strokeGradient.get(), state.strokePattern.get(), m_state->m_strokeColor);
-
- float width = m_state->m_strokeThickness;
-
- paint->setStyle(SkPaint::kStroke_Style);
- paint->setStrokeWidth(SkFloatToScalar(width));
- paint->setStrokeCap(m_state->m_lineCap);
- paint->setStrokeJoin(m_state->m_lineJoin);
- paint->setStrokeMiter(SkFloatToScalar(m_state->m_miterLimit));
-
- if (m_state->m_dash)
- paint->setPathEffect(m_state->m_dash);
- else {
- switch (m_state->m_strokeStyle) {
- case NoStroke:
- case SolidStroke:
-#if ENABLE(CSS3_TEXT)
- case DoubleStroke:
- case WavyStroke: // FIXME: https://bugs.webkit.org/show_bug.cgi?id=93509 - Needs platform support.
-#endif // CSS3_TEXT
- break;
- case DashedStroke:
- width = m_state->m_dashRatio * width;
- // Fall through.
- case DottedStroke:
- // Truncate the width, since we don't want fuzzy dots or dashes.
- int dashLength = static_cast<int>(width);
- // Subtract off the endcaps, since they're rendered separately.
- int distance = length - 2 * static_cast<int>(m_state->m_strokeThickness);
- int phase = 1;
- if (dashLength > 1) {
- // Determine how many dashes or dots we should have.
- int numDashes = distance / dashLength;
- int remainder = distance % dashLength;
- // Adjust the phase to center the dashes within the line.
- if (numDashes % 2 == 0) {
- // Even: shift right half a dash, minus half the remainder
- phase = (dashLength - remainder) / 2;
- } else {
- // Odd: shift right a full dash, minus half the remainder
- phase = dashLength - remainder / 2;
- }
- }
- SkScalar dashLengthSk = SkIntToScalar(dashLength);
- SkScalar intervals[2] = { dashLengthSk, dashLengthSk };
- paint->setPathEffect(new SkDashPathEffect(intervals, 2, SkIntToScalar(phase)))->unref();
- }
- }
-
- return width;
-}
-
-void PlatformContextSkia::setDrawLooper(SkDrawLooper* dl)
-{
- SkRefCnt_SafeAssign(m_state->m_looper, dl);
-}
-
-void PlatformContextSkia::setMiterLimit(float ml)
-{
- m_state->m_miterLimit = ml;
-}
-
-void PlatformContextSkia::setAlpha(float alpha)
-{
- m_state->m_alpha = alpha;
-}
-
-void PlatformContextSkia::setLineCap(SkPaint::Cap lc)
-{
- m_state->m_lineCap = lc;
-}
-
-void PlatformContextSkia::setLineJoin(SkPaint::Join lj)
-{
- m_state->m_lineJoin = lj;
-}
-
-void PlatformContextSkia::setXfermodeMode(SkXfermode::Mode pdm)
-{
- m_state->m_xferMode = pdm;
-}
-
-void PlatformContextSkia::setFillColor(SkColor color)
-{
- m_state->m_fillColor = color;
-}
-
-SkDrawLooper* PlatformContextSkia::getDrawLooper() const
-{
- return m_state->m_looper;
-}
-
-StrokeStyle PlatformContextSkia::getStrokeStyle() const
-{
- return m_state->m_strokeStyle;
-}
-
-void PlatformContextSkia::setStrokeStyle(StrokeStyle strokeStyle)
-{
- m_state->m_strokeStyle = strokeStyle;
-}
-
-void PlatformContextSkia::setStrokeColor(SkColor strokeColor)
-{
- m_state->m_strokeColor = strokeColor;
-}
-
-float PlatformContextSkia::getStrokeThickness() const
-{
- return m_state->m_strokeThickness;
-}
-
-void PlatformContextSkia::setStrokeThickness(float thickness)
-{
- m_state->m_strokeThickness = thickness;
-}
-
-TextDrawingModeFlags PlatformContextSkia::getTextDrawingMode() const
-{
- return m_state->m_textDrawingMode;
-}
-
-float PlatformContextSkia::getAlpha() const
-{
- return m_state->m_alpha;
-}
-
-int PlatformContextSkia::getNormalizedAlpha() const
-{
- int alpha = roundf(m_state->m_alpha * 256);
- if (alpha > 255)
- alpha = 255;
- else if (alpha < 0)
- alpha = 0;
- return alpha;
-}
-
-SkXfermode::Mode PlatformContextSkia::getXfermodeMode() const
-{
- return m_state->m_xferMode;
-}
-
-void PlatformContextSkia::setTextDrawingMode(TextDrawingModeFlags mode)
-{
- m_state->m_textDrawingMode = mode;
-}
-
-void PlatformContextSkia::setUseAntialiasing(bool enable)
-{
- m_state->m_useAntialiasing = enable;
-}
-
-SkColor PlatformContextSkia::effectiveFillColor() const
-{
- return m_state->applyAlpha(m_state->m_fillColor);
-}
-
-SkColor PlatformContextSkia::effectiveStrokeColor() const
-{
- return m_state->applyAlpha(m_state->m_strokeColor);
-}
-
-void PlatformContextSkia::canvasClipPath(const SkPath& path)
-{
- m_canvas->clipPath(path);
-}
-
-InterpolationQuality PlatformContextSkia::interpolationQuality() const
-{
- return m_state->m_interpolationQuality;
-}
-
-void PlatformContextSkia::setInterpolationQuality(InterpolationQuality interpolationQuality)
-{
- m_state->m_interpolationQuality = interpolationQuality;
-}
-
-void PlatformContextSkia::setDashPathEffect(SkDashPathEffect* dash)
-{
- if (dash != m_state->m_dash) {
- SkSafeUnref(m_state->m_dash);
- m_state->m_dash = dash;
- }
-}
-
-const SkBitmap* PlatformContextSkia::bitmap() const
-{
-#if PLATFORM(CHROMIUM)
- TRACE_EVENT0("skia", "PlatformContextSkia::bitmap");
-#endif
- return &m_canvas->getDevice()->accessBitmap(false);
-}
-
-bool PlatformContextSkia::isNativeFontRenderingAllowed()
-{
-#if USE(SKIA_TEXT)
- return false;
-#else
- if (isAccelerated())
- return false;
- return skia::SupportsPlatformPaint(m_canvas);
-#endif
-}
-
-void PlatformContextSkia::applyClipFromImage(const SkRect& rect, const SkBitmap& imageBuffer)
-{
- // NOTE: this assumes the image mask contains opaque black for the portions that are to be shown, as such we
- // only look at the alpha when compositing. I'm not 100% sure this is what WebKit expects for image clipping.
- SkPaint paint;
- paint.setXfermodeMode(SkXfermode::kDstIn_Mode);
- m_canvas->save(SkCanvas::kMatrix_SaveFlag);
- m_canvas->resetMatrix();
- m_canvas->drawBitmapRect(imageBuffer, 0, rect, &paint);
- m_canvas->restore();
-}
-
-void PlatformContextSkia::didDrawRect(const SkRect& rect, const SkPaint& paint, const SkBitmap* bitmap)
-{
- if (m_trackOpaqueRegion)
- m_opaqueRegion.didDrawRect(this, rect, paint, bitmap);
-}
-
-void PlatformContextSkia::adjustTextRenderMode(SkPaint* paint)
-{
- if (!paint->isLCDRenderText())
- return;
-
- paint->setLCDRenderText(couldUseLCDRenderedText());
-}
-
-bool PlatformContextSkia::couldUseLCDRenderedText()
-{
- // Our layers only have a single alpha channel. This means that subpixel
- // rendered text cannot be composited correctly when the layer is
- // collapsed. Therefore, subpixel text is disabled when we are drawing
- // onto a layer.
- if (isDrawingToLayer())
- return false;
-
- // If this text is not in an image buffer and so won't be externally
- // composited, then subpixel antialiasing is fine.
- return !isDrawingToImageBuffer();
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h b/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h
deleted file mode 100644
index 501ac0552..000000000
--- a/Source/WebCore/platform/graphics/skia/PlatformContextSkia.h
+++ /dev/null
@@ -1,464 +0,0 @@
-/*
- * Copyright (c) 2008, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef PlatformContextSkia_h
-#define PlatformContextSkia_h
-
-#include "GraphicsContext.h"
-#include "OpaqueRegionSkia.h"
-
-#include "SkCanvas.h"
-#include "SkDashPathEffect.h"
-#include "SkDevice.h"
-#include "SkDrawLooper.h"
-#include "SkPaint.h"
-#include "SkPath.h"
-
-#include <wtf/Noncopyable.h>
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-enum CompositeOperator;
-class Texture;
-
-// This class holds the platform-specific state for GraphicsContext. We put
-// most of our Skia wrappers on this class. In theory, a lot of this stuff could
-// be moved to GraphicsContext directly, except that some code external to this
-// would like to poke at our graphics layer as well (like the Image and Font
-// stuff, which needs some amount of our wrappers and state around SkCanvas).
-//
-// So in general, this class uses just Skia types except when there's no easy
-// conversion. GraphicsContext is responsible for converting the WebKit types to
-// Skia types and setting up the eventual call to the Skia functions.
-//
-// This class then keeps track of all the current Skia state. WebKit expects
-// that the graphics state that is pushed and popped by save() and restore()
-// includes things like colors and pen styles. Skia does this differently, where
-// push and pop only includes transforms and bitmaps, and the application is
-// responsible for managing the painting state which is store in separate
-// SkPaint objects. This class provides the adaptor that allows the painting
-// state to be pushed and popped along with the bitmap.
-class PlatformContextSkia {
- WTF_MAKE_NONCOPYABLE(PlatformContextSkia);
-public:
- // For printing, there shouldn't be any canvas. canvas can be NULL. If you
- // supply a NULL canvas, you can also call setCanvas later.
- PlatformContextSkia(SkCanvas*);
- ~PlatformContextSkia();
-
- // Sets the graphics context associated with this context.
- // GraphicsContextSkia calls this from its constructor.
- void setGraphicsContext(const GraphicsContext* gc) { m_gc = gc; }
-
- // Sets the canvas associated with this context. Use when supplying NULL
- // to the constructor.
- void setCanvas(SkCanvas*);
-
- // If false we're rendering to a GraphicsContext for a web page, if false
- // we're not (as is the case when rendering to a canvas object).
- // If this is true the contents have not been marked up with the magic
- // color and all text drawing needs to go to a layer so that the alpha is
- // correctly updated.
- void setDrawingToImageBuffer(bool);
- bool isDrawingToImageBuffer() const;
-
- void save();
- void restore();
-
- void saveLayer(const SkRect* bounds, const SkPaint*);
- void saveLayer(const SkRect* bounds, const SkPaint*, SkCanvas::SaveFlags);
- void restoreLayer();
-
- // Begins a layer that is clipped to the image |imageBuffer| at the location
- // |rect|. This layer is implicitly restored when the next restore is
- // invoked.
- // NOTE: |imageBuffer| may be deleted before the |restore| is invoked.
- void beginLayerClippedToImage(const FloatRect&, const ImageBuffer*);
-
- // Sets up the common flags on a paint for antialiasing, effects, etc.
- // This is implicitly called by setupPaintFill and setupPaintStroke, but
- // you may wish to call it directly sometimes if you don't want that other
- // behavior.
- void setupPaintCommon(SkPaint*) const;
-
- // Sets up the paint for the current fill style.
- void setupPaintForFilling(SkPaint*) const;
-
- // Sets up the paint for stroking. Returns an int representing the width of
- // the pen, or 1 if the pen's width is 0 if a non-zero length is provided,
- // the number of dashes/dots on a dashed/dotted line will be adjusted to
- // start and end that length with a dash/dot.
- float setupPaintForStroking(SkPaint*, SkRect*, int length) const;
-
- // State setting functions.
- void setDrawLooper(SkDrawLooper*); // Note: takes an additional ref.
- void setMiterLimit(float);
- void setAlpha(float);
- void setLineCap(SkPaint::Cap);
- void setLineJoin(SkPaint::Join);
- void setXfermodeMode(SkXfermode::Mode);
- void setFillColor(SkColor);
- void setStrokeStyle(StrokeStyle);
- void setStrokeColor(SkColor);
- void setStrokeThickness(float thickness);
- void setTextDrawingMode(TextDrawingModeFlags mode);
- void setUseAntialiasing(bool enable);
- void setDashPathEffect(SkDashPathEffect*);
-
- SkDrawLooper* getDrawLooper() const;
- StrokeStyle getStrokeStyle() const;
- float getStrokeThickness() const;
- TextDrawingModeFlags getTextDrawingMode() const;
- float getAlpha() const;
- int getNormalizedAlpha() const;
- SkXfermode::Mode getXfermodeMode() const;
-
- void canvasClipPath(const SkPath&);
-
- // Returns the fill color. The returned color has it's alpha adjusted
- // by the current alpha.
- SkColor effectiveFillColor() const;
-
- // Returns the stroke color. The returned color has it's alpha adjusted
- // by the current alpha.
- SkColor effectiveStrokeColor() const;
-
- // Returns the canvas used for painting, NOT guaranteed to be non-null.
- SkCanvas* canvas() { return m_canvas; }
- const SkCanvas* canvas() const { return m_canvas; }
-
- InterpolationQuality interpolationQuality() const;
- void setInterpolationQuality(InterpolationQuality interpolationQuality);
-
- // FIXME: This should be pushed down to GraphicsContext.
- void drawRect(SkRect rect);
-
- // Returns if the context is a printing context instead of a display
- // context. Bitmap shouldn't be resampled when printing to keep the best
- // possible quality.
- bool printing() const { return m_printing; }
- void setPrinting(bool p) { m_printing = p; }
-
- // Returns if the context allows rendering of fonts using native platform
- // APIs. If false is returned font rendering is performed using the skia
- // text drawing APIs.
- // if USE(SKIA_TEXT) is enabled, this always returns false
- bool isNativeFontRenderingAllowed();
-
- bool isAccelerated() const { return m_accelerated; }
- void setAccelerated(bool accelerated) { m_accelerated = accelerated; }
-
- // True if this context is deferring draw calls to be executed later.
- // We need to know this for context-to-context draws, in order to know if
- // the source bitmap needs to be copied.
- bool isDeferred() const { return m_deferred; }
- void setDeferred(bool deferred) { m_deferred = deferred; }
-
- float deviceScaleFactor() const { return m_deviceScaleFactor; }
- void setDeviceScaleFactor(float scale) { m_deviceScaleFactor = scale; }
-
- void setTrackOpaqueRegion(bool track) { m_trackOpaqueRegion = track; }
-
- // This will be an empty region unless tracking is enabled.
- const OpaqueRegionSkia& opaqueRegion() const { return m_opaqueRegion; }
-
- // After drawing directly to the context's canvas, use this function to notify the context so
- // it can track the opaque region.
- // FIXME: this is still needed only because ImageSkia::paintSkBitmap() may need to notify for a
- // smaller rect than the one drawn to, due to its clipping logic.
- void didDrawRect(const SkRect&, const SkPaint&, const SkBitmap* = 0);
-
- // Turn off LCD text for the paint if not supported on this context.
- void adjustTextRenderMode(SkPaint*);
- bool couldUseLCDRenderedText();
-
- enum AntiAliasingMode {
- NotAntiAliased,
- AntiAliased
- };
- enum AccessMode {
- ReadOnly,
- ReadWrite
- };
-
- // SkCanvas wrappers.
- const SkBitmap* bitmap() const;
- const SkBitmap& layerBitmap(AccessMode = ReadOnly) const;
- bool readPixels(SkBitmap*, int x, int y,
- SkCanvas::Config8888 = SkCanvas::kNative_Premul_Config8888);
- void writePixels(const SkBitmap&, int x, int y,
- SkCanvas::Config8888 = SkCanvas::kNative_Premul_Config8888);
- bool isDrawingToLayer() const;
- bool isVector() const;
-
- bool clipPath(const SkPath&, AntiAliasingMode = NotAntiAliased,
- SkRegion::Op = SkRegion::kIntersect_Op);
- bool clipRect(const SkRect&, AntiAliasingMode = NotAntiAliased,
- SkRegion::Op = SkRegion::kIntersect_Op);
- bool getClipBounds(SkRect*) const;
-
- void setMatrix(const SkMatrix&);
- const SkMatrix& getTotalMatrix() const;
- bool concat(const SkMatrix&);
- bool rotate(SkScalar degrees);
- bool scale(SkScalar sx, SkScalar sy);
- bool translate(SkScalar dx, SkScalar dy);
-
- void drawBitmap(const SkBitmap&, SkScalar, SkScalar, const SkPaint* = 0);
- void drawBitmapRect(const SkBitmap&, const SkIRect*, const SkRect&, const SkPaint* = 0);
- void drawOval(const SkRect&, const SkPaint&);
- void drawPath(const SkPath&, const SkPaint&);
- void drawPoints(SkCanvas::PointMode, size_t count, const SkPoint pts[], const SkPaint&);
- void drawRect(const SkRect&, const SkPaint&);
- void drawIRect(const SkIRect&, const SkPaint&);
- void drawPosText(const void* text, size_t byteLength, const SkPoint pos[], const SkPaint&);
- void drawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], SkScalar constY,
- const SkPaint&);
- void drawTextOnPath(const void* text, size_t byteLength, const SkPath&,
- const SkMatrix*, const SkPaint&);
-
-#if defined(SK_SUPPORT_HINTING_SCALE_FACTOR)
- void setHintingScaleFactor(SkScalar factor) { m_hintingScaleFactor = factor; }
- SkScalar hintingScaleFactor() const { return m_hintingScaleFactor; }
-#endif
-
-private:
- // Used when restoring and the state has an image clip. Only shows the pixels in
- // m_canvas that are also in imageBuffer.
- // The clipping rectangle is given in absolute coordinates.
- void applyClipFromImage(const SkRect&, const SkBitmap&);
-
- // common code between setupPaintFor[Filling,Stroking]
- void setupShader(SkPaint*, Gradient*, Pattern*, SkColor) const;
-
- // Defines drawing style.
- struct State;
-
- // NULL indicates painting is disabled. Never delete this object.
- SkCanvas* m_canvas;
- const GraphicsContext* m_gc;
-
- // States stack. Enables local drawing state change with save()/restore()
- // calls.
- WTF::Vector<State> m_stateStack;
- // Pointer to the current drawing state. This is a cached value of
- // mStateStack.back().
- State* m_state;
-
- // Tracks the region painted opaque via the GraphicsContext.
- OpaqueRegionSkia m_opaqueRegion;
- bool m_trackOpaqueRegion;
-
- bool m_printing;
- bool m_accelerated;
- bool m_deferred;
- bool m_drawingToImageBuffer;
- float m_deviceScaleFactor;
-#if defined(SK_SUPPORT_HINTING_SCALE_FACTOR)
- SkScalar m_hintingScaleFactor;
-#endif
-};
-
-inline const SkBitmap& PlatformContextSkia::layerBitmap(AccessMode access) const
-{
- return m_canvas->getTopDevice()->accessBitmap(access == ReadWrite);
-}
-
-inline bool PlatformContextSkia::readPixels(SkBitmap* bitmap, int x, int y,
- SkCanvas::Config8888 config8888)
-{
- return m_canvas->readPixels(bitmap, x, y, config8888);
-}
-
-inline void PlatformContextSkia::writePixels(const SkBitmap& bitmap, int x, int y,
- SkCanvas::Config8888 config8888)
-{
- m_canvas->writePixels(bitmap, x, y, config8888);
-
- if (m_trackOpaqueRegion) {
- SkRect rect = SkRect::MakeXYWH(x, y, bitmap.width(), bitmap.height());
- SkPaint paint;
-
- paint.setXfermodeMode(SkXfermode::kSrc_Mode);
- m_opaqueRegion.didDrawRect(this, rect, paint, &bitmap);
- }
-}
-
-inline bool PlatformContextSkia::isDrawingToLayer() const
-{
- return m_canvas->isDrawingToLayer();
-}
-
-inline bool PlatformContextSkia::isVector() const
-{
- return m_canvas->getTopDevice()->getDeviceCapabilities() & SkDevice::kVector_Capability;
-}
-
-inline bool PlatformContextSkia::clipPath(const SkPath& path, AntiAliasingMode aa, SkRegion::Op op)
-{
- return m_canvas->clipPath(path, op, aa == AntiAliased);
-}
-
-inline bool PlatformContextSkia::clipRect(const SkRect& rect, AntiAliasingMode aa, SkRegion::Op op)
-{
- return m_canvas->clipRect(rect, op, aa == AntiAliased);
-}
-
-inline bool PlatformContextSkia::getClipBounds(SkRect* bounds) const
-{
- return m_canvas->getClipBounds(bounds);
-}
-
-inline void PlatformContextSkia::setMatrix(const SkMatrix& matrix)
-{
- m_canvas->setMatrix(matrix);
-}
-
-inline const SkMatrix& PlatformContextSkia::getTotalMatrix() const
-{
- return m_canvas->getTotalMatrix();
-}
-
-inline bool PlatformContextSkia::concat(const SkMatrix& matrix)
-{
- return m_canvas->concat(matrix);
-}
-
-inline bool PlatformContextSkia::rotate(SkScalar degrees)
-{
- return m_canvas->rotate(degrees);
-}
-
-inline bool PlatformContextSkia::scale(SkScalar sx, SkScalar sy)
-{
- return m_canvas->scale(sx, sy);
-}
-
-inline bool PlatformContextSkia::translate(SkScalar dx, SkScalar dy)
-{
- return m_canvas->translate(dx, dy);
-}
-
-inline void PlatformContextSkia::drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
- const SkPaint* paint)
-{
- m_canvas->drawBitmap(bitmap, left, top, paint);
-
- if (m_trackOpaqueRegion) {
- SkRect rect = SkRect::MakeXYWH(left, top, bitmap.width(), bitmap.height());
- m_opaqueRegion.didDrawRect(this, rect, *paint, &bitmap);
- }
-}
-
-inline void PlatformContextSkia::drawBitmapRect(const SkBitmap& bitmap, const SkIRect* isrc,
- const SkRect& dst, const SkPaint* paint)
-{
- m_canvas->drawBitmapRect(bitmap, isrc, dst, paint);
-
- if (m_trackOpaqueRegion)
- m_opaqueRegion.didDrawRect(this, dst, *paint, &bitmap);
-}
-
-inline void PlatformContextSkia::drawOval(const SkRect& oval, const SkPaint& paint)
-{
- m_canvas->drawOval(oval, paint);
-
- if (m_trackOpaqueRegion)
- m_opaqueRegion.didDrawBounded(this, oval, paint);
-}
-
-inline void PlatformContextSkia::drawPath(const SkPath& path, const SkPaint& paint)
-{
- m_canvas->drawPath(path, paint);
-
- if (m_trackOpaqueRegion)
- m_opaqueRegion.didDrawPath(this, path, paint);
-}
-
-inline void PlatformContextSkia::drawPoints(SkCanvas::PointMode mode, size_t count,
- const SkPoint pts[], const SkPaint& paint)
-{
- m_canvas->drawPoints(mode, count, pts, paint);
-
- if (m_trackOpaqueRegion)
- m_opaqueRegion.didDrawPoints(this, mode, count, pts, paint);
-}
-
-inline void PlatformContextSkia::drawRect(const SkRect& rect, const SkPaint& paint)
-{
- m_canvas->drawRect(rect, paint);
-
- if (m_trackOpaqueRegion)
- m_opaqueRegion.didDrawRect(this, rect, paint, 0);
-}
-
-inline void PlatformContextSkia::drawIRect(const SkIRect& rect, const SkPaint& paint)
-{
- m_canvas->drawIRect(rect, paint);
-
- if (m_trackOpaqueRegion) {
- SkRect r = SkRect::MakeFromIRect(rect);
- m_opaqueRegion.didDrawRect(this, r, paint, 0);
- }
-}
-
-inline void PlatformContextSkia::drawPosText(const void* text, size_t byteLength,
- const SkPoint pos[], const SkPaint& paint)
-{
- m_canvas->drawPosText(text, byteLength, pos, paint);
-
- // FIXME: compute bounds for positioned text.
- if (m_trackOpaqueRegion)
- m_opaqueRegion.didDrawUnbounded(this, paint, OpaqueRegionSkia::FillOrStroke);
-}
-
-inline void PlatformContextSkia::drawPosTextH(const void* text, size_t byteLength,
- const SkScalar xpos[], SkScalar constY, const SkPaint& paint)
-{
- m_canvas->drawPosTextH(text, byteLength, xpos, constY, paint);
-
- // FIXME: compute bounds for positioned text.
- if (m_trackOpaqueRegion)
- m_opaqueRegion.didDrawUnbounded(this, paint, OpaqueRegionSkia::FillOrStroke);
-}
-
-inline void PlatformContextSkia::drawTextOnPath(const void* text, size_t byteLength,
- const SkPath& path, const SkMatrix* matrix, const SkPaint& paint)
-{
- m_canvas->drawTextOnPath(text, byteLength, path, matrix, paint);
-
- // FIXME: compute bounds for positioned text.
- if (m_trackOpaqueRegion)
- m_opaqueRegion.didDrawUnbounded(this, paint, OpaqueRegionSkia::FillOrStroke);
-}
-
-}
-#endif // PlatformContextSkia_h
diff --git a/Source/WebCore/platform/graphics/skia/PlatformGraphics.h b/Source/WebCore/platform/graphics/skia/PlatformGraphics.h
deleted file mode 100644
index 4ae88352b..000000000
--- a/Source/WebCore/platform/graphics/skia/PlatformGraphics.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2008, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef PlatformGraphics_h
-#define PlatformGraphics_h
-
-typedef class SkShader* PlatformGradient;
-typedef class SkShader* PlatformPattern;
-
-#endif // PlatformGraphics_h
diff --git a/Source/WebCore/platform/graphics/skia/SimpleFontDataSkia.cpp b/Source/WebCore/platform/graphics/skia/SimpleFontDataSkia.cpp
deleted file mode 100644
index 4fc098124..000000000
--- a/Source/WebCore/platform/graphics/skia/SimpleFontDataSkia.cpp
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SimpleFontData.h"
-
-#include "FloatRect.h"
-#include "Font.h"
-#include "FontCache.h"
-#include "FontDescription.h"
-#include "Logging.h"
-#include "SkFontHost.h"
-#include "SkPaint.h"
-#include "SkTime.h"
-#include "SkTypeface.h"
-#include "SkTypes.h"
-#include "VDMXParser.h"
-#include <unicode/normlzr.h>
-#include <wtf/unicode/Unicode.h>
-
-namespace WebCore {
-
-// This is the largest VDMX table which we'll try to load and parse.
-static const size_t maxVDMXTableSize = 1024 * 1024; // 1 MB
-
-void SimpleFontData::platformInit()
-{
- if (!m_platformData.size()) {
- m_fontMetrics.reset();
- m_avgCharWidth = 0;
- m_maxCharWidth = 0;
- return;
- }
-
- SkPaint paint;
- SkPaint::FontMetrics metrics;
-
- m_platformData.setupPaint(&paint);
- paint.getFontMetrics(&metrics);
- const SkFontID fontID = m_platformData.uniqueID();
-
- static const uint32_t vdmxTag = SkSetFourByteTag('V', 'D', 'M', 'X');
- int pixelSize = m_platformData.size() + 0.5;
- int vdmxAscent, vdmxDescent;
- bool isVDMXValid = false;
-
- size_t vdmxSize = SkFontHost::GetTableSize(fontID, vdmxTag);
- if (vdmxSize && vdmxSize < maxVDMXTableSize) {
- uint8_t* vdmxTable = (uint8_t*) fastMalloc(vdmxSize);
- if (vdmxTable
- && SkFontHost::GetTableData(fontID, vdmxTag, 0, vdmxSize, vdmxTable) == vdmxSize
- && parseVDMX(&vdmxAscent, &vdmxDescent, vdmxTable, vdmxSize, pixelSize))
- isVDMXValid = true;
- fastFree(vdmxTable);
- }
-
- float ascent;
- float descent;
-
- // Beware those who step here: This code is designed to match Win32 font
- // metrics *exactly* (except the adjustment of ascent/descent on Linux/Android).
- if (isVDMXValid) {
- ascent = vdmxAscent;
- descent = -vdmxDescent;
- } else {
- SkScalar height = -metrics.fAscent + metrics.fDescent + metrics.fLeading;
- ascent = SkScalarRound(-metrics.fAscent);
- descent = SkScalarRound(height) - ascent;
-#if OS(LINUX) || OS(ANDROID)
- // When subpixel positioning is enabled, if the descent is rounded down, the descent part
- // of the glyph may be truncated when displayed in a 'overflow: hidden' container.
- // To avoid that, borrow 1 unit from the ascent when possible.
- // FIXME: This can be removed if sub-pixel ascent/descent is supported.
- if (platformData().fontRenderStyle().useSubpixelPositioning && descent < SkScalarToFloat(metrics.fDescent) && ascent >= 1) {
- ++descent;
- --ascent;
- }
-#endif
- }
-
- m_fontMetrics.setAscent(ascent);
- m_fontMetrics.setDescent(descent);
-
- float xHeight;
- if (metrics.fXHeight) {
- xHeight = metrics.fXHeight;
- m_fontMetrics.setXHeight(xHeight);
- } else {
- xHeight = ascent * 0.56; // Best guess from Windows font metrics.
- m_fontMetrics.setXHeight(xHeight);
- m_fontMetrics.setHasXHeight(false);
- }
-
-
- float lineGap = SkScalarToFloat(metrics.fLeading);
- m_fontMetrics.setLineGap(lineGap);
- m_fontMetrics.setLineSpacing(lroundf(ascent) + lroundf(descent) + lroundf(lineGap));
-
- if (platformData().orientation() == Vertical && !isTextOrientationFallback()) {
- static const uint32_t vheaTag = SkSetFourByteTag('v', 'h', 'e', 'a');
- static const uint32_t vorgTag = SkSetFourByteTag('V', 'O', 'R', 'G');
- size_t vheaSize = SkFontHost::GetTableSize(fontID, vheaTag);
- size_t vorgSize = SkFontHost::GetTableSize(fontID, vorgTag);
- if ((vheaSize > 0) || (vorgSize > 0))
- m_hasVerticalGlyphs = true;
- }
-
- // In WebKit/WebCore/platform/graphics/SimpleFontData.cpp, m_spaceWidth is
- // calculated for us, but we need to calculate m_maxCharWidth and
- // m_avgCharWidth in order for text entry widgets to be sized correctly.
-
- SkScalar xRange = metrics.fXMax - metrics.fXMin;
- m_maxCharWidth = SkScalarRound(xRange * SkScalarRound(m_platformData.size()));
-
- if (metrics.fAvgCharWidth)
- m_avgCharWidth = SkScalarRound(metrics.fAvgCharWidth);
- else {
- m_avgCharWidth = xHeight;
-
- GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->page();
-
- if (glyphPageZero) {
- static const UChar32 xChar = 'x';
- const Glyph xGlyph = glyphPageZero->glyphDataForCharacter(xChar).glyph;
-
- if (xGlyph) {
- // In widthForGlyph(), xGlyph will be compared with
- // m_zeroWidthSpaceGlyph, which isn't initialized yet here.
- // Initialize it with zero to make sure widthForGlyph() returns
- // the right width.
- m_zeroWidthSpaceGlyph = 0;
- m_avgCharWidth = widthForGlyph(xGlyph);
- }
- }
- }
-
- if (int unitsPerEm = paint.getTypeface()->getUnitsPerEm())
- m_fontMetrics.setUnitsPerEm(unitsPerEm);
-}
-
-void SimpleFontData::platformCharWidthInit()
-{
- // charwidths are set in platformInit.
-}
-
-void SimpleFontData::platformDestroy()
-{
-}
-
-PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
-{
- const float scaledSize = lroundf(fontDescription.computedSize() * scaleFactor);
- return SimpleFontData::create(FontPlatformData(m_platformData, scaledSize), isCustomFont(), false);
-}
-
-bool SimpleFontData::containsCharacters(const UChar* characters, int length) const
-{
- SkPaint paint;
- static const unsigned maxBufferCount = 64;
- uint16_t glyphs[maxBufferCount];
-
- m_platformData.setupPaint(&paint);
- paint.setTextEncoding(SkPaint::kUTF16_TextEncoding);
-
- while (length > 0) {
- int n = SkMin32(length, SK_ARRAY_COUNT(glyphs));
-
- // textToGlyphs takes a byte count so we double the character count.
- int count = paint.textToGlyphs(characters, n * 2, glyphs);
- for (int i = 0; i < count; i++) {
- if (!glyphs[i])
- return false; // missing glyph
- }
-
- characters += n;
- length -= n;
- }
-
- return true;
-}
-
-void SimpleFontData::determinePitch()
-{
- m_treatAsFixedPitch = platformData().isFixedPitch();
-}
-
-FloatRect SimpleFontData::platformBoundsForGlyph(Glyph glyph) const
-{
- if (!m_platformData.size())
- return FloatRect();
-
- SkASSERT(sizeof(glyph) == 2); // compile-time assert
-
- SkPaint paint;
-
- m_platformData.setupPaint(&paint);
-
- paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
- SkRect bounds;
- paint.measureText(&glyph, 2, &bounds);
- if (!paint.isSubpixelText()) {
- SkIRect ir;
- bounds.round(&ir);
- bounds.set(ir);
- }
- return FloatRect(bounds);
-}
-
-float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
-{
- if (!m_platformData.size())
- return 0;
-
- SkASSERT(sizeof(glyph) == 2); // compile-time assert
-
- SkPaint paint;
-
- m_platformData.setupPaint(&paint);
-
- paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
- SkScalar width = paint.measureText(&glyph, 2);
- if (!paint.isSubpixelText())
- width = SkScalarRound(width);
- return SkScalarToFloat(width);
-}
-
-#if USE(HARFBUZZ_NG)
-bool SimpleFontData::canRenderCombiningCharacterSequence(const UChar* characters, size_t length) const
-{
- if (!m_combiningCharacterSequenceSupport)
- m_combiningCharacterSequenceSupport = adoptPtr(new HashMap<String, bool>);
-
- WTF::HashMap<String, bool>::AddResult addResult = m_combiningCharacterSequenceSupport->add(String(characters, length), false);
- if (!addResult.isNewEntry)
- return addResult.iterator->value;
-
- UErrorCode error = U_ZERO_ERROR;
- Vector<UChar, 4> normalizedCharacters(length);
- int32_t normalizedLength = unorm_normalize(characters, length, UNORM_NFC, UNORM_UNICODE_3_2, &normalizedCharacters[0], length, &error);
- // Can't render if we have an error or no composition occurred.
- if (U_FAILURE(error) || (static_cast<size_t>(normalizedLength) == length))
- return false;
-
- SkPaint paint;
- m_platformData.setupPaint(&paint);
- paint.setTextEncoding(SkPaint::kUTF16_TextEncoding);
- if (paint.textToGlyphs(&normalizedCharacters[0], normalizedLength * 2, 0)) {
- addResult.iterator->value = true;
- return true;
- }
- return false;
-}
-#endif
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/skia/SkiaFontWin.cpp b/Source/WebCore/platform/graphics/skia/SkiaFontWin.cpp
deleted file mode 100644
index 104d82457..000000000
--- a/Source/WebCore/platform/graphics/skia/SkiaFontWin.cpp
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * Copyright (c) 2008, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SkiaFontWin.h"
-
-#include "AffineTransform.h"
-#include "FontPlatformDataChromiumWin.h"
-#include "Gradient.h"
-#include "Pattern.h"
-#include "PlatformContextSkia.h"
-#include "SimpleFontData.h"
-#include "SkCanvas.h"
-#include "SkDevice.h"
-#include "SkPaint.h"
-#include "SkShader.h"
-#include "SkTemplates.h"
-
-namespace WebCore {
-
-#if !USE(SKIA_TEXT)
-bool windowsCanHandleDrawTextShadow(GraphicsContext* context)
-{
- FloatSize shadowOffset;
- float shadowBlur;
- Color shadowColor;
- ColorSpace shadowColorSpace;
-
- bool hasShadow = context->getShadow(shadowOffset, shadowBlur, shadowColor, shadowColorSpace);
- return !hasShadow || (!shadowBlur && (shadowColor.alpha() == 255) && (context->fillColor().alpha() == 255));
-}
-
-bool windowsCanHandleTextDrawing(GraphicsContext* context)
-{
- if (!windowsCanHandleTextDrawingWithoutShadow(context))
- return false;
-
- // Check for shadow effects.
- if (!windowsCanHandleDrawTextShadow(context))
- return false;
-
- return true;
-}
-
-bool windowsCanHandleTextDrawingWithoutShadow(GraphicsContext* context)
-{
- // Check for non-translation transforms. Sometimes zooms will look better in
- // Skia, and sometimes better in Windows. The main problem is that zooming
- // in using Skia will show you the hinted outlines for the smaller size,
- // which look weird. All else being equal, it's better to use Windows' text
- // drawing, so we don't check for zooms.
- const AffineTransform& matrix = context->getCTM();
- if (matrix.b() || matrix.c()) // Check for skew.
- return false;
-
- // Check for stroke effects.
- if (context->platformContext()->getTextDrawingMode() != TextModeFill)
- return false;
-
- // Check for gradients.
- if (context->fillGradient() || context->strokeGradient())
- return false;
-
- // Check for patterns.
- if (context->fillPattern() || context->strokePattern())
- return false;
-
- if (!context->platformContext()->isNativeFontRenderingAllowed())
- return false;
-
- return true;
-}
-#endif
-
-static void skiaDrawText(PlatformContextSkia* context,
- const SkPoint& point,
- SkPaint* paint,
- const WORD* glyphs,
- const int* advances,
- const GOFFSET* offsets,
- int numGlyphs)
-{
- // Reserve space for 64 SkPoints on the stack. If numGlyphs is larger, the array
- // will dynamically allocate it space for numGlyph glyphs. This is used to store
- // the computed x,y locations. In the case where offsets==null, then we use it
- // to store (twice as many) SkScalars for x[]
- static const size_t kLocalGlyphMax = 64;
-
- SkScalar x = point.fX;
- SkScalar y = point.fY;
- if (offsets) {
- SkAutoSTArray<kLocalGlyphMax, SkPoint> storage(numGlyphs);
- SkPoint* pos = storage.get();
- for (int i = 0; i < numGlyphs; i++) {
- // GDI has dv go up, so we negate it
- pos[i].set(x + SkIntToScalar(offsets[i].du),
- y + -SkIntToScalar(offsets[i].dv));
- x += SkIntToScalar(advances[i]);
- }
- context->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, *paint);
- } else {
- SkAutoSTArray<kLocalGlyphMax * 2, SkScalar> storage(numGlyphs);
- SkScalar* xpos = storage.get();
- for (int i = 0; i < numGlyphs; i++) {
- xpos[i] = x;
- x += SkIntToScalar(advances[i]);
- }
- context->drawPosTextH(glyphs, numGlyphs * sizeof(uint16_t),
- xpos, y, *paint);
- }
-}
-
-// Lookup the current system settings for font smoothing.
-// We cache these values for performance, but if the browser has away to be
-// notified when these change, we could re-query them at that time.
-static uint32_t getDefaultGDITextFlags()
-{
- static bool gInited;
- static uint32_t gFlags;
- if (!gInited) {
- BOOL enabled;
- gFlags = 0;
- if (SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, &enabled, 0) && enabled) {
- gFlags |= SkPaint::kAntiAlias_Flag;
-
- UINT smoothType;
- if (SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &smoothType, 0)) {
- if (FE_FONTSMOOTHINGCLEARTYPE == smoothType)
- gFlags |= SkPaint::kLCDRenderText_Flag;
- }
- }
- gInited = true;
- }
- return gFlags;
-}
-
-static void setupPaintForFont(SkPaint* paint, PlatformContextSkia* pcs,
- SkTypeface* face, float size, int quality)
-{
- paint->setTextSize(SkFloatToScalar(size));
- paint->setTypeface(face);
-
- // turn quality into text flags
- uint32_t textFlags;
- switch (quality) {
- case NONANTIALIASED_QUALITY:
- textFlags = 0;
- break;
- case ANTIALIASED_QUALITY:
- textFlags = SkPaint::kAntiAlias_Flag;
- break;
- case CLEARTYPE_QUALITY:
- textFlags = (SkPaint::kAntiAlias_Flag | SkPaint::kLCDRenderText_Flag);
- break;
- default:
- textFlags = getDefaultGDITextFlags();
- break;
- }
- // only allow features that SystemParametersInfo allows
- textFlags &= getDefaultGDITextFlags();
-
- // do this check after our switch on lfQuality
- if (!pcs->couldUseLCDRenderedText()) {
- textFlags &= ~SkPaint::kLCDRenderText_Flag;
- // If we *just* clear our request for LCD, then GDI seems to
- // sometimes give us AA text, and sometimes give us BW text. Since the
- // original intent was LCD, we want to force AA (rather than BW), so we
- // add a special bit to tell Skia to do its best to avoid the BW: by
- // drawing LCD offscreen and downsampling that to AA.
- textFlags |= SkPaint::kGenA8FromLCD_Flag;
- }
-
- static const uint32_t textFlagsMask = SkPaint::kAntiAlias_Flag |
- SkPaint::kLCDRenderText_Flag |
- SkPaint::kGenA8FromLCD_Flag;
-
- // now copy in just the text flags
- SkASSERT(!(textFlags & ~textFlagsMask));
- uint32_t flags = paint->getFlags();
- flags &= ~textFlagsMask;
- flags |= textFlags;
- paint->setFlags(flags);
-}
-
-static void paintSkiaText(GraphicsContext* context, HFONT hfont,
- SkTypeface* face, float size, int quality,
- int numGlyphs,
- const WORD* glyphs,
- const int* advances,
- const GOFFSET* offsets,
- const SkPoint* origin)
-{
- PlatformContextSkia* platformContext = context->platformContext();
- TextDrawingModeFlags textMode = platformContext->getTextDrawingMode();
- // Ensure font load for printing, because PDF device needs it.
- if (platformContext->isVector())
- FontPlatformData::ensureFontLoaded(hfont);
-
- // Filling (if necessary). This is the common case.
- SkPaint paint;
- platformContext->setupPaintForFilling(&paint);
- paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
- setupPaintForFont(&paint, platformContext, face, size, quality);
-
- bool didFill = false;
-
- if ((textMode & TextModeFill) && (SkColorGetA(paint.getColor()) || paint.getLooper())) {
- skiaDrawText(platformContext, *origin, &paint, &glyphs[0], &advances[0], &offsets[0], numGlyphs);
- didFill = true;
- }
-
- // Stroking on top (if necessary).
- if ((textMode & TextModeStroke)
- && platformContext->getStrokeStyle() != NoStroke
- && platformContext->getStrokeThickness() > 0) {
-
- paint.reset();
- platformContext->setupPaintForStroking(&paint, 0, 0);
- paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
- setupPaintForFont(&paint, platformContext, face, size, quality);
-
- if (didFill) {
- // If there is a shadow and we filled above, there will already be
- // a shadow. We don't want to draw it again or it will be too dark
- // and it will go on top of the fill.
- //
- // Note that this isn't strictly correct, since the stroke could be
- // very thick and the shadow wouldn't account for this. The "right"
- // thing would be to draw to a new layer and then draw that layer
- // with a shadow. But this is a lot of extra work for something
- // that isn't normally an issue.
- paint.setLooper(0);
- }
-
- skiaDrawText(platformContext, *origin, &paint, &glyphs[0], &advances[0], &offsets[0], numGlyphs);
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////
-
-void paintSkiaText(GraphicsContext* context,
- const FontPlatformData& data,
- int numGlyphs,
- const WORD* glyphs,
- const int* advances,
- const GOFFSET* offsets,
- const SkPoint* origin)
-{
- paintSkiaText(context, data.hfont(), data.typeface(), data.size(), data.lfQuality(),
- numGlyphs, glyphs, advances, offsets, origin);
-}
-
-void paintSkiaText(GraphicsContext* context,
- HFONT hfont,
- int numGlyphs,
- const WORD* glyphs,
- const int* advances,
- const GOFFSET* offsets,
- const SkPoint* origin)
-{
- int size;
- int quality;
- SkTypeface* face = CreateTypefaceFromHFont(hfont, &size, &quality);
- SkAutoUnref aur(face);
-
- paintSkiaText(context, hfont, face, size, quality, numGlyphs, glyphs, advances, offsets, origin);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/skia/SkiaFontWin.h b/Source/WebCore/platform/graphics/skia/SkiaFontWin.h
deleted file mode 100644
index 0f3432dc0..000000000
--- a/Source/WebCore/platform/graphics/skia/SkiaFontWin.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (c) 2008, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SkiaFontWin_h
-#define SkiaFontWin_h
-
-#include <windows.h>
-#include <usp10.h>
-
-struct SkPoint;
-
-namespace WebCore {
-
-class FontPlatformData;
-class GraphicsContext;
-class PlatformContextSkia;
-
-#if !USE(SKIA_TEXT)
-// The functions below are used for more complex font drawing (effects such as
-// stroking and more complex transforms) than Windows supports directly. Since
-// Windows drawing is faster you should use windowsCanHandleTextDrawing first to
-// check if using Skia is required at all.
-// Note that the text will look different (no ClearType) so this should only be
-// used when necessary.
-//
-// When you call a Skia* text drawing function, various glyph outlines will be
-// cached. As a result, you should call SkiaWinOutlineCache::removePathsForFont
-// when the font is destroyed so that the cache does not outlive the font (since
-// the HFONTs are recycled).
-//
-// Remember that Skia's text drawing origin is the baseline, like WebKit, not
-// the top, like Windows.
-
-// Returns true if the fillColor and shadowColor are opaque and the text-shadow
-// is not blurred.
-bool windowsCanHandleDrawTextShadow(GraphicsContext*);
-
-// Returns true if advanced font rendering is recommended.
-bool windowsCanHandleTextDrawing(GraphicsContext*);
-
-// Returns true if advanced font rendering is recommended if shadows are
-// disregarded.
-bool windowsCanHandleTextDrawingWithoutShadow(GraphicsContext*);
-#endif
-
-// Note that the offsets parameter is optional. If not null it represents a
-// per glyph offset (such as returned by ScriptPlace Windows API function).
-void paintSkiaText(GraphicsContext*,
- const FontPlatformData&,
- int numGlyphs,
- const WORD* glyphs,
- const int* advances,
- const GOFFSET* offsets,
- const SkPoint* origin);
-
-// Note that the offsets parameter is optional. If not null it represents a
-// per glyph offset (such as returned by ScriptPlace Windows API function).
-// Note: this is less efficient than calling the version with FontPlatformData,
-// as that caches the SkTypeface object.
-void paintSkiaText(GraphicsContext*,
- HFONT,
- int numGlyphs,
- const WORD* glyphs,
- const int* advances,
- const GOFFSET* offsets,
- const SkPoint* origin);
-
-} // namespace WebCore
-
-#endif // SkiaFontWin_h
diff --git a/Source/WebCore/platform/graphics/skia/SkiaUtils.cpp b/Source/WebCore/platform/graphics/skia/SkiaUtils.cpp
deleted file mode 100644
index c8419943e..000000000
--- a/Source/WebCore/platform/graphics/skia/SkiaUtils.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (c) 2006,2007,2008, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "SkiaUtils.h"
-
-#include "ImageBuffer.h"
-#include "SharedBuffer.h"
-#include "SkCanvas.h"
-#include "SkColorPriv.h"
-#include "SkMatrix.h"
-#include "SkRegion.h"
-
-namespace WebCore {
-
-static const struct CompositOpToXfermodeMode {
- uint8_t mCompositOp;
- uint8_t m_xfermodeMode;
-} gMapCompositOpsToXfermodeModes[] = {
- { CompositeClear, SkXfermode::kClear_Mode },
- { CompositeCopy, SkXfermode::kSrc_Mode },
- { CompositeSourceOver, SkXfermode::kSrcOver_Mode },
- { CompositeSourceIn, SkXfermode::kSrcIn_Mode },
- { CompositeSourceOut, SkXfermode::kSrcOut_Mode },
- { CompositeSourceAtop, SkXfermode::kSrcATop_Mode },
- { CompositeDestinationOver, SkXfermode::kDstOver_Mode },
- { CompositeDestinationIn, SkXfermode::kDstIn_Mode },
- { CompositeDestinationOut, SkXfermode::kDstOut_Mode },
- { CompositeDestinationAtop, SkXfermode::kDstATop_Mode },
- { CompositeXOR, SkXfermode::kXor_Mode },
- { CompositePlusDarker, SkXfermode::kDarken_Mode },
- { CompositePlusLighter, SkXfermode::kPlus_Mode }
-};
-
-SkXfermode::Mode WebCoreCompositeToSkiaComposite(CompositeOperator op)
-{
- const CompositOpToXfermodeMode* table = gMapCompositOpsToXfermodeModes;
-
- for (unsigned i = 0; i < SK_ARRAY_COUNT(gMapCompositOpsToXfermodeModes); i++) {
- if (table[i].mCompositOp == op)
- return (SkXfermode::Mode)table[i].m_xfermodeMode;
- }
-
- SkDEBUGF(("GraphicsContext::setPlatformCompositeOperation unknown CompositeOperator %d\n", op));
- return SkXfermode::kSrcOver_Mode; // fall-back
-}
-
-static U8CPU InvScaleByte(U8CPU component, uint32_t scale)
-{
- SkASSERT(component == (uint8_t)component);
- return (component * scale + 0x8000) >> 16;
-}
-
-SkColor SkPMColorToColor(SkPMColor pm)
-{
- if (!pm)
- return 0;
- unsigned a = SkGetPackedA32(pm);
- if (!a) {
- // A zero alpha value when there are non-zero R, G, or B channels is an
- // invalid premultiplied color (since all channels should have been
- // multiplied by 0 if a=0).
- SkASSERT(false);
- // In production, return 0 to protect against division by zero.
- return 0;
- }
-
- uint32_t scale = (255 << 16) / a;
-
- return SkColorSetARGB(a,
- InvScaleByte(SkGetPackedR32(pm), scale),
- InvScaleByte(SkGetPackedG32(pm), scale),
- InvScaleByte(SkGetPackedB32(pm), scale));
-}
-
-Color SkPMColorToWebCoreColor(SkPMColor pm)
-{
- return SkPMColorToColor(pm);
-}
-
-void ClipRectToCanvas(const PlatformContextSkia* context, const SkRect& srcRect, SkRect* destRect)
-{
- if (!context->getClipBounds(destRect) || !destRect->intersect(srcRect))
- destRect->setEmpty();
-}
-
-bool SkPathContainsPoint(SkPath* originalPath, const FloatPoint& point, SkPath::FillType ft)
-{
- SkRect bounds = originalPath->getBounds();
-
- // We can immediately return false if the point is outside the bounding
- // rect. We don't use bounds.contains() here, since it would exclude
- // points on the right and bottom edges of the bounding rect, and we want
- // to include them.
- SkScalar fX = SkFloatToScalar(point.x());
- SkScalar fY = SkFloatToScalar(point.y());
- if (fX < bounds.fLeft || fX > bounds.fRight || fY < bounds.fTop || fY > bounds.fBottom)
- return false;
-
- // Scale the path to a large size before hit testing for two reasons:
- // 1) Skia has trouble with coordinates close to the max signed 16-bit values, so we scale larger paths down.
- // TODO: when Skia is patched to work properly with large values, this will not be necessary.
- // 2) Skia does not support analytic hit testing, so we scale paths up to do raster hit testing with subpixel accuracy.
- SkScalar biggestCoord = std::max(std::max(std::max(bounds.fRight, bounds.fBottom), -bounds.fLeft), -bounds.fTop);
- if (SkScalarNearlyZero(biggestCoord))
- return false;
- biggestCoord = std::max(std::max(biggestCoord, fX + 1), fY + 1);
-
- const SkScalar kMaxCoordinate = SkIntToScalar(1 << 15);
- SkScalar scale = SkScalarDiv(kMaxCoordinate, biggestCoord);
-
- SkRegion rgn;
- SkRegion clip;
- SkMatrix m;
- SkPath scaledPath;
-
- SkPath::FillType originalFillType = originalPath->getFillType();
- originalPath->setFillType(ft);
-
- m.setScale(scale, scale);
- originalPath->transform(m, &scaledPath);
-
- int x = static_cast<int>(floorf(0.5f + point.x() * scale));
- int y = static_cast<int>(floorf(0.5f + point.y() * scale));
- clip.setRect(x - 1, y - 1, x + 1, y + 1);
-
- bool contains = rgn.setPath(scaledPath, clip);
- originalPath->setFillType(originalFillType);
- return contains;
-}
-
-GraphicsContext* scratchContext()
-{
- static ImageBuffer* scratch = ImageBuffer::create(IntSize(1, 1)).leakPtr();
- // We don't bother checking for failure creating the ImageBuffer, since our
- // ImageBuffer initializer won't fail.
- return scratch->context();
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/skia/SkiaUtils.h b/Source/WebCore/platform/graphics/skia/SkiaUtils.h
deleted file mode 100644
index 358f86d11..000000000
--- a/Source/WebCore/platform/graphics/skia/SkiaUtils.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2006,2007,2008, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-// All of the functions in this file should move to new homes and this file should be deleted.
-
-#ifndef SkiaUtils_h
-#define SkiaUtils_h
-
-#include <wtf/MathExtras.h>
-#include "GraphicsContext.h"
-#include "SkPath.h"
-#include "SkXfermode.h"
-
-class SkCanvas;
-class SkRegion;
-
-namespace WebCore {
-
-SkXfermode::Mode WebCoreCompositeToSkiaComposite(CompositeOperator);
-
-// move this guy into SkColor.h
-SkColor SkPMColorToColor(SkPMColor);
-
-// This should be an operator on Color
-Color SkPMColorToWebCoreColor(SkPMColor);
-
-// Skia has problems when passed infinite, etc floats, filter them to 0.
-inline SkScalar WebCoreFloatToSkScalar(float f)
-{
- return SkFloatToScalar(isfinite(f) ? f : 0);
-}
-
-inline SkScalar WebCoreDoubleToSkScalar(double d)
-{
- return SkDoubleToScalar(isfinite(d) ? d : 0);
-}
-
-// Computes the smallest rectangle that, which when drawn to the given canvas,
-// will cover the same area as the source rectangle. It will clip to the canvas'
-// clip, doing the necessary coordinate transforms.
-//
-// srcRect and destRect can be the same.
-void ClipRectToCanvas(const PlatformContextSkia*, const SkRect& srcRect, SkRect* destRect);
-
-// Determine if a given WebKit point is contained in a path
-bool SkPathContainsPoint(SkPath*, const FloatPoint&, SkPath::FillType);
-
-// Returns a statically allocated 1x1 GraphicsContext intended for temporary
-// operations. Please save() the state and restore() it when you're done with
-// the context.
-GraphicsContext* scratchContext();
-
-} // namespace WebCore
-
-#endif // SkiaUtils_h
diff --git a/Source/WebCore/platform/graphics/skia/TransformationMatrixSkia.cpp b/Source/WebCore/platform/graphics/skia/TransformationMatrixSkia.cpp
deleted file mode 100644
index dc610d714..000000000
--- a/Source/WebCore/platform/graphics/skia/TransformationMatrixSkia.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright (c) 2008, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#include "config.h"
-#include "AffineTransform.h"
-#include "TransformationMatrix.h"
-
-#include "SkiaUtils.h"
-
-namespace WebCore {
-
-TransformationMatrix::operator SkMatrix() const
-{
- SkMatrix result;
-
- result.setScaleX(WebCoreDoubleToSkScalar(a()));
- result.setSkewX(WebCoreDoubleToSkScalar(c()));
- result.setTranslateX(WebCoreDoubleToSkScalar(e()));
-
- result.setScaleY(WebCoreDoubleToSkScalar(d()));
- result.setSkewY(WebCoreDoubleToSkScalar(b()));
- result.setTranslateY(WebCoreDoubleToSkScalar(f()));
-
- // FIXME: Set perspective properly.
- result.setPerspX(0);
- result.setPerspY(0);
- result.set(SkMatrix::kMPersp2, SK_Scalar1);
-
- return result;
-}
-
-AffineTransform::operator SkMatrix() const
-{
- SkMatrix result;
-
- result.setScaleX(WebCoreDoubleToSkScalar(a()));
- result.setSkewX(WebCoreDoubleToSkScalar(c()));
- result.setTranslateX(WebCoreDoubleToSkScalar(e()));
-
- result.setScaleY(WebCoreDoubleToSkScalar(d()));
- result.setSkewY(WebCoreDoubleToSkScalar(b()));
- result.setTranslateY(WebCoreDoubleToSkScalar(f()));
-
- // FIXME: Set perspective properly.
- result.setPerspX(0);
- result.setPerspY(0);
- result.set(SkMatrix::kMPersp2, SK_Scalar1);
-
- return result;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.cpp b/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.cpp
index 0a115f02c..2a7a4b243 100644
--- a/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.cpp
+++ b/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.cpp
@@ -63,9 +63,9 @@ void GraphicsSurface::copyFromTexture(uint32_t texture, const IntRect& sourceRec
platformCopyFromTexture(texture, sourceRect);
}
-void GraphicsSurface::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
+void GraphicsSurface::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity)
{
- platformPaintToTextureMapper(textureMapper, targetRect, transform, opacity, mask);
+ platformPaintToTextureMapper(textureMapper, targetRect, transform, opacity);
}
uint32_t GraphicsSurface::frontBuffer()
@@ -83,10 +83,8 @@ IntSize GraphicsSurface::size() const
return platformSize();
}
-GraphicsSurface::GraphicsSurface(const IntSize& size, Flags flags)
+GraphicsSurface::GraphicsSurface(const IntSize&, Flags flags)
: m_flags(flags)
- , m_platformSurface(0)
- , m_texture(0)
, m_fbo(0)
, m_private(0)
{
diff --git a/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h b/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h
index 549e804c4..731af2b6d 100644
--- a/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h
+++ b/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h
@@ -73,14 +73,13 @@ public:
typedef int LockOptions;
Flags flags() const { return m_flags; }
- PlatformGraphicsSurface platformSurface() const { return m_platformSurface; }
IntSize size() const;
static PassRefPtr<GraphicsSurface> create(const IntSize&, Flags, const PlatformGraphicsContext3D shareContext = 0);
static PassRefPtr<GraphicsSurface> create(const IntSize&, Flags, const GraphicsSurfaceToken&);
void copyToGLTexture(uint32_t target, uint32_t texture, const IntRect& targetRect, const IntPoint& sourceOffset);
void copyFromTexture(uint32_t texture, const IntRect& sourceRect);
- void paintToTextureMapper(TextureMapper*, const FloatRect& targetRect, const TransformationMatrix&, float opacity, BitmapTexture* mask);
+ void paintToTextureMapper(TextureMapper*, const FloatRect& targetRect, const TransformationMatrix&, float opacity);
uint32_t frontBuffer();
uint32_t swapBuffers();
GraphicsSurfaceToken exportToken();
@@ -100,7 +99,7 @@ protected:
void platformUnlock();
void platformCopyToGLTexture(uint32_t target, uint32_t texture, const IntRect&, const IntPoint&);
void platformCopyFromTexture(uint32_t texture, const IntRect& sourceRect);
- void platformPaintToTextureMapper(TextureMapper*, const FloatRect& targetRect, const TransformationMatrix&, float opacity, BitmapTexture* mask);
+ void platformPaintToTextureMapper(TextureMapper*, const FloatRect& targetRect, const TransformationMatrix&, float opacity);
uint32_t platformFrontBuffer() const;
uint32_t platformSwapBuffers();
IntSize platformSize() const;
@@ -119,8 +118,6 @@ private:
#endif
private:
- PlatformGraphicsSurface m_platformSurface;
- uint32_t m_texture;
uint32_t m_fbo;
GraphicsSurfacePrivate* m_private;
};
diff --git a/Source/WebCore/platform/graphics/surfaces/efl/GLTransportSurface.cpp b/Source/WebCore/platform/graphics/surfaces/efl/GLTransportSurface.cpp
new file mode 100644
index 000000000..8199d6ba6
--- /dev/null
+++ b/Source/WebCore/platform/graphics/surfaces/efl/GLTransportSurface.cpp
@@ -0,0 +1,263 @@
+/*
+ * Copyright (C) 2013 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "GLTransportSurface.h"
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "FloatRect.h"
+
+#if USE(GLX)
+#include "GLXSurface.h"
+#endif
+
+#if USE(EGL)
+#include "EGLSurface.h"
+#endif
+
+#include <texmap/TextureMapperShaderProgram.h>
+
+namespace WebCore {
+
+static const GLfloat vertices[] = { 0, 0, 1, 0, 1, 1, 0, 1 };
+static bool vertexArrayObjectSupported = false;
+
+PassOwnPtr<GLTransportSurface> GLTransportSurface::createTransportSurface(const IntSize& size, SurfaceAttributes attributes)
+{
+ OwnPtr<GLTransportSurface> surface;
+#if USE(GLX)
+ surface = adoptPtr(new GLXTransportSurface(size, attributes));
+#elif USE(EGL)
+ surface = EGLTransportSurface::createTransportSurface(size, attributes);
+#endif
+
+ if (surface && surface->handle() && surface->drawable())
+ return surface.release();
+
+ return nullptr;
+}
+
+GLTransportSurface::GLTransportSurface(const IntSize& size, SurfaceAttributes attributes)
+ : GLPlatformSurface(attributes)
+ , m_vbo(0)
+ , m_vertexHandle(0)
+ , m_boundTexture(0)
+{
+ m_rect = IntRect(IntPoint(), size);
+}
+
+GLTransportSurface::~GLTransportSurface()
+{
+}
+
+void GLTransportSurface::updateContents(const uint32_t texture)
+{
+ if (!m_shaderProgram)
+ initializeShaderProgram();
+
+ draw(texture);
+ swapBuffers();
+}
+
+void GLTransportSurface::setGeometry(const IntRect& newRect)
+{
+ m_rect = newRect;
+
+ if (!m_shaderProgram)
+ return;
+
+ updateTransformationMatrix();
+}
+
+void GLTransportSurface::destroy()
+{
+ m_rect = IntRect();
+
+ if (!m_shaderProgram || !m_context3D)
+ return;
+
+ ::glBindFramebuffer(GL_FRAMEBUFFER, 0);
+ ::glBindTexture(GL_TEXTURE_2D, 0);
+ ::glBindBuffer(GL_ARRAY_BUFFER, 0);
+
+ if (m_vbo)
+ ::glDeleteBuffers(1, &m_vbo);
+
+ if (m_vertexHandle) {
+ m_context3D->getExtensions()->bindVertexArrayOES(0);
+ m_context3D->getExtensions()->deleteVertexArrayOES(m_vertexHandle);
+ } else if (m_shaderProgram)
+ ::glDisableVertexAttribArray(m_shaderProgram->vertexLocation());
+
+ ::glUseProgram(0);
+
+ m_shaderProgram = nullptr;
+ m_context3D = nullptr;
+ m_boundTexture = 0;
+}
+
+void GLTransportSurface::draw(const uint32_t texture)
+{
+ if (!m_vertexHandle)
+ bindArrayBuffer();
+
+ if (m_boundTexture != texture) {
+ ::glBindTexture(GL_TEXTURE_2D, texture);
+ m_boundTexture = texture;
+ }
+
+ ::glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+}
+
+void GLTransportSurface::bindArrayBuffer() const
+{
+ ::glEnableVertexAttribArray(m_shaderProgram->vertexLocation());
+ ::glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
+ ::glVertexAttribPointer(m_shaderProgram->vertexLocation(), 2, GraphicsContext3D::FLOAT, false, 0, 0);
+}
+
+void GLTransportSurface::updateTransformationMatrix()
+{
+ if (!m_shaderProgram)
+ return;
+
+ ::glViewport(m_rect.x(), m_rect.y(), m_rect.width(), m_rect.height());
+ m_boundTexture = 0;
+
+ FloatRect targetRect = FloatRect(m_rect);
+ TransformationMatrix identityMatrix;
+ TransformationMatrix matrix = TransformationMatrix(identityMatrix).multiply(TransformationMatrix::rectToRect(FloatRect(0, 0, 1, 1), targetRect));
+ m_shaderProgram->setMatrix(m_shaderProgram->modelViewMatrixLocation(), matrix);
+
+ // Taken from TextureMapperGL.
+ const float nearValue = 9999999;
+ const float farValue = -99999;
+
+ TransformationMatrix projectionMatrix = TransformationMatrix(2.0 / float(m_rect.width()), 0, 0, 0,
+ 0, (-2.0) / float(m_rect.height()), 0, 0,
+ 0, 0, -2.f / (farValue - nearValue), 0,
+ -1, 1, -(farValue + nearValue) / (farValue - nearValue), 1);
+
+ m_shaderProgram->setMatrix(m_shaderProgram->projectionMatrixLocation(), projectionMatrix);
+}
+
+void GLTransportSurface::initializeShaderProgram()
+{
+ if (!m_context3D)
+ m_context3D = GraphicsContext3D::createForCurrentGLContext();
+
+ vertexArrayObjectSupported = m_context3D->getExtensions()->supports("GL_OES_vertex_array_object");
+
+ TextureMapperShaderProgram::Options options = TextureMapperShaderProgram::Texture;
+ m_shaderProgram = TextureMapperShaderProgram::create(m_context3D, options);
+
+ ::glUseProgram(m_shaderProgram->programID());
+ ::glUniform1i(m_shaderProgram->samplerLocation(), 0);
+ ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+ TransformationMatrix flipTransform;
+ flipTransform.flipY();
+ flipTransform.translate(0, -1);
+ m_shaderProgram->setMatrix(m_shaderProgram->textureSpaceMatrixLocation(), flipTransform);
+
+ ::glUniform1f(m_shaderProgram->opacityLocation(), 1.0);
+
+ if (!m_vbo) {
+ ::glGenBuffers(1, &m_vbo);
+ ::glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
+ ::glBufferData(GL_ARRAY_BUFFER, sizeof(GC3Dfloat) * 8, vertices, GL_STATIC_DRAW);
+ }
+
+ // Create and set-up vertex array object.
+ if (vertexArrayObjectSupported) {
+ m_vertexHandle = m_context3D->getExtensions()->createVertexArrayOES();
+
+ if (m_vertexHandle) {
+ m_context3D->getExtensions()->bindVertexArrayOES(m_vertexHandle);
+ bindArrayBuffer();
+ }
+ }
+
+ updateTransformationMatrix();
+}
+
+PassOwnPtr<GLTransportSurfaceClient> GLTransportSurfaceClient::createTransportSurfaceClient(const PlatformBufferHandle handle, const IntSize& size, bool hasAlpha)
+{
+ OwnPtr<GLTransportSurfaceClient> client;
+#if USE(GLX)
+ client = adoptPtr(new GLXTransportSurfaceClient(handle, hasAlpha));
+ UNUSED_PARAM(size);
+#else
+ client = EGLTransportSurface::createTransportSurfaceClient(handle, size, hasAlpha);
+#endif
+
+ if (!client || !client->texture()) {
+ LOG_ERROR("Failed to Create Transport Surface client.");
+ return nullptr;
+ }
+
+ return client.release();
+}
+
+
+GLTransportSurfaceClient::GLTransportSurfaceClient()
+ : m_texture(0)
+{
+}
+
+GLTransportSurfaceClient::~GLTransportSurfaceClient()
+{
+}
+
+void GLTransportSurfaceClient::destroy()
+{
+ if (m_texture) {
+ glBindTexture(GL_TEXTURE_2D, 0);
+ glDeleteTextures(1, &m_texture);
+ m_texture = 0;
+ }
+}
+
+void GLTransportSurfaceClient::prepareTexture()
+{
+}
+
+void GLTransportSurfaceClient::createTexture()
+{
+ ::glGenTextures(1, &m_texture);
+ ::glBindTexture(GL_TEXTURE_2D, m_texture);
+ ::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ ::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ ::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ ::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/platform/graphics/surfaces/efl/GLTransportSurface.h b/Source/WebCore/platform/graphics/surfaces/efl/GLTransportSurface.h
new file mode 100644
index 000000000..7b343ca10
--- /dev/null
+++ b/Source/WebCore/platform/graphics/surfaces/efl/GLTransportSurface.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2013 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef GLTransportSurface_h
+#define GLTransportSurface_h
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "GLPlatformSurface.h"
+#include <wtf/PassOwnPtr.h>
+
+namespace WebCore {
+
+class TextureMapperShaderProgram;
+
+class GLTransportSurface : public GLPlatformSurface {
+
+public:
+ // Creates a GL surface whose results can be transported to the UI process for display.
+ static PassOwnPtr<GLTransportSurface> createTransportSurface(const IntSize&, SurfaceAttributes = GLPlatformSurface::Default);
+ virtual ~GLTransportSurface();
+ virtual void updateContents(const uint32_t) OVERRIDE;
+ virtual void setGeometry(const IntRect&) OVERRIDE;
+ virtual void destroy() OVERRIDE;
+
+protected:
+ GLTransportSurface(const IntSize&, SurfaceAttributes);
+ void updateTransformationMatrix();
+ void bindArrayBuffer() const;
+ void initializeShaderProgram();
+ void draw(const uint32_t);
+
+ RefPtr<GraphicsContext3D> m_context3D;
+ RefPtr<TextureMapperShaderProgram> m_shaderProgram;
+ Platform3DObject m_vbo;
+ Platform3DObject m_vertexHandle;
+ GLuint m_boundTexture;
+};
+
+class GLTransportSurfaceClient {
+
+public:
+ static PassOwnPtr<GLTransportSurfaceClient> createTransportSurfaceClient(const PlatformBufferHandle, const IntSize&, bool);
+ virtual ~GLTransportSurfaceClient();
+ virtual void prepareTexture();
+ virtual void destroy();
+ GLuint texture() const { return m_texture; }
+
+protected:
+ GLTransportSurfaceClient();
+ void createTexture();
+ GLuint m_texture;
+};
+
+}
+
+#endif
+
+#endif
diff --git a/Source/WebCore/platform/graphics/surfaces/efl/GraphicsSurfaceCommon.cpp b/Source/WebCore/platform/graphics/surfaces/efl/GraphicsSurfaceCommon.cpp
new file mode 100644
index 000000000..06d15b7ea
--- /dev/null
+++ b/Source/WebCore/platform/graphics/surfaces/efl/GraphicsSurfaceCommon.cpp
@@ -0,0 +1,270 @@
+/*
+ * Copyright (C) 2013 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "GraphicsSurface.h"
+
+#if USE(GRAPHICS_SURFACE)
+
+#include "GLPlatformContext.h"
+#include "GLTransportSurface.h"
+#include "NotImplemented.h"
+#include "TextureMapperGL.h"
+
+namespace WebCore {
+
+struct GraphicsSurfacePrivate {
+
+ GraphicsSurfacePrivate()
+ {
+ }
+
+ GraphicsSurfacePrivate(PlatformBufferHandle winId, const IntSize& size, GraphicsSurface::Flags flags)
+ : m_flags(0)
+ , m_rect(FloatPoint::zero(), size)
+ , m_size(size)
+ , m_sharedHandle(winId)
+ {
+ if (flags & GraphicsSurface::SupportsAlpha)
+ m_flags |= TextureMapperGL::ShouldBlend;
+ }
+
+ ~GraphicsSurfacePrivate()
+ {
+ }
+
+ void destroy()
+ {
+ if (m_client)
+ m_client->destroy();
+
+ if (m_sharedContext && m_sharedContext->handle() && m_sharedSurface)
+ makeContextCurrent();
+
+ if (m_sharedSurface)
+ m_sharedSurface->destroy();
+
+ if (m_sharedContext) {
+ m_sharedContext->destroy();
+ m_sharedContext->releaseCurrent();
+ }
+ }
+
+ bool initializeTransportSurface(const IntSize& size, GraphicsSurface::Flags flags, const PlatformGraphicsContext3D shareContext)
+ {
+ GLPlatformSurface::SurfaceAttributes sharedSurfaceAttributes = GLPlatformSurface::Default;
+ m_size = size;
+
+ if (flags & GraphicsSurface::SupportsAlpha)
+ sharedSurfaceAttributes = GLPlatformSurface::SupportAlpha;
+
+ m_sharedSurface = GLTransportSurface::createTransportSurface(size, sharedSurfaceAttributes);
+ if (!m_sharedSurface)
+ return false;
+
+ m_sharedContext = GLPlatformContext::createContext(GraphicsContext3D::RenderOffscreen);
+ if (!m_sharedContext)
+ return false;
+
+ if (!m_sharedContext->initialize(m_sharedSurface.get(), static_cast<PlatformContext>(shareContext)))
+ return false;
+
+ if (!makeContextCurrent())
+ return false;
+
+ return true;
+ }
+
+ bool makeContextCurrent() const
+ {
+ return m_sharedContext->makeCurrent(m_sharedSurface.get());
+ }
+
+ void copyFromTexture(GLuint textureId)
+ {
+ if (!makeContextCurrent())
+ return;
+
+ m_sharedSurface->updateContents(textureId);
+ }
+
+ PlatformBufferHandle handle() const
+ {
+ return m_sharedSurface->handle();
+ }
+
+ // Client
+ void updateClientBuffer()
+ {
+ if (!m_client)
+ return;
+
+ m_client->prepareTexture();
+ }
+
+ TextureMapperGL::Flags flags() const { return m_flags; }
+
+ const FloatRect& rect() const { return m_rect; }
+ const IntSize& size() const { return m_size; }
+
+ GLuint textureId() const
+ {
+ if (!m_client)
+ const_cast<GraphicsSurfacePrivate*>(this)->initializeClient();
+
+ return m_client ? m_client->texture() : 0;
+ }
+
+private:
+ void initializeClient()
+ {
+ m_client = GLTransportSurfaceClient::createTransportSurfaceClient(m_sharedHandle, m_size, m_flags & TextureMapperGL::ShouldBlend);
+
+ if (!m_client)
+ return;
+ }
+
+ TextureMapperGL::Flags m_flags;
+ FloatRect m_rect;
+ IntSize m_size;
+ PlatformBufferHandle m_sharedHandle;
+ OwnPtr<GLTransportSurfaceClient> m_client;
+ OwnPtr<GLPlatformContext> m_sharedContext;
+ OwnPtr<GLTransportSurface> m_sharedSurface;
+};
+
+GraphicsSurfaceToken GraphicsSurface::platformExport()
+{
+ return m_private->handle();
+}
+
+uint32_t GraphicsSurface::platformGetTextureID()
+{
+ return m_private->textureId();
+}
+
+void GraphicsSurface::platformCopyToGLTexture(uint32_t /*target*/, uint32_t /*id*/, const IntRect& /*targetRect*/, const IntPoint& /*offset*/)
+{
+ notImplemented();
+}
+
+void GraphicsSurface::platformCopyFromTexture(uint32_t textureId, const IntRect&)
+{
+ if (!m_private)
+ return;
+
+ m_private->copyFromTexture(textureId);
+}
+
+void GraphicsSurface::platformPaintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity)
+{
+ uint32_t texture = platformGetTextureID();
+ if (!texture)
+ return;
+
+ TransformationMatrix adjustedTransform = transform;
+ adjustedTransform.multiply(TransformationMatrix::rectToRect(m_private->rect(), targetRect));
+ static_cast<TextureMapperGL*>(textureMapper)->drawTexture(texture, m_private->flags(), m_private->size(), m_private->rect(), adjustedTransform, opacity);
+}
+
+uint32_t GraphicsSurface::platformFrontBuffer() const
+{
+ return 0;
+}
+
+uint32_t GraphicsSurface::platformSwapBuffers()
+{
+ m_private->updateClientBuffer();
+ return 0;
+}
+
+IntSize GraphicsSurface::platformSize() const
+{
+ return m_private->size();
+}
+
+PassRefPtr<GraphicsSurface> GraphicsSurface::platformCreate(const IntSize& size, Flags flags, const PlatformGraphicsContext3D shareContext)
+{
+ // GraphicsSurface doesn't yet support copyToTexture or singlebuffered surface.
+ if (flags & SupportsCopyToTexture || flags & SupportsSingleBuffered)
+ return PassRefPtr<GraphicsSurface>();
+
+ RefPtr<GraphicsSurface> surface = adoptRef(new GraphicsSurface(size, flags));
+ surface->m_private = new GraphicsSurfacePrivate();
+
+ if (surface->m_private->initializeTransportSurface(size, flags, shareContext))
+ return surface;
+
+ return PassRefPtr<GraphicsSurface>();
+}
+
+PassRefPtr<GraphicsSurface> GraphicsSurface::platformImport(const IntSize& size, Flags flags, const GraphicsSurfaceToken& token)
+{
+ // GraphicsSurface doesn't yet support copyToTexture or singlebuffered surface.
+ if (flags & SupportsCopyToTexture || flags & SupportsSingleBuffered)
+ return PassRefPtr<GraphicsSurface>();
+
+ RefPtr<GraphicsSurface> surface = adoptRef(new GraphicsSurface(size, flags));
+ surface->m_private = new GraphicsSurfacePrivate(token.frontBufferHandle, size, flags);
+ return surface;
+}
+
+char* GraphicsSurface::platformLock(const IntRect&, int* /*outputStride*/, LockOptions)
+{
+ // GraphicsSurface is currently only being used for WebGL, which does not require this locking mechanism.
+ return 0;
+}
+
+void GraphicsSurface::platformUnlock()
+{
+ // GraphicsSurface is currently only being used for WebGL, which does not require this locking mechanism.
+}
+
+void GraphicsSurface::platformDestroy()
+{
+ if (!m_private)
+ return;
+
+ m_private->destroy();
+
+ delete m_private;
+ m_private = 0;
+}
+
+PassOwnPtr<GraphicsContext> GraphicsSurface::platformBeginPaint(const IntSize&, char*, int)
+{
+ notImplemented();
+ return nullptr;
+}
+
+PassRefPtr<Image> GraphicsSurface::createReadOnlyImage(const IntRect&)
+{
+ notImplemented();
+ return 0;
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.cpp b/Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.cpp
new file mode 100644
index 000000000..8d6033014
--- /dev/null
+++ b/Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.cpp
@@ -0,0 +1,230 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "EGLConfigSelector.h"
+
+#if USE(EGL)
+
+#include "EGLHelper.h"
+
+namespace WebCore {
+
+EGLConfigSelector::EGLConfigSelector(GLPlatformSurface::SurfaceAttributes attributes)
+ : m_pixmapFBConfig(0)
+ , m_surfaceContextFBConfig(0)
+ , m_attributes(attributes)
+{
+ m_sharedDisplay = EGLHelper::eglDisplay();
+}
+
+EGLConfigSelector::~EGLConfigSelector()
+{
+}
+
+EGLConfig EGLConfigSelector::pixmapContextConfig()
+{
+ if (!m_pixmapFBConfig)
+ m_pixmapFBConfig = createConfig(EGL_PIXMAP_BIT);
+
+ return m_pixmapFBConfig;
+}
+
+EGLConfig EGLConfigSelector::surfaceContextConfig()
+{
+ if (!m_surfaceContextFBConfig)
+ m_surfaceContextFBConfig = createConfig(EGL_WINDOW_BIT);
+
+ return m_surfaceContextFBConfig;
+}
+
+EGLint EGLConfigSelector::nativeVisualId(const EGLConfig& config) const
+{
+ if (m_sharedDisplay == EGL_NO_DISPLAY)
+ return -1;
+
+ EGLint eglValue = 0;
+ eglGetConfigAttrib(m_sharedDisplay, config, EGL_NATIVE_VISUAL_ID, &eglValue);
+
+ return eglValue;
+}
+
+GLPlatformSurface::SurfaceAttributes EGLConfigSelector::attributes() const
+{
+ return m_attributes;
+}
+
+void EGLConfigSelector::reset()
+{
+ m_surfaceContextFBConfig = 0;
+ m_pixmapFBConfig = 0;
+}
+
+EGLConfig EGLConfigSelector::createConfig(EGLint expectedSurfaceType)
+{
+ if (m_sharedDisplay == EGL_NO_DISPLAY)
+ return 0;
+
+ EGLint numConfigs;
+
+ eglGetConfigs(m_sharedDisplay, 0, 0, &numConfigs);
+
+ if (!numConfigs) {
+ LOG_ERROR("Failed to retrieve number of EGL configs.");
+ return 0;
+ }
+
+ EGLConfig configs[numConfigs];
+ eglGetConfigs(m_sharedDisplay, configs, numConfigs, &numConfigs);
+
+ if (!numConfigs) {
+ LOG_ERROR("Failed to retrieve any EGL configs.");
+ return 0;
+ }
+
+ EGLConfig config = 0;
+ EGLint alpha, surface, red, green, blue, renderType;
+ EGLint expectedAlpha = m_attributes & GLPlatformSurface::SupportAlpha ? 8 : 0;
+ EGLint expectedRed = 8;
+ EGLint expectedBlue = 8;
+ EGLint expectedGreen = 8;
+#if USE(OPENGL_ES_2)
+ EGLint expectedRenderType = EGL_OPENGL_ES2_BIT;
+#else
+ EGLint expectedRenderType = EGL_OPENGL_BIT,
+#endif
+
+ for (int i = 0; i < numConfigs; i++) {
+ EGLConfig tempConfig = configs[i];
+ eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_RENDERABLE_TYPE, &renderType);
+
+ if (!(renderType & expectedRenderType))
+ continue;
+
+ eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_ALPHA_SIZE, &alpha);
+
+ if (alpha != expectedAlpha)
+ continue;
+
+ eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_RED_SIZE, &red);
+
+ if (red != expectedRed)
+ continue;
+
+ eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_GREEN_SIZE, &green);
+
+ if (green != expectedGreen)
+ continue;
+
+ eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_BLUE_SIZE, &blue);
+
+ if (blue != expectedBlue)
+ continue;
+
+ eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_SURFACE_TYPE, &surface);
+
+ if (surface & expectedSurfaceType) {
+ config = configs[i];
+ break;
+ }
+ }
+
+ if ((m_attributes & GLPlatformSurface::SupportAlpha) && !config) {
+ LOG_ERROR("Failed to retrieve EGL Configuration with alpha. Trying to find one without alpha support.");
+ m_attributes &= ~GLPlatformSurface::SupportAlpha;
+ config = createConfig(expectedSurfaceType);
+ }
+
+ if (!config)
+ LOG_ERROR("Failed to find a valid EGL Configuration.");
+
+ return config;
+}
+
+#if PLATFORM(X11)
+EGLConfig EGLConfigSelector::surfaceClientConfig(NativeVisualId id)
+{
+ EGLConfig config = findMatchingConfigWithVisualId(id);
+
+ if (!config)
+ config = createConfig(EGL_PIXMAP_BIT);
+
+ return config;
+}
+
+EGLConfig EGLConfigSelector::findMatchingConfigWithVisualId(NativeVisualId id)
+{
+ if (m_sharedDisplay == EGL_NO_DISPLAY)
+ return 0;
+
+ EGLint numConfigs;
+ EGLint i;
+ EGLint visualId;
+ EGLConfig config = 0;
+
+ eglGetConfigs(m_sharedDisplay, 0, 0, &numConfigs);
+
+ if (!numConfigs) {
+ LOG_ERROR("Failed to retrieve any EGL configs.");
+ return 0;
+ }
+
+ EGLConfig configs[numConfigs];
+ eglGetConfigs(m_sharedDisplay, configs, numConfigs, &numConfigs);
+
+ if (!numConfigs) {
+ LOG_ERROR("Failed to retrieve any EGL configs.");
+ return 0;
+ }
+
+ int alphaChannelRequired = m_attributes & GLPlatformSurface::SupportAlpha ? 8 : 0;
+ for (i = 0; i < numConfigs; i++) {
+ EGLint alpha, surfaces;
+ EGLConfig tempConfig = configs[i];
+ eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_NATIVE_VISUAL_ID, &visualId);
+
+ if (static_cast<NativeVisualId>(visualId) != id)
+ continue;
+
+ eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_ALPHA_SIZE, &alpha);
+
+ if (alphaChannelRequired != alpha)
+ continue;
+
+ eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_SURFACE_TYPE, &surfaces);
+
+ if (surfaces & EGL_PIXMAP_BIT) {
+ config = tempConfig;
+ break;
+ }
+ }
+
+ return config;
+}
+#endif
+
+}
+
+#endif
diff --git a/Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.h b/Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.h
new file mode 100644
index 000000000..272cbdbc5
--- /dev/null
+++ b/Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef EGLConfigSelector_h
+#define EGLConfigSelector_h
+
+#if USE(EGL)
+
+#include <opengl/GLDefs.h>
+#include <opengl/GLPlatformSurface.h>
+#include <wtf/Noncopyable.h>
+
+namespace WebCore {
+#if PLATFORM(X11)
+typedef VisualID NativeVisualId;
+#endif
+
+class EGLConfigSelector {
+ WTF_MAKE_NONCOPYABLE(EGLConfigSelector);
+public:
+ EGLConfigSelector(GLPlatformSurface::SurfaceAttributes);
+ virtual ~EGLConfigSelector();
+ virtual EGLConfig pixmapContextConfig();
+ virtual EGLConfig surfaceContextConfig();
+ EGLint nativeVisualId(const EGLConfig&) const;
+ GLPlatformSurface::SurfaceAttributes attributes() const;
+ void reset();
+#if PLATFORM(X11)
+ virtual EGLConfig surfaceClientConfig(NativeVisualId);
+#endif
+
+private:
+#if PLATFORM(X11)
+ EGLConfig findMatchingConfigWithVisualId(NativeVisualId);
+#endif
+ EGLConfig createConfig(EGLint expectedSurfaceType);
+
+protected:
+ EGLConfig m_pixmapFBConfig;
+ EGLConfig m_surfaceContextFBConfig;
+ unsigned m_attributes : 3;
+ PlatformDisplay m_sharedDisplay;
+};
+
+}
+
+#endif
+
+#endif
diff --git a/Source/WebCore/platform/graphics/surfaces/egl/EGLContext.cpp b/Source/WebCore/platform/graphics/surfaces/egl/EGLContext.cpp
new file mode 100644
index 000000000..c208dcc37
--- /dev/null
+++ b/Source/WebCore/platform/graphics/surfaces/egl/EGLContext.cpp
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "EGLContext.h"
+
+#if USE(EGL)
+
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+static const EGLint contextAttributes[] = {
+#if USE(OPENGL_ES_2)
+ EGL_CONTEXT_CLIENT_VERSION, 2,
+#endif
+ EGL_NONE
+};
+
+static const EGLint contextRobustnessAttributes[] = {
+#if USE(OPENGL_ES_2)
+ EGL_CONTEXT_CLIENT_VERSION, 2,
+#endif
+ EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT,
+ EGL_LOSE_CONTEXT_ON_RESET_EXT,
+ EGL_NONE
+};
+
+static bool isRobustnessExtSupported(EGLDisplay display)
+{
+ static bool didQueryForRobustnessExtension = false;
+ static bool isRobustnessExtensionSupported = false;
+
+ if (!didQueryForRobustnessExtension) {
+ didQueryForRobustnessExtension = true;
+ isRobustnessExtensionSupported = GLPlatformContext::supportsEGLExtension(display, "EGL_EXT_create_context_robustness");
+ }
+
+ return isRobustnessExtensionSupported;
+}
+
+EGLOffScreenContext::EGLOffScreenContext()
+ : GLPlatformContext()
+ , m_display(0)
+{
+}
+
+bool EGLOffScreenContext::initialize(GLPlatformSurface* surface, PlatformContext sharedContext)
+{
+ if (!surface)
+ return false;
+
+ if (!eglBindAPI(eglAPIVersion)) {
+ LOG_ERROR("Failed to set EGL API(%d).", eglGetError());
+ return false;
+ }
+
+ m_display = surface->sharedDisplay();
+ if (!m_display)
+ return false;
+
+ EGLConfig config = surface->configuration();
+ if (!config)
+ return false;
+
+ if (isRobustnessExtSupported(m_display))
+ m_contextHandle = eglCreateContext(m_display, config, sharedContext, contextRobustnessAttributes);
+
+ if (m_contextHandle != EGL_NO_CONTEXT) {
+ // The EGL_EXT_create_context_robustness spec requires that a context created with
+ // EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT bit set must also support GL_EXT_robustness or
+ // a version of OpenGL incorporating equivalent functionality.
+ // The spec also defines similar requirements for attribute EGL_LOSE_CONTEXT_ON_RESET_EXT.
+ if (platformMakeCurrent(surface) && (GLPlatformContext::supportsGLExtension("GL_EXT_robustness")))
+ m_resetLostContext = true;
+ else
+ eglDestroyContext(m_display, m_contextHandle);
+ }
+
+ if (m_contextHandle == EGL_NO_CONTEXT)
+ m_contextHandle = eglCreateContext(m_display, config, sharedContext, contextAttributes);
+
+ if (m_contextHandle != EGL_NO_CONTEXT)
+ return true;
+
+ return false;
+}
+
+EGLOffScreenContext::~EGLOffScreenContext()
+{
+}
+
+bool EGLOffScreenContext::isCurrentContext() const
+{
+ return m_contextHandle == eglGetCurrentContext();
+}
+
+bool EGLOffScreenContext::platformMakeCurrent(GLPlatformSurface* surface)
+{
+ if (!eglMakeCurrent(m_display, surface->drawable(), surface->drawable(), m_contextHandle)) {
+ LOG_ERROR("Failed to make context current(%d).", eglGetError());
+
+ if (m_resetLostContext && eglGetError() == EGL_CONTEXT_LOST) {
+ LOG_ERROR("Lost current context.");
+ m_contextLost = true;
+ }
+
+ return false;
+ }
+
+ return true;
+}
+
+void EGLOffScreenContext::platformReleaseCurrent()
+{
+ eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+}
+
+void EGLOffScreenContext::freeResources()
+{
+ if (m_contextHandle == EGL_NO_CONTEXT)
+ return;
+
+ eglDestroyContext(m_display, m_contextHandle);
+ m_contextHandle = EGL_NO_CONTEXT;
+ m_display = 0;
+}
+
+void EGLOffScreenContext::destroy()
+{
+ GLPlatformContext::destroy();
+ freeResources();
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/platform/graphics/surfaces/egl/EGLContext.h b/Source/WebCore/platform/graphics/surfaces/egl/EGLContext.h
new file mode 100644
index 000000000..ec31913c8
--- /dev/null
+++ b/Source/WebCore/platform/graphics/surfaces/egl/EGLContext.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef EGLContext_h
+#define EGLContext_h
+
+#if USE(EGL)
+
+#include "GLPlatformContext.h"
+
+namespace WebCore {
+
+class EGLOffScreenContext : public GLPlatformContext {
+
+public:
+ EGLOffScreenContext();
+ virtual ~EGLOffScreenContext();
+ virtual bool initialize(GLPlatformSurface*, PlatformContext) OVERRIDE;
+ virtual bool platformMakeCurrent(GLPlatformSurface*) OVERRIDE;
+ virtual void platformReleaseCurrent() OVERRIDE;
+ virtual void destroy() OVERRIDE;
+ virtual bool isCurrentContext() const OVERRIDE;
+
+private:
+ void freeResources();
+ EGLDisplay m_display;
+};
+
+}
+
+#endif
+
+#endif
diff --git a/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.cpp b/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.cpp
new file mode 100644
index 000000000..9aed9af53
--- /dev/null
+++ b/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.cpp
@@ -0,0 +1,176 @@
+/*
+ * Copyright (C) 2013 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "EGLHelper.h"
+
+#if USE(EGL)
+
+#include <opengl/GLPlatformContext.h>
+
+#if PLATFORM(X11)
+#include "X11Helper.h"
+#endif
+
+namespace WebCore {
+
+#if PLATFORM(X11)
+typedef X11Helper NativeWrapper;
+typedef Display NativeSharedDisplay;
+#else
+typedef void NativeSharedDisplay;
+#endif
+
+static PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR = 0;
+static PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR = 0;
+static PFNGLEGLIMAGETARGETTEXTURE2DOESPROC eglImageTargetTexture2DOES = 0;
+
+struct EGLDisplayConnection {
+
+ EGLDisplayConnection(NativeSharedDisplay* display = 0)
+ {
+ if (display)
+ m_eglDisplay = eglGetDisplay(reinterpret_cast<EGLNativeDisplayType>(display));
+ else
+ m_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+
+ if (m_eglDisplay == EGL_NO_DISPLAY) {
+ LOG_ERROR("EGLDisplay Initialization failed.");
+ return;
+ }
+
+ EGLBoolean success;
+ success = eglInitialize(m_eglDisplay, 0, 0);
+
+ if (success != EGL_TRUE) {
+ LOG_ERROR("EGLInitialization failed.");
+ terminate();
+ return;
+ }
+
+ success = eglBindAPI(eglAPIVersion);
+
+ if (success != EGL_TRUE) {
+ LOG_ERROR("Failed to set EGL API(%d).", eglGetError());
+ terminate();
+ return;
+ }
+ }
+
+ ~EGLDisplayConnection()
+ {
+ terminate();
+ }
+
+ EGLDisplay display() { return m_eglDisplay; }
+
+private:
+ void terminate()
+ {
+ if (m_eglDisplay == EGL_NO_DISPLAY)
+ return;
+
+ eglTerminate(m_eglDisplay);
+ m_eglDisplay = EGL_NO_DISPLAY;
+ }
+
+ EGLDisplay m_eglDisplay;
+};
+
+PlatformDisplay EGLHelper::eglDisplay()
+{
+ // Display connection will only be broken at program shutdown.
+#if PLATFORM(X11)
+ static EGLDisplayConnection displayConnection(NativeWrapper::nativeDisplay());
+#else
+ static EGLDisplayConnection displayConnection;
+#endif
+ return displayConnection.display();
+}
+
+PlatformDisplay EGLHelper::currentDisplay()
+{
+ EGLDisplay display = eglGetCurrentDisplay();
+
+ if (display == EGL_NO_DISPLAY)
+ display = EGLHelper::eglDisplay();
+
+ return display;
+}
+
+void EGLHelper::resolveEGLBindings()
+{
+ static bool initialized = false;
+
+ if (initialized)
+ return;
+
+ initialized = true;
+
+ EGLDisplay display = currentDisplay();
+
+ if (display == EGL_NO_DISPLAY)
+ return;
+
+ if (GLPlatformContext::supportsEGLExtension(display, "EGL_KHR_image") && GLPlatformContext::supportsEGLExtension(display, "EGL_KHR_image_pixmap") && GLPlatformContext::supportsGLExtension("GL_OES_EGL_image")) {
+ eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC) eglGetProcAddress("eglCreateImageKHR");
+ eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC) eglGetProcAddress("eglDestroyImageKHR");
+ eglImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)eglGetProcAddress("glEGLImageTargetTexture2DOES");
+ }
+}
+
+void EGLHelper::createEGLImage(EGLImageKHR* image, GLenum target, const EGLClientBuffer clientBuffer, const EGLint attributes[])
+{
+ EGLDisplay display = currentDisplay();
+
+ if (display == EGL_NO_DISPLAY)
+ return;
+
+ EGLImageKHR tempHandle = EGL_NO_IMAGE_KHR;
+
+ if (eglCreateImageKHR && eglImageTargetTexture2DOES && eglDestroyImageKHR)
+ tempHandle = eglCreateImageKHR(display, EGL_NO_CONTEXT, target, clientBuffer, attributes);
+
+ *image = tempHandle;
+}
+
+void EGLHelper::destroyEGLImage(const EGLImageKHR image)
+{
+ EGLDisplay display = currentDisplay();
+
+ if (display == EGL_NO_DISPLAY)
+ return;
+
+ if (eglDestroyImageKHR)
+ eglDestroyImageKHR(display, image);
+}
+
+void EGLHelper::imageTargetTexture2DOES(const EGLImageKHR image)
+{
+ eglImageTargetTexture2DOES(GL_TEXTURE_2D, static_cast<GLeglImageOES>(image));
+}
+
+}
+#endif
diff --git a/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.h b/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.h
new file mode 100644
index 000000000..f2458fb5d
--- /dev/null
+++ b/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2013 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef EGLHelper_h
+#define EGLHelper_h
+
+#if USE(EGL)
+
+#include <opengl/GLDefs.h>
+
+namespace WebCore {
+
+class EGLHelper {
+public:
+ static PlatformDisplay eglDisplay();
+ static PlatformDisplay currentDisplay();
+ static void resolveEGLBindings();
+ static void createEGLImage(EGLImageKHR*, GLenum, const EGLClientBuffer, const EGLint* = 0);
+ static void destroyEGLImage(const EGLImageKHR);
+ static void imageTargetTexture2DOES(const EGLImageKHR);
+};
+
+}
+
+#endif
+
+#endif
diff --git a/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp b/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp
new file mode 100644
index 000000000..975d486b5
--- /dev/null
+++ b/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp
@@ -0,0 +1,170 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "EGLSurface.h"
+
+#if USE(EGL) && USE(GRAPHICS_SURFACE)
+
+#include "EGLConfigSelector.h"
+#include "EGLHelper.h"
+#include "GLPlatformContext.h"
+
+#if PLATFORM(X11)
+#include "EGLXSurface.h"
+#endif
+
+namespace WebCore {
+
+PassOwnPtr<GLTransportSurface> EGLTransportSurface::createTransportSurface(const IntSize& size, SurfaceAttributes attributes)
+{
+ OwnPtr<GLTransportSurface> surface;
+#if PLATFORM(X11)
+ surface = adoptPtr(new EGLWindowTransportSurface(size, attributes));
+#else
+ UNUSED_PARAM(size);
+ UNUSED_PARAM(attributes);
+#endif
+
+ if (surface)
+ return surface.release();
+
+ return nullptr;
+}
+
+PassOwnPtr<GLTransportSurfaceClient> EGLTransportSurface::createTransportSurfaceClient(const PlatformBufferHandle handle, const IntSize& size, bool hasAlpha)
+{
+ EGLHelper::resolveEGLBindings();
+ OwnPtr<GLTransportSurfaceClient> client;
+#if PLATFORM(X11)
+ client = adoptPtr(new EGLXTransportSurfaceClient(handle, size, hasAlpha));
+#else
+ UNUSED_PARAM(handle);
+ UNUSED_PARAM(size);
+ UNUSED_PARAM(hasAlpha);
+#endif
+
+ if (client)
+ return client.release();
+
+ return nullptr;
+}
+
+EGLTransportSurface::EGLTransportSurface(const IntSize& size, SurfaceAttributes attributes)
+ : GLTransportSurface(size, attributes)
+{
+ m_sharedDisplay = EGLHelper::eglDisplay();
+
+ if (m_sharedDisplay == EGL_NO_DISPLAY)
+ return;
+
+ m_configSelector = adoptPtr(new EGLConfigSelector(attributes));
+}
+
+GLPlatformSurface::SurfaceAttributes EGLTransportSurface::attributes() const
+{
+ return m_configSelector->attributes();
+}
+
+EGLTransportSurface::~EGLTransportSurface()
+{
+}
+
+void EGLTransportSurface::destroy()
+{
+ if (m_drawable == EGL_NO_SURFACE || m_sharedDisplay == EGL_NO_DISPLAY)
+ return;
+
+ GLTransportSurface::destroy();
+
+ if (m_drawable) {
+ eglDestroySurface(m_sharedDisplay, m_drawable);
+ m_drawable = EGL_NO_SURFACE;
+ }
+
+ m_configSelector = nullptr;
+}
+
+PlatformSurfaceConfig EGLTransportSurface::configuration()
+{
+ return m_configSelector->surfaceContextConfig();
+}
+
+PassOwnPtr<GLPlatformSurface> EGLOffScreenSurface::createOffScreenSurface(SurfaceAttributes attributes)
+{
+ OwnPtr<GLPlatformSurface> surface;
+#if PLATFORM(X11)
+ surface = adoptPtr(new EGLPixmapSurface(attributes));
+#else
+ UNUSED_PARAM(attributes);
+#endif
+
+ if (surface)
+ return surface.release();
+
+ return nullptr;
+}
+
+EGLOffScreenSurface::EGLOffScreenSurface(SurfaceAttributes surfaceAttributes)
+ : GLPlatformSurface(surfaceAttributes)
+{
+ m_sharedDisplay = EGLHelper::eglDisplay();
+
+ if (m_sharedDisplay == EGL_NO_DISPLAY)
+ return;
+
+ m_configSelector = adoptPtr(new EGLConfigSelector(surfaceAttributes));
+}
+
+EGLOffScreenSurface::~EGLOffScreenSurface()
+{
+}
+
+GLPlatformSurface::SurfaceAttributes EGLOffScreenSurface::attributes() const
+{
+ return m_configSelector->attributes();
+}
+
+PlatformSurfaceConfig EGLOffScreenSurface::configuration()
+{
+ return m_configSelector->pixmapContextConfig();
+}
+
+void EGLOffScreenSurface::destroy()
+{
+ if (m_sharedDisplay == EGL_NO_DISPLAY || m_drawable == EGL_NO_SURFACE)
+ return;
+
+ if (m_drawable) {
+ eglDestroySurface(m_sharedDisplay, m_drawable);
+ m_drawable = EGL_NO_SURFACE;
+ }
+
+ m_configSelector = nullptr;
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.h b/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.h
new file mode 100644
index 000000000..dc88668d1
--- /dev/null
+++ b/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef EGLSurface_h
+#define EGLSurface_h
+
+#if USE(EGL) && USE(GRAPHICS_SURFACE)
+
+#include "GLTransportSurface.h"
+
+#include <wtf/Noncopyable.h>
+#include <wtf/PassOwnPtr.h>
+
+namespace WebCore {
+
+class EGLConfigSelector;
+
+class EGLTransportSurface : public GLTransportSurface {
+public:
+ static PassOwnPtr<GLTransportSurface> createTransportSurface(const IntSize&, SurfaceAttributes);
+ static PassOwnPtr<GLTransportSurfaceClient> createTransportSurfaceClient(const PlatformBufferHandle, const IntSize&, bool);
+ virtual ~EGLTransportSurface();
+ virtual PlatformSurfaceConfig configuration() OVERRIDE;
+ virtual void destroy() OVERRIDE;
+ virtual GLPlatformSurface::SurfaceAttributes attributes() const OVERRIDE;
+
+protected:
+ EGLTransportSurface(const IntSize&, SurfaceAttributes);
+ OwnPtr<EGLConfigSelector> m_configSelector;
+};
+
+class EGLOffScreenSurface : public GLPlatformSurface {
+public:
+ static PassOwnPtr<GLPlatformSurface> createOffScreenSurface(SurfaceAttributes);
+ virtual ~EGLOffScreenSurface();
+ virtual PlatformSurfaceConfig configuration() OVERRIDE;
+ virtual void destroy() OVERRIDE;
+ virtual GLPlatformSurface::SurfaceAttributes attributes() const OVERRIDE;
+
+protected:
+ EGLOffScreenSurface(SurfaceAttributes);
+ OwnPtr<EGLConfigSelector> m_configSelector;
+};
+
+}
+
+#endif
+
+#endif
diff --git a/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.cpp b/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.cpp
new file mode 100644
index 000000000..546619cce
--- /dev/null
+++ b/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.cpp
@@ -0,0 +1,333 @@
+/*
+ * Copyright (C) 2013 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "EGLXSurface.h"
+
+#if PLATFORM(X11) && USE(EGL) && USE(GRAPHICS_SURFACE)
+
+#include "EGLConfigSelector.h"
+#include "EGLHelper.h"
+#include "GLPlatformContext.h"
+
+namespace WebCore {
+
+EGLWindowTransportSurface::EGLWindowTransportSurface(const IntSize& size, GLPlatformSurface::SurfaceAttributes attributes)
+ : EGLTransportSurface(size, attributes)
+{
+ if (!m_configSelector)
+ return;
+
+ if (!m_configSelector->surfaceContextConfig()) {
+ destroy();
+ return;
+ }
+
+ EGLint visualId = m_configSelector->nativeVisualId(m_configSelector->surfaceContextConfig());
+
+ if (visualId == -1) {
+ destroy();
+ return;
+ }
+
+ NativeWrapper::createOffScreenWindow(&m_bufferHandle, visualId, m_configSelector->attributes() & GLPlatformSurface::SupportAlpha, size);
+
+ if (!m_bufferHandle) {
+ destroy();
+ return;
+ }
+
+ m_drawable = eglCreateWindowSurface(m_sharedDisplay, m_configSelector->surfaceContextConfig(), static_cast<EGLNativeWindowType>(m_bufferHandle), 0);
+
+ if (m_drawable == EGL_NO_SURFACE) {
+ LOG_ERROR("Failed to create EGL surface(%d).", eglGetError());
+ destroy();
+ }
+}
+
+EGLWindowTransportSurface::~EGLWindowTransportSurface()
+{
+}
+
+void EGLWindowTransportSurface::swapBuffers()
+{
+ if (!eglSwapBuffers(m_sharedDisplay, m_drawable))
+ LOG_ERROR("Failed to SwapBuffers(%d).", eglGetError());
+}
+
+void EGLWindowTransportSurface::destroy()
+{
+ EGLTransportSurface::destroy();
+
+ if (m_bufferHandle) {
+ NativeWrapper::destroyWindow(m_bufferHandle);
+ m_bufferHandle = 0;
+ }
+}
+
+EGLPixmapSurface::EGLPixmapSurface(GLPlatformSurface::SurfaceAttributes surfaceAttributes)
+ : EGLOffScreenSurface(surfaceAttributes)
+{
+ if (!m_configSelector)
+ return;
+
+ EGLConfig config = m_configSelector->pixmapContextConfig();
+
+ if (!config) {
+ destroy();
+ return;
+ }
+
+ EGLint visualId = m_configSelector->nativeVisualId(config);
+
+ if (visualId == -1) {
+ destroy();
+ return;
+ }
+
+ NativePixmap pixmap;
+ NativeWrapper::createPixmap(&pixmap, visualId, m_configSelector->attributes() & GLPlatformSurface::SupportAlpha);
+ m_bufferHandle = pixmap;
+
+ if (!m_bufferHandle) {
+ destroy();
+ return;
+ }
+
+ m_drawable = eglCreatePixmapSurface(m_sharedDisplay, config, static_cast<EGLNativePixmapType>(m_bufferHandle), 0);
+
+ if (m_drawable == EGL_NO_SURFACE) {
+ LOG_ERROR("Failed to create EGL surface(%d).", eglGetError());
+ destroy();
+ }
+}
+
+EGLPixmapSurface::~EGLPixmapSurface()
+{
+}
+
+void EGLPixmapSurface::destroy()
+{
+ EGLOffScreenSurface::destroy();
+
+ if (m_bufferHandle) {
+ NativeWrapper::destroyPixmap(m_bufferHandle);
+ m_bufferHandle = 0;
+ }
+}
+
+EGLXTransportSurfaceClient::EGLXTransportSurfaceClient(const PlatformBufferHandle handle, const IntSize& size, bool hasAlpha)
+ : GLTransportSurfaceClient()
+ , m_image(0)
+ , m_size(size)
+ , m_totalBytes(0)
+{
+ if (!handle)
+ return;
+
+ m_handle = handle;
+ XWindowAttributes attr;
+
+ if (!XGetWindowAttributes(NativeWrapper::nativeDisplay(), m_handle, &attr))
+ return;
+
+ createTexture();
+ GLPlatformSurface::SurfaceAttributes sharedSurfaceAttributes = GLPlatformSurface::Default;
+
+ if (hasAlpha)
+ sharedSurfaceAttributes = GLPlatformSurface::SupportAlpha;
+
+ EGLConfigSelector configSelector(sharedSurfaceAttributes);
+ EGLConfig config = configSelector.surfaceClientConfig(XVisualIDFromVisual(attr.visual));
+ m_eglImage = adoptPtr(new EGLTextureFromPixmap(m_handle, hasAlpha, config));
+
+ if (!m_eglImage->isValid() || eglGetError() != EGL_SUCCESS)
+ destroy();
+
+ if (m_eglImage)
+ return;
+
+ m_totalBytes = m_size.width() * m_size.height() * 4;
+
+#if USE(OPENGL_ES_2)
+ m_format = GraphicsContext3D::RGBA;
+ static bool bgraSupported = GLPlatformContext::supportsGLExtension("GL_EXT_texture_format_BGRA8888");
+ if (bgraSupported)
+ m_format = GraphicsContext3D::BGRA;
+#endif
+
+ createTexture();
+ prepareTexture();
+}
+
+EGLXTransportSurfaceClient::~EGLXTransportSurfaceClient()
+{
+}
+
+void EGLXTransportSurfaceClient::destroy()
+{
+ GLTransportSurfaceClient::destroy();
+
+ if (m_eglImage) {
+ m_eglImage->destroy();
+ m_eglImage = nullptr;
+ }
+
+ eglWaitGL();
+
+ if (m_image) {
+ XDestroyImage(m_image);
+ m_image = 0;
+ }
+}
+
+void EGLXTransportSurfaceClient::prepareTexture()
+{
+ ::glBindTexture(GL_TEXTURE_2D, m_texture);
+
+ if (m_eglImage) {
+ m_eglImage->reBindTexImage();
+ return;
+ }
+
+ // Fallback to use XImage in case EGLImage and TextureToPixmap are not supported.
+ m_image = XGetImage(NativeWrapper::nativeDisplay(), m_handle, 0, 0, m_size.width(), m_size.height(), AllPlanes, ZPixmap);
+
+#if USE(OPENGL_ES_2)
+ if (m_format != GraphicsContext3D::BGRA) {
+ for (unsigned i = 0; i < m_totalBytes; i += 4)
+ std::swap(m_image->data[i], m_image->data[i + 2]);
+ }
+#endif
+
+ glTexImage2D(GL_TEXTURE_2D, 0, m_format, m_size.width(), m_size.height(), 0, m_format, GL_UNSIGNED_BYTE, m_image->data);
+
+ if (m_image) {
+ XDestroyImage(m_image);
+ m_image = 0;
+ }
+}
+
+EGLTextureFromPixmap::EGLTextureFromPixmap(const NativePixmap handle, bool hasAlpha, EGLConfig config)
+ : m_eglImage(0)
+ , m_surface(EGL_NO_SURFACE)
+{
+ if (!handle)
+ return;
+
+ static bool textureFromPixmapSupported = GLPlatformContext::supportsEGLExtension(EGLHelper::eglDisplay(), "EGL_NOK_texture_from_pixmap");
+
+ if (textureFromPixmapSupported) {
+ const EGLint pixmapAttribs[] = { EGL_TEXTURE_FORMAT, hasAlpha ? EGL_TEXTURE_RGBA : EGL_TEXTURE_RGB, EGL_TEXTURE_TARGET, EGL_TEXTURE_2D, EGL_NONE };
+ m_surface = eglCreatePixmapSurface(EGLHelper::eglDisplay(), config, handle, pixmapAttribs);
+
+ if (m_surface != EGL_NO_SURFACE && !eglBindTexImage(EGLHelper::eglDisplay(), m_surface, EGL_BACK_BUFFER))
+ destroy();
+ }
+
+ if (m_surface != EGL_NO_SURFACE)
+ return;
+
+ static const EGLint imageAttrs[] = { EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE };
+ EGLHelper::createEGLImage(&m_eglImage, EGL_NATIVE_PIXMAP_KHR, (EGLClientBuffer)(handle), imageAttrs);
+
+ if (m_eglImage) {
+ EGLHelper::imageTargetTexture2DOES(m_eglImage);
+ EGLint error = eglGetError();
+
+ if (error != EGL_SUCCESS)
+ destroy();
+ }
+}
+
+EGLTextureFromPixmap::~EGLTextureFromPixmap()
+{
+}
+
+void EGLTextureFromPixmap::destroy()
+{
+ eglWaitNative(EGL_CORE_NATIVE_ENGINE);
+
+ if (m_surface != EGL_NO_SURFACE)
+ eglReleaseTexImage(EGLHelper::eglDisplay(), m_surface, EGL_BACK_BUFFER);
+
+ if (m_eglImage) {
+ EGLHelper::destroyEGLImage(m_eglImage);
+ m_eglImage = 0;
+ }
+
+ if (m_surface != EGL_NO_SURFACE) {
+ eglDestroySurface(EGLHelper::eglDisplay(), m_surface);
+ m_surface = EGL_NO_SURFACE;
+ }
+
+ eglWaitGL();
+}
+
+bool EGLTextureFromPixmap::isValid() const
+{
+ if (m_surface || m_eglImage)
+ return true;
+
+ return false;
+}
+
+bool EGLTextureFromPixmap::bindTexImage()
+{
+ if (m_surface != EGL_NO_SURFACE) {
+ bool success = eglBindTexImage(EGLHelper::eglDisplay(), m_surface, EGL_BACK_BUFFER);
+ return success;
+ }
+
+ if (m_eglImage) {
+ EGLHelper::imageTargetTexture2DOES(m_eglImage);
+ return true;
+ }
+
+ return false;
+}
+
+bool EGLTextureFromPixmap::reBindTexImage()
+{
+ if (m_surface != EGL_NO_SURFACE) {
+ bool success = eglReleaseTexImage(EGLHelper::eglDisplay(), m_surface, EGL_BACK_BUFFER);
+
+ if (success)
+ success = eglBindTexImage(EGLHelper::eglDisplay(), m_surface, EGL_BACK_BUFFER);
+
+ return success;
+ }
+
+ if (m_eglImage) {
+ EGLHelper::imageTargetTexture2DOES(m_eglImage);
+ return true;
+ }
+
+ return false;
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.h b/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.h
new file mode 100644
index 000000000..7c74232c1
--- /dev/null
+++ b/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.h
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2013 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef EGLXSurface_h
+#define EGLXSurface_h
+
+#if PLATFORM(X11) && USE(EGL) && USE(GRAPHICS_SURFACE)
+
+#include "EGLSurface.h"
+#include <glx/X11Helper.h>
+
+namespace WebCore {
+
+typedef X11Helper NativeWrapper;
+typedef Pixmap NativePixmap;
+
+// Contents of the surface are backed by native window.
+class EGLWindowTransportSurface : public EGLTransportSurface {
+public:
+ EGLWindowTransportSurface(const IntSize&, GLPlatformSurface::SurfaceAttributes);
+ virtual ~EGLWindowTransportSurface();
+ virtual void swapBuffers() OVERRIDE;
+ virtual void destroy() OVERRIDE;
+};
+
+class EGLPixmapSurface : public EGLOffScreenSurface {
+public:
+ EGLPixmapSurface(GLPlatformSurface::SurfaceAttributes);
+ virtual ~EGLPixmapSurface();
+ virtual void destroy() OVERRIDE;
+};
+
+class EGLTextureFromPixmap {
+public:
+ EGLTextureFromPixmap(const NativePixmap, bool, EGLConfig);
+ virtual ~EGLTextureFromPixmap();
+ bool bindTexImage();
+ bool isValid() const;
+ bool reBindTexImage();
+ void destroy();
+
+private:
+ EGLImageKHR m_eglImage;
+ EGLSurface m_surface;
+};
+
+class EGLXTransportSurfaceClient : public GLTransportSurfaceClient {
+public:
+ EGLXTransportSurfaceClient(const PlatformBufferHandle, const IntSize&, bool);
+ virtual ~EGLXTransportSurfaceClient();
+ virtual void prepareTexture() OVERRIDE;
+ virtual void destroy() OVERRIDE;
+
+private:
+ XImage* m_image;
+ IntSize m_size;
+ PlatformBufferHandle m_handle;
+ GLuint m_format;
+ unsigned m_totalBytes;
+ OwnPtr<EGLTextureFromPixmap> m_eglImage;
+};
+
+}
+
+#endif
+
+#endif
diff --git a/Source/WebCore/platform/graphics/surfaces/glx/GLXConfigSelector.h b/Source/WebCore/platform/graphics/surfaces/glx/GLXConfigSelector.h
new file mode 100644
index 000000000..2fea7b004
--- /dev/null
+++ b/Source/WebCore/platform/graphics/surfaces/glx/GLXConfigSelector.h
@@ -0,0 +1,211 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef GLXConfigSelector_h
+#define GLXConfigSelector_h
+
+#if USE(ACCELERATED_COMPOSITING) && USE(GLX)
+
+#include "X11Helper.h"
+#include <opengl/GLDefs.h>
+#include <opengl/GLPlatformSurface.h>
+
+namespace WebCore {
+
+static int clientAttributes[] = {
+ // The specification is a set key value pairs stored in a simple array.
+ GLX_LEVEL, 0,
+ static_cast<int>(GLX_VISUAL_ID), 0,
+ GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT,
+ GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_2D_BIT_EXT,
+ GLX_BIND_TO_TEXTURE_RGBA_EXT, TRUE,
+ 0
+};
+
+static int glxSurfaceAttributes[] = {
+ GLX_LEVEL, 0,
+ GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT,
+ GLX_RENDER_TYPE, 0,
+ GLX_RED_SIZE, 1,
+ GLX_GREEN_SIZE, 1,
+ GLX_BLUE_SIZE, 1,
+ GLX_ALPHA_SIZE, 0,
+ GLX_DOUBLEBUFFER, GL_FALSE,
+ None
+};
+
+class GLXConfigSelector {
+ WTF_MAKE_NONCOPYABLE(GLXConfigSelector);
+
+public:
+ GLXConfigSelector(GLPlatformSurface::SurfaceAttributes attr = GLPlatformSurface::Default)
+ : m_surfaceContextFBConfig(0)
+ , m_pixmapContextFBConfig(0)
+ , m_attributes(attr)
+ {
+ }
+
+ virtual ~GLXConfigSelector()
+ {
+ }
+
+ XVisualInfo* visualInfo(const GLXFBConfig& config)
+ {
+ return glXGetVisualFromFBConfig(X11Helper::nativeDisplay(), config);
+ }
+
+ GLXFBConfig pixmapContextConfig()
+ {
+ if (!m_pixmapContextFBConfig) {
+ validateAttributes();
+ m_pixmapContextFBConfig = findMatchingConfig(glxSurfaceAttributes, m_attributes & GLPlatformSurface::SupportAlpha ? 32 : 24);
+ }
+
+ return m_pixmapContextFBConfig;
+ }
+
+
+ GLXFBConfig surfaceContextConfig()
+ {
+ if (!m_surfaceContextFBConfig) {
+ glxSurfaceAttributes[3] = GLX_WINDOW_BIT;
+ glxSurfaceAttributes[7] = 8;
+ glxSurfaceAttributes[9] = 8;
+ glxSurfaceAttributes[11] = 8;
+ validateAttributes();
+ m_surfaceContextFBConfig = findMatchingConfig(glxSurfaceAttributes, m_attributes & GLPlatformSurface::SupportAlpha ? 32 : 24);
+ }
+
+ return m_surfaceContextFBConfig;
+ }
+
+ GLXFBConfig surfaceClientConfig(int depth, VisualID id)
+ {
+ clientAttributes[3] = static_cast<int>(id);
+ clientAttributes[8] = depth == 32 ? GLX_BIND_TO_TEXTURE_RGBA_EXT : GLX_BIND_TO_TEXTURE_RGB_EXT;
+ // Prefer to match with Visual Id.
+ GLXFBConfig config = findMatchingConfigWithVisualId(clientAttributes, depth, id);
+
+ if (!config)
+ config = findMatchingConfig(clientAttributes, depth);
+
+ return config;
+ }
+
+ void reset()
+ {
+ m_surfaceContextFBConfig = 0;
+ m_pixmapContextFBConfig = 0;
+ }
+
+ GLPlatformSurface::SurfaceAttributes attributes() const
+ {
+ return m_attributes;
+ }
+
+private:
+ void validateAttributes()
+ {
+ if (m_attributes & GLPlatformSurface::SupportAlpha) {
+ glxSurfaceAttributes[13] = 8;
+ glxSurfaceAttributes[5] = GLX_RGBA_BIT;
+ }
+
+ if (m_attributes & GLPlatformSurface::DoubleBuffered)
+ glxSurfaceAttributes[15] = GL_TRUE;
+ }
+
+ GLXFBConfig findMatchingConfig(const int attributes[], int depth = 32)
+ {
+ int numAvailableConfigs;
+ OwnPtrX11<GLXFBConfig> temp(glXChooseFBConfig(X11Helper::nativeDisplay(), DefaultScreen(X11Helper::nativeDisplay()), attributes, &numAvailableConfigs));
+
+ if (!numAvailableConfigs || !temp.get())
+ return 0;
+
+ OwnPtrX11<XVisualInfo> scopedVisualInfo;
+ for (int i = 0; i < numAvailableConfigs; ++i) {
+ scopedVisualInfo = glXGetVisualFromFBConfig(X11Helper::nativeDisplay(), temp[i]);
+ if (!scopedVisualInfo.get())
+ continue;
+
+#if USE(GRAPHICS_SURFACE) && USE(GLX)
+ if (X11Helper::isXRenderExtensionSupported()) {
+ XRenderPictFormat* format = XRenderFindVisualFormat(X11Helper::nativeDisplay(), scopedVisualInfo->visual);
+
+ if (format) {
+ if (m_attributes & GLPlatformSurface::SupportAlpha) {
+ if (scopedVisualInfo->depth == depth && format->direct.alphaMask > 0)
+ return temp[i];
+ } else if (!format->direct.alphaMask)
+ return temp[i];
+ }
+ }
+#endif
+ if (scopedVisualInfo->depth == depth)
+ return temp[i];
+ }
+
+ // Did not find any visual supporting alpha, select the first available config.
+ scopedVisualInfo = glXGetVisualFromFBConfig(X11Helper::nativeDisplay(), temp[0]);
+
+ if ((m_attributes & GLPlatformSurface::SupportAlpha) && (scopedVisualInfo->depth != 32))
+ m_attributes &= ~GLPlatformSurface::SupportAlpha;
+
+ return temp[0];
+ }
+
+ GLXFBConfig findMatchingConfigWithVisualId(const int attributes[], int depth, VisualID id)
+ {
+ int numAvailableConfigs;
+ OwnPtrX11<GLXFBConfig> temp(glXChooseFBConfig(X11Helper::nativeDisplay(), DefaultScreen(X11Helper::nativeDisplay()), attributes, &numAvailableConfigs));
+
+ if (!numAvailableConfigs || !temp.get())
+ return 0;
+
+ OwnPtrX11<XVisualInfo> scopedVisualInfo;
+ for (int i = 0; i < numAvailableConfigs; ++i) {
+ scopedVisualInfo = glXGetVisualFromFBConfig(X11Helper::nativeDisplay(), temp[i]);
+ if (!scopedVisualInfo.get())
+ continue;
+
+ if (id && scopedVisualInfo->depth == depth && scopedVisualInfo->visualid == id)
+ return temp[i];
+ }
+
+ return 0;
+ }
+
+ GLXFBConfig m_surfaceContextFBConfig;
+ GLXFBConfig m_pixmapContextFBConfig;
+ GLPlatformSurface::SurfaceAttributes m_attributes : 3;
+};
+
+}
+
+#endif
+
+#endif
+
diff --git a/Source/WebCore/platform/graphics/surfaces/glx/GLXContext.cpp b/Source/WebCore/platform/graphics/surfaces/glx/GLXContext.cpp
index 295f06cf6..10d44f882 100644
--- a/Source/WebCore/platform/graphics/surfaces/glx/GLXContext.cpp
+++ b/Source/WebCore/platform/graphics/surfaces/glx/GLXContext.cpp
@@ -26,7 +26,9 @@
#include "config.h"
#include "GLXContext.h"
-#if USE(ACCELERATED_COMPOSITING) && HAVE(GLX)
+#if USE(ACCELERATED_COMPOSITING) && USE(GLX)
+
+#include "X11Helper.h"
namespace WebCore {
@@ -41,27 +43,26 @@ static int Attribs[] = {
static void initializeARBExtensions()
{
static bool initialized = false;
-
if (initialized)
return;
initialized = true;
- glXCreateContextAttribsARB = reinterpret_cast<GLXCREATECONTEXTATTRIBSARBPROC>(glXGetProcAddress(reinterpret_cast<const GLubyte*>("glXCreateContextAttribsARB")));
+ if (GLPlatformContext::supportsGLXExtension(X11Helper::nativeDisplay(), "GLX_ARB_create_context_robustness"))
+ glXCreateContextAttribsARB = reinterpret_cast<GLXCREATECONTEXTATTRIBSARBPROC>(glXGetProcAddress(reinterpret_cast<const GLubyte*>("glXCreateContextAttribsARB")));
}
GLXOffScreenContext::GLXOffScreenContext()
: GLPlatformContext()
- , m_display(0)
{
}
-bool GLXOffScreenContext::initialize(GLPlatformSurface* surface)
+bool GLXOffScreenContext::initialize(GLPlatformSurface* surface, PlatformContext sharedContext)
{
if (!surface)
return false;
- m_display = surface->sharedDisplay();
- if (!m_display)
+ Display* x11Display = surface->sharedDisplay();
+ if (!x11Display)
return false;
GLXFBConfig config = surface->configuration();
@@ -70,12 +71,22 @@ bool GLXOffScreenContext::initialize(GLPlatformSurface* surface)
initializeARBExtensions();
if (glXCreateContextAttribsARB)
- m_contextHandle = glXCreateContextAttribsARB(m_display, config, 0, true, Attribs);
-
- if (m_contextHandle)
- m_resetLostContext = true;
- else
- m_contextHandle = glXCreateNewContext(m_display, config, GLX_RGBA_TYPE, 0, true);
+ m_contextHandle = glXCreateContextAttribsARB(x11Display, config, sharedContext, true, Attribs);
+
+ if (m_contextHandle) {
+ // The GLX_ARB_create_context_robustness spec requires that a context created with
+ // GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB bit set must also support GL_ARB_robustness or
+ // a version of OpenGL incorporating equivalent functionality.
+ // The spec also defines similar requirements for attribute GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB.
+ if (platformMakeCurrent(surface) && GLPlatformContext::supportsGLExtension("GL_ARB_robustness"))
+ m_resetLostContext = true;
+ else
+ glXDestroyContext(x11Display, m_contextHandle);
+ }
+
+ bool supportsAlpha = surface->attributes() & GLPlatformSurface::SupportAlpha;
+ if (!m_contextHandle)
+ m_contextHandle = glXCreateNewContext(x11Display, config, supportsAlpha ? GLX_RGBA_TYPE : 0, sharedContext, true);
if (m_contextHandle)
return true;
@@ -95,21 +106,28 @@ bool GLXOffScreenContext::isCurrentContext() const
bool GLXOffScreenContext::platformMakeCurrent(GLPlatformSurface* surface)
{
- return glXMakeCurrent(surface->sharedDisplay(), surface->handle(), m_contextHandle);
+ return glXMakeCurrent(surface->sharedDisplay(), surface->drawable(), m_contextHandle);
}
void GLXOffScreenContext::platformReleaseCurrent()
{
- glXMakeCurrent(m_display, 0, 0);
+ Display* x11Display = X11Helper::nativeDisplay();
+ if (!x11Display)
+ return;
+
+ glXMakeCurrent(x11Display, 0, 0);
}
void GLXOffScreenContext::freeResources()
{
+ Display* x11Display = X11Helper::nativeDisplay();
+ if (!x11Display)
+ return;
+
if (m_contextHandle)
- glXDestroyContext(m_display, m_contextHandle);
+ glXDestroyContext(x11Display, m_contextHandle);
m_contextHandle = 0;
- m_display = 0;
}
void GLXOffScreenContext::destroy()
diff --git a/Source/WebCore/platform/graphics/surfaces/glx/GLXContext.h b/Source/WebCore/platform/graphics/surfaces/glx/GLXContext.h
index 7cff8d51f..3cc43bcba 100644
--- a/Source/WebCore/platform/graphics/surfaces/glx/GLXContext.h
+++ b/Source/WebCore/platform/graphics/surfaces/glx/GLXContext.h
@@ -26,40 +26,25 @@
#ifndef GLXContext_h
#define GLXContext_h
-#if USE(ACCELERATED_COMPOSITING) && HAVE(GLX)
+#if USE(ACCELERATED_COMPOSITING) && USE(GLX)
#include "GLPlatformContext.h"
namespace WebCore {
-class GLXCurrentContextWrapper : public GLPlatformContext {
- WTF_MAKE_NONCOPYABLE(GLXCurrentContextWrapper);
-
-public:
- GLXCurrentContextWrapper()
- : GLPlatformContext()
- {
- m_contextHandle = glXGetCurrentContext();
- }
-
- virtual ~GLXCurrentContextWrapper() { }
-};
-
class GLXOffScreenContext : public GLPlatformContext {
- WTF_MAKE_NONCOPYABLE(GLXOffScreenContext);
public:
GLXOffScreenContext();
virtual ~GLXOffScreenContext();
- bool initialize(GLPlatformSurface*);
- bool platformMakeCurrent(GLPlatformSurface*);
- void platformReleaseCurrent();
- void destroy();
- bool isCurrentContext() const;
+ virtual bool initialize(GLPlatformSurface*, PlatformContext) OVERRIDE;
+ virtual bool platformMakeCurrent(GLPlatformSurface*) OVERRIDE;
+ virtual void platformReleaseCurrent() OVERRIDE;
+ virtual void destroy() OVERRIDE;
+ virtual bool isCurrentContext() const OVERRIDE;
private:
void freeResources();
- Display* m_display;
};
}
diff --git a/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp b/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp
index 38f2c0bac..4db9c8987 100644
--- a/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp
+++ b/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.cpp
@@ -26,177 +26,256 @@
#include "config.h"
#include "GLXSurface.h"
-#if USE(ACCELERATED_COMPOSITING) && HAVE(GLX)
+#if USE(ACCELERATED_COMPOSITING) && USE(GLX)
namespace WebCore {
-SharedX11Resources* SharedX11Resources::m_staticSharedResource = 0;
+static PFNGLXBINDTEXIMAGEEXTPROC pGlXBindTexImageEXT = 0;
+static PFNGLXRELEASETEXIMAGEEXTPROC pGlXReleaseTexImageEXT = 0;
-static const int pbufferAttributes[] = { GLX_PBUFFER_WIDTH, 1, GLX_PBUFFER_HEIGHT, 1, 0 };
-
-GLXSurface::GLXSurface()
- : GLPlatformSurface()
+static bool resolveGLMethods()
{
- m_sharedResources = SharedX11Resources::create();
- m_sharedDisplay = m_sharedResources->display();
-}
+ static bool resolved = false;
+ if (resolved)
+ return true;
-GLXSurface::~GLXSurface()
-{
+ pGlXBindTexImageEXT = reinterpret_cast<PFNGLXBINDTEXIMAGEEXTPROC>(glXGetProcAddress(reinterpret_cast<const GLubyte*>("glXBindTexImageEXT")));
+ pGlXReleaseTexImageEXT = reinterpret_cast<PFNGLXRELEASETEXIMAGEEXTPROC>(glXGetProcAddress(reinterpret_cast<const GLubyte*>("glXReleaseTexImageEXT")));
+
+ resolved = pGlXBindTexImageEXT && pGlXReleaseTexImageEXT;
+
+ return resolved;
}
-XVisualInfo* GLXSurface::visualInfo()
+static int glxAttributes[] = {
+ GLX_TEXTURE_FORMAT_EXT,
+ GLX_TEXTURE_FORMAT_RGBA_EXT,
+ GLX_TEXTURE_TARGET_EXT,
+ GLX_TEXTURE_2D_EXT,
+ 0
+};
+
+static bool isMesaGLX()
{
- return m_sharedResources->visualInfo();
+ static bool isMesa = !!strstr(glXGetClientString(X11Helper::nativeDisplay(), GLX_VENDOR), "Mesa");
+ return isMesa;
}
-Window GLXSurface::xWindow()
+GLXTransportSurface::GLXTransportSurface(const IntSize& size, SurfaceAttributes attributes)
+ : GLTransportSurface(size, attributes)
{
- return m_sharedResources->getXWindow();
+ m_sharedDisplay = X11Helper::nativeDisplay();
+ attributes |= GLPlatformSurface::DoubleBuffered;
+ m_configSelector = adoptPtr(new GLXConfigSelector(attributes));
+ OwnPtrX11<XVisualInfo> visInfo(m_configSelector->visualInfo(m_configSelector->surfaceContextConfig()));
+
+ if (!visInfo.get()) {
+ destroy();
+ return;
+ }
+
+ X11Helper::createOffScreenWindow(&m_bufferHandle, *visInfo.get(), size);
+
+ if (!m_bufferHandle) {
+ destroy();
+ return;
+ }
+
+ m_drawable = m_bufferHandle;
}
-GLXFBConfig GLXSurface::pBufferConfiguration()
+GLXTransportSurface::~GLXTransportSurface()
{
- return m_sharedResources->pBufferContextConfig();
}
-GLXFBConfig GLXSurface::transportSurfaceConfiguration()
+PlatformSurfaceConfig GLXTransportSurface::configuration()
{
- return m_sharedResources->surfaceContextConfig();
+ return m_configSelector->surfaceContextConfig();
}
-bool GLXSurface::isXRenderExtensionSupported()
+void GLXTransportSurface::setGeometry(const IntRect& newRect)
{
- return m_sharedResources->isXRenderExtensionSupported();
+ GLTransportSurface::setGeometry(newRect);
+ X11Helper::resizeWindow(newRect, m_drawable);
+ // Force resize of GL surface after window resize.
+ glXSwapBuffers(sharedDisplay(), m_drawable);
}
-GLXTransportSurface::GLXTransportSurface()
- : GLXSurface()
+void GLXTransportSurface::swapBuffers()
{
- initialize();
+ if (!m_drawable)
+ return;
+
+ glXSwapBuffers(sharedDisplay(), m_drawable);
}
-GLXTransportSurface::~GLXTransportSurface()
+void GLXTransportSurface::destroy()
{
+ GLTransportSurface::destroy();
+
+ if (m_bufferHandle) {
+ X11Helper::destroyWindow(m_bufferHandle);
+ m_bufferHandle = 0;
+ m_drawable = 0;
+ }
+
+ m_configSelector = nullptr;
}
-PlatformSurfaceConfig GLXTransportSurface::configuration()
+GLPlatformSurface::SurfaceAttributes GLXTransportSurface::attributes() const
{
- return transportSurfaceConfiguration();
+ return m_configSelector->attributes();
}
-void GLXTransportSurface::swapBuffers()
+GLXOffScreenSurface::GLXOffScreenSurface(SurfaceAttributes surfaceAttributes)
+ : GLPlatformSurface(surfaceAttributes)
+ , m_pixmap(0)
+ , m_glxPixmap(0)
{
- if (!m_drawable)
- return;
-
- if (m_restoreNeeded) {
- GLint oldFBO;
- glGetIntegerv(GL_FRAMEBUFFER_BINDING, &oldFBO);
- glBindFramebuffer(GL_FRAMEBUFFER, 0);
- glXSwapBuffers(sharedDisplay(), m_drawable);
- glBindFramebuffer(GL_FRAMEBUFFER, oldFBO);
- } else
- glXSwapBuffers(sharedDisplay(), m_drawable);
+ initialize(surfaceAttributes);
}
-void GLXTransportSurface::setGeometry(const IntRect& newRect)
+GLXOffScreenSurface::~GLXOffScreenSurface()
{
- GLPlatformSurface::setGeometry(newRect);
- int width = newRect.width();
- int height = newRect.height();
- XResizeWindow(sharedDisplay(), m_drawable, width, height);
}
-void GLXTransportSurface::initialize()
+void GLXOffScreenSurface::initialize(SurfaceAttributes attributes)
{
- Display* display = sharedDisplay();
- GLXFBConfig config = transportSurfaceConfiguration();
- if (!config)
- return;
+ m_sharedDisplay = X11Helper::nativeDisplay();
+
+ m_configSelector = adoptPtr(new GLXConfigSelector(attributes));
- XVisualInfo* visInfo = visualInfo();
- if (!visInfo)
+ OwnPtrX11<XVisualInfo> visualInfo(m_configSelector->visualInfo(m_configSelector->pixmapContextConfig()));
+ X11Helper::createPixmap(&m_pixmap, *visualInfo.get());
+
+ if (!m_pixmap) {
+ destroy();
return;
+ }
- Colormap cmap = XCreateColormap(display, xWindow(), visInfo->visual, AllocNone);
- XSetWindowAttributes attribute;
- attribute.background_pixel = WhitePixel(display, 0);
- attribute.border_pixel = BlackPixel(display, 0);
- attribute.colormap = cmap;
- m_drawable = XCreateWindow(display, xWindow(), 0, 0, 1, 1, 0, visInfo->depth, InputOutput, visInfo->visual, CWBackPixel | CWBorderPixel | CWColormap, &attribute);
- if (!m_drawable)
+ m_glxPixmap = glXCreateGLXPixmap(m_sharedDisplay, visualInfo.get(), m_pixmap);
+
+ if (!m_glxPixmap) {
+ destroy();
return;
+ }
- XSetWindowBackgroundPixmap(display, m_drawable, 0);
- XCompositeRedirectWindow(display, m_drawable, CompositeRedirectManual);
+ m_drawable = m_glxPixmap;
+}
- if (isXRenderExtensionSupported())
- XMapWindow(display, m_drawable);
+PlatformSurfaceConfig GLXOffScreenSurface::configuration()
+{
+ return m_configSelector->pixmapContextConfig();
}
-void GLXTransportSurface::destroy()
+void GLXOffScreenSurface::destroy()
{
freeResources();
- GLPlatformSurface::destroy();
}
-void GLXTransportSurface::freeResources()
+void GLXOffScreenSurface::freeResources()
{
- if (!m_drawable)
- return;
-
- GLPlatformSurface::destroy();
Display* display = sharedDisplay();
+
if (!display)
return;
- XDestroyWindow(display, m_drawable);
+ if (m_glxPixmap) {
+ glXDestroyGLXPixmap(display, m_glxPixmap);
+ glXWaitGL();
+ m_glxPixmap = 0;
+ }
+
+ if (m_pixmap) {
+ X11Helper::destroyPixmap(m_pixmap);
+ m_pixmap = 0;
+ }
+
+ m_configSelector = nullptr;
m_drawable = 0;
}
-GLXPBuffer::GLXPBuffer()
- : GLXSurface()
+GLXTransportSurfaceClient::GLXTransportSurfaceClient(const PlatformBufferHandle handle, bool hasAlpha)
+ : GLTransportSurfaceClient()
{
- initialize();
-}
+ if (!resolveGLMethods())
+ return;
-GLXPBuffer::~GLXPBuffer()
-{
-}
+ XWindowAttributes attr;
+ Display* display = X11Helper::nativeDisplay();
+ if (!XGetWindowAttributes(display, handle, &attr))
+ return;
-void GLXPBuffer::initialize()
-{
- Display* display = sharedDisplay();
- GLXFBConfig config = pBufferConfiguration();
- if (!config)
+ // Ensure that the window is mapped.
+ if (attr.map_state == IsUnmapped || attr.map_state == IsUnviewable)
return;
- m_drawable = glXCreatePbuffer(display, config, pbufferAttributes);
-}
+ ScopedXPixmapCreationErrorHandler handler;
-PlatformSurfaceConfig GLXPBuffer::configuration()
-{
- return pBufferConfiguration();
+ XRenderPictFormat* format = XRenderFindVisualFormat(display, attr.visual);
+ m_xPixmap = XCompositeNameWindowPixmap(display, handle);
+
+ if (!m_xPixmap)
+ return;
+
+ glxAttributes[1] = (format->depth == 32 && hasAlpha) ? GLX_TEXTURE_FORMAT_RGBA_EXT : GLX_TEXTURE_FORMAT_RGB_EXT;
+
+ GLPlatformSurface::SurfaceAttributes sharedSurfaceAttributes = GLPlatformSurface::Default;
+
+ if (hasAlpha)
+ sharedSurfaceAttributes = GLPlatformSurface::SupportAlpha;
+
+ GLXConfigSelector configSelector(sharedSurfaceAttributes);
+
+ m_glxPixmap = glXCreatePixmap(display, configSelector.surfaceClientConfig(format->depth, XVisualIDFromVisual(attr.visual)), m_xPixmap, glxAttributes);
+
+ if (!m_glxPixmap || !handler.isValidOperation()) {
+ destroy();
+ return;
+ }
+
+ createTexture();
+ glXWaitX();
+ pGlXBindTexImageEXT(display, m_glxPixmap, GLX_FRONT_EXT, 0);
}
-void GLXPBuffer::destroy()
+GLXTransportSurfaceClient::~GLXTransportSurfaceClient()
{
- freeResources();
}
-void GLXPBuffer::freeResources()
+void GLXTransportSurfaceClient::destroy()
{
- if (!m_drawable)
- return;
-
- GLPlatformSurface::destroy();
- Display* display = sharedDisplay();
+ Display* display = X11Helper::nativeDisplay();
if (!display)
return;
- glXDestroyPbuffer(display, m_drawable);
- m_drawable = 0;
+ if (m_texture) {
+ pGlXReleaseTexImageEXT(display, m_glxPixmap, GLX_FRONT_EXT);
+ GLTransportSurfaceClient::destroy();
+ }
+
+ if (m_glxPixmap) {
+ glXDestroyPixmap(display, m_glxPixmap);
+ m_glxPixmap = 0;
+ glXWaitGL();
+ }
+
+ if (m_xPixmap) {
+ X11Helper::destroyPixmap(m_xPixmap);
+ m_xPixmap = 0;
+ }
+}
+
+void GLXTransportSurfaceClient::prepareTexture()
+{
+ if (isMesaGLX() && m_texture) {
+ Display* display = X11Helper::nativeDisplay();
+ glBindTexture(GL_TEXTURE_2D, m_texture);
+ // Mesa doesn't re-bind texture to the front buffer on glXSwapBufer
+ // Manually release previous lock and rebind texture to surface to ensure frame updates.
+ pGlXReleaseTexImageEXT(display, m_glxPixmap, GLX_FRONT_EXT);
+ pGlXBindTexImageEXT(display, m_glxPixmap, GLX_FRONT_EXT, 0);
+ }
}
}
diff --git a/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.h b/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.h
index dd71397d9..8802da329 100644
--- a/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.h
+++ b/Source/WebCore/platform/graphics/surfaces/glx/GLXSurface.h
@@ -26,259 +26,56 @@
#ifndef GLXSurface_h
#define GLXSurface_h
-#if USE(ACCELERATED_COMPOSITING) && HAVE(GLX)
+#if USE(ACCELERATED_COMPOSITING) && USE(GLX)
-#include "GLPlatformSurface.h"
-
-#include <X11/extensions/Xcomposite.h>
-#include <X11/extensions/Xrender.h>
-#include <wtf/Noncopyable.h>
+#include "GLTransportSurface.h"
+#include "GLXConfigSelector.h"
+#include "X11Helper.h"
namespace WebCore {
-class SharedX11Resources : public WTF::RefCountedBase {
- WTF_MAKE_NONCOPYABLE(SharedX11Resources);
-
-public:
- static PassRefPtr<SharedX11Resources> create()
- {
- if (!m_staticSharedResource)
- m_staticSharedResource = new SharedX11Resources();
- else
- m_staticSharedResource->ref();
-
- return adoptRef(m_staticSharedResource);
- }
-
- void deref()
- {
- if (derefBase()) {
- m_staticSharedResource = 0;
- delete this;
- }
- }
-
- Window getXWindow()
- {
- if (!m_window) {
- Display* dpy = display();
- XSetWindowAttributes attributes;
- attributes.override_redirect = true;
- m_window = XCreateSimpleWindow(dpy, XDefaultRootWindow(dpy), -1, -1, 1, 1, 0, BlackPixel(dpy, 0), WhitePixel(dpy, 0));
- // From http://tronche.com/gui/x/xlib/window/attributes/
- XChangeWindowAttributes(dpy, m_window, CWOverrideRedirect, &attributes);
- XMapWindow(dpy, m_window);
- }
-
- return m_window;
- }
-
- Display* display()
- {
- if (!m_display)
- m_display = XOpenDisplay(0);
-
- return m_display;
- }
-
- XVisualInfo* visualInfo()
- {
- if (!m_VisualInfo)
- surfaceContextConfig();
-
- return m_VisualInfo;
- }
-
- GLXFBConfig createConfig(const int attributes[])
- {
- int numReturned;
- m_VisualInfo = 0;
- GLXFBConfig* temp = glXChooseFBConfig(display(), DefaultScreen(display()), attributes, &numReturned);
-
- if (!numReturned)
- return 0;
-
- GLXFBConfig selectedConfig = 0;
- bool found = false;
-
- for (int i = 0; i < numReturned; ++i) {
- m_VisualInfo = glXGetVisualFromFBConfig(display(), temp[i]);
- if (!m_VisualInfo)
- continue;
-
- if (m_supportsXRenderExtension) {
- XRenderPictFormat* format = XRenderFindVisualFormat(display(), m_VisualInfo->visual);
- if (format && format->direct.alphaMask > 0) {
- selectedConfig = temp[i];
- found = true;
- break;
- }
- } else if (m_VisualInfo->depth == 32) {
- selectedConfig = temp[i];
- found = true;
- }
- }
-
- // Did not find any visual supporting alpha, select the first available config.
- if (!found) {
- selectedConfig = temp[0];
- m_VisualInfo = glXGetVisualFromFBConfig(m_display, temp[0]);
- }
-
- XFree(temp);
-
- return selectedConfig;
- }
-
- GLXFBConfig pBufferContextConfig()
- {
- if (!m_pbufferfbConfig) {
- static const int attributes[] = {
- GLX_LEVEL, 0,
- GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
- GLX_RENDER_TYPE, GLX_RGBA_BIT,
- GLX_RED_SIZE, 1,
- GLX_GREEN_SIZE, 1,
- GLX_BLUE_SIZE, 1,
- GLX_DOUBLEBUFFER, GL_FALSE,
- None
- };
-
- int numReturned;
- GLXFBConfig* temp = glXChooseFBConfig(display(), DefaultScreen(display()), attributes, &numReturned);
- if (numReturned)
- m_pbufferfbConfig = temp[0];
- XFree(temp);
- }
-
- return m_pbufferfbConfig;
- }
-
- GLXFBConfig surfaceContextConfig()
- {
- if (!m_surfaceContextfbConfig) {
- static int attributes[] = {
- GLX_LEVEL, 0,
- GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
- GLX_RENDER_TYPE, GLX_RGBA_BIT,
- GLX_RED_SIZE, 1,
- GLX_GREEN_SIZE, 1,
- GLX_BLUE_SIZE, 1,
- GLX_ALPHA_SIZE, 1,
- GLX_DEPTH_SIZE, 1,
- GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR,
- GLX_DOUBLEBUFFER, True,
- None
- };
-
- int eventBasep, errorBasep;
- m_supportsXRenderExtension = XRenderQueryExtension(display(), &eventBasep, &errorBasep);
-
- m_surfaceContextfbConfig = createConfig(attributes);
- }
-
- return m_surfaceContextfbConfig;
- }
-
- bool isXRenderExtensionSupported()
- {
- return m_supportsXRenderExtension;
- }
-
-private:
- SharedX11Resources()
- : m_supportsXRenderExtension(false)
- , m_markForDeletion(false)
- , m_window(0)
- , m_display(0)
- , m_pbufferfbConfig(0)
- , m_surfaceContextfbConfig(0)
- , m_VisualInfo(0)
- {
- }
-
- ~SharedX11Resources()
- {
- if (!m_display)
- return;
-
- if (m_window) {
- XUnmapWindow(m_display, m_window);
- XDestroyWindow(m_display, m_window);
- m_window = 0;
- }
-
- if (m_pbufferfbConfig)
- m_pbufferfbConfig = 0;
-
- if (m_surfaceContextfbConfig)
- m_surfaceContextfbConfig = 0;
-
- if (m_VisualInfo) {
- XFree(m_VisualInfo);
- m_VisualInfo = 0;
- }
-
- XCloseDisplay(m_display);
- m_display = 0;
- }
-
- static SharedX11Resources* m_staticSharedResource;
- bool m_supportsXRenderExtension;
- bool m_markForDeletion;
- Window m_window;
- Display* m_display;
- GLXFBConfig m_pbufferfbConfig;
- GLXFBConfig m_surfaceContextfbConfig;
- XVisualInfo* m_VisualInfo;
-};
-
-class GLXSurface : public GLPlatformSurface {
- WTF_MAKE_NONCOPYABLE(GLXSurface);
+class GLXTransportSurface : public GLTransportSurface {
public:
- GLXSurface();
- virtual ~GLXSurface();
-
-protected:
- XVisualInfo* visualInfo();
- Window xWindow();
- GLXFBConfig pBufferConfiguration();
- GLXFBConfig transportSurfaceConfiguration();
- bool isXRenderExtensionSupported();
+ GLXTransportSurface(const IntSize&, SurfaceAttributes);
+ virtual ~GLXTransportSurface();
+ virtual PlatformSurfaceConfig configuration() OVERRIDE;
+ virtual void swapBuffers() OVERRIDE;
+ virtual void setGeometry(const IntRect&) OVERRIDE;
+ virtual GLPlatformSurface::SurfaceAttributes attributes() const OVERRIDE;
+ virtual void destroy() OVERRIDE;
private:
- RefPtr<SharedX11Resources> m_sharedResources;
+ OwnPtr<GLXConfigSelector> m_configSelector;
};
-class GLXTransportSurface : public GLXSurface {
- WTF_MAKE_NONCOPYABLE(GLXTransportSurface);
+class GLXOffScreenSurface : public GLPlatformSurface {
public:
- GLXTransportSurface();
- virtual ~GLXTransportSurface();
- PlatformSurfaceConfig configuration();
- void swapBuffers();
- void setGeometry(const IntRect& newRect);
- void destroy();
+ GLXOffScreenSurface(SurfaceAttributes);
+ virtual ~GLXOffScreenSurface();
+ virtual PlatformSurfaceConfig configuration() OVERRIDE;
+ virtual void destroy() OVERRIDE;
private:
- void initialize();
+ void initialize(SurfaceAttributes);
void freeResources();
+ OwnPtr<GLXConfigSelector> m_configSelector;
+ Pixmap m_pixmap;
+ GLXPixmap m_glxPixmap;
};
-class GLXPBuffer : public GLXSurface {
- WTF_MAKE_NONCOPYABLE(GLXPBuffer);
+class GLXTransportSurfaceClient : public GLTransportSurfaceClient {
public:
- GLXPBuffer();
- virtual ~GLXPBuffer();
- PlatformSurfaceConfig configuration();
- void destroy();
+ GLXTransportSurfaceClient(const PlatformBufferHandle, bool);
+ virtual ~GLXTransportSurfaceClient();
+ virtual void prepareTexture() OVERRIDE;
+ virtual void destroy() OVERRIDE;
private:
- void initialize();
- void freeResources();
+ Pixmap m_xPixmap;
+ GLXPixmap m_glxPixmap;
};
}
diff --git a/Source/WebCore/platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp b/Source/WebCore/platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp
index a8a430aa7..23f8afb48 100644
--- a/Source/WebCore/platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp
+++ b/Source/WebCore/platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp
@@ -1,5 +1,6 @@
/*
Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2013 Intel Corporation.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -30,18 +31,15 @@
#include <QGuiApplication>
#include <QOpenGLContext>
#include <qpa/qplatformnativeinterface.h>
-#elif PLATFORM(EFL)
-#include <GL/gl.h>
-#endif
-
#include <GL/glext.h>
#include <GL/glx.h>
-#include <X11/extensions/Xcomposite.h>
-#include <X11/extensions/Xrender.h>
+#else
+#include <opengl/GLDefs.h>
+#endif
-namespace WebCore {
+#include "GLXConfigSelector.h"
-static long X11OverrideRedirect = 1L << 9;
+namespace WebCore {
static PFNGLXBINDTEXIMAGEEXTPROC pGlXBindTexImageEXT = 0;
static PFNGLXRELEASETEXIMAGEEXTPROC pGlXReleaseTexImageEXT = 0;
@@ -51,84 +49,7 @@ static PFNGLGENFRAMEBUFFERSPROC pGlGenFramebuffers = 0;
static PFNGLDELETEFRAMEBUFFERSPROC pGlDeleteFramebuffers = 0;
static PFNGLFRAMEBUFFERTEXTURE2DPROC pGlFramebufferTexture2D = 0;
-static int attributes[] = {
- GLX_LEVEL, 0,
- GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
- GLX_RENDER_TYPE, GLX_RGBA_BIT,
- GLX_RED_SIZE, 1,
- GLX_GREEN_SIZE, 1,
- GLX_BLUE_SIZE, 1,
- GLX_ALPHA_SIZE, 1,
- GLX_DEPTH_SIZE, 1,
- GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR,
- GLX_DOUBLEBUFFER, True,
- None
-};
-
-class OffScreenRootWindow {
-public:
- OffScreenRootWindow()
- {
- ++m_refCount;
- }
-
- Window getXWindow()
- {
- if (!m_window) {
- Display* dpy = display();
- m_window = XCreateSimpleWindow(dpy, XDefaultRootWindow(dpy), -1, -1, 1, 1, 0, BlackPixel(dpy, 0), WhitePixel(dpy, 0));
- XSetWindowAttributes attributes;
- attributes.override_redirect = true;
- XChangeWindowAttributes(dpy, m_window, X11OverrideRedirect, &attributes);
- // Map window to the screen
- XMapWindow(dpy, m_window);
- }
-
- return m_window;
- }
-
- Display* display()
- {
- if (!m_display)
- m_display = XOpenDisplay(0);
- return m_display;
- }
-
- ~OffScreenRootWindow()
- {
- if (--m_refCount || !m_display)
- return;
-
- if (m_window) {
- XUnmapWindow(m_display, m_window);
- XDestroyWindow(m_display, m_window);
- m_window = 0;
- }
-
- XCloseDisplay(m_display);
- m_display = 0;
- }
-
-private:
- static int m_refCount;
- static Window m_window;
- static Display* m_display;
-};
-
-int OffScreenRootWindow::m_refCount = 0;
-Window OffScreenRootWindow::m_window = 0;
-Display* OffScreenRootWindow::m_display = 0;
-
-static const int glxSpec[] = {
- // The specification is a set key value pairs stored in a simple array.
- GLX_LEVEL, 0,
- GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT | GLX_WINDOW_BIT,
- GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_2D_BIT_EXT,
- GLX_BIND_TO_TEXTURE_RGBA_EXT, TRUE,
- 0
-};
-
-static const int glxAttributes[] = {
+static int glxAttributes[] = {
GLX_TEXTURE_FORMAT_EXT,
GLX_TEXTURE_FORMAT_RGBA_EXT,
GLX_TEXTURE_TARGET_EXT,
@@ -136,151 +57,129 @@ static const int glxAttributes[] = {
0
};
+static bool isMesaGLX()
+{
+ static bool isMesa = !!strstr(glXGetClientString(X11Helper::nativeDisplay(), GLX_VENDOR), "Mesa");
+ return isMesa;
+}
+
struct GraphicsSurfacePrivate {
GraphicsSurfacePrivate(const PlatformGraphicsContext3D shareContext = 0)
- : m_display(m_offScreenWindow.display())
- , m_xPixmap(0)
+ : m_xPixmap(0)
, m_glxPixmap(0)
, m_surface(0)
, m_glxSurface(0)
, m_glContext(0)
, m_detachedContext(0)
, m_detachedSurface(0)
- , m_fbConfig(0)
- , m_textureIsYInverted(false)
- , m_hasAlpha(false)
, m_isReceiver(false)
+ , m_texture(0)
{
GLXContext shareContextObject = 0;
#if PLATFORM(QT)
if (shareContext) {
-#if 0
- // This code path requires QXcbNativeInterface::nativeResourceForContext() which is not availble in Qt5 on the build bots yet.
QPlatformNativeInterface* nativeInterface = QGuiApplication::platformNativeInterface();
shareContextObject = static_cast<GLXContext>(nativeInterface->nativeResourceForContext(QByteArrayLiteral("glxcontext"), shareContext));
if (!shareContextObject)
return;
-#else
- // This code path should be removed as soon as QXcbNativeInterface::nativeResourceForContext() can provide the GLXContext.
- QOpenGLContext* previousContext = QOpenGLContext::currentContext();
- QSurface* previousSurface = previousContext->surface();
- QSurface* currentSurface = shareContext->surface();
- shareContext->makeCurrent(currentSurface);
-
- shareContextObject = glXGetCurrentContext();
-
- previousContext->makeCurrent(previousSurface);
-#endif
}
#else
UNUSED_PARAM(shareContext);
#endif
- int numReturned;
- GLXFBConfig* fbConfigs = glXChooseFBConfig(m_display, DefaultScreen(m_display), attributes, &numReturned);
-
- // Make sure that we choose a configuration that supports an alpha mask.
- for (int i = 0; i < numReturned; ++i) {
- XVisualInfo* visualInfo = glXGetVisualFromFBConfig(m_display, fbConfigs[i]);
- if (!visualInfo)
- continue;
+ GLPlatformSurface::SurfaceAttributes sharedSurfaceAttributes = GLPlatformSurface::DoubleBuffered |
+ GLPlatformSurface::SupportAlpha;
+ m_configSelector = adoptPtr(new GLXConfigSelector(sharedSurfaceAttributes));
- XRenderPictFormat* format = XRenderFindVisualFormat(m_display, visualInfo->visual);
- if (format && format->direct.alphaMask > 0) {
- m_fbConfig = fbConfigs[i];
- break;
- }
+ if (!m_configSelector->surfaceContextConfig()) {
+ clear();
+ return;
}
- XFree(fbConfigs);
-
// Create a GLX context for OpenGL rendering
- m_glContext = glXCreateNewContext(m_display, m_fbConfig, GLX_RGBA_TYPE, shareContextObject, true);
+ m_glContext = glXCreateNewContext(display(), m_configSelector->surfaceContextConfig(), GLX_RGBA_TYPE, shareContextObject, true);
}
GraphicsSurfacePrivate(uint32_t winId)
- : m_display(m_offScreenWindow.display())
- , m_xPixmap(0)
+ : m_xPixmap(0)
, m_glxPixmap(0)
, m_surface(winId)
, m_glxSurface(0)
, m_glContext(0)
, m_detachedContext(0)
, m_detachedSurface(0)
- , m_fbConfig(0)
- , m_textureIsYInverted(false)
- , m_hasAlpha(false)
, m_isReceiver(true)
- { }
+ , m_texture(0)
+ {
+ }
~GraphicsSurfacePrivate()
{
- if (m_glxPixmap)
- glXDestroyPixmap(m_display, m_glxPixmap);
- m_glxPixmap = 0;
-
- if (m_xPixmap)
- XFreePixmap(m_display, m_xPixmap);
- m_xPixmap = 0;
-
- if (m_glContext)
- glXDestroyContext(m_display, m_glContext);
+ clear();
}
uint32_t createSurface(const IntSize& size)
{
- XVisualInfo* visualInfo = glXGetVisualFromFBConfig(m_display, m_fbConfig);
- if (!visualInfo)
+ if (!display() || !m_configSelector)
+ return 0;
+
+ GLXFBConfig config = m_configSelector->surfaceContextConfig();
+ OwnPtrX11<XVisualInfo> visInfo(m_configSelector->visualInfo(config));
+
+ if (!visInfo.get()) {
+ clear();
return 0;
+ }
- Colormap cmap = XCreateColormap(m_display, m_offScreenWindow.getXWindow(), visualInfo->visual, AllocNone);
-
- XSetWindowAttributes a;
- a.background_pixel = WhitePixel(m_display, 0);
- a.border_pixel = BlackPixel(m_display, 0);
- a.colormap = cmap;
- m_surface = XCreateWindow(m_display, m_offScreenWindow.getXWindow(), 0, 0, size.width(), size.height(),
- 0, visualInfo->depth, InputOutput, visualInfo->visual,
- CWBackPixel | CWBorderPixel | CWColormap, &a);
- XSetWindowBackgroundPixmap(m_display, m_surface, 0);
- XCompositeRedirectWindow(m_display, m_surface, CompositeRedirectManual);
- m_glxSurface = glXCreateWindow(m_display, m_fbConfig, m_surface, 0);
- XFree(visualInfo);
-
- // Make sure the XRender Extension is available.
- int eventBasep, errorBasep;
- if (!XRenderQueryExtension(m_display, &eventBasep, &errorBasep))
+ X11Helper::createOffScreenWindow(&m_surface, *visInfo.get(), size);
+
+ if (!m_surface) {
+ clear();
return 0;
+ }
- XMapWindow(m_display, m_surface);
+ m_glxSurface = glXCreateWindow(display(), config, m_surface, 0);
return m_surface;
}
void createPixmap(uint32_t winId)
{
XWindowAttributes attr;
- XGetWindowAttributes(m_display, winId, &attr);
+ if (!XGetWindowAttributes(display(), winId, &attr))
+ return;
- XRenderPictFormat* format = XRenderFindVisualFormat(m_display, attr.visual);
- m_hasAlpha = (format->type == PictTypeDirect && format->direct.alphaMask);
+ // Ensure that the window is mapped.
+ if (attr.map_state == IsUnmapped || attr.map_state == IsUnviewable)
+ return;
- int numberOfConfigs;
- GLXFBConfig* configs = glXChooseFBConfig(m_display, XDefaultScreen(m_display), glxSpec, &numberOfConfigs);
+ ScopedXPixmapCreationErrorHandler handler;
+ m_size = IntSize(attr.width, attr.height);
- m_xPixmap = XCompositeNameWindowPixmap(m_display, winId);
- m_glxPixmap = glXCreatePixmap(m_display, *configs, m_xPixmap, glxAttributes);
+ XRenderPictFormat* format = XRenderFindVisualFormat(display(), attr.visual);
+ bool hasAlpha = (format->type == PictTypeDirect && format->direct.alphaMask);
+ m_xPixmap = XCompositeNameWindowPixmap(display(), winId);
+ glxAttributes[1] = (format->depth == 32 && hasAlpha) ? GLX_TEXTURE_FORMAT_RGBA_EXT : GLX_TEXTURE_FORMAT_RGB_EXT;
- uint inverted = 0;
- glXQueryDrawable(m_display, m_glxPixmap, GLX_Y_INVERTED_EXT, &inverted);
- m_textureIsYInverted = !!inverted;
+ GLPlatformSurface::SurfaceAttributes sharedSurfaceAttributes = GLPlatformSurface::Default;
+ if (hasAlpha)
+ sharedSurfaceAttributes = GLPlatformSurface::SupportAlpha;
- XFree(configs);
- }
+ if (!m_configSelector)
+ m_configSelector = adoptPtr(new GLXConfigSelector(sharedSurfaceAttributes));
- bool textureIsYInverted()
- {
- return m_textureIsYInverted;
+ m_glxPixmap = glXCreatePixmap(display(), m_configSelector->surfaceClientConfig(format->depth, XVisualIDFromVisual(attr.visual)), m_xPixmap, glxAttributes);
+
+ if (!handler.isValidOperation())
+ clear();
+ else {
+ uint inverted = 0;
+ glXQueryDrawable(display(), m_glxPixmap, GLX_Y_INVERTED_EXT, &inverted);
+ m_flags = !!inverted ? TextureMapperGL::ShouldFlipTexture : 0;
+
+ if (hasAlpha)
+ m_flags |= TextureMapperGL::ShouldBlend;
+ }
}
void makeCurrent()
@@ -288,22 +187,29 @@ struct GraphicsSurfacePrivate {
m_detachedContext = glXGetCurrentContext();
m_detachedSurface = glXGetCurrentDrawable();
if (m_surface && m_glContext)
- glXMakeCurrent(m_display, m_surface, m_glContext);
+ glXMakeCurrent(display(), m_surface, m_glContext);
}
void doneCurrent()
{
if (m_detachedContext)
- glXMakeCurrent(m_display, m_detachedSurface, m_detachedContext);
+ glXMakeCurrent(display(), m_detachedSurface, m_detachedContext);
m_detachedContext = 0;
}
void swapBuffers()
{
- // The buffers are being switched on the writing side, the reading side just reads
- // whatever texture the XWindow contains.
- if (m_isReceiver)
+ if (isReceiver()) {
+ if (isMesaGLX() && textureID()) {
+ glBindTexture(GL_TEXTURE_2D, textureID());
+ // Mesa doesn't re-bind texture to the front buffer on glXSwapBufer
+ // Manually release previous lock and rebind texture to surface to ensure frame updates.
+ pGlXReleaseTexImageEXT(display(), glxPixmap(), GLX_FRONT_EXT);
+ pGlXBindTexImageEXT(display(), glxPixmap(), GLX_FRONT_EXT, 0);
+ }
+
return;
+ }
GLXContext glContext = glXGetCurrentContext();
@@ -311,7 +217,7 @@ struct GraphicsSurfacePrivate {
GLint oldFBO;
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &oldFBO);
pGlBindFramebuffer(GL_FRAMEBUFFER, 0);
- glXSwapBuffers(m_display, m_surface);
+ glXSwapBuffers(display(), m_surface);
pGlBindFramebuffer(GL_FRAMEBUFFER, oldFBO);
}
}
@@ -348,7 +254,7 @@ struct GraphicsSurfacePrivate {
doneCurrent();
}
- Display* display() const { return m_display; }
+ Display* display() const { return X11Helper::nativeDisplay(); }
GLXPixmap glxPixmap() const
{
@@ -361,27 +267,84 @@ struct GraphicsSurfacePrivate {
{
if (m_size.isEmpty()) {
XWindowAttributes attr;
- XGetWindowAttributes(m_display, m_surface, &attr);
- const_cast<GraphicsSurfacePrivate*>(this)->m_size = IntSize(attr.width, attr.height);
+ if (XGetWindowAttributes(display(), m_surface, &attr))
+ const_cast<GraphicsSurfacePrivate*>(this)->m_size = IntSize(attr.width, attr.height);
}
return m_size;
}
+ bool isReceiver() const { return m_isReceiver; }
+
+ TextureMapperGL::Flags flags() const { return m_flags; }
+
+ Window surface() const { return m_surface; }
+
+ GLuint textureID() const
+ {
+ if (m_texture)
+ return m_texture;
+
+ GLXPixmap pixmap = glxPixmap();
+ if (!pixmap)
+ return 0;
+
+ GLuint texture;
+ glGenTextures(1, &texture);
+ glBindTexture(GL_TEXTURE_2D, texture);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ pGlXBindTexImageEXT(display(), pixmap, GLX_FRONT_EXT, 0);
+ const_cast<GraphicsSurfacePrivate*>(this)->m_texture = texture;
+
+ return texture;
+ }
private:
- OffScreenRootWindow m_offScreenWindow;
+ void clear()
+ {
+ if (m_texture) {
+ pGlXReleaseTexImageEXT(display(), glxPixmap(), GLX_FRONT_EXT);
+ glDeleteTextures(1, &m_texture);
+ }
+
+ if (m_glxPixmap) {
+ glXDestroyPixmap(display(), m_glxPixmap);
+ m_glxPixmap = 0;
+ }
+
+ if (m_xPixmap) {
+ XFreePixmap(display(), m_xPixmap);
+ m_xPixmap = 0;
+ }
+
+ // Client doesn't own the window. Delete surface only on writing side.
+ if (!m_isReceiver && m_surface) {
+ XDestroyWindow(display(), m_surface);
+ m_surface = 0;
+ }
+
+ if (m_glContext) {
+ glXDestroyContext(display(), m_glContext);
+ m_glContext = 0;
+ }
+
+ if (m_configSelector)
+ m_configSelector = nullptr;
+ }
+
IntSize m_size;
- Display* m_display;
Pixmap m_xPixmap;
GLXPixmap m_glxPixmap;
- Window m_surface;
+ uint32_t m_surface;
Window m_glxSurface;
GLXContext m_glContext;
GLXContext m_detachedContext;
GLXDrawable m_detachedSurface;
- GLXFBConfig m_fbConfig;
- bool m_textureIsYInverted;
- bool m_hasAlpha;
+ OwnPtr<GLXConfigSelector> m_configSelector;
bool m_isReceiver;
+ TextureMapperGL::Flags m_flags;
+ GLuint m_texture;
};
static bool resolveGLMethods()
@@ -404,22 +367,12 @@ static bool resolveGLMethods()
GraphicsSurfaceToken GraphicsSurface::platformExport()
{
- return GraphicsSurfaceToken(m_platformSurface);
+ return GraphicsSurfaceToken(m_private->surface());
}
uint32_t GraphicsSurface::platformGetTextureID()
{
- if (!m_texture) {
- glGenTextures(1, &m_texture);
- glBindTexture(GL_TEXTURE_2D, m_texture);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- pGlXBindTexImageEXT(m_private->display(), m_private->glxPixmap(), GLX_FRONT_EXT, 0);
- }
-
- return m_texture;
+ return m_private->textureID();
}
void GraphicsSurface::platformCopyToGLTexture(uint32_t /*target*/, uint32_t /*id*/, const IntRect& /*targetRect*/, const IntPoint& /*offset*/)
@@ -432,15 +385,19 @@ void GraphicsSurface::platformCopyFromTexture(uint32_t texture, const IntRect& s
m_private->copyFromTexture(texture, sourceRect);
}
-
-void GraphicsSurface::platformPaintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
+void GraphicsSurface::platformPaintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity)
{
- TextureMapperGL* texMapGL = static_cast<TextureMapperGL*>(textureMapper);
+ IntSize size = m_private->size();
+ if (size.isEmpty())
+ return;
+ uint32_t texture = platformGetTextureID();
+ if (!texture)
+ return;
+
+ FloatRect rectOnContents(FloatPoint::zero(), size);
TransformationMatrix adjustedTransform = transform;
- adjustedTransform.multiply(TransformationMatrix::rectToRect(FloatRect(FloatPoint::zero(), m_private->size()), targetRect));
- TextureMapperGL::Flags flags = m_private->textureIsYInverted() ? TextureMapperGL::ShouldFlipTexture : 0;
- flags |= TextureMapperGL::SupportsBlending;
- texMapGL->drawTexture(platformGetTextureID(), flags, m_private->size(), targetRect, adjustedTransform, opacity, mask);
+ adjustedTransform.multiply(TransformationMatrix::rectToRect(rectOnContents, targetRect));
+ static_cast<TextureMapperGL*>(textureMapper)->drawTexture(texture, m_private->flags(), size, rectOnContents, adjustedTransform, opacity);
}
uint32_t GraphicsSurface::platformFrontBuffer() const
@@ -473,7 +430,7 @@ PassRefPtr<GraphicsSurface> GraphicsSurface::platformCreate(const IntSize& size,
if (!resolveGLMethods())
return PassRefPtr<GraphicsSurface>();
- surface->m_platformSurface = surface->m_private->createSurface(size);
+ surface->m_private->createSurface(size);
return surface;
}
@@ -487,9 +444,8 @@ PassRefPtr<GraphicsSurface> GraphicsSurface::platformImport(const IntSize& size,
return PassRefPtr<GraphicsSurface>();
RefPtr<GraphicsSurface> surface = adoptRef(new GraphicsSurface(size, flags));
- surface->m_platformSurface = token.frontBufferHandle;
- surface->m_private = new GraphicsSurfacePrivate(surface->m_platformSurface);
+ surface->m_private = new GraphicsSurfacePrivate(token.frontBufferHandle);
if (!resolveGLMethods())
return PassRefPtr<GraphicsSurface>();
@@ -509,11 +465,6 @@ void GraphicsSurface::platformUnlock()
void GraphicsSurface::platformDestroy()
{
- if (m_texture) {
- pGlXReleaseTexImageEXT(m_private->display(), m_private->glxPixmap(), GLX_FRONT_EXT);
- glDeleteTextures(1, &m_texture);
- }
-
delete m_private;
m_private = 0;
}
diff --git a/Source/WebCore/platform/graphics/surfaces/glx/OwnPtrX11.h b/Source/WebCore/platform/graphics/surfaces/glx/OwnPtrX11.h
new file mode 100644
index 000000000..b877610ab
--- /dev/null
+++ b/Source/WebCore/platform/graphics/surfaces/glx/OwnPtrX11.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef OwnPtrX11_h
+#define OwnPtrX11_h
+
+namespace WebCore {
+
+template<typename T>
+struct OwnPtrX11 {
+
+ OwnPtrX11() : m_xResource(0) { }
+ OwnPtrX11(T* xResource) : m_xResource(xResource) { }
+
+ ~OwnPtrX11()
+ {
+ if (m_xResource)
+ XFree(m_xResource);
+ }
+
+ OwnPtrX11& operator=(T* xResource)
+ {
+ if (m_xResource)
+ XFree(m_xResource);
+
+ m_xResource = xResource;
+ return *this;
+ }
+
+ operator T*() const { return m_xResource; }
+ T* operator->() const { return m_xResource; }
+ T* get() const { return m_xResource; }
+
+private:
+ OwnPtrX11(const OwnPtrX11&);
+ OwnPtrX11& operator=(const OwnPtrX11&);
+ static void* operator new (size_t);
+ static void operator delete (void*);
+ T* m_xResource;
+};
+
+}
+
+#endif
diff --git a/Source/WebCore/platform/graphics/surfaces/glx/X11Helper.cpp b/Source/WebCore/platform/graphics/surfaces/glx/X11Helper.cpp
new file mode 100644
index 000000000..698e80214
--- /dev/null
+++ b/Source/WebCore/platform/graphics/surfaces/glx/X11Helper.cpp
@@ -0,0 +1,343 @@
+/*
+ * Copyright (C) 2013 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "X11Helper.h"
+
+namespace WebCore {
+
+// Used for handling XError.
+static bool validOperation = true;
+static int handleXPixmapCreationError(Display*, XErrorEvent* event)
+{
+ if (event->error_code == BadMatch || event->error_code == BadWindow || event->error_code == BadAlloc) {
+ validOperation = false;
+
+ switch (event->error_code) {
+ case BadMatch:
+ LOG_ERROR("BadMatch.");
+ break;
+ case BadWindow:
+ LOG_ERROR("BadWindow.");
+ break;
+ case BadAlloc:
+ LOG_ERROR("BadAlloc.");
+ break;
+ default:
+ break;
+ }
+ }
+
+ return 0;
+}
+
+struct DisplayConnection {
+ DisplayConnection()
+ {
+ m_display = XOpenDisplay(0);
+
+ if (!m_display)
+ LOG_ERROR("Failed to make connection with X");
+ }
+
+ ~DisplayConnection()
+ {
+ XCloseDisplay(m_display);
+ }
+
+ Display* display() { return m_display; }
+private:
+ Display* m_display;
+};
+
+struct OffScreenRootWindow {
+
+ OffScreenRootWindow()
+ {
+ m_window = 0;
+ Display* dpy = X11Helper::nativeDisplay();
+ if (!dpy)
+ return;
+
+ XSetWindowAttributes attributes;
+ attributes.override_redirect = true;
+ m_window = XCreateSimpleWindow(dpy, XDefaultRootWindow(dpy), -1, -1, 1, 1, 0, BlackPixel(dpy, 0), WhitePixel(dpy, 0));
+ // From http://tronche.com/gui/x/xlib/window/attributes/
+ XChangeWindowAttributes(dpy, m_window, CWOverrideRedirect, &attributes);
+ XMapWindow(dpy, m_window);
+
+ if (!m_window)
+ LOG_ERROR("Failed to create offscreen root window.");
+ }
+
+ ~OffScreenRootWindow()
+ {
+ if (!X11Helper::nativeDisplay())
+ return;
+
+ if (m_window) {
+ XUnmapWindow(X11Helper::nativeDisplay(), m_window);
+ XDestroyWindow(X11Helper::nativeDisplay(), m_window);
+ m_window = 0;
+ }
+ }
+
+ Window rootWindow()
+ {
+ return m_window;
+ }
+
+private:
+ Window m_window;
+};
+
+ScopedXPixmapCreationErrorHandler::ScopedXPixmapCreationErrorHandler()
+{
+ // XSync must be called to ensure that current errors are handled by the original handler.
+ XSync(X11Helper::nativeDisplay(), false);
+ m_previousErrorHandler = XSetErrorHandler(handleXPixmapCreationError);
+}
+
+ScopedXPixmapCreationErrorHandler::~ScopedXPixmapCreationErrorHandler()
+{
+ // Restore the original handler.
+ XSetErrorHandler(m_previousErrorHandler);
+}
+
+bool ScopedXPixmapCreationErrorHandler::isValidOperation() const
+{
+ validOperation = true;
+ // XSync is needed to catch possible errors as they are generated asynchronously.
+ XSync(X11Helper::nativeDisplay(), false);
+ return validOperation;
+}
+
+void X11Helper::resizeWindow(const IntRect& newRect, const uint32_t windowId)
+{
+ XResizeWindow(nativeDisplay(), windowId, newRect.width(), newRect.height());
+ XFlush(nativeDisplay());
+}
+
+void X11Helper::createPixmap(Pixmap* handleId, const XVisualInfo& visualInfo, const IntSize& size)
+{
+ Display* display = nativeDisplay();
+ if (!display)
+ return;
+
+ if (!visualInfo.visual) {
+ LOG_ERROR("Failed to find valid XVisual.");
+ return;
+ }
+
+ Window xWindow = offscreenRootWindow();
+ if (!xWindow) {
+ LOG_ERROR("Failed to create offscreen root window.");
+ return;
+ }
+
+ Pixmap tempHandleId = XCreatePixmap(display, xWindow, size.width(), size.height(), visualInfo.depth);
+
+ if (!tempHandleId) {
+ LOG_ERROR("Failed to create offscreen pixmap.");
+ return;
+ }
+
+ *handleId = tempHandleId;
+ XSync(X11Helper::nativeDisplay(), false);
+}
+
+void X11Helper::destroyPixmap(const uint32_t pixmapId)
+{
+ if (!pixmapId)
+ return;
+
+ Display* display = nativeDisplay();
+ if (!display)
+ return;
+
+ XFreePixmap(display, pixmapId);
+ XSync(X11Helper::nativeDisplay(), false);
+}
+
+void X11Helper::createOffScreenWindow(uint32_t* handleId, const XVisualInfo& visInfo, const IntSize& size)
+{
+#if USE(GRAPHICS_SURFACE)
+ Display* display = nativeDisplay();
+ if (!display)
+ return;
+
+ if (!visInfo.visual) {
+ LOG_ERROR("Failed to find valid XVisual.");
+ return;
+ }
+
+ Window xWindow = offscreenRootWindow();
+ if (!xWindow)
+ return;
+
+ Colormap cmap = XCreateColormap(display, xWindow, visInfo.visual, AllocNone);
+ XSetWindowAttributes attribute;
+ attribute.background_pixel = WhitePixel(display, 0);
+ attribute.border_pixel = BlackPixel(display, 0);
+ attribute.colormap = cmap;
+#if USE(GLX)
+ attribute.event_mask = ResizeRedirectMask;
+#endif
+ uint32_t tempHandleId = XCreateWindow(display, xWindow, 0, 0, size.width(), size.height(), 0, visInfo.depth, InputOutput, visInfo.visual, CWBackPixel | CWBorderPixel | CWColormap, &attribute);
+
+ if (!tempHandleId) {
+ LOG_ERROR("Failed to create offscreen window.");
+ return;
+ }
+
+ XSetWindowBackgroundPixmap(display, tempHandleId, 0);
+#if USE(GLX)
+ XCompositeRedirectWindow(display, tempHandleId, CompositeRedirectManual);
+#endif
+ XMapWindow(display, tempHandleId);
+ *handleId = tempHandleId;
+#else
+ UNUSED_PARAM(handleId);
+ UNUSED_PARAM(visInfo);
+ UNUSED_PARAM(size);
+#endif
+}
+
+#if USE(EGL)
+void X11Helper::createOffScreenWindow(uint32_t* handleId, const EGLint id, bool supportsAlpha, const IntSize& size)
+{
+#if USE(GRAPHICS_SURFACE)
+ VisualID visualId = static_cast<VisualID>(id);
+
+ if (!visualId)
+ return;
+
+ // EGL has suggested a visual id, so get the rest of the visual info for that id.
+ XVisualInfo visualInfoTemplate;
+ memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
+ visualInfoTemplate.visualid = visualId;
+ int matchingCount = 0;
+ OwnPtrX11<XVisualInfo> matchingVisuals(XGetVisualInfo(nativeDisplay(), VisualIDMask, &visualInfoTemplate, &matchingCount));
+ XVisualInfo* foundVisual = 0;
+
+ if (matchingVisuals) {
+ for (int i = 0; i< matchingCount; i++) {
+ XVisualInfo* temp = &matchingVisuals[i];
+ int matchingdepth = supportsAlpha ? 32 : 24;
+
+ if (temp->visualid == visualId && temp->depth == matchingdepth) {
+ foundVisual = temp;
+ break;
+ }
+ }
+
+ if (foundVisual)
+ createOffScreenWindow(handleId, *foundVisual, size);
+ }
+#else
+ UNUSED_PARAM(handleId);
+ UNUSED_PARAM(id);
+ UNUSED_PARAM(size);
+#endif
+}
+
+void X11Helper::createPixmap(Pixmap* handleId, const EGLint id, bool hasAlpha, const IntSize& size)
+{
+ VisualID visualId = static_cast<VisualID>(id);
+
+ if (!visualId)
+ return;
+
+ // EGL has suggested a visual id, so get the rest of the visual info for that id.
+ XVisualInfo visualInfoTemplate;
+ memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
+ visualInfoTemplate.visualid = visualId;
+ int matchingCount = 0;
+ OwnPtrX11<XVisualInfo> matchingVisuals(XGetVisualInfo(nativeDisplay(), VisualIDMask, &visualInfoTemplate, &matchingCount));
+ XVisualInfo* foundVisual = 0;
+ int requiredDepth = hasAlpha ? 32 : 24;
+
+ if (matchingVisuals) {
+ for (int i = 0; i< matchingCount; i++) {
+ XVisualInfo* temp = &matchingVisuals[i];
+
+ if (temp->visualid == visualId && temp->depth == requiredDepth) {
+ foundVisual = temp;
+ break;
+ }
+ }
+
+ if (foundVisual)
+ createPixmap(handleId, *foundVisual, size);
+ }
+}
+#endif
+
+void X11Helper::destroyWindow(const uint32_t windowId)
+{
+ if (!windowId)
+ return;
+
+ Display* display = nativeDisplay();
+ if (!display)
+ return;
+
+ XDestroyWindow(display, windowId);
+}
+
+bool X11Helper::isXRenderExtensionSupported()
+{
+ static bool queryDone = false;
+ static bool supportsXRenderExtension = false;
+
+ if (!queryDone) {
+ queryDone = true;
+#if USE(GRAPHICS_SURFACE) && USE(GLX)
+ Display* display = nativeDisplay();
+
+ if (display) {
+ int eventBasep, errorBasep;
+ supportsXRenderExtension = XRenderQueryExtension(display, &eventBasep, &errorBasep);
+ }
+#endif
+ }
+
+ return supportsXRenderExtension;
+}
+
+Display* X11Helper::nativeDisplay()
+{
+ // Display connection will only be broken at program shutdown.
+ static DisplayConnection displayConnection;
+ return displayConnection.display();
+}
+
+Window X11Helper::offscreenRootWindow()
+{
+ static OffScreenRootWindow offscreenWindow;
+ return offscreenWindow.rootWindow();
+}
+
+}
diff --git a/Source/WebCore/platform/graphics/surfaces/glx/X11Helper.h b/Source/WebCore/platform/graphics/surfaces/glx/X11Helper.h
new file mode 100644
index 000000000..a7aeb70da
--- /dev/null
+++ b/Source/WebCore/platform/graphics/surfaces/glx/X11Helper.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2013 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef X11Helper_h
+#define X11Helper_h
+
+#include "IntRect.h"
+#include "OwnPtrX11.h"
+
+#if USE(EGL)
+#include <opengl/GLDefs.h>
+#endif
+
+#if USE(GRAPHICS_SURFACE) && USE(GLX)
+#include <X11/extensions/Xcomposite.h>
+#include <X11/extensions/Xrender.h>
+#else
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#endif
+
+namespace WebCore {
+
+class X11Helper {
+
+public:
+ static void createPixmap(Pixmap*, const XVisualInfo&, const IntSize& = IntSize(1, 1));
+ static void createOffScreenWindow(uint32_t*, const XVisualInfo&, const IntSize& = IntSize(1, 1));
+#if USE(EGL)
+ static void createPixmap(Pixmap*, const EGLint, bool, const IntSize& = IntSize(1, 1));
+ static void createOffScreenWindow(uint32_t*, const EGLint, bool, const IntSize& = IntSize(1, 1));
+#endif
+ static void destroyWindow(const uint32_t);
+ static void destroyPixmap(const uint32_t);
+ static void resizeWindow(const IntRect&, const uint32_t);
+ static bool isXRenderExtensionSupported();
+ static Display* nativeDisplay();
+ static Window offscreenRootWindow();
+};
+
+class ScopedXPixmapCreationErrorHandler {
+
+public:
+ ScopedXPixmapCreationErrorHandler();
+ ~ScopedXPixmapCreationErrorHandler();
+ bool isValidOperation() const;
+
+private:
+ XErrorHandler m_previousErrorHandler;
+};
+
+}
+
+#endif
diff --git a/Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp b/Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp
index 439bf9a2d..c4d2d5418 100644
--- a/Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp
+++ b/Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp
@@ -50,10 +50,7 @@ static uint32_t createTexture(IOSurfaceRef handle)
return 0;
GLint prevTexture;
- GLboolean wasEnabled = glIsEnabled(GL_TEXTURE_RECTANGLE_ARB);
glGetIntegerv(GL_TEXTURE_RECTANGLE_ARB, &prevTexture);
- if (!wasEnabled)
- glEnable(GL_TEXTURE_RECTANGLE_ARB);
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture);
@@ -64,8 +61,6 @@ static uint32_t createTexture(IOSurfaceRef handle)
}
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, prevTexture);
- if (!wasEnabled)
- glDisable(GL_TEXTURE_RECTANGLE_ARB);
return texture;
}
@@ -216,7 +211,6 @@ public:
glFlush(); // Make sure the texture has actually been completely written in the original context.
makeCurrent();
- glEnable(GL_TEXTURE_RECTANGLE_ARB);
int x = sourceRect.x();
int y = sourceRect.y();
@@ -319,8 +313,6 @@ void GraphicsSurface::platformCopyToGLTexture(uint32_t target, uint32_t id, cons
if (!m_fbo)
glGenFramebuffers(1, &m_fbo);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
- glEnable(GL_TEXTURE_RECTANGLE_ARB);
- glEnable(target);
glBindTexture(target, id);
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo);
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE_ARB, m_private->frontBufferTextureID(), 0);
@@ -341,11 +333,13 @@ void GraphicsSurface::platformCopyFromTexture(uint32_t texture, const IntRect& s
m_private->copyFromTexture(texture, sourceRect);
}
-void GraphicsSurface::platformPaintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
+void GraphicsSurface::platformPaintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity)
{
+ IntSize size = m_private->size();
+ FloatRect rectOnContents(FloatPoint::zero(), size);
TransformationMatrix adjustedTransform = transform;
- adjustedTransform.multiply(TransformationMatrix::rectToRect(FloatRect(FloatPoint::zero(), m_private->size()), targetRect));
- static_cast<TextureMapperGL*>(textureMapper)->drawTextureRectangleARB(m_private->frontBufferTextureID(), TextureMapperGL::SupportsBlending, m_private->size(), targetRect, adjustedTransform, opacity, mask);
+ adjustedTransform.multiply(TransformationMatrix::rectToRect(rectOnContents, targetRect));
+ static_cast<TextureMapperGL*>(textureMapper)->drawTexture(m_private->frontBufferTextureID(), TextureMapperGL::ShouldBlend | TextureMapperGL::ShouldUseARBTextureRect, size, rectOnContents, adjustedTransform, opacity);
}
uint32_t GraphicsSurface::platformFrontBuffer() const
diff --git a/Source/WebCore/platform/graphics/surfaces/win/GraphicsSurfaceWin.cpp b/Source/WebCore/platform/graphics/surfaces/win/GraphicsSurfaceWin.cpp
index b8586ac18..218c5e7e3 100644
--- a/Source/WebCore/platform/graphics/surfaces/win/GraphicsSurfaceWin.cpp
+++ b/Source/WebCore/platform/graphics/surfaces/win/GraphicsSurfaceWin.cpp
@@ -421,13 +421,13 @@ void GraphicsSurface::platformCopyFromTexture(uint32_t texture, const IntRect& s
m_private->copyFromTexture(texture, sourceRect);
}
-void GraphicsSurface::platformPaintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
+void GraphicsSurface::platformPaintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity)
{
- GLuint frontBufferTexture = platformGetTextureID();
-
+ IntSize size = m_private->size();
+ FloatRect rectOnContents(FloatPoint::zero(), size);
TransformationMatrix adjustedTransform = transform;
- adjustedTransform.multiply(TransformationMatrix::rectToRect(FloatRect(FloatPoint::zero(), m_private->size()), targetRect));
- static_cast<TextureMapperGL*>(textureMapper)->drawTexture(frontBufferTexture, 0, m_private->size(), targetRect, adjustedTransform, opacity, mask);
+ adjustedTransform.multiply(TransformationMatrix::rectToRect(rectOnContents, targetRect));
+ static_cast<TextureMapperGL*>(textureMapper)->drawTexture(platformGetTextureID(), 0, size, rectOnContents, adjustedTransform, opacity);
}
uint32_t GraphicsSurface::platformFrontBuffer() const
diff --git a/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp b/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp
index 5ba109066..bfca0bf17 100644
--- a/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp
+++ b/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp
@@ -24,16 +24,17 @@
#include "GraphicsLayerAnimation.h"
#include "GraphicsLayerFactory.h"
#include "ImageBuffer.h"
-#include "NotImplemented.h"
#include <wtf/CurrentTime.h>
-#if USE(CAIRO)
-#include "CairoUtilities.h"
-#include <wtf/text/CString.h>
-#endif
+#if USE(TEXTURE_MAPPER)
namespace WebCore {
+TextureMapperLayer* toTextureMapperLayer(GraphicsLayer* layer)
+{
+ return layer ? toGraphicsLayerTextureMapper(layer)->layer() : 0;
+}
+
PassOwnPtr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient* client)
{
if (!factory)
@@ -44,8 +45,6 @@ PassOwnPtr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, G
PassOwnPtr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerClient* client)
{
- if (s_graphicsLayerFactory)
- return (*s_graphicsLayerFactory)(client);
return adoptPtr(new GraphicsLayerTextureMapper(client));
}
@@ -53,18 +52,17 @@ GraphicsLayerTextureMapper::GraphicsLayerTextureMapper(GraphicsLayerClient* clie
: GraphicsLayer(client)
, m_layer(adoptPtr(new TextureMapperLayer()))
, m_compositedNativeImagePtr(0)
- , m_changeMask(0)
+ , m_changeMask(NoChanges)
, m_needsDisplay(false)
- , m_hasOwnBackingStore(true)
, m_fixedToViewport(false)
, m_debugBorderWidth(0)
, m_contentsLayer(0)
- , m_animationStartedTimer(this, &GraphicsLayerTextureMapper::animationStartedTimerFired)
, m_animationStartTime(0)
+ , m_isScrollable(false)
{
}
-void GraphicsLayerTextureMapper::notifyChange(TextureMapperLayer::ChangeMask changeMask)
+void GraphicsLayerTextureMapper::notifyChange(ChangeMask changeMask)
{
m_changeMask |= changeMask;
if (!client())
@@ -79,6 +77,9 @@ void GraphicsLayerTextureMapper::setName(const String& name)
GraphicsLayerTextureMapper::~GraphicsLayerTextureMapper()
{
+ if (m_contentsLayer)
+ m_contentsLayer->setClient(0);
+
willBeDestroyed();
}
@@ -91,11 +92,11 @@ void GraphicsLayerTextureMapper::willBeDestroyed()
*/
void GraphicsLayerTextureMapper::setNeedsDisplay()
{
- if (!m_hasOwnBackingStore)
+ if (!drawsContent())
return;
m_needsDisplay = true;
- notifyChange(TextureMapperLayer::DisplayChange);
+ notifyChange(DisplayChange);
addRepaintRect(FloatRect(FloatPoint(), m_size));
}
@@ -103,7 +104,7 @@ void GraphicsLayerTextureMapper::setNeedsDisplay()
*/
void GraphicsLayerTextureMapper::setContentsNeedsDisplay()
{
- notifyChange(TextureMapperLayer::DisplayChange);
+ notifyChange(DisplayChange);
addRepaintRect(contentsRect());
}
@@ -111,37 +112,32 @@ void GraphicsLayerTextureMapper::setContentsNeedsDisplay()
*/
void GraphicsLayerTextureMapper::setNeedsDisplayInRect(const FloatRect& rect)
{
- if (!m_hasOwnBackingStore)
+ if (!drawsContent())
return;
if (m_needsDisplay)
return;
m_needsDisplayRect.unite(rect);
- notifyChange(TextureMapperLayer::DisplayChange);
+ notifyChange(DisplayChange);
addRepaintRect(rect);
}
/* \reimp (GraphicsLayer.h)
*/
-void GraphicsLayerTextureMapper::setParent(GraphicsLayer* layer)
-{
- notifyChange(TextureMapperLayer::ParentChange);
- GraphicsLayer::setParent(layer);
-}
-
-/* \reimp (GraphicsLayer.h)
-*/
bool GraphicsLayerTextureMapper::setChildren(const Vector<GraphicsLayer*>& children)
{
- notifyChange(TextureMapperLayer::ChildrenChange);
- return GraphicsLayer::setChildren(children);
+ if (GraphicsLayer::setChildren(children)) {
+ notifyChange(ChildrenChange);
+ return true;
+ }
+ return false;
}
/* \reimp (GraphicsLayer.h)
*/
void GraphicsLayerTextureMapper::addChild(GraphicsLayer* layer)
{
- notifyChange(TextureMapperLayer::ChildrenChange);
+ notifyChange(ChildrenChange);
GraphicsLayer::addChild(layer);
}
@@ -150,15 +146,15 @@ void GraphicsLayerTextureMapper::addChild(GraphicsLayer* layer)
void GraphicsLayerTextureMapper::addChildAtIndex(GraphicsLayer* layer, int index)
{
GraphicsLayer::addChildAtIndex(layer, index);
- notifyChange(TextureMapperLayer::ChildrenChange);
+ notifyChange(ChildrenChange);
}
/* \reimp (GraphicsLayer.h)
*/
void GraphicsLayerTextureMapper::addChildAbove(GraphicsLayer* layer, GraphicsLayer* sibling)
{
- GraphicsLayer::addChildAbove(layer, sibling);
- notifyChange(TextureMapperLayer::ChildrenChange);
+ GraphicsLayer::addChildAbove(layer, sibling);
+ notifyChange(ChildrenChange);
}
/* \reimp (GraphicsLayer.h)
@@ -166,7 +162,7 @@ void GraphicsLayerTextureMapper::addChildAbove(GraphicsLayer* layer, GraphicsLay
void GraphicsLayerTextureMapper::addChildBelow(GraphicsLayer* layer, GraphicsLayer* sibling)
{
GraphicsLayer::addChildBelow(layer, sibling);
- notifyChange(TextureMapperLayer::ChildrenChange);
+ notifyChange(ChildrenChange);
}
/* \reimp (GraphicsLayer.h)
@@ -174,7 +170,7 @@ void GraphicsLayerTextureMapper::addChildBelow(GraphicsLayer* layer, GraphicsLay
bool GraphicsLayerTextureMapper::replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild)
{
if (GraphicsLayer::replaceChild(oldChild, newChild)) {
- notifyChange(TextureMapperLayer::ChildrenChange);
+ notifyChange(ChildrenChange);
return true;
}
return false;
@@ -182,22 +178,12 @@ bool GraphicsLayerTextureMapper::replaceChild(GraphicsLayer* oldChild, GraphicsL
/* \reimp (GraphicsLayer.h)
*/
-void GraphicsLayerTextureMapper::removeFromParent()
-{
- if (!parent())
- return;
- notifyChange(TextureMapperLayer::ParentChange);
- GraphicsLayer::removeFromParent();
-}
-
-/* \reimp (GraphicsLayer.h)
-*/
void GraphicsLayerTextureMapper::setMaskLayer(GraphicsLayer* value)
{
if (value == maskLayer())
return;
GraphicsLayer::setMaskLayer(value);
- notifyChange(TextureMapperLayer::MaskLayerChange);
+ notifyChange(MaskLayerChange);
if (!value)
return;
@@ -213,7 +199,7 @@ void GraphicsLayerTextureMapper::setReplicatedByLayer(GraphicsLayer* value)
if (value == replicaLayer())
return;
GraphicsLayer::setReplicatedByLayer(value);
- notifyChange(TextureMapperLayer::ReplicaLayerChange);
+ notifyChange(ReplicaLayerChange);
}
/* \reimp (GraphicsLayer.h)
@@ -223,7 +209,7 @@ void GraphicsLayerTextureMapper::setPosition(const FloatPoint& value)
if (value == position())
return;
GraphicsLayer::setPosition(value);
- notifyChange(TextureMapperLayer::PositionChange);
+ notifyChange(PositionChange);
}
/* \reimp (GraphicsLayer.h)
@@ -233,7 +219,7 @@ void GraphicsLayerTextureMapper::setAnchorPoint(const FloatPoint3D& value)
if (value == anchorPoint())
return;
GraphicsLayer::setAnchorPoint(value);
- notifyChange(TextureMapperLayer::AnchorPointChange);
+ notifyChange(AnchorPointChange);
}
/* \reimp (GraphicsLayer.h)
@@ -246,7 +232,7 @@ void GraphicsLayerTextureMapper::setSize(const FloatSize& value)
GraphicsLayer::setSize(value);
if (maskLayer())
maskLayer()->setSize(value);
- notifyChange(TextureMapperLayer::SizeChange);
+ notifyChange(SizeChange);
}
/* \reimp (GraphicsLayer.h)
@@ -257,7 +243,7 @@ void GraphicsLayerTextureMapper::setTransform(const TransformationMatrix& value)
return;
GraphicsLayer::setTransform(value);
- notifyChange(TextureMapperLayer::TransformChange);
+ notifyChange(TransformChange);
}
/* \reimp (GraphicsLayer.h)
@@ -267,7 +253,7 @@ void GraphicsLayerTextureMapper::setChildrenTransform(const TransformationMatrix
if (value == childrenTransform())
return;
GraphicsLayer::setChildrenTransform(value);
- notifyChange(TextureMapperLayer::ChildrenTransformChange);
+ notifyChange(ChildrenTransformChange);
}
/* \reimp (GraphicsLayer.h)
@@ -277,7 +263,7 @@ void GraphicsLayerTextureMapper::setPreserves3D(bool value)
if (value == preserves3D())
return;
GraphicsLayer::setPreserves3D(value);
- notifyChange(TextureMapperLayer::Preserves3DChange);
+ notifyChange(Preserves3DChange);
}
/* \reimp (GraphicsLayer.h)
@@ -287,7 +273,7 @@ void GraphicsLayerTextureMapper::setMasksToBounds(bool value)
if (value == masksToBounds())
return;
GraphicsLayer::setMasksToBounds(value);
- notifyChange(TextureMapperLayer::MasksToBoundsChange);
+ notifyChange(MasksToBoundsChange);
}
/* \reimp (GraphicsLayer.h)
@@ -296,8 +282,11 @@ void GraphicsLayerTextureMapper::setDrawsContent(bool value)
{
if (value == drawsContent())
return;
- notifyChange(TextureMapperLayer::DrawsContentChange);
GraphicsLayer::setDrawsContent(value);
+ notifyChange(DrawsContentChange);
+
+ if (value)
+ setNeedsDisplay();
}
/* \reimp (GraphicsLayer.h)
@@ -306,7 +295,7 @@ void GraphicsLayerTextureMapper::setContentsVisible(bool value)
{
if (value == contentsAreVisible())
return;
- notifyChange(TextureMapperLayer::ContentsVisibleChange);
+ notifyChange(ContentsVisibleChange);
GraphicsLayer::setContentsVisible(value);
if (maskLayer())
maskLayer()->setContentsVisible(value);
@@ -318,7 +307,7 @@ void GraphicsLayerTextureMapper::setContentsOpaque(bool value)
{
if (value == contentsOpaque())
return;
- notifyChange(TextureMapperLayer::ContentsOpaqueChange);
+ notifyChange(ContentsOpaqueChange);
GraphicsLayer::setContentsOpaque(value);
}
@@ -329,7 +318,7 @@ void GraphicsLayerTextureMapper::setBackfaceVisibility(bool value)
if (value == backfaceVisibility())
return;
GraphicsLayer::setBackfaceVisibility(value);
- notifyChange(TextureMapperLayer::BackfaceVisibilityChange);
+ notifyChange(BackfaceVisibilityChange);
}
/* \reimp (GraphicsLayer.h)
@@ -339,7 +328,7 @@ void GraphicsLayerTextureMapper::setOpacity(float value)
if (value == opacity())
return;
GraphicsLayer::setOpacity(value);
- notifyChange(TextureMapperLayer::OpacityChange);
+ notifyChange(OpacityChange);
}
/* \reimp (GraphicsLayer.h)
@@ -349,9 +338,19 @@ void GraphicsLayerTextureMapper::setContentsRect(const IntRect& value)
if (value == contentsRect())
return;
GraphicsLayer::setContentsRect(value);
- notifyChange(TextureMapperLayer::ContentsRectChange);
+ notifyChange(ContentsRectChange);
}
+void GraphicsLayerTextureMapper::setContentsToSolidColor(const Color& color)
+{
+ if (color == m_solidColor)
+ return;
+
+ m_solidColor = color;
+ notifyChange(BackgroundColorChange);
+}
+
+
/* \reimp (GraphicsLayer.h)
*/
void GraphicsLayerTextureMapper::setContentsToImage(Image* image)
@@ -377,7 +376,7 @@ void GraphicsLayerTextureMapper::setContentsToImage(Image* image)
}
setContentsToMedia(m_compositedImage.get());
- notifyChange(TextureMapperLayer::ContentChange);
+ notifyChange(ContentChange);
GraphicsLayer::setContentsToImage(image);
}
@@ -387,62 +386,227 @@ void GraphicsLayerTextureMapper::setContentsToMedia(TextureMapperPlatformLayer*
return;
GraphicsLayer::setContentsToMedia(media);
- notifyChange(TextureMapperLayer::ContentChange);
+ notifyChange(ContentChange);
+
+ if (m_contentsLayer)
+ m_contentsLayer->setClient(0);
+
m_contentsLayer = media;
+
+ if (m_contentsLayer)
+ m_contentsLayer->setClient(this);
+}
+
+void GraphicsLayerTextureMapper::setShowDebugBorder(bool show)
+{
+ if (isShowingDebugBorder() == show)
+ return;
+
+ GraphicsLayer::setShowDebugBorder(show);
+ notifyChange(DebugVisualsChange);
+}
+
+void GraphicsLayerTextureMapper::setShowRepaintCounter(bool show)
+{
+ if (isShowingRepaintCounter() == show)
+ return;
+
+ GraphicsLayer::setShowRepaintCounter(show);
+ notifyChange(DebugVisualsChange);
+}
+
+void GraphicsLayerTextureMapper::didCommitScrollOffset(const IntSize& offset)
+{
+ if (offset.isZero())
+ return;
+
+ m_committedScrollOffset = offset;
+ notifyChange(CommittedScrollOffsetChange);
+}
+
+void GraphicsLayerTextureMapper::setIsScrollable(bool isScrollable)
+{
+ if (m_isScrollable == isScrollable)
+ return;
+
+ m_isScrollable = isScrollable;
+ notifyChange(IsScrollableChange);
}
/* \reimp (GraphicsLayer.h)
*/
void GraphicsLayerTextureMapper::flushCompositingStateForThisLayerOnly()
{
- m_layer->flushCompositingState(this);
- didFlushCompositingState();
+ prepareBackingStoreIfNeeded();
+ commitLayerChanges();
+ m_layer->syncAnimations();
+ updateBackingStoreIfNeeded();
}
-/* \reimp (GraphicsLayer.h)
-*/
-void GraphicsLayerTextureMapper::flushCompositingState(const FloatRect&)
+void GraphicsLayerTextureMapper::prepareBackingStoreIfNeeded()
{
- m_layer->flushCompositingState(this, TextureMapperLayer::TraverseDescendants);
- didFlushCompositingStateRecursive();
+ if (!shouldHaveBackingStore()) {
+ m_backingStore.clear();
+ m_changeMask |= BackingStoreChange;
+ } else {
+ if (!m_backingStore) {
+ m_backingStore = TextureMapperTiledBackingStore::create();
+ m_changeMask |= BackingStoreChange;
+ }
+ }
+
+ updateDebugBorderAndRepaintCount();
}
-void GraphicsLayerTextureMapper::didFlushCompositingState()
+void GraphicsLayerTextureMapper::updateDebugBorderAndRepaintCount()
{
- updateBackingStore();
- m_changeMask = 0;
+ if (isShowingDebugBorder())
+ updateDebugIndicators();
+
+ // When this has its own backing store (e.g. Qt WK1), update the repaint count before calling TextureMapperLayer::flushCompositingStateForThisLayerOnly().
+ bool needsToRepaint = shouldHaveBackingStore() && (m_needsDisplay || !m_needsDisplayRect.isEmpty());
+ if (isShowingRepaintCounter() && needsToRepaint) {
+ incrementRepaintCount();
+ m_changeMask |= RepaintCountChange;
+ }
}
-void GraphicsLayerTextureMapper::didFlushCompositingStateRecursive()
+void GraphicsLayerTextureMapper::setDebugBorder(const Color& color, float width)
{
- didFlushCompositingState();
- for (size_t i = 0; i < children().size(); ++i)
- toGraphicsLayerTextureMapper(children()[i])->didFlushCompositingStateRecursive();
- if (maskLayer())
- toGraphicsLayerTextureMapper(maskLayer())->didFlushCompositingStateRecursive();
- if (replicaLayer())
- toGraphicsLayerTextureMapper(replicaLayer())->didFlushCompositingStateRecursive();
+ m_debugBorderColor = color;
+ m_debugBorderWidth = width;
+ m_changeMask |= DebugVisualsChange;
+}
+
+static void toTextureMapperLayerVector(const Vector<GraphicsLayer*>& layers, Vector<TextureMapperLayer*>& texmapLayers)
+{
+ texmapLayers.reserveCapacity(layers.size());
+ for (size_t i = 0; i < layers.size(); ++i)
+ texmapLayers.append(toTextureMapperLayer(layers[i]));
}
-void GraphicsLayerTextureMapper::updateBackingStore()
+void GraphicsLayerTextureMapper::commitLayerChanges()
{
- if (!m_hasOwnBackingStore)
+ if (m_changeMask == NoChanges)
return;
- prepareBackingStore();
- m_layer->setBackingStore(m_backingStore);
+ if (m_changeMask & ChildrenChange) {
+ Vector<TextureMapperLayer*> textureMapperLayerChildren;
+ toTextureMapperLayerVector(children(), textureMapperLayerChildren);
+ m_layer->setChildren(textureMapperLayerChildren);
+ }
+
+ if (m_changeMask & MaskLayerChange)
+ m_layer->setMaskLayer(toTextureMapperLayer(maskLayer()));
+
+ if (m_changeMask & ReplicaLayerChange)
+ m_layer->setReplicaLayer(toTextureMapperLayer(replicaLayer()));
+
+ if (m_changeMask & PositionChange)
+ m_layer->setPosition(position());
+
+ if (m_changeMask & AnchorPointChange)
+ m_layer->setAnchorPoint(anchorPoint());
+
+ if (m_changeMask & SizeChange)
+ m_layer->setSize(size());
+
+ if (m_changeMask & TransformChange)
+ m_layer->setTransform(transform());
+
+ if (m_changeMask & ChildrenTransformChange)
+ m_layer->setChildrenTransform(childrenTransform());
+
+ if (m_changeMask & Preserves3DChange)
+ m_layer->setPreserves3D(preserves3D());
+
+ if (m_changeMask & ContentsRectChange)
+ m_layer->setContentsRect(contentsRect());
+
+ if (m_changeMask & MasksToBoundsChange)
+ m_layer->setMasksToBounds(masksToBounds());
+
+ if (m_changeMask & DrawsContentChange)
+ m_layer->setDrawsContent(drawsContent());
+
+ if (m_changeMask & ContentsVisibleChange)
+ m_layer->setContentsVisible(contentsAreVisible());
+
+ if (m_changeMask & ContentsOpaqueChange)
+ m_layer->setContentsOpaque(contentsOpaque());
+
+ if (m_changeMask & BackfaceVisibilityChange)
+ m_layer->setBackfaceVisibility(backfaceVisibility());
+
+ if (m_changeMask & OpacityChange)
+ m_layer->setOpacity(opacity());
+
+ if (m_changeMask & BackgroundColorChange)
+ m_layer->setSolidColor(solidColor());
+
+#if ENABLE(CSS_FILTERS)
+ if (m_changeMask & FilterChange)
+ m_layer->setFilters(filters());
+#endif
+
+ if (m_changeMask & BackingStoreChange)
+ m_layer->setBackingStore(m_backingStore);
+
+ if (m_changeMask & DebugVisualsChange)
+ m_layer->setDebugVisuals(isShowingDebugBorder(), debugBorderColor(), debugBorderWidth(), isShowingRepaintCounter());
+
+ if (m_changeMask & RepaintCountChange)
+ m_layer->setRepaintCount(repaintCount());
+
+ if (m_changeMask & ContentChange)
+ m_layer->setContentsLayer(platformLayer());
+
+ if (m_changeMask & AnimationChange)
+ m_layer->setAnimations(m_animations);
+
+ if (m_changeMask & AnimationStarted)
+ client()->notifyAnimationStarted(this, m_animationStartTime);
+
+ if (m_changeMask & FixedToViewporChange)
+ m_layer->setFixedToViewport(fixedToViewport());
+
+ if (m_changeMask & IsScrollableChange)
+ m_layer->setIsScrollable(isScrollable());
+
+ if (m_changeMask & CommittedScrollOffsetChange)
+ m_layer->didCommitScrollOffset(m_committedScrollOffset);
+
+ m_changeMask = NoChanges;
+}
+
+/* \reimp (GraphicsLayer.h)
+*/
+void GraphicsLayerTextureMapper::flushCompositingState(const FloatRect& rect)
+{
+ if (!m_layer->textureMapper())
+ return;
+
+ flushCompositingStateForThisLayerOnly();
+
+ if (maskLayer())
+ maskLayer()->flushCompositingState(rect);
+ if (replicaLayer())
+ replicaLayer()->flushCompositingState(rect);
+ for (size_t i = 0; i < children().size(); ++i)
+ children()[i]->flushCompositingState(rect);
}
-void GraphicsLayerTextureMapper::prepareBackingStore()
+void GraphicsLayerTextureMapper::updateBackingStoreIfNeeded()
{
TextureMapper* textureMapper = m_layer->textureMapper();
if (!textureMapper)
return;
if (!shouldHaveBackingStore()) {
- m_backingStore.clear();
+ ASSERT(!m_backingStore);
return;
}
+ ASSERT(m_backingStore);
IntRect dirtyRect = enclosingIntRect(FloatRect(FloatPoint::zero(), m_size));
if (!m_needsDisplay)
@@ -450,42 +614,12 @@ void GraphicsLayerTextureMapper::prepareBackingStore()
if (dirtyRect.isEmpty())
return;
- if (!m_backingStore)
- m_backingStore = TextureMapperTiledBackingStore::create();
-
-#ifndef QT_NO_DYNAMIC_CAST
+#if PLATFORM(QT) && !defined(QT_NO_DYNAMIC_CAST)
ASSERT(dynamic_cast<TextureMapperTiledBackingStore*>(m_backingStore.get()));
#endif
TextureMapperTiledBackingStore* backingStore = static_cast<TextureMapperTiledBackingStore*>(m_backingStore.get());
- if (isShowingRepaintCounter())
- incrementRepaintCount();
-
- // Paint into an intermediate buffer to avoid painting content more than once.
- bool paintOnce = true;
- const IntSize maxTextureSize = textureMapper->maxTextureSize();
- // We need to paint directly if the dirty rect exceeds one of the maximum dimensions.
- if (dirtyRect.width() > maxTextureSize.width() || dirtyRect.height() > maxTextureSize.height())
- paintOnce = false;
-
- if (paintOnce) {
- OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(dirtyRect.size());
- GraphicsContext* context = imageBuffer->context();
- context->setImageInterpolationQuality(textureMapper->imageInterpolationQuality());
- context->setTextDrawingMode(textureMapper->textDrawingMode());
- context->translate(-dirtyRect.x(), -dirtyRect.y());
- paintGraphicsLayerContents(*context, dirtyRect);
-
- if (isShowingRepaintCounter())
- drawRepaintCounter(context);
-
- RefPtr<Image> image = imageBuffer->copyImage(DontCopyBackingStore);
- backingStore->updateContents(textureMapper, image.get(), m_size, dirtyRect, BitmapTexture::UpdateCanModifyOriginalImageData);
- } else
- backingStore->updateContents(textureMapper, this, m_size, dirtyRect, BitmapTexture::UpdateCanModifyOriginalImageData);
-
- backingStore->setShowDebugBorders(isShowingDebugBorder());
- backingStore->setDebugBorder(m_debugBorderColor, m_debugBorderWidth);
+ backingStore->updateContents(textureMapper, this, m_size, dirtyRect, BitmapTexture::UpdateCanModifyOriginalImageData);
m_needsDisplay = false;
m_needsDisplayRect = IntRect();
@@ -496,40 +630,6 @@ bool GraphicsLayerTextureMapper::shouldHaveBackingStore() const
return drawsContent() && contentsAreVisible() && !m_size.isEmpty();
}
-#if USE(CAIRO)
-void GraphicsLayerTextureMapper::drawRepaintCounter(GraphicsContext* context)
-{
- cairo_t* cr = context->platformContext()->cr();
- cairo_save(cr);
-
- CString repaintCount = String::format("%i", this->repaintCount()).utf8();
- cairo_select_font_face(cr, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
- cairo_set_font_size(cr, 18);
-
- cairo_text_extents_t repaintTextExtents;
- cairo_text_extents(cr, repaintCount.data(), &repaintTextExtents);
-
- static const int repaintCountBorderWidth = 10;
- setSourceRGBAFromColor(cr, isShowingDebugBorder() ? m_debugBorderColor : Color(0, 255, 0, 127));
- cairo_rectangle(cr, 0, 0,
- repaintTextExtents.width + (repaintCountBorderWidth * 2),
- repaintTextExtents.height + (repaintCountBorderWidth * 2));
- cairo_fill(cr);
-
- cairo_set_source_rgb(cr, 1, 1, 1);
- cairo_move_to(cr, repaintCountBorderWidth, repaintTextExtents.height + repaintCountBorderWidth);
- cairo_show_text(cr, repaintCount.data());
-
- cairo_restore(cr);
-}
-#else
-void GraphicsLayerTextureMapper::drawRepaintCounter(GraphicsContext* context)
-{
- notImplemented();
-}
-
-#endif
-
bool GraphicsLayerTextureMapper::addAnimation(const KeyframeValueList& valueList, const IntSize& boxSize, const Animation* anim, const String& keyframesName, double timeOffset)
{
ASSERT(!keyframesName.isEmpty());
@@ -550,15 +650,15 @@ bool GraphicsLayerTextureMapper::addAnimation(const KeyframeValueList& valueList
m_animationStartTime = currentTime;
else
m_animationStartTime = currentTime - timeOffset;
- notifyChange(TextureMapperLayer::AnimationChange);
- m_animationStartedTimer.startOneShot(0);
+ notifyChange(AnimationChange);
+ notifyChange(AnimationStarted);
return true;
}
void GraphicsLayerTextureMapper::setAnimations(const GraphicsLayerAnimations& animations)
{
m_animations = animations;
- notifyChange(TextureMapperLayer::AnimationChange);
+ notifyChange(AnimationChange);
}
@@ -572,25 +672,28 @@ void GraphicsLayerTextureMapper::removeAnimation(const String& animationName)
m_animations.remove(animationName);
}
-void GraphicsLayerTextureMapper::animationStartedTimerFired(Timer<GraphicsLayerTextureMapper>*)
+#if ENABLE(CSS_FILTERS)
+bool GraphicsLayerTextureMapper::setFilters(const FilterOperations& filters)
{
- client()->notifyAnimationStarted(this, m_animationStartTime);
+ notifyChange(FilterChange);
+ return GraphicsLayer::setFilters(filters);
}
+#endif
-void GraphicsLayerTextureMapper::setDebugBorder(const Color& color, float width)
+void GraphicsLayerTextureMapper::setFixedToViewport(bool fixed)
{
- // The default values for GraphicsLayer debug borders are a little
- // hard to see (some less than one pixel wide), so we double their size here.
- m_debugBorderColor = color;
- m_debugBorderWidth = width * 2;
+ if (m_fixedToViewport == fixed)
+ return;
+
+ m_fixedToViewport = fixed;
+ notifyChange(FixedToViewporChange);
}
-#if ENABLE(CSS_FILTERS)
-bool GraphicsLayerTextureMapper::setFilters(const FilterOperations& filters)
+void GraphicsLayerTextureMapper::setRepaintCount(int repaintCount)
{
- notifyChange(TextureMapperLayer::FilterChange);
- return GraphicsLayer::setFilters(filters);
+ m_repaintCount = repaintCount;
+ notifyChange(RepaintCountChange);
}
-#endif
}
+#endif
diff --git a/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h b/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h
index 00b0fe7c1..61ddfb92a 100644
--- a/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h
+++ b/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h
@@ -20,36 +20,36 @@
#ifndef GraphicsLayerTextureMapper_h
#define GraphicsLayerTextureMapper_h
-#include "GraphicsContext.h"
+#if USE(TEXTURE_MAPPER)
+
#include "GraphicsLayer.h"
#include "GraphicsLayerClient.h"
#include "Image.h"
#include "TextureMapperLayer.h"
+#include "TextureMapperPlatformLayer.h"
+#include "TextureMapperTiledBackingStore.h"
#include "Timer.h"
namespace WebCore {
-class TextureMapper;
-
-class GraphicsLayerTextureMapper : public GraphicsLayer {
- friend class TextureMapperLayer;
-
+class GraphicsLayerTextureMapper : public GraphicsLayer, public TextureMapperPlatformLayer::Client {
public:
explicit GraphicsLayerTextureMapper(GraphicsLayerClient*);
virtual ~GraphicsLayerTextureMapper();
+ void setScrollClient(TextureMapperLayer::ScrollingClient* client) { m_layer->setScrollClient(client); }
+ void setID(uint32_t id) { m_layer->setID(id); }
+
// reimps from GraphicsLayer.h
virtual void setNeedsDisplay();
virtual void setContentsNeedsDisplay();
virtual void setNeedsDisplayInRect(const FloatRect&);
- virtual void setParent(GraphicsLayer* layer);
virtual bool setChildren(const Vector<GraphicsLayer*>&);
virtual void addChild(GraphicsLayer*);
virtual void addChildAtIndex(GraphicsLayer*, int index);
virtual void addChildAbove(GraphicsLayer* layer, GraphicsLayer* sibling);
virtual void addChildBelow(GraphicsLayer* layer, GraphicsLayer* sibling);
virtual bool replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild);
- virtual void removeFromParent();
virtual void setMaskLayer(GraphicsLayer* layer);
virtual void setPosition(const FloatPoint& p);
virtual void setAnchorPoint(const FloatPoint3D& p);
@@ -66,14 +66,19 @@ public:
virtual void setContentsRect(const IntRect& r);
virtual void setReplicatedByLayer(GraphicsLayer*);
virtual void setContentsToImage(Image*);
+ virtual void setContentsToSolidColor(const Color&);
+ Color solidColor() const { return m_solidColor; }
virtual void setContentsToMedia(PlatformLayer*);
virtual void setContentsToCanvas(PlatformLayer* canvas) { setContentsToMedia(canvas); }
+ virtual void setShowDebugBorder(bool) OVERRIDE;
+ virtual void setDebugBorder(const Color&, float width) OVERRIDE;
+ virtual void setShowRepaintCounter(bool) OVERRIDE;
virtual void flushCompositingState(const FloatRect&);
virtual void flushCompositingStateForThisLayerOnly();
virtual void setName(const String& name);
+ virtual bool hasContentsLayer() const { return m_contentsLayer; }
virtual PlatformLayer* platformLayer() const { return m_contentsLayer; }
- void notifyChange(TextureMapperLayer::ChangeMask);
inline int changeMask() const { return m_changeMask; }
virtual bool addAnimation(const KeyframeValueList&, const IntSize&, const Animation*, const String&, double);
@@ -83,27 +88,76 @@ public:
TextureMapperLayer* layer() const { return m_layer.get(); }
- virtual void setDebugBorder(const Color&, float width);
+ void didCommitScrollOffset(const IntSize&);
+ void setIsScrollable(bool);
+ bool isScrollable() const { return m_isScrollable; }
#if ENABLE(CSS_FILTERS)
virtual bool setFilters(const FilterOperations&);
#endif
- // FIXME: It will be removed after removing dependency of LayerTreeRenderer on GraphicsLayerTextureMapper.
- void setHasOwnBackingStore(bool b) { m_hasOwnBackingStore = b; }
-
- void setFixedToViewport(bool fixed) { m_fixedToViewport = fixed; }
+ void setFixedToViewport(bool);
bool fixedToViewport() const { return m_fixedToViewport; }
- void drawRepaintCounter(GraphicsContext*);
+ Color debugBorderColor() const { return m_debugBorderColor; }
+ float debugBorderWidth() const { return m_debugBorderWidth; }
+ void setRepaintCount(int);
+
private:
virtual void willBeDestroyed();
- void didFlushCompositingState();
- void didFlushCompositingStateRecursive();
- void updateBackingStore();
- void prepareBackingStore();
+
+ void commitLayerChanges();
+ void updateDebugBorderAndRepaintCount();
+ void updateBackingStoreIfNeeded();
+ void prepareBackingStoreIfNeeded();
bool shouldHaveBackingStore() const;
- void animationStartedTimerFired(Timer<GraphicsLayerTextureMapper>*);
+
+ virtual void setPlatformLayerNeedsDisplay() OVERRIDE { setContentsNeedsDisplay(); }
+
+ // This set of flags help us defer which properties of the layer have been
+ // modified by the compositor, so we can know what to look for in the next flush.
+ enum ChangeMask {
+ NoChanges = 0,
+
+ ChildrenChange = (1L << 1),
+ MaskLayerChange = (1L << 2),
+ ReplicaLayerChange = (1L << 3),
+
+ ContentChange = (1L << 4),
+ ContentsRectChange = (1L << 5),
+ ContentsVisibleChange = (1L << 6),
+ ContentsOpaqueChange = (1L << 7),
+
+ PositionChange = (1L << 8),
+ AnchorPointChange = (1L << 9),
+ SizeChange = (1L << 10),
+ TransformChange = (1L << 11),
+ ChildrenTransformChange = (1L << 12),
+ Preserves3DChange = (1L << 13),
+
+ MasksToBoundsChange = (1L << 14),
+ DrawsContentChange = (1L << 15),
+ OpacityChange = (1L << 16),
+ BackfaceVisibilityChange = (1L << 17),
+
+ BackingStoreChange = (1L << 18),
+ DisplayChange = (1L << 19),
+ ContentsDisplayChange = (1L << 20),
+ BackgroundColorChange = (1L << 21),
+
+ AnimationChange = (1L << 22),
+ FilterChange = (1L << 23),
+
+ DebugVisualsChange = (1L << 24),
+ RepaintCountChange = (1L << 25),
+
+ FixedToViewporChange = (1L << 26),
+ AnimationStarted = (1L << 27),
+
+ CommittedScrollOffsetChange = (1L << 28),
+ IsScrollableChange = (1L << 29)
+ };
+ void notifyChange(ChangeMask);
OwnPtr<TextureMapperLayer> m_layer;
RefPtr<TextureMapperTiledBackingStore> m_compositedImage;
@@ -114,6 +168,7 @@ private:
bool m_needsDisplay;
bool m_hasOwnBackingStore;
bool m_fixedToViewport;
+ Color m_solidColor;
Color m_debugBorderColor;
float m_debugBorderWidth;
@@ -121,8 +176,10 @@ private:
TextureMapperPlatformLayer* m_contentsLayer;
FloatRect m_needsDisplayRect;
GraphicsLayerAnimations m_animations;
- Timer<GraphicsLayerTextureMapper> m_animationStartedTimer;
double m_animationStartTime;
+
+ IntSize m_committedScrollOffset;
+ bool m_isScrollable;
};
inline static GraphicsLayerTextureMapper* toGraphicsLayerTextureMapper(GraphicsLayer* layer)
@@ -130,5 +187,9 @@ inline static GraphicsLayerTextureMapper* toGraphicsLayerTextureMapper(GraphicsL
return static_cast<GraphicsLayerTextureMapper*>(layer);
}
+TextureMapperLayer* toTextureMapperLayer(GraphicsLayer*);
+
}
+#endif
+
#endif // GraphicsLayerTextureMapper_h
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapper.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapper.cpp
index 43fec543c..12b04ba42 100644
--- a/Source/WebCore/platform/graphics/texmap/TextureMapper.cpp
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapper.cpp
@@ -20,6 +20,7 @@
#include "config.h"
#include "TextureMapper.h"
+#include "FilterOperations.h"
#include "GraphicsLayer.h"
#include "TextureMapperImageBuffer.h"
#include "Timer.h"
@@ -136,10 +137,13 @@ PassOwnPtr<TextureMapper> TextureMapper::create(AccelerationMode mode)
}
TextureMapper::TextureMapper(AccelerationMode accelerationMode)
- : m_interpolationQuality(InterpolationDefault)
+ : m_context(0)
+ , m_interpolationQuality(InterpolationDefault)
, m_textDrawingMode(TextModeFill)
, m_texturePool(adoptPtr(new BitmapTexturePool()))
, m_accelerationMode(accelerationMode)
+ , m_isMaskMode(false)
+ , m_wrapMode(StretchWrap)
{ }
TextureMapper::~TextureMapper()
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapper.h b/Source/WebCore/platform/graphics/texmap/TextureMapper.h
index 22efd5ff7..6ec675794 100644
--- a/Source/WebCore/platform/graphics/texmap/TextureMapper.h
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapper.h
@@ -20,7 +20,7 @@
#ifndef TextureMapper_h
#define TextureMapper_h
-#if USE(ACCELERATED_COMPOSITING)
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
#if PLATFORM(QT)
#include <qglobal.h>
@@ -28,17 +28,14 @@
#define TEXMAP_OPENGL_ES_2
#endif
#endif
-#if PLATFORM(GTK) && USE(OPENGL_ES_2)
+#if (PLATFORM(GTK) || PLATFORM(EFL)) && USE(OPENGL_ES_2)
#define TEXMAP_OPENGL_ES_2
#endif
-#include "FilterOperations.h"
#include "GraphicsContext.h"
#include "IntRect.h"
#include "IntSize.h"
-#include "TextureMapperPlatformLayer.h"
#include "TransformationMatrix.h"
-#include <wtf/UnusedParam.h>
/*
TextureMapper is a mechanism that enables hardware acceleration of CSS animations (accelerated compositing) without
@@ -51,6 +48,7 @@ class BitmapTexturePool;
class CustomFilterProgram;
class GraphicsLayer;
class TextureMapper;
+class FilterOperations;
// A 2D texture that can be the target of software or GL rendering.
class BitmapTexture : public RefCounted<BitmapTexture> {
@@ -96,7 +94,7 @@ public:
inline bool isOpaque() const { return !(m_flags & SupportsAlpha); }
#if ENABLE(CSS_FILTERS)
- virtual PassRefPtr<BitmapTexture> applyFilters(TextureMapper*, const BitmapTexture& contentTexture, const FilterOperations&) { return this; }
+ virtual PassRefPtr<BitmapTexture> applyFilters(TextureMapper*, const FilterOperations&) { return this; }
#endif
protected:
@@ -116,6 +114,12 @@ public:
enum PaintFlag {
PaintingMirrored = 1 << 0,
};
+
+ enum WrapMode {
+ StretchWrap,
+ RepeatWrap
+ };
+
typedef unsigned PaintFlags;
static PassOwnPtr<TextureMapper> create(AccelerationMode newMode = SoftwareMode);
@@ -130,17 +134,19 @@ public:
AllEdges = LeftEdge | RightEdge | TopEdge | BottomEdge,
};
- virtual void drawBorder(const Color&, float borderWidth, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix = TransformationMatrix()) = 0;
- virtual void drawRepaintCounter(int value, int pointSize, const FloatPoint&, const TransformationMatrix& modelViewMatrix = TransformationMatrix()) = 0;
- virtual void drawTexture(const BitmapTexture&, const FloatRect& target, const TransformationMatrix& modelViewMatrix = TransformationMatrix(), float opacity = 1.0f, const BitmapTexture* maskTexture = 0, unsigned exposedEdges = AllEdges) = 0;
+ virtual void drawBorder(const Color&, float borderWidth, const FloatRect&, const TransformationMatrix&) = 0;
+ virtual void drawNumber(int number, const Color&, const FloatPoint&, const TransformationMatrix&) = 0;
+
+ virtual void drawTexture(const BitmapTexture&, const FloatRect& target, const TransformationMatrix& modelViewMatrix = TransformationMatrix(), float opacity = 1.0f, unsigned exposedEdges = AllEdges) = 0;
virtual void drawSolidColor(const FloatRect&, const TransformationMatrix&, const Color&) = 0;
// makes a surface the target for the following drawTexture calls.
virtual void bindSurface(BitmapTexture* surface) = 0;
- virtual void setGraphicsContext(GraphicsContext* context) { m_context = context; }
- virtual GraphicsContext* graphicsContext() { return m_context; }
+ void setGraphicsContext(GraphicsContext* context) { m_context = context; }
+ GraphicsContext* graphicsContext() { return m_context; }
virtual void beginClip(const TransformationMatrix&, const FloatRect&) = 0;
virtual void endClip() = 0;
+ virtual IntRect clipBounds() = 0;
virtual PassRefPtr<BitmapTexture> createTexture() = 0;
void setImageInterpolationQuality(InterpolationQuality quality) { m_interpolationQuality = quality; }
@@ -153,6 +159,8 @@ public:
virtual void beginPainting(PaintFlags = 0) { }
virtual void endPainting() { }
+ void setMaskMode(bool m) { m_isMaskMode = m; }
+
virtual IntSize maxTextureSize() const = 0;
virtual PassRefPtr<BitmapTexture> acquireTextureFromPool(const IntSize&);
@@ -161,9 +169,18 @@ public:
virtual void removeCachedCustomFilterProgram(CustomFilterProgram*) { }
#endif
+ void setPatternTransform(const TransformationMatrix& p) { m_patternTransform = p; }
+ void setWrapMode(WrapMode m) { m_wrapMode = m; }
+
protected:
explicit TextureMapper(AccelerationMode);
+ GraphicsContext* m_context;
+
+ bool isInMaskMode() const { return m_isMaskMode; }
+ WrapMode wrapMode() const { return m_wrapMode; }
+ const TransformationMatrix& patternTransform() const { return m_patternTransform; }
+
private:
#if USE(TEXTURE_MAPPER_GL)
static PassOwnPtr<TextureMapper> platformCreateAccelerated();
@@ -176,8 +193,10 @@ private:
InterpolationQuality m_interpolationQuality;
TextDrawingModeFlags m_textDrawingMode;
OwnPtr<BitmapTexturePool> m_texturePool;
- GraphicsContext* m_context;
AccelerationMode m_accelerationMode;
+ bool m_isMaskMode;
+ TransformationMatrix m_patternTransform;
+ WrapMode m_wrapMode;
};
}
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.cpp
index 788bb12a1..e68bc0914 100644
--- a/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.cpp
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.cpp
@@ -19,7 +19,7 @@
#include "config.h"
-#if USE(ACCELERATED_COMPOSITING)
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
#include "TextureMapperBackingStore.h"
#include "GraphicsLayer.h"
@@ -33,92 +33,6 @@
namespace WebCore {
-#if USE(GRAPHICS_SURFACE)
-void TextureMapperSurfaceBackingStore::setGraphicsSurface(PassRefPtr<GraphicsSurface> surface)
-{
- m_graphicsSurface = surface;
-}
-
-void TextureMapperSurfaceBackingStore::swapBuffersIfNeeded(uint32_t frontBuffer)
-{
- if (m_graphicsSurface && m_graphicsSurface->frontBuffer() != frontBuffer)
- m_graphicsSurface->swapBuffers();
-}
-
-PassRefPtr<BitmapTexture> TextureMapperSurfaceBackingStore::texture() const
-{
- // FIXME: Instead of just returning an empty texture, we should wrap the texture contents into a BitmapTexture.
- RefPtr<BitmapTexture> emptyTexture;
- return emptyTexture;
-}
-
-void TextureMapperSurfaceBackingStore::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
-{
- if (m_graphicsSurface)
- m_graphicsSurface->paintToTextureMapper(textureMapper, targetRect, transform, opacity, mask);
-}
-#endif
-
-void TextureMapperTile::updateContents(TextureMapper* textureMapper, Image* image, const IntRect& dirtyRect, BitmapTexture::UpdateContentsFlag updateContentsFlag)
-{
- IntRect targetRect = enclosingIntRect(m_rect);
- targetRect.intersect(dirtyRect);
- if (targetRect.isEmpty())
- return;
- IntPoint sourceOffset = targetRect.location();
-
- // Normalize sourceRect to the buffer's coordinates.
- sourceOffset.move(-dirtyRect.x(), -dirtyRect.y());
-
- // Normalize targetRect to the texture's coordinates.
- targetRect.move(-m_rect.x(), -m_rect.y());
- if (!m_texture) {
- m_texture = textureMapper->createTexture();
- m_texture->reset(targetRect.size(), image->currentFrameHasAlpha() ? BitmapTexture::SupportsAlpha : 0);
- }
-
- m_texture->updateContents(image, targetRect, sourceOffset, updateContentsFlag);
-}
-
-void TextureMapperTile::updateContents(TextureMapper* textureMapper, GraphicsLayer* sourceLayer, const IntRect& dirtyRect, BitmapTexture::UpdateContentsFlag updateContentsFlag)
-{
- IntRect targetRect = enclosingIntRect(m_rect);
- targetRect.intersect(dirtyRect);
- if (targetRect.isEmpty())
- return;
- IntPoint sourceOffset = targetRect.location();
-
- // Normalize targetRect to the texture's coordinates.
- targetRect.move(-m_rect.x(), -m_rect.y());
-
- if (!m_texture) {
- m_texture = textureMapper->createTexture();
- m_texture->reset(targetRect.size(), BitmapTexture::SupportsAlpha);
- }
-
- m_texture->updateContents(textureMapper, sourceLayer, targetRect, sourceOffset, updateContentsFlag);
-}
-
-void TextureMapperTile::paint(TextureMapper* textureMapper, const TransformationMatrix& transform, float opacity, BitmapTexture* mask, const unsigned exposedEdges)
-{
- if (texture().get())
- textureMapper->drawTexture(*texture().get(), rect(), transform, opacity, mask, exposedEdges);
-}
-
-TextureMapperTiledBackingStore::TextureMapperTiledBackingStore()
- : m_drawsDebugBorders(false)
-{
-}
-
-void TextureMapperTiledBackingStore::updateContentsFromImageIfNeeded(TextureMapper* textureMapper)
-{
- if (!m_image)
- return;
-
- updateContents(textureMapper, m_image.get(), m_image->size(), m_image->rect(), BitmapTexture::UpdateCannotModifyOriginalImageData);
- m_image.clear();
-}
-
unsigned TextureMapperBackingStore::calculateExposedTileEdges(const FloatRect& totalRect, const FloatRect& tileRect)
{
unsigned exposedEdges = TextureMapper::NoEdges;
@@ -133,112 +47,5 @@ unsigned TextureMapperBackingStore::calculateExposedTileEdges(const FloatRect& t
return exposedEdges;
}
-void TextureMapperTiledBackingStore::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
-{
- updateContentsFromImageIfNeeded(textureMapper);
- TransformationMatrix adjustedTransform = transform;
- adjustedTransform.multiply(TransformationMatrix::rectToRect(rect(), targetRect));
- for (size_t i = 0; i < m_tiles.size(); ++i) {
- m_tiles[i].paint(textureMapper, adjustedTransform, opacity, mask, calculateExposedTileEdges(rect(), m_tiles[i].rect()));
- if (m_drawsDebugBorders)
- textureMapper->drawBorder(m_debugBorderColor, m_debugBorderWidth, m_tiles[i].rect(), adjustedTransform);
- }
-}
-
-void TextureMapperTiledBackingStore::createOrDestroyTilesIfNeeded(const FloatSize& size, const IntSize& tileSize, bool hasAlpha)
-{
- if (size == m_size)
- return;
-
- m_size = size;
-
- Vector<FloatRect> tileRectsToAdd;
- Vector<int> tileIndicesToRemove;
- static const size_t TileEraseThreshold = 6;
-
- // This method recycles tiles. We check which tiles we need to add, which to remove, and use as many
- // removable tiles as replacement for new tiles when possible.
- for (float y = 0; y < m_size.height(); y += tileSize.height()) {
- for (float x = 0; x < m_size.width(); x += tileSize.width()) {
- FloatRect tileRect(x, y, tileSize.width(), tileSize.height());
- tileRect.intersect(rect());
- tileRectsToAdd.append(tileRect);
- }
- }
-
- // Check which tiles need to be removed, and which already exist.
- for (int i = m_tiles.size() - 1; i >= 0; --i) {
- FloatRect oldTile = m_tiles[i].rect();
- bool existsAlready = false;
-
- for (int j = tileRectsToAdd.size() - 1; j >= 0; --j) {
- FloatRect newTile = tileRectsToAdd[j];
- if (oldTile != newTile)
- continue;
-
- // A tile that we want to add already exists, no need to add or remove it.
- existsAlready = true;
- tileRectsToAdd.remove(j);
- break;
- }
-
- // This tile is not needed.
- if (!existsAlready)
- tileIndicesToRemove.append(i);
- }
-
- // Recycle removable tiles to be used for newly requested tiles.
- for (size_t i = 0; i < tileRectsToAdd.size(); ++i) {
- if (!tileIndicesToRemove.isEmpty()) {
- // We recycle an existing tile for usage with a new tile rect.
- TextureMapperTile& tile = m_tiles[tileIndicesToRemove.last()];
- tileIndicesToRemove.removeLast();
- tile.setRect(tileRectsToAdd[i]);
-
- if (tile.texture())
- tile.texture()->reset(enclosingIntRect(tile.rect()).size(), hasAlpha ? BitmapTexture::SupportsAlpha : 0);
- continue;
- }
-
- m_tiles.append(TextureMapperTile(tileRectsToAdd[i]));
- }
-
- // Remove unnecessary tiles, if they weren't recycled.
- // We use a threshold to make sure we don't create/destroy tiles too eagerly.
- for (size_t i = 0; i < tileIndicesToRemove.size() && m_tiles.size() > TileEraseThreshold; ++i)
- m_tiles.remove(tileIndicesToRemove[i]);
-}
-
-void TextureMapperTiledBackingStore::updateContents(TextureMapper* textureMapper, Image* image, const FloatSize& totalSize, const IntRect& dirtyRect, BitmapTexture::UpdateContentsFlag updateContentsFlag)
-{
- createOrDestroyTilesIfNeeded(totalSize, textureMapper->maxTextureSize(), image->currentFrameHasAlpha());
- for (size_t i = 0; i < m_tiles.size(); ++i)
- m_tiles[i].updateContents(textureMapper, image, dirtyRect, updateContentsFlag);
-}
-
-void TextureMapperTiledBackingStore::updateContents(TextureMapper* textureMapper, GraphicsLayer* sourceLayer, const FloatSize& totalSize, const IntRect& dirtyRect, BitmapTexture::UpdateContentsFlag updateContentsFlag)
-{
- createOrDestroyTilesIfNeeded(totalSize, textureMapper->maxTextureSize(), true);
- for (size_t i = 0; i < m_tiles.size(); ++i)
- m_tiles[i].updateContents(textureMapper, sourceLayer, dirtyRect, updateContentsFlag);
-}
-
-PassRefPtr<BitmapTexture> TextureMapperTiledBackingStore::texture() const
-{
- for (size_t i = 0; i < m_tiles.size(); ++i) {
- RefPtr<BitmapTexture> texture = m_tiles[i].texture();
- if (texture)
- return texture;
- }
-
- return PassRefPtr<BitmapTexture>();
-}
-
-void TextureMapperTiledBackingStore::setDebugBorder(const Color& color, float width)
-{
- m_debugBorderColor = color;
- m_debugBorderWidth = width;
-}
-
}
#endif
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.h b/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.h
index 0dd2df4b1..4bae45b4f 100644
--- a/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.h
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.h
@@ -20,7 +20,7 @@
#ifndef TextureMapperBackingStore_h
#define TextureMapperBackingStore_h
-#if USE(ACCELERATED_COMPOSITING)
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
#include "FloatRect.h"
#include "Image.h"
@@ -39,83 +39,14 @@ class GraphicsLayer;
class TextureMapperBackingStore : public TextureMapperPlatformLayer, public RefCounted<TextureMapperBackingStore> {
public:
virtual PassRefPtr<BitmapTexture> texture() const = 0;
- virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float, BitmapTexture*) = 0;
+ virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float) = 0;
+ virtual void drawRepaintCounter(TextureMapper*, int /* repaintCount */, const Color&, const FloatRect&, const TransformationMatrix&) { }
virtual ~TextureMapperBackingStore() { }
protected:
static unsigned calculateExposedTileEdges(const FloatRect& totalRect, const FloatRect& tileRect);
};
-#if USE(GRAPHICS_SURFACE)
-class TextureMapperSurfaceBackingStore : public TextureMapperBackingStore {
-public:
- static PassRefPtr<TextureMapperSurfaceBackingStore> create() { return adoptRef(new TextureMapperSurfaceBackingStore); }
- void setGraphicsSurface(PassRefPtr<GraphicsSurface>);
- void swapBuffersIfNeeded(uint32_t frontBuffer);
- virtual PassRefPtr<BitmapTexture> texture() const;
- virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float, BitmapTexture*);
- virtual ~TextureMapperSurfaceBackingStore() { }
-
-private:
- TextureMapperSurfaceBackingStore()
- : TextureMapperBackingStore()
- { }
-
- RefPtr<GraphicsSurface> m_graphicsSurface;
-};
-#endif
-
-class TextureMapperTile {
-public:
- inline PassRefPtr<BitmapTexture> texture() const { return m_texture; }
- inline FloatRect rect() const { return m_rect; }
- inline void setTexture(BitmapTexture* texture) { m_texture = texture; }
- inline void setRect(const FloatRect& rect) { m_rect = rect; }
-
- void updateContents(TextureMapper*, Image*, const IntRect&, BitmapTexture::UpdateContentsFlag UpdateCanModifyOriginalImageData);
- void updateContents(TextureMapper*, GraphicsLayer*, const IntRect&, BitmapTexture::UpdateContentsFlag UpdateCanModifyOriginalImageData);
- virtual void paint(TextureMapper*, const TransformationMatrix&, float, BitmapTexture*, const unsigned exposedEdges);
- virtual ~TextureMapperTile() { }
-
- explicit TextureMapperTile(const FloatRect& rect)
- : m_rect(rect)
- {
- }
-
-private:
- RefPtr<BitmapTexture> m_texture;
- FloatRect m_rect;
-};
-
-class TextureMapperTiledBackingStore : public TextureMapperBackingStore {
-public:
- static PassRefPtr<TextureMapperTiledBackingStore> create() { return adoptRef(new TextureMapperTiledBackingStore); }
- virtual ~TextureMapperTiledBackingStore() { }
-
- virtual PassRefPtr<BitmapTexture> texture() const OVERRIDE;
- virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float, BitmapTexture*) OVERRIDE;
- void updateContents(TextureMapper*, Image*, const FloatSize&, const IntRect&, BitmapTexture::UpdateContentsFlag);
- void updateContents(TextureMapper*, GraphicsLayer*, const FloatSize&, const IntRect&, BitmapTexture::UpdateContentsFlag);
-
- void setContentsToImage(Image* image) { m_image = image; }
- void setShowDebugBorders(bool drawsDebugBorders) { m_drawsDebugBorders = drawsDebugBorders; }
- void setDebugBorder(const Color&, float width);
-
-private:
- TextureMapperTiledBackingStore();
- void createOrDestroyTilesIfNeeded(const FloatSize& backingStoreSize, const IntSize& tileSize, bool hasAlpha);
- void updateContentsFromImageIfNeeded(TextureMapper*);
- inline FloatRect rect() const { return FloatRect(FloatPoint::zero(), m_size); }
-
- Vector<TextureMapperTile> m_tiles;
- FloatSize m_size;
- RefPtr<Image> m_image;
-
- bool m_drawsDebugBorders;
- Color m_debugBorderColor;
- float m_debugBorderWidth;
-};
-
}
#endif
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperFPSCounter.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperFPSCounter.cpp
new file mode 100644
index 000000000..1704f477d
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperFPSCounter.cpp
@@ -0,0 +1,67 @@
+/*
+ Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2012, 2013 Company 100, Inc.
+ Copyright (C) 2012, 2013 basysKom GmbH
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
+
+#include "TextureMapperFPSCounter.h"
+
+#include "TextureMapper.h"
+#include <wtf/CurrentTime.h>
+
+namespace WebCore {
+
+TextureMapperFPSCounter::TextureMapperFPSCounter()
+ : m_isShowingFPS(false)
+ , m_fpsInterval(0)
+ , m_fpsTimestamp(0)
+ , m_lastFPS(0)
+ , m_frameCount(0)
+{
+ String showFPSEnvironment = getenv("WEBKIT_SHOW_FPS");
+ bool ok = false;
+ m_fpsInterval = showFPSEnvironment.toDouble(&ok);
+ if (ok && m_fpsInterval) {
+ m_isShowingFPS = true;
+ m_fpsTimestamp = WTF::currentTime();
+ }
+}
+
+void TextureMapperFPSCounter::updateFPSAndDisplay(TextureMapper* textureMapper, const FloatPoint& location, const TransformationMatrix& matrix)
+{
+ if (!m_isShowingFPS)
+ return;
+
+ m_frameCount++;
+ double delta = WTF::currentTime() - m_fpsTimestamp;
+ if (delta >= m_fpsInterval) {
+ m_lastFPS = int(m_frameCount / delta);
+ m_frameCount = 0;
+ m_fpsTimestamp += delta;
+ }
+
+ textureMapper->drawNumber(m_lastFPS, Color::black, location, matrix);
+}
+
+} // namespace WebCore
+
+#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebCore/platform/graphics/qt/LayoutSizeQt.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperFPSCounter.h
index 040441de0..006237383 100644
--- a/Source/WebCore/platform/graphics/qt/LayoutSizeQt.cpp
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperFPSCounter.h
@@ -1,5 +1,7 @@
/*
Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2012, 2013 Company 100, Inc.
+ Copyright (C) 2012, 2013 basysKom GmbH
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -17,30 +19,36 @@
Boston, MA 02110-1301, USA.
*/
-#include "config.h"
+#ifndef TextureMapperFPSCounter_h
+#define TextureMapperFPSCounter_h
-#include "LayoutSize.h"
-
-#include <QSize>
-#include <QSizeF>
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
+#include "FloatPoint.h"
+#include "TransformationMatrix.h"
+#include <wtf/Noncopyable.h>
namespace WebCore {
+class TextureMapper;
+
+class TextureMapperFPSCounter {
+ WTF_MAKE_NONCOPYABLE(TextureMapperFPSCounter);
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ TextureMapperFPSCounter();
+ void updateFPSAndDisplay(TextureMapper*, const FloatPoint& = FloatPoint::zero(), const TransformationMatrix& = TransformationMatrix());
+
+private:
+ bool m_isShowingFPS;
+ double m_fpsInterval;
+ double m_fpsTimestamp;
+ int m_lastFPS;
+ int m_frameCount;
+};
+
+} // namespace WebCore
-LayoutSize::LayoutSize(const QSize& size)
- : m_width(size.width())
- , m_height(size.height())
-{
-}
+#endif // USE(ACCELERATED_COMPOSITING)
-LayoutSize::LayoutSize(const QSizeF& size)
- : m_width(size.width())
- , m_height(size.height())
-{
-}
+#endif // TextureMapperFPSCounter_h
-LayoutSize::operator QSizeF() const
-{
- return QSizeF(width(), height());
-}
-} // namespace
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp
index 2a6f29fdf..55c0b6aca 100644
--- a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp
@@ -22,17 +22,20 @@
#include "config.h"
#include "TextureMapperGL.h"
+#include "Extensions3D.h"
+#include "FilterOperations.h"
#include "GraphicsContext.h"
#include "Image.h"
#include "LengthFunctions.h"
#include "NotImplemented.h"
-#include "TextureMapperShaderManager.h"
+#include "TextureMapperShaderProgram.h"
#include "Timer.h"
#include <wtf/HashMap.h>
#include <wtf/OwnArrayPtr.h>
#include <wtf/PassOwnArrayPtr.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
+#include <wtf/TemporaryChange.h>
#if PLATFORM(QT)
#include "NativeImageQt.h"
@@ -56,13 +59,14 @@
#if !USE(TEXMAP_OPENGL_ES_2)
// FIXME: Move to Extensions3D.h.
-#define GL_TEXTURE_RECTANGLE_ARB 0x84F5
#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
#define GL_UNPACK_ROW_LENGTH 0x0CF2
#define GL_UNPACK_SKIP_PIXELS 0x0CF4
#define GL_UNPACK_SKIP_ROWS 0x0CF3
#endif
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
+
namespace WebCore {
struct TextureMapperGLData {
WTF_MAKE_FAST_ALLOCATED;
@@ -85,12 +89,20 @@ public:
return adoptRef(new SharedGLData(context));
}
+ PassRefPtr<TextureMapperShaderProgram> getShaderProgram(TextureMapperShaderProgram::Options options)
+ {
+ HashMap<TextureMapperShaderProgram::Options, RefPtr<TextureMapperShaderProgram> >::AddResult result = m_programs.add(options, 0);
+ if (result.isNewEntry)
+ result.iterator->value = TextureMapperShaderProgram::create(m_context, options);
+ return result.iterator->value;
+ }
- TextureMapperShaderManager textureMapperShaderManager;
+ HashMap<TextureMapperShaderProgram::Options, RefPtr<TextureMapperShaderProgram> > m_programs;
+ RefPtr<GraphicsContext3D> m_context;
explicit SharedGLData(GraphicsContext3D* context)
- : textureMapperShaderManager(context)
+ : m_context(context)
{
glContextDataMap().add(context->platformGraphicsContext3D(), this);
}
@@ -111,7 +123,7 @@ public:
SharedGLData& sharedGLData() const
{
- return *m_sharedGLData;
+ return *sharedData;
}
void initializeStencil();
@@ -124,9 +136,15 @@ public:
, didModifyStencil(false)
, previousScissorState(0)
, previousDepthState(0)
- , m_sharedGLData(TextureMapperGLData::SharedGLData::currentSharedGLData(this->context))
+ , sharedData(TextureMapperGLData::SharedGLData::currentSharedGLData(this->context))
+#if ENABLE(CSS_FILTERS)
+ , filterInfo(0)
+#endif
{ }
+ ~TextureMapperGLData();
+ Platform3DObject getStaticVBO(GC3Denum target, GC3Dsizeiptr, const void* data);
+
GraphicsContext3D* context;
TransformationMatrix projectionMatrix;
TextureMapper::PaintFlags PaintFlags;
@@ -137,19 +155,59 @@ public:
GC3Dint previousDepthState;
GC3Dint viewport[4];
GC3Dint previousScissor[4];
- RefPtr<SharedGLData> m_sharedGLData;
+ RefPtr<SharedGLData> sharedData;
RefPtr<BitmapTexture> currentSurface;
+ HashMap<const void*, Platform3DObject> vbos;
+#if ENABLE(CSS_FILTERS)
+ const BitmapTextureGL::FilterInfo* filterInfo;
+#endif
};
-void TextureMapperGL::ClipStack::init(const IntRect& rect)
+Platform3DObject TextureMapperGLData::getStaticVBO(GC3Denum target, GC3Dsizeiptr size, const void* data)
+{
+ HashMap<const void*, Platform3DObject>::AddResult result = vbos.add(data, 0);
+ if (result.isNewEntry) {
+ Platform3DObject vbo = context->createBuffer();
+ context->bindBuffer(target, vbo);
+ context->bufferData(target, size, data, GraphicsContext3D::STATIC_DRAW);
+ result.iterator->value = vbo;
+ }
+
+ return result.iterator->value;
+}
+
+TextureMapperGLData::~TextureMapperGLData()
+{
+ HashMap<const void*, Platform3DObject>::iterator end = vbos.end();
+ for (HashMap<const void*, Platform3DObject>::iterator it = vbos.begin(); it != end; ++it)
+ context->deleteBuffer(it->value);
+}
+
+void TextureMapperGL::ClipStack::reset(const IntRect& rect, TextureMapperGL::ClipStack::YAxisMode mode)
{
clipStack.clear();
+ size = rect.size();
+ yAxisMode = mode;
clipState = TextureMapperGL::ClipState(rect);
+ clipStateDirty = true;
+}
+
+void TextureMapperGL::ClipStack::intersect(const IntRect& rect)
+{
+ clipState.scissorBox.intersect(rect);
+ clipStateDirty = true;
+}
+
+void TextureMapperGL::ClipStack::setStencilIndex(int stencilIndex)
+{
+ clipState.stencilIndex = stencilIndex;
+ clipStateDirty = true;
}
void TextureMapperGL::ClipStack::push()
{
clipStack.append(clipState);
+ clipStateDirty = true;
}
void TextureMapperGL::ClipStack::pop()
@@ -158,21 +216,17 @@ void TextureMapperGL::ClipStack::pop()
return;
clipState = clipStack.last();
clipStack.removeLast();
+ clipStateDirty = true;
}
-static void scissorClip(GraphicsContext3D* context, const IntRect& rect)
+void TextureMapperGL::ClipStack::apply(GraphicsContext3D* context)
{
- if (rect.isEmpty())
+ if (clipState.scissorBox.isEmpty())
return;
- GC3Dint viewport[4];
- context->getIntegerv(GraphicsContext3D::VIEWPORT, viewport);
- context->scissor(rect.x(), viewport[3] - rect.maxY(), rect.width(), rect.height());
-}
-
-void TextureMapperGL::ClipStack::apply(GraphicsContext3D* context)
-{
- scissorClip(context, clipState.scissorBox);
+ context->scissor(clipState.scissorBox.x(),
+ (yAxisMode == InvertedYAxis) ? size.height() - clipState.scissorBox.maxY() : clipState.scissorBox.y(),
+ clipState.scissorBox.width(), clipState.scissorBox.height());
context->stencilOp(GraphicsContext3D::KEEP, GraphicsContext3D::KEEP, GraphicsContext3D::KEEP);
context->stencilFunc(GraphicsContext3D::EQUAL, clipState.stencilIndex - 1, clipState.stencilIndex - 1);
if (clipState.stencilIndex == 1)
@@ -181,6 +235,14 @@ void TextureMapperGL::ClipStack::apply(GraphicsContext3D* context)
context->enable(GraphicsContext3D::STENCIL_TEST);
}
+void TextureMapperGL::ClipStack::applyIfNeeded(GraphicsContext3D* context)
+{
+ if (!clipStateDirty)
+ return;
+
+ clipStateDirty = false;
+ apply(context);
+}
void TextureMapperGLData::initializeStencil()
{
@@ -207,7 +269,6 @@ BitmapTextureGL* toBitmapTextureGL(BitmapTexture* texture)
TextureMapperGL::TextureMapperGL()
: TextureMapper(OpenGLMode)
- , m_context(0)
, m_enableEdgeDistanceAntialiasing(false)
{
m_context3D = GraphicsContext3D::createForCurrentGLContext();
@@ -237,7 +298,7 @@ void TextureMapperGL::beginPainting(PaintFlags flags)
m_context3D->depthMask(0);
m_context3D->getIntegerv(GraphicsContext3D::VIEWPORT, data().viewport);
m_context3D->getIntegerv(GraphicsContext3D::SCISSOR_BOX, data().previousScissor);
- m_clipStack.init(IntRect(0, 0, data().viewport[2], data().viewport[3]));
+ m_clipStack.reset(IntRect(0, 0, data().viewport[2], data().viewport[3]), ClipStack::InvertedYAxis);
m_context3D->getIntegerv(GraphicsContext3D::FRAMEBUFFER_BINDING, &data().targetFrameBuffer);
data().PaintFlags = flags;
bindSurface(0);
@@ -272,62 +333,28 @@ void TextureMapperGL::endPainting()
#endif
}
-void TextureMapperGL::drawQuad(const DrawQuad& quadToDraw, const TransformationMatrix& modelViewMatrix, TextureMapperShaderProgram* shaderProgram, GC3Denum drawingMode, bool needsBlending)
-{
- m_context3D->enableVertexAttribArray(shaderProgram->vertexLocation());
- m_context3D->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, 0);
-
- const GC3Dfloat quad[] = {
- quadToDraw.targetRectMappedToUnitSquare.p1().x(), quadToDraw.targetRectMappedToUnitSquare.p1().y(),
- quadToDraw.targetRectMappedToUnitSquare.p2().x(), quadToDraw.targetRectMappedToUnitSquare.p2().y(),
- quadToDraw.targetRectMappedToUnitSquare.p3().x(), quadToDraw.targetRectMappedToUnitSquare.p3().y(),
- quadToDraw.targetRectMappedToUnitSquare.p4().x(), quadToDraw.targetRectMappedToUnitSquare.p4().y()
- };
- m_context3D->vertexAttribPointer(shaderProgram->vertexLocation(), 2, GraphicsContext3D::FLOAT, false, 0, GC3Dintptr(quad));
-
- TransformationMatrix matrix = TransformationMatrix(data().projectionMatrix).multiply(modelViewMatrix).multiply(TransformationMatrix(
- quadToDraw.originalTargetRect.width(), 0, 0, 0,
- 0, quadToDraw.originalTargetRect.height(), 0, 0,
- 0, 0, 1, 0,
- quadToDraw.originalTargetRect.x(), quadToDraw.originalTargetRect.y(), 0, 1));
- GC3Dfloat m4[] = {
- matrix.m11(), matrix.m12(), matrix.m13(), matrix.m14(),
- matrix.m21(), matrix.m22(), matrix.m23(), matrix.m24(),
- matrix.m31(), matrix.m32(), matrix.m33(), matrix.m34(),
- matrix.m41(), matrix.m42(), matrix.m43(), matrix.m44()
- };
- m_context3D->uniformMatrix4fv(shaderProgram->matrixLocation(), 1, false, m4);
-
- if (needsBlending) {
- m_context3D->blendFunc(GraphicsContext3D::ONE, GraphicsContext3D::ONE_MINUS_SRC_ALPHA);
- m_context3D->enable(GraphicsContext3D::BLEND);
- } else
- m_context3D->disable(GraphicsContext3D::BLEND);
-
- m_context3D->drawArrays(drawingMode, 0, 4);
- m_context3D->disableVertexAttribArray(shaderProgram->vertexLocation());
-}
-
void TextureMapperGL::drawBorder(const Color& color, float width, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix)
{
- if (clipStack().current().scissorBox.isEmpty())
+ if (clipStack().isCurrentScissorBoxEmpty())
return;
- RefPtr<TextureMapperShaderProgram> program = data().sharedGLData().textureMapperShaderManager.getShaderProgram(TextureMapperShaderManager::SolidColor);
+ RefPtr<TextureMapperShaderProgram> program = data().sharedGLData().getShaderProgram(TextureMapperShaderProgram::SolidColor);
m_context3D->useProgram(program->programID());
float r, g, b, a;
- color.getRGBA(r, g, b, a);
+ Color(premultipliedARGBFromColor(color)).getRGBA(r, g, b, a);
m_context3D->uniform4f(program->colorLocation(), r, g, b, a);
m_context3D->lineWidth(width);
- drawQuad(targetRect, modelViewMatrix, program.get(), GraphicsContext3D::LINE_LOOP, color.hasAlpha());
+ draw(targetRect, modelViewMatrix, program.get(), GraphicsContext3D::LINE_LOOP, color.hasAlpha() ? ShouldBlend : 0);
}
-void TextureMapperGL::drawRepaintCounter(int value, int pointSize, const FloatPoint& targetPoint, const TransformationMatrix& modelViewMatrix)
+// FIXME: drawNumber() should save a number texture-atlas and re-use whenever possible.
+void TextureMapperGL::drawNumber(int number, const Color& color, const FloatPoint& targetPoint, const TransformationMatrix& modelViewMatrix)
{
+ int pointSize = 8;
#if PLATFORM(QT)
- QString counterString = QString::number(value);
+ QString counterString = QString::number(number);
QFont font(QString::fromLatin1("Monospace"), pointSize, QFont::Bold);
font.setStyleHint(QFont::TypeWriter);
@@ -342,7 +369,7 @@ void TextureMapperGL::drawRepaintCounter(int value, int pointSize, const FloatPo
QImage image(size, NativeImageQt::defaultFormatForAlphaEnabledImages());
QPainter painter(&image);
- painter.fillRect(sourceRect, Qt::blue); // Since we won't swap R+B for speed, this will paint red.
+ painter.fillRect(sourceRect, Color::createUnchecked(color.blue(), color.green(), color.red())); // Since we won't swap R+B when uploading a texture, paint with the swapped R+B color.
painter.setFont(font);
painter.setPen(Qt::white);
painter.drawText(2, height * 0.85, counterString);
@@ -350,10 +377,10 @@ void TextureMapperGL::drawRepaintCounter(int value, int pointSize, const FloatPo
RefPtr<BitmapTexture> texture = acquireTextureFromPool(size);
const uchar* bits = image.bits();
static_cast<BitmapTextureGL*>(texture.get())->updateContentsNoSwizzle(bits, sourceRect, IntPoint::zero(), image.bytesPerLine());
- drawTexture(*texture, targetRect, modelViewMatrix, 1.0f, 0, AllEdges);
+ drawTexture(*texture, targetRect, modelViewMatrix, 1.0f, AllEdges);
#elif USE(CAIRO)
- CString counterString = String::number(value).ascii();
+ CString counterString = String::number(number).ascii();
// cairo_text_extents() requires a cairo_t, so dimensions need to be guesstimated.
int width = counterString.length() * pointSize * 1.2;
int height = pointSize * 1.5;
@@ -361,7 +388,9 @@ void TextureMapperGL::drawRepaintCounter(int value, int pointSize, const FloatPo
cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
cairo_t* cr = cairo_create(surface);
- cairo_set_source_rgb(cr, 0, 0, 1); // Since we won't swap R+B for speed, this will paint red.
+ float r, g, b, a;
+ color.getRGBA(r, g, b, a);
+ cairo_set_source_rgba(cr, b, g, r, a); // Since we won't swap R+B when uploading a texture, paint with the swapped R+B color.
cairo_rectangle(cr, 0, 0, width, height);
cairo_fill(cr);
@@ -379,13 +408,13 @@ void TextureMapperGL::drawRepaintCounter(int value, int pointSize, const FloatPo
const unsigned char* bits = cairo_image_surface_get_data(surface);
int stride = cairo_image_surface_get_stride(surface);
static_cast<BitmapTextureGL*>(texture.get())->updateContentsNoSwizzle(bits, sourceRect, IntPoint::zero(), stride);
- drawTexture(*texture, targetRect, modelViewMatrix, 1.0f, 0, AllEdges);
+ drawTexture(*texture, targetRect, modelViewMatrix, 1.0f, AllEdges);
cairo_surface_destroy(surface);
cairo_destroy(cr);
#else
- UNUSED_PARAM(value);
+ UNUSED_PARAM(number);
UNUSED_PARAM(pointSize);
UNUSED_PARAM(targetPoint);
UNUSED_PARAM(modelViewMatrix);
@@ -393,229 +422,337 @@ void TextureMapperGL::drawRepaintCounter(int value, int pointSize, const FloatPo
#endif
}
-void TextureMapperGL::drawTexture(const BitmapTexture& texture, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity, const BitmapTexture* mask, unsigned exposedEdges)
-{
- if (!texture.isValid())
- return;
+#if ENABLE(CSS_FILTERS)
- if (clipStack().current().scissorBox.isEmpty())
- return;
+static TextureMapperShaderProgram::Options optionsForFilterType(FilterOperation::OperationType type, unsigned pass)
+{
+ switch (type) {
+ case FilterOperation::GRAYSCALE:
+ return TextureMapperShaderProgram::Texture | TextureMapperShaderProgram::GrayscaleFilter;
+ case FilterOperation::SEPIA:
+ return TextureMapperShaderProgram::Texture | TextureMapperShaderProgram::SepiaFilter;
+ case FilterOperation::SATURATE:
+ return TextureMapperShaderProgram::Texture | TextureMapperShaderProgram::SaturateFilter;
+ case FilterOperation::HUE_ROTATE:
+ return TextureMapperShaderProgram::Texture | TextureMapperShaderProgram::HueRotateFilter;
+ case FilterOperation::INVERT:
+ return TextureMapperShaderProgram::Texture | TextureMapperShaderProgram::InvertFilter;
+ case FilterOperation::BRIGHTNESS:
+ return TextureMapperShaderProgram::Texture | TextureMapperShaderProgram::BrightnessFilter;
+ case FilterOperation::CONTRAST:
+ return TextureMapperShaderProgram::Texture | TextureMapperShaderProgram::ContrastFilter;
+ case FilterOperation::OPACITY:
+ return TextureMapperShaderProgram::Texture | TextureMapperShaderProgram::OpacityFilter;
+ case FilterOperation::BLUR:
+ return TextureMapperShaderProgram::BlurFilter;
+ case FilterOperation::DROP_SHADOW:
+ return TextureMapperShaderProgram::AlphaBlur
+ | (pass ? TextureMapperShaderProgram::ContentTexture | TextureMapperShaderProgram::SolidColor: 0);
+ default:
+ ASSERT_NOT_REACHED();
+ return 0;
+ }
+}
- const BitmapTextureGL& textureGL = static_cast<const BitmapTextureGL&>(texture);
- drawTexture(textureGL.id(), textureGL.isOpaque() ? 0 : SupportsBlending, textureGL.size(), targetRect, matrix, opacity, mask, exposedEdges);
+static unsigned getPassesRequiredForFilter(FilterOperation::OperationType type)
+{
+ switch (type) {
+ case FilterOperation::GRAYSCALE:
+ case FilterOperation::SEPIA:
+ case FilterOperation::SATURATE:
+ case FilterOperation::HUE_ROTATE:
+ case FilterOperation::INVERT:
+ case FilterOperation::BRIGHTNESS:
+ case FilterOperation::CONTRAST:
+ case FilterOperation::OPACITY:
+#if ENABLE(CSS_SHADERS)
+ case FilterOperation::CUSTOM:
+ case FilterOperation::VALIDATED_CUSTOM:
+#endif
+ return 1;
+ case FilterOperation::BLUR:
+ case FilterOperation::DROP_SHADOW:
+ // We use two-passes (vertical+horizontal) for blur and drop-shadow.
+ return 2;
+ default:
+ return 0;
+ }
}
-#if !USE(TEXMAP_OPENGL_ES_2)
-void TextureMapperGL::drawTextureRectangleARB(uint32_t texture, Flags flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture)
+// Create a normal distribution of 21 values between -2 and 2.
+static const unsigned GaussianKernelHalfWidth = 11;
+static const float GaussianKernelStep = 0.2;
+
+static inline float gauss(float x)
{
- RefPtr<TextureMapperShaderProgram> program;
- if (maskTexture)
- program = data().sharedGLData().textureMapperShaderManager.getShaderProgram(TextureMapperShaderManager::MaskedRect);
- else
- program = data().sharedGLData().textureMapperShaderManager.getShaderProgram(TextureMapperShaderManager::Rect);
- m_context3D->useProgram(program->programID());
+ return exp(-(x * x) / 2.);
+}
- m_context3D->enableVertexAttribArray(program->vertexLocation());
- m_context3D->activeTexture(GraphicsContext3D::TEXTURE0);
- m_context3D->bindTexture(GL_TEXTURE_RECTANGLE_ARB, texture);
- m_context3D->uniform1i(program->samplerLocation(), 0);
+static float* gaussianKernel()
+{
+ static bool prepared = false;
+ static float kernel[GaussianKernelHalfWidth] = {0, };
- m_context3D->uniform1f(program->flipLocation(), !!(flags & ShouldFlipTexture));
- m_context3D->uniform2f(program->samplerSizeLocation(), textureSize.width(), textureSize.height());
- m_context3D->uniform1f(program->opacityLocation(), opacity);
+ if (prepared)
+ return kernel;
- if (maskTexture && maskTexture->isValid()) {
- const BitmapTextureGL* maskTextureGL = static_cast<const BitmapTextureGL*>(maskTexture);
- m_context3D->activeTexture(GraphicsContext3D::TEXTURE1);
- m_context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, maskTextureGL->id());
- m_context3D->uniform1i(program->maskLocation(), 1);
- m_context3D->activeTexture(GraphicsContext3D::TEXTURE0);
+ kernel[0] = gauss(0);
+ float sum = kernel[0];
+ for (unsigned i = 1; i < GaussianKernelHalfWidth; ++i) {
+ kernel[i] = gauss(i * GaussianKernelStep);
+ sum += 2 * kernel[i];
}
- bool needsBlending = (flags & SupportsBlending) || opacity < 0.99 || maskTexture;
- drawQuad(targetRect, modelViewMatrix, program.get(), GraphicsContext3D::TRIANGLE_FAN, needsBlending);
+ // Normalize the kernel.
+ float scale = 1 / sum;
+ for (unsigned i = 0; i < GaussianKernelHalfWidth; ++i)
+ kernel[i] *= scale;
+
+ prepared = true;
+ return kernel;
}
-#endif // !USE(TEXMAP_OPENGL_ES_2)
-void TextureMapperGL::drawTexture(uint32_t texture, Flags flags, const IntSize& /* textureSize */, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges)
+static void prepareFilterProgram(TextureMapperShaderProgram* program, const FilterOperation& operation, unsigned pass, const IntSize& size, GC3Duint contentTexture)
{
- bool needsAntialiasing = m_enableEdgeDistanceAntialiasing && !modelViewMatrix.isIntegerTranslation();
- if (needsAntialiasing && drawTextureWithAntialiasing(texture, flags, targetRect, modelViewMatrix, opacity, maskTexture, exposedEdges))
- return;
+ RefPtr<GraphicsContext3D> context = program->context();
+ context->useProgram(program->programID());
- RefPtr<TextureMapperShaderProgram> program;
- if (maskTexture)
- program = data().sharedGLData().textureMapperShaderManager.getShaderProgram(TextureMapperShaderManager::Masked);
- else
- program = data().sharedGLData().textureMapperShaderManager.getShaderProgram(TextureMapperShaderManager::Default);
- m_context3D->useProgram(program->programID());
+ switch (operation.getOperationType()) {
+ case FilterOperation::GRAYSCALE:
+ case FilterOperation::SEPIA:
+ case FilterOperation::SATURATE:
+ case FilterOperation::HUE_ROTATE:
+ context->uniform1f(program->filterAmountLocation(), static_cast<const BasicColorMatrixFilterOperation&>(operation).amount());
+ break;
+ case FilterOperation::INVERT:
+ case FilterOperation::BRIGHTNESS:
+ case FilterOperation::CONTRAST:
+ case FilterOperation::OPACITY:
+ context->uniform1f(program->filterAmountLocation(), static_cast<const BasicComponentTransferFilterOperation&>(operation).amount());
+ break;
+ case FilterOperation::BLUR: {
+ const BlurFilterOperation& blur = static_cast<const BlurFilterOperation&>(operation);
+ FloatSize radius;
- drawTexturedQuadWithProgram(program.get(), texture, flags, targetRect, modelViewMatrix, opacity, maskTexture);
+ // Blur is done in two passes, first horizontally and then vertically. The same shader is used for both.
+ if (pass)
+ radius.setHeight(floatValueForLength(blur.stdDeviation(), size.height()) / size.height());
+ else
+ radius.setWidth(floatValueForLength(blur.stdDeviation(), size.width()) / size.width());
+
+ context->uniform2f(program->blurRadiusLocation(), radius.width(), radius.height());
+ context->uniform1fv(program->gaussianKernelLocation(), GaussianKernelHalfWidth, gaussianKernel());
+ break;
+ }
+ case FilterOperation::DROP_SHADOW: {
+ const DropShadowFilterOperation& shadow = static_cast<const DropShadowFilterOperation&>(operation);
+ context->uniform1fv(program->gaussianKernelLocation(), GaussianKernelHalfWidth, gaussianKernel());
+ switch (pass) {
+ case 0:
+ // First pass: horizontal alpha blur.
+ context->uniform2f(program->blurRadiusLocation(), shadow.stdDeviation() / float(size.width()), 0);
+ context->uniform2f(program->shadowOffsetLocation(), float(shadow.location().x()) / float(size.width()), float(shadow.location().y()) / float(size.height()));
+ break;
+ case 1:
+ // Second pass: we need the shadow color and the content texture for compositing.
+ float r, g, b, a;
+ Color(premultipliedARGBFromColor(shadow.color())).getRGBA(r, g, b, a);
+ context->uniform4f(program->colorLocation(), r, g, b, a);
+ context->uniform2f(program->blurRadiusLocation(), 0, shadow.stdDeviation() / float(size.height()));
+ context->uniform2f(program->shadowOffsetLocation(), 0, 0);
+ context->activeTexture(GraphicsContext3D::TEXTURE1);
+ context->bindTexture(GraphicsContext3D::TEXTURE_2D, contentTexture);
+ context->uniform1i(program->contentTextureLocation(), 1);
+ break;
+ }
+ break;
+ }
+ default:
+ break;
+ }
}
+#endif
-void TextureMapperGL::drawSolidColor(const FloatRect& rect, const TransformationMatrix& matrix, const Color& color)
+void TextureMapperGL::drawTexture(const BitmapTexture& texture, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity, unsigned exposedEdges)
{
- RefPtr<TextureMapperShaderProgram> program = data().sharedGLData().textureMapperShaderManager.getShaderProgram(TextureMapperShaderManager::SolidColor);
- m_context3D->useProgram(program->programID());
+ if (!texture.isValid())
+ return;
- float r, g, b, a;
- color.getRGBA(r, g, b, a);
- m_context3D->uniform4f(program->colorLocation(), r, g, b, a);
+ if (clipStack().isCurrentScissorBoxEmpty())
+ return;
- drawQuad(rect, matrix, program.get(), GraphicsContext3D::TRIANGLE_FAN, false);
+ const BitmapTextureGL& textureGL = static_cast<const BitmapTextureGL&>(texture);
+#if ENABLE(CSS_FILTERS)
+ TemporaryChange<const BitmapTextureGL::FilterInfo*> filterInfo(data().filterInfo, textureGL.filterInfo());
+#endif
+
+ drawTexture(textureGL.id(), textureGL.isOpaque() ? 0 : ShouldBlend, textureGL.size(), targetRect, matrix, opacity, exposedEdges);
}
-static TransformationMatrix viewportMatrix(GraphicsContext3D* context3D)
+void TextureMapperGL::drawTexture(Platform3DObject texture, Flags flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, unsigned exposedEdges)
{
- GC3Dint viewport[4];
- context3D->getIntegerv(GraphicsContext3D::VIEWPORT, viewport);
+ bool useRect = flags & ShouldUseARBTextureRect;
+ bool useAntialiasing = m_enableEdgeDistanceAntialiasing
+ && exposedEdges == AllEdges
+ && !modelViewMatrix.mapQuad(targetRect).isRectilinear();
+
+ TextureMapperShaderProgram::Options options = TextureMapperShaderProgram::Texture;
+ if (useRect)
+ options |= TextureMapperShaderProgram::Rect;
+ if (opacity < 1)
+ options |= TextureMapperShaderProgram::Opacity;
+ if (useAntialiasing) {
+ options |= TextureMapperShaderProgram::Antialiasing;
+ flags |= ShouldAntialias;
+ }
- TransformationMatrix matrix;
- matrix.translate3d(viewport[0], viewport[1], 0);
- matrix.scale3d(viewport[2], viewport[3], 0);
+#if ENABLE(CSS_FILTERS)
+ RefPtr<FilterOperation> filter = data().filterInfo ? data().filterInfo->filter: 0;
+ GC3Duint filterContentTextureID = 0;
+
+ if (filter) {
+ if (data().filterInfo->contentTexture)
+ filterContentTextureID = toBitmapTextureGL(data().filterInfo->contentTexture.get())->id();
+ options |= optionsForFilterType(filter->getOperationType(), data().filterInfo->pass);
+ if (filter->affectsOpacity())
+ flags |= ShouldBlend;
+ }
+#endif
- // Map x, y and z to unit square from OpenGL normalized device
- // coordinates which are -1 to 1 on every axis.
- matrix.translate3d(0.5, 0.5, 0.5);
- matrix.scale3d(0.5, 0.5, 0.5);
+ if (useAntialiasing || opacity < 1)
+ flags |= ShouldBlend;
- return matrix;
-}
+ RefPtr<TextureMapperShaderProgram> program;
+ program = data().sharedGLData().getShaderProgram(options);
-static void scaleLineEquationCoeffecientsToOptimizeDistanceCalculation(float* coeffecients)
-{
- // In the fragment shader we want to calculate the distance from this
- // line to a point (p), which is given by the formula:
- // (A*p.x + B*p.y + C) / sqrt (a^2 + b^2)
- // We can do a small amount of precalculation here to reduce the
- // amount of math in the shader by scaling the coeffecients now.
- float scale = 1.0 / FloatPoint(coeffecients[0], coeffecients[1]).length();
- coeffecients[0] = coeffecients[0] * scale;
- coeffecients[1] = coeffecients[1] * scale;
- coeffecients[2] = coeffecients[2] * scale;
-}
+#if ENABLE(CSS_FILTERS)
+ if (filter)
+ prepareFilterProgram(program.get(), *filter.get(), data().filterInfo->pass, textureSize, filterContentTextureID);
+#endif
-static void getStandardEquationCoeffecientsForLine(const FloatPoint& p1, const FloatPoint& p2, float* coeffecients)
-{
- // Given two points, the standard equation of a line (Ax + By + C = 0)
- // can be calculated via the formula:
- // (p1.y – p2.y)x + (p1.x – p2.x)y + ((p1.x*p2.y) – (p2.x*p1.y)) = 0
- coeffecients[0] = p1.y() - p2.y();
- coeffecients[1] = p2.x() - p1.x();
- coeffecients[2] = p1.x() * p2.y() - p2.x() * p1.y();
- scaleLineEquationCoeffecientsToOptimizeDistanceCalculation(coeffecients);
+ drawTexturedQuadWithProgram(program.get(), texture, flags, textureSize, targetRect, modelViewMatrix, opacity);
}
-static void quadToEdgeArray(const FloatQuad& quad, float* edgeArray)
+void TextureMapperGL::drawSolidColor(const FloatRect& rect, const TransformationMatrix& matrix, const Color& color)
{
- if (quad.isCounterclockwise()) {
- getStandardEquationCoeffecientsForLine(quad.p4(), quad.p3(), edgeArray);
- getStandardEquationCoeffecientsForLine(quad.p3(), quad.p2(), edgeArray + 3);
- getStandardEquationCoeffecientsForLine(quad.p2(), quad.p1(), edgeArray + 6);
- getStandardEquationCoeffecientsForLine(quad.p1(), quad.p4(), edgeArray + 9);
- return;
+ Flags flags = 0;
+ TextureMapperShaderProgram::Options options = TextureMapperShaderProgram::SolidColor;
+ if (!matrix.mapQuad(rect).isRectilinear()) {
+ options |= TextureMapperShaderProgram::Antialiasing;
+ flags |= ShouldBlend | ShouldAntialias;
}
- getStandardEquationCoeffecientsForLine(quad.p4(), quad.p1(), edgeArray);
- getStandardEquationCoeffecientsForLine(quad.p1(), quad.p2(), edgeArray + 3);
- getStandardEquationCoeffecientsForLine(quad.p2(), quad.p3(), edgeArray + 6);
- getStandardEquationCoeffecientsForLine(quad.p3(), quad.p4(), edgeArray + 9);
-}
-static FloatSize scaledVectorDifference(const FloatPoint& point1, const FloatPoint& point2, float scale)
-{
- FloatSize vector = point1 - point2;
- if (vector.diagonalLengthSquared())
- vector.scale(1.0 / vector.diagonalLength());
+ RefPtr<TextureMapperShaderProgram> program = data().sharedGLData().getShaderProgram(options);
+ m_context3D->useProgram(program->programID());
+
+ float r, g, b, a;
+ Color(premultipliedARGBFromColor(color)).getRGBA(r, g, b, a);
+ m_context3D->uniform4f(program->colorLocation(), r, g, b, a);
+ if (a < 1)
+ flags |= ShouldBlend;
- vector.scale(scale);
- return vector;
+ draw(rect, matrix, program.get(), GraphicsContext3D::TRIANGLE_FAN, flags);
}
-static FloatQuad inflateQuad(const FloatQuad& quad, float distance)
+void TextureMapperGL::drawEdgeTriangles(TextureMapperShaderProgram* program)
{
- FloatQuad expandedQuad = quad;
- expandedQuad.setP1(expandedQuad.p1() + scaledVectorDifference(quad.p1(), quad.p2(), distance));
- expandedQuad.setP4(expandedQuad.p4() + scaledVectorDifference(quad.p4(), quad.p3(), distance));
-
- expandedQuad.setP1(expandedQuad.p1() + scaledVectorDifference(quad.p1(), quad.p4(), distance));
- expandedQuad.setP2(expandedQuad.p2() + scaledVectorDifference(quad.p2(), quad.p3(), distance));
-
- expandedQuad.setP2(expandedQuad.p2() + scaledVectorDifference(quad.p2(), quad.p1(), distance));
- expandedQuad.setP3(expandedQuad.p3() + scaledVectorDifference(quad.p3(), quad.p4(), distance));
+ const GC3Dfloat left = 0;
+ const GC3Dfloat top = 0;
+ const GC3Dfloat right = 1;
+ const GC3Dfloat bottom = 1;
+ const GC3Dfloat center = 0.5;
+
+// Each 4d triangle consists of a center point and two edge points, where the zw coordinates
+// of each vertex equals the nearest point to the vertex on the edge.
+#define SIDE_TRIANGLE_DATA(x1, y1, x2, y2) \
+ x1, y1, x1, y1, \
+ x2, y2, x2, y2, \
+ center, center, (x1 + x2) / 2, (y1 + y2) / 2
+
+ static const GC3Dfloat unitRectSideTriangles[] = {
+ SIDE_TRIANGLE_DATA(left, top, right, top),
+ SIDE_TRIANGLE_DATA(left, top, left, bottom),
+ SIDE_TRIANGLE_DATA(right, top, right, bottom),
+ SIDE_TRIANGLE_DATA(left, bottom, right, bottom)
+ };
+#undef SIDE_TRIANGLE_DATA
- expandedQuad.setP3(expandedQuad.p3() + scaledVectorDifference(quad.p3(), quad.p2(), distance));
- expandedQuad.setP4(expandedQuad.p4() + scaledVectorDifference(quad.p4(), quad.p1(), distance));
+ Platform3DObject vbo = data().getStaticVBO(GraphicsContext3D::ARRAY_BUFFER, sizeof(GC3Dfloat) * 48, unitRectSideTriangles);
+ m_context3D->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, vbo);
+ m_context3D->vertexAttribPointer(program->vertexLocation(), 4, GraphicsContext3D::FLOAT, false, 0, 0);
+ m_context3D->drawArrays(GraphicsContext3D::TRIANGLES, 0, 12);
+ m_context3D->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, 0);
+}
- return expandedQuad;
+void TextureMapperGL::drawUnitRect(TextureMapperShaderProgram* program, GC3Denum drawingMode)
+{
+ static const GC3Dfloat unitRect[] = { 0, 0, 1, 0, 1, 1, 0, 1 };
+ Platform3DObject vbo = data().getStaticVBO(GraphicsContext3D::ARRAY_BUFFER, sizeof(GC3Dfloat) * 8, unitRect);
+ m_context3D->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, vbo);
+ m_context3D->vertexAttribPointer(program->vertexLocation(), 2, GraphicsContext3D::FLOAT, false, 0, 0);
+ m_context3D->drawArrays(drawingMode, 0, 4);
+ m_context3D->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, 0);
}
-bool TextureMapperGL::drawTextureWithAntialiasing(uint32_t texture, Flags flags, const FloatRect& originalTargetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges)
+void TextureMapperGL::draw(const FloatRect& rect, const TransformationMatrix& modelViewMatrix, TextureMapperShaderProgram* shaderProgram, GC3Denum drawingMode, Flags flags)
{
- // The antialiasing path does not support mask textures at the moment.
- if (maskTexture)
- return false;
+ TransformationMatrix matrix =
+ TransformationMatrix(modelViewMatrix).multiply(TransformationMatrix::rectToRect(FloatRect(0, 0, 1, 1), rect));
- // For now we punt on rendering tiled layers with antialiasing. It's quite hard
- // to render them without seams.
- if (exposedEdges != AllEdges)
- return false;
+ m_context3D->enableVertexAttribArray(shaderProgram->vertexLocation());
+ shaderProgram->setMatrix(shaderProgram->modelViewMatrixLocation(), matrix);
+ shaderProgram->setMatrix(shaderProgram->projectionMatrixLocation(), data().projectionMatrix);
- // The goal here is render a slightly larger (0.75 pixels in screen space) quad and to
- // gradually taper off the alpha values to do a simple version of edge distance
- // antialiasing. Note here that we are also including the viewport matrix (which
- // translates from normalized device coordinates to screen coordinates), because these
- // values are consumed in the fragment shader, which works in screen coordinates.
- TransformationMatrix screenSpaceTransform = viewportMatrix(m_context3D.get()).multiply(TransformationMatrix(data().projectionMatrix)).multiply(modelViewMatrix).to2dTransform();
- if (!screenSpaceTransform.isInvertible())
- return false;
- FloatQuad quadInScreenSpace = screenSpaceTransform.mapQuad(originalTargetRect);
-
- const float inflationDistance = 0.75;
- FloatQuad expandedQuadInScreenSpace = inflateQuad(quadInScreenSpace, inflationDistance);
-
- // In the non-antialiased case the vertices passed are the unit rectangle and double
- // as the texture coordinates (0,0 1,0, 1,1 and 0,1). Here we map the expanded quad
- // coordinates in screen space back to the original rect's texture coordinates.
- // This has the effect of slightly increasing the size of the original quad's geometry
- // in the vertex shader.
- FloatQuad expandedQuadInTextureCoordinates = screenSpaceTransform.inverse().mapQuad(expandedQuadInScreenSpace);
- expandedQuadInTextureCoordinates.move(-originalTargetRect.x(), -originalTargetRect.y());
- expandedQuadInTextureCoordinates.scale(1 / originalTargetRect.width(), 1 / originalTargetRect.height());
-
- // We prepare both the expanded quad for the fragment shader as well as the rectangular bounding
- // box of that quad, as that seems necessary to properly antialias backfacing quads.
- float targetQuadEdges[24];
- quadToEdgeArray(expandedQuadInScreenSpace, targetQuadEdges);
- quadToEdgeArray(inflateQuad(quadInScreenSpace.boundingBox(), inflationDistance), targetQuadEdges + 12);
-
- RefPtr<TextureMapperShaderProgram> program = data().sharedGLData().textureMapperShaderManager.getShaderProgram(TextureMapperShaderManager::Antialiased);
- m_context3D->useProgram(program->programID());
- m_context3D->uniform3fv(program->expandedQuadEdgesInScreenSpaceLocation(), 8, targetQuadEdges);
+ if (isInMaskMode()) {
+ m_context3D->blendFunc(GraphicsContext3D::ZERO, GraphicsContext3D::SRC_ALPHA);
+ m_context3D->enable(GraphicsContext3D::BLEND);
+ } else {
+ if (flags & ShouldBlend) {
+ m_context3D->blendFunc(GraphicsContext3D::ONE, GraphicsContext3D::ONE_MINUS_SRC_ALPHA);
+ m_context3D->enable(GraphicsContext3D::BLEND);
+ } else
+ m_context3D->disable(GraphicsContext3D::BLEND);
+ }
- drawTexturedQuadWithProgram(program.get(), texture, flags, DrawQuad(originalTargetRect, expandedQuadInTextureCoordinates), modelViewMatrix, opacity, 0 /* maskTexture */);
- return true;
+ if (flags & ShouldAntialias)
+ drawEdgeTriangles(shaderProgram);
+ else
+ drawUnitRect(shaderProgram, drawingMode);
+
+ m_context3D->disableVertexAttribArray(shaderProgram->vertexLocation());
+ m_context3D->blendFunc(GraphicsContext3D::ONE, GraphicsContext3D::ONE_MINUS_SRC_ALPHA);
+ m_context3D->enable(GraphicsContext3D::BLEND);
}
-void TextureMapperGL::drawTexturedQuadWithProgram(TextureMapperShaderProgram* program, uint32_t texture, Flags flags, const DrawQuad& quadToDraw, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture)
+void TextureMapperGL::drawTexturedQuadWithProgram(TextureMapperShaderProgram* program, uint32_t texture, Flags flags, const IntSize& size, const FloatRect& rect, const TransformationMatrix& modelViewMatrix, float opacity)
{
- m_context3D->enableVertexAttribArray(program->vertexLocation());
+ m_context3D->useProgram(program->programID());
m_context3D->activeTexture(GraphicsContext3D::TEXTURE0);
- m_context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, texture);
+ GC3Denum target = flags & ShouldUseARBTextureRect ? GC3Denum(Extensions3D::TEXTURE_RECTANGLE_ARB) : GC3Denum(GraphicsContext3D::TEXTURE_2D);
+ m_context3D->bindTexture(target, texture);
m_context3D->uniform1i(program->samplerLocation(), 0);
+ if (wrapMode() == RepeatWrap) {
+ m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::REPEAT);
+ m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::REPEAT);
+ }
+
+ TransformationMatrix patternTransform = this->patternTransform();
+ if (flags & ShouldFlipTexture)
+ patternTransform.flipY();
+ if (flags & ShouldUseARBTextureRect)
+ patternTransform.scaleNonUniform(size.width(), size.height());
+ if (flags & ShouldFlipTexture)
+ patternTransform.translate(0, -1);
- m_context3D->uniform1f(program->flipLocation(), !!(flags & ShouldFlipTexture));
+ program->setMatrix(program->textureSpaceMatrixLocation(), patternTransform);
m_context3D->uniform1f(program->opacityLocation(), opacity);
- if (maskTexture && maskTexture->isValid()) {
- const BitmapTextureGL* maskTextureGL = static_cast<const BitmapTextureGL*>(maskTexture);
- m_context3D->activeTexture(GraphicsContext3D::TEXTURE1);
- m_context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, maskTextureGL->id());
- m_context3D->uniform1i(program->maskLocation(), 1);
- m_context3D->activeTexture(GraphicsContext3D::TEXTURE0);
- }
+ if (opacity < 1)
+ flags |= ShouldBlend;
- bool needsBlending = (flags & SupportsBlending) || opacity < 0.99 || maskTexture;
- drawQuad(quadToDraw, modelViewMatrix, program, GraphicsContext3D::TRIANGLE_FAN, needsBlending);
+ draw(rect, modelViewMatrix, program, GraphicsContext3D::TRIANGLE_FAN, flags);
+ m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE);
+ m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE);
}
BitmapTextureGL::BitmapTextureGL(TextureMapperGL* textureMapper)
@@ -649,24 +786,26 @@ static void swizzleBGRAToRGBA(uint32_t* data, const IntRect& rect, int stride =
}
}
-static bool driverSupportsBGRASwizzling()
+// If GL_EXT_texture_format_BGRA8888 is supported in the OpenGLES
+// internal and external formats need to be BGRA
+static bool driverSupportsExternalTextureBGRA(GraphicsContext3D* context)
{
-#if defined(TEXMAP_OPENGL_ES_2)
- // FIXME: Implement reliable detection. See also https://bugs.webkit.org/show_bug.cgi?id=81103.
- return false;
-#else
+ if (context->isGLES2Compliant()) {
+ static bool supportsExternalTextureBGRA = context->getExtensions()->supports("GL_EXT_texture_format_BGRA8888");
+ return supportsExternalTextureBGRA;
+ }
+
return true;
-#endif
}
-static bool driverSupportsSubImage()
+static bool driverSupportsSubImage(GraphicsContext3D* context)
{
-#if defined(TEXMAP_OPENGL_ES_2)
- // FIXME: Implement reliable detection.
- return false;
-#else
+ if (context->isGLES2Compliant()) {
+ static bool supportsSubImage = context->getExtensions()->supports("GL_EXT_unpack_subimage");
+ return supportsSubImage;
+ }
+
return true;
-#endif
}
void BitmapTextureGL::didReset()
@@ -678,7 +817,6 @@ void BitmapTextureGL::didReset()
if (m_textureSize == contentSize())
return;
- Platform3DObject format = driverSupportsBGRASwizzling() ? GraphicsContext3D::BGRA : GraphicsContext3D::RGBA;
m_textureSize = contentSize();
m_context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, m_id);
@@ -686,28 +824,36 @@ void BitmapTextureGL::didReset()
m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR);
m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE);
m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE);
- m_context3D->texImage2DDirect(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, m_textureSize.width(), m_textureSize.height(), 0, format, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, 0);
+
+ Platform3DObject internalFormat = GraphicsContext3D::RGBA;
+ Platform3DObject externalFormat = GraphicsContext3D::BGRA;
+ if (m_context3D->isGLES2Compliant()) {
+ if (driverSupportsExternalTextureBGRA(m_context3D.get()))
+ internalFormat = GraphicsContext3D::BGRA;
+ else
+ externalFormat = GraphicsContext3D::RGBA;
+ }
+
+ m_context3D->texImage2DDirect(GraphicsContext3D::TEXTURE_2D, 0, internalFormat, m_textureSize.width(), m_textureSize.height(), 0, externalFormat, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, 0);
}
void BitmapTextureGL::updateContentsNoSwizzle(const void* srcData, const IntRect& targetRect, const IntPoint& sourceOffset, int bytesPerLine, unsigned bytesPerPixel, Platform3DObject glFormat)
{
m_context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, m_id);
-#if !defined(TEXMAP_OPENGL_ES_2)
- if (driverSupportsSubImage()) { // For ES drivers that don't support sub-images.
+ if (driverSupportsSubImage(m_context3D.get())) { // For ES drivers that don't support sub-images.
// Use the OpenGL sub-image extension, now that we know it's available.
m_context3D->pixelStorei(GL_UNPACK_ROW_LENGTH, bytesPerLine / bytesPerPixel);
m_context3D->pixelStorei(GL_UNPACK_SKIP_ROWS, sourceOffset.y());
m_context3D->pixelStorei(GL_UNPACK_SKIP_PIXELS, sourceOffset.x());
}
-#endif
+
m_context3D->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, srcData);
-#if !defined(TEXMAP_OPENGL_ES_2)
- if (driverSupportsSubImage()) { // For ES drivers that don't support sub-images.
+
+ if (driverSupportsSubImage(m_context3D.get())) { // For ES drivers that don't support sub-images.
m_context3D->pixelStorei(GL_UNPACK_ROW_LENGTH, 0);
m_context3D->pixelStorei(GL_UNPACK_SKIP_ROWS, 0);
m_context3D->pixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
}
-#endif
}
void BitmapTextureGL::updateContents(const void* srcData, const IntRect& targetRect, const IntPoint& sourceOffset, int bytesPerLine, UpdateContentsFlag updateContentsFlag)
@@ -721,11 +867,11 @@ void BitmapTextureGL::updateContents(const void* srcData, const IntRect& targetR
IntPoint adjustedSourceOffset = sourceOffset;
// Texture upload requires subimage buffer if driver doesn't support subimage and we don't have full image upload.
- bool requireSubImageBuffer = !driverSupportsSubImage()
+ bool requireSubImageBuffer = !driverSupportsSubImage(m_context3D.get())
&& !(bytesPerLine == static_cast<int>(targetRect.width() * bytesPerPixel) && adjustedSourceOffset == IntPoint::zero());
// prepare temporaryData if necessary
- if ((!driverSupportsBGRASwizzling() && updateContentsFlag == UpdateCannotModifyOriginalImageData) || requireSubImageBuffer) {
+ if ((!driverSupportsExternalTextureBGRA(m_context3D.get()) && updateContentsFlag == UpdateCannotModifyOriginalImageData) || requireSubImageBuffer) {
temporaryData.resize(targetRect.width() * targetRect.height() * bytesPerPixel);
data = temporaryData.data();
const char* bits = static_cast<const char*>(srcData);
@@ -742,10 +888,10 @@ void BitmapTextureGL::updateContents(const void* srcData, const IntRect& targetR
adjustedSourceOffset = IntPoint(0, 0);
}
- if (driverSupportsBGRASwizzling())
+ if (driverSupportsExternalTextureBGRA(m_context3D.get()))
glFormat = GraphicsContext3D::BGRA;
else
- swizzleBGRAToRGBA(reinterpret_cast<uint32_t*>(data), IntRect(adjustedSourceOffset, targetRect.size()), bytesPerLine / bytesPerPixel);
+ swizzleBGRAToRGBA(reinterpret_cast_ptr<uint32_t*>(data), IntRect(adjustedSourceOffset, targetRect.size()), bytesPerLine / bytesPerPixel);
updateContentsNoSwizzle(data, targetRect, adjustedSourceOffset, bytesPerLine, bytesPerPixel, glFormat);
}
@@ -766,7 +912,7 @@ void BitmapTextureGL::updateContents(Image* image, const IntRect& targetRect, co
imageData = reinterpret_cast<const char*>(qImage.constBits());
bytesPerLine = qImage.bytesPerLine();
#elif USE(CAIRO)
- cairo_surface_t* surface = frameImage->surface();
+ cairo_surface_t* surface = frameImage.get();
imageData = reinterpret_cast<const char*>(cairo_image_surface_get_data(surface));
bytesPerLine = cairo_image_surface_get_stride(surface);
#endif
@@ -774,154 +920,6 @@ void BitmapTextureGL::updateContents(Image* image, const IntRect& targetRect, co
updateContents(imageData, targetRect, offset, bytesPerLine, updateContentsFlag);
}
-#if ENABLE(CSS_FILTERS)
-
-static TextureMapperShaderManager::ShaderKey keyForFilterType(FilterOperation::OperationType type, unsigned pass)
-{
- switch (type) {
- case FilterOperation::GRAYSCALE:
- return TextureMapperShaderManager::GrayscaleFilter;
- case FilterOperation::SEPIA:
- return TextureMapperShaderManager::SepiaFilter;
- case FilterOperation::SATURATE:
- return TextureMapperShaderManager::SaturateFilter;
- case FilterOperation::HUE_ROTATE:
- return TextureMapperShaderManager::HueRotateFilter;
- case FilterOperation::INVERT:
- return TextureMapperShaderManager::InvertFilter;
- case FilterOperation::BRIGHTNESS:
- return TextureMapperShaderManager::BrightnessFilter;
- case FilterOperation::CONTRAST:
- return TextureMapperShaderManager::ContrastFilter;
- case FilterOperation::OPACITY:
- return TextureMapperShaderManager::OpacityFilter;
- case FilterOperation::BLUR:
- return TextureMapperShaderManager::BlurFilter;
- case FilterOperation::DROP_SHADOW:
- return pass ? TextureMapperShaderManager::ShadowFilterPass2 : TextureMapperShaderManager::ShadowFilterPass1;
- default:
- ASSERT_NOT_REACHED();
- return TextureMapperShaderManager::Invalid;
- }
-}
-
-static unsigned getPassesRequiredForFilter(FilterOperation::OperationType type)
-{
- switch (type) {
- case FilterOperation::GRAYSCALE:
- case FilterOperation::SEPIA:
- case FilterOperation::SATURATE:
- case FilterOperation::HUE_ROTATE:
- case FilterOperation::INVERT:
- case FilterOperation::BRIGHTNESS:
- case FilterOperation::CONTRAST:
- case FilterOperation::OPACITY:
-#if ENABLE(CSS_SHADERS)
- case FilterOperation::CUSTOM:
- case FilterOperation::VALIDATED_CUSTOM:
-#endif
- return 1;
- case FilterOperation::BLUR:
- case FilterOperation::DROP_SHADOW:
- // We use two-passes (vertical+horizontal) for blur and drop-shadow.
- return 2;
- default:
- return 0;
- }
-}
-
-// Create a normal distribution of 21 values between -2 and 2.
-static const unsigned GaussianKernelHalfWidth = 11;
-static const float GaussianKernelStep = 0.2;
-
-static inline float gauss(float x)
-{
- return exp(-(x * x) / 2.);
-}
-
-static float* gaussianKernel()
-{
- static bool prepared = false;
- static float kernel[GaussianKernelHalfWidth] = {0, };
-
- if (prepared)
- return kernel;
-
- kernel[0] = gauss(0);
- float sum = kernel[0];
- for (unsigned i = 1; i < GaussianKernelHalfWidth; ++i) {
- kernel[i] = gauss(i * GaussianKernelStep);
- sum += 2 * kernel[i];
- }
-
- // Normalize the kernel.
- float scale = 1 / sum;
- for (unsigned i = 0; i < GaussianKernelHalfWidth; ++i)
- kernel[i] *= scale;
-
- prepared = true;
- return kernel;
-}
-
-static void prepareFilterProgram(TextureMapperShaderProgram* program, const FilterOperation& operation, unsigned pass, const IntSize& size, GC3Duint contentTexture)
-{
- RefPtr<GraphicsContext3D> context = program->context();
- context->useProgram(program->programID());
-
- switch (operation.getOperationType()) {
- case FilterOperation::GRAYSCALE:
- case FilterOperation::SEPIA:
- case FilterOperation::SATURATE:
- case FilterOperation::HUE_ROTATE:
- context->uniform1f(program->amountLocation(), static_cast<const BasicColorMatrixFilterOperation&>(operation).amount());
- break;
- case FilterOperation::INVERT:
- case FilterOperation::BRIGHTNESS:
- case FilterOperation::CONTRAST:
- case FilterOperation::OPACITY:
- context->uniform1f(program->amountLocation(), static_cast<const BasicComponentTransferFilterOperation&>(operation).amount());
- break;
- case FilterOperation::BLUR: {
- const BlurFilterOperation& blur = static_cast<const BlurFilterOperation&>(operation);
- FloatSize radius;
-
- // Blur is done in two passes, first horizontally and then vertically. The same shader is used for both.
- if (pass)
- radius.setHeight(floatValueForLength(blur.stdDeviation(), size.height()) / size.height());
- else
- radius.setWidth(floatValueForLength(blur.stdDeviation(), size.width()) / size.width());
-
- context->uniform2f(program->blurRadiusLocation(), radius.width(), radius.height());
- context->uniform1fv(program->gaussianKernelLocation(), GaussianKernelHalfWidth, gaussianKernel());
- break;
- }
- case FilterOperation::DROP_SHADOW: {
- const DropShadowFilterOperation& shadow = static_cast<const DropShadowFilterOperation&>(operation);
- context->uniform1fv(program->gaussianKernelLocation(), GaussianKernelHalfWidth, gaussianKernel());
- switch (pass) {
- case 0:
- // First pass: vertical alpha blur.
- context->uniform2f(program->shadowOffsetLocation(), float(shadow.location().x()) / float(size.width()), float(shadow.location().y()) / float(size.height()));
- context->uniform1f(program->blurRadiusLocation(), shadow.stdDeviation() / float(size.width()));
- break;
- case 1:
- // Second pass: we need the shadow color and the content texture for compositing.
- context->uniform1f(program->blurRadiusLocation(), shadow.stdDeviation() / float(size.height()));
- context->activeTexture(GraphicsContext3D::TEXTURE1);
- context->bindTexture(GraphicsContext3D::TEXTURE_2D, contentTexture);
- context->uniform1i(program->contentTextureLocation(), 1);
- float r, g, b, a;
- shadow.color().getRGBA(r, g, b, a);
- context->uniform4f(program->shadowColorLocation(), r, g, b, a);
- break;
- }
- break;
- }
- default:
- break;
- }
-}
-
#if ENABLE(CSS_SHADERS)
void TextureMapperGL::removeCachedCustomFilterProgram(CustomFilterProgram* program)
{
@@ -938,15 +936,11 @@ bool TextureMapperGL::drawUsingCustomFilter(BitmapTexture& target, const BitmapT
const CustomFilterOperation* customFilter = static_cast<const CustomFilterOperation*>(&filter);
RefPtr<CustomFilterProgram> program = customFilter->program();
renderer = CustomFilterRenderer::create(m_context3D, program->programType(), customFilter->parameters(),
- customFilter->meshRows(), customFilter->meshColumns(), customFilter->meshBoxType(), customFilter->meshType());
- RefPtr<CustomFilterCompiledProgram> compiledProgram;
- CustomFilterProgramMap::iterator iter = m_customFilterPrograms.find(program->programInfo());
- if (iter == m_customFilterPrograms.end()) {
- compiledProgram = CustomFilterCompiledProgram::create(m_context3D, program->vertexShaderString(), program->fragmentShaderString(), program->programType());
- m_customFilterPrograms.set(program->programInfo(), compiledProgram);
- } else
- compiledProgram = iter->value;
- renderer->setCompiledProgram(compiledProgram.release());
+ customFilter->meshRows(), customFilter->meshColumns(), customFilter->meshType());
+ CustomFilterProgramMap::AddResult result = m_customFilterPrograms.add(program->programInfo(), 0);
+ if (result.isNewEntry)
+ result.iterator->value = CustomFilterCompiledProgram::create(m_context3D, program->vertexShaderString(), program->fragmentShaderString(), program->programType());
+ renderer->setCompiledProgram(result.iterator->value);
break;
}
case FilterOperation::VALIDATED_CUSTOM: {
@@ -954,15 +948,12 @@ bool TextureMapperGL::drawUsingCustomFilter(BitmapTexture& target, const BitmapT
const ValidatedCustomFilterOperation* customFilter = static_cast<const ValidatedCustomFilterOperation*>(&filter);
RefPtr<CustomFilterValidatedProgram> program = customFilter->validatedProgram();
renderer = CustomFilterRenderer::create(m_context3D, program->programInfo().programType(), customFilter->parameters(),
- customFilter->meshRows(), customFilter->meshColumns(), customFilter->meshBoxType(), customFilter->meshType());
+ customFilter->meshRows(), customFilter->meshColumns(), customFilter->meshType());
RefPtr<CustomFilterCompiledProgram> compiledProgram;
- CustomFilterProgramMap::iterator iter = m_customFilterPrograms.find(program->programInfo());
- if (iter == m_customFilterPrograms.end()) {
- compiledProgram = CustomFilterCompiledProgram::create(m_context3D, program->validatedVertexShader(), program->validatedFragmentShader(), program->programInfo().programType());
- m_customFilterPrograms.set(program->programInfo(), compiledProgram);
- } else
- compiledProgram = iter->value;
- renderer->setCompiledProgram(compiledProgram.release());
+ CustomFilterProgramMap::AddResult result = m_customFilterPrograms.add(program->programInfo(), 0);
+ if (result.isNewEntry)
+ result.iterator->value = CustomFilterCompiledProgram::create(m_context3D, program->validatedVertexShader(), program->validatedFragmentShader(), program->programInfo().programType());
+ renderer->setCompiledProgram(result.iterator->value);
break;
}
default:
@@ -988,65 +979,79 @@ bool TextureMapperGL::drawUsingCustomFilter(BitmapTexture& target, const BitmapT
}
#endif
-void TextureMapperGL::drawFiltered(const BitmapTexture& sampler, const BitmapTexture& contentTexture, const FilterOperation& filter, int pass)
+#if ENABLE(CSS_FILTERS)
+void TextureMapperGL::drawFiltered(const BitmapTexture& sampler, const BitmapTexture* contentTexture, const FilterOperation& filter, int pass)
{
// For standard filters, we always draw the whole texture without transformations.
- TextureMapperShaderManager::ShaderKey key = keyForFilterType(filter.getOperationType(), pass);
- RefPtr<TextureMapperShaderProgram> program = data().sharedGLData().textureMapperShaderManager.getShaderProgram(key);
+ TextureMapperShaderProgram::Options options = optionsForFilterType(filter.getOperationType(), pass);
+ RefPtr<TextureMapperShaderProgram> program = data().sharedGLData().getShaderProgram(options);
ASSERT(program);
- prepareFilterProgram(program.get(), filter, pass, sampler.contentSize(), static_cast<const BitmapTextureGL&>(contentTexture).id());
+ prepareFilterProgram(program.get(), filter, pass, sampler.contentSize(), contentTexture ? static_cast<const BitmapTextureGL*>(contentTexture)->id() : 0);
+ FloatRect targetRect(IntPoint::zero(), sampler.contentSize());
+ drawTexturedQuadWithProgram(program.get(), static_cast<const BitmapTextureGL&>(sampler).id(), 0, IntSize(1, 1), targetRect, TransformationMatrix(), 1);
+}
- m_context3D->enableVertexAttribArray(program->vertexLocation());
- m_context3D->enableVertexAttribArray(program->texCoordLocation());
- m_context3D->activeTexture(GraphicsContext3D::TEXTURE0);
- m_context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, static_cast<const BitmapTextureGL&>(sampler).id());
- m_context3D->uniform1i(program->samplerLocation(), 0);
- const GC3Dfloat targetVertices[] = {-1, -1, 1, -1, 1, 1, -1, 1};
- const GC3Dfloat sourceVertices[] = {0, 0, 1, 0, 1, 1, 0, 1};
- m_context3D->vertexAttribPointer(program->vertexLocation(), 2, GraphicsContext3D::FLOAT, false, 0, GC3Dintptr(targetVertices));
- m_context3D->vertexAttribPointer(program->texCoordLocation(), 2, GraphicsContext3D::FLOAT, false, 0, GC3Dintptr(sourceVertices));
- m_context3D->disable(GraphicsContext3D::BLEND);
- m_context3D->drawArrays(GraphicsContext3D::TRIANGLE_FAN, 0, 4);
- m_context3D->disableVertexAttribArray(program->vertexLocation());
- m_context3D->disableVertexAttribArray(program->texCoordLocation());
+static bool isCustomFilter(FilterOperation::OperationType type)
+{
+#if ENABLE(CSS_SHADERS)
+ return type == FilterOperation::CUSTOM || type == FilterOperation::VALIDATED_CUSTOM;
+#else
+ return false;
+#endif
}
-PassRefPtr<BitmapTexture> BitmapTextureGL::applyFilters(TextureMapper* textureMapper, const BitmapTexture& contentTexture, const FilterOperations& filters)
+PassRefPtr<BitmapTexture> BitmapTextureGL::applyFilters(TextureMapper* textureMapper, const FilterOperations& filters)
{
- TextureMapperGL* textureMapperGL = static_cast<TextureMapperGL*>(textureMapper);
- RefPtr<BitmapTexture> previousSurface = textureMapperGL->data().currentSurface;
+ if (filters.isEmpty())
+ return this;
+
+ TextureMapperGL* texmapGL = static_cast<TextureMapperGL*>(textureMapper);
+ RefPtr<BitmapTexture> previousSurface = texmapGL->data().currentSurface;
+ RefPtr<BitmapTexture> resultSurface = this;
+ RefPtr<BitmapTexture> intermediateSurface;
+ RefPtr<BitmapTexture> spareSurface;
- RefPtr<BitmapTexture> source = this;
- RefPtr<BitmapTexture> target = textureMapper->acquireTextureFromPool(m_textureSize);
+ m_filterInfo = FilterInfo();
- bool useContentTexture = true;
for (size_t i = 0; i < filters.size(); ++i) {
- const FilterOperation* filter = filters.at(i);
+ RefPtr<FilterOperation> filter = filters.operations()[i];
ASSERT(filter);
+ bool custom = isCustomFilter(filter->getOperationType());
+
int numPasses = getPassesRequiredForFilter(filter->getOperationType());
for (int j = 0; j < numPasses; ++j) {
- textureMapperGL->bindSurface(target.get());
- const BitmapTexture& sourceTexture = useContentTexture ? contentTexture : *source;
+ bool last = (i == filters.size() - 1) && (j == numPasses - 1);
+ if (custom || !last) {
+ if (!intermediateSurface)
+ intermediateSurface = texmapGL->acquireTextureFromPool(contentSize());
+ texmapGL->bindSurface(intermediateSurface.get());
+ }
+
#if ENABLE(CSS_SHADERS)
- if (filter->getOperationType() == FilterOperation::CUSTOM || filter->getOperationType() == FilterOperation::VALIDATED_CUSTOM) {
- if (textureMapperGL->drawUsingCustomFilter(*target, sourceTexture, *filter)) {
- // Only swap if the draw was successful.
- std::swap(source, target);
- useContentTexture = false;
- }
+ if (custom) {
+ if (texmapGL->drawUsingCustomFilter(*intermediateSurface.get(), *resultSurface.get(), *filter))
+ std::swap(resultSurface, intermediateSurface);
continue;
}
#endif
- textureMapperGL->drawFiltered(sourceTexture, contentTexture, *filter, j);
- std::swap(source, target);
- useContentTexture = false;
+ if (last) {
+ toBitmapTextureGL(resultSurface.get())->m_filterInfo = BitmapTextureGL::FilterInfo(filter, j, spareSurface);
+ break;
+ }
+
+ texmapGL->drawFiltered(*resultSurface.get(), spareSurface.get(), *filter, j);
+ if (!j && filter->getOperationType() == FilterOperation::DROP_SHADOW) {
+ spareSurface = resultSurface;
+ resultSurface.clear();
+ }
+ std::swap(resultSurface, intermediateSurface);
}
}
- textureMapperGL->bindSurface(previousSurface.get());
- return source;
+ texmapGL->bindSurface(previousSurface.get());
+ return resultSurface;
}
#endif
@@ -1096,8 +1101,8 @@ void BitmapTextureGL::clearIfNeeded()
if (!m_shouldClear)
return;
- m_clipStack.init(IntRect(IntPoint::zero(), m_textureSize));
- m_clipStack.apply(m_context3D.get());
+ m_clipStack.reset(IntRect(IntPoint::zero(), m_textureSize), TextureMapperGL::ClipStack::DefaultYAxis);
+ m_clipStack.applyIfNeeded(m_context3D.get());
m_context3D->clearColor(0, 0, 0, 0);
m_context3D->clear(GraphicsContext3D::COLOR_BUFFER_BIT);
m_shouldClear = false;
@@ -1190,8 +1195,8 @@ bool TextureMapperGL::beginScissorClip(const TransformationMatrix& modelViewMatr
if (!quad.isRectilinear() || rect.isEmpty())
return false;
- clipStack().current().scissorBox.intersect(rect);
- clipStack().apply(m_context3D.get());
+ clipStack().intersect(rect);
+ clipStack().applyIfNeeded(m_context3D.get());
return true;
}
@@ -1203,35 +1208,19 @@ void TextureMapperGL::beginClip(const TransformationMatrix& modelViewMatrix, con
data().initializeStencil();
- RefPtr<TextureMapperShaderProgram> program = data().sharedGLData().textureMapperShaderManager.getShaderProgram(TextureMapperShaderManager::Default);
+ RefPtr<TextureMapperShaderProgram> program = data().sharedGLData().getShaderProgram(TextureMapperShaderProgram::SolidColor);
m_context3D->useProgram(program->programID());
m_context3D->enableVertexAttribArray(program->vertexLocation());
const GC3Dfloat unitRect[] = {0, 0, 1, 0, 1, 1, 0, 1};
m_context3D->vertexAttribPointer(program->vertexLocation(), 2, GraphicsContext3D::FLOAT, false, 0, GC3Dintptr(unitRect));
- TransformationMatrix matrix = TransformationMatrix(data().projectionMatrix)
- .multiply(modelViewMatrix)
- .multiply(TransformationMatrix(targetRect.width(), 0, 0, 0,
- 0, targetRect.height(), 0, 0,
- 0, 0, 1, 0,
- targetRect.x(), targetRect.y(), 0, 1));
-
- const GC3Dfloat m4[] = {
- matrix.m11(), matrix.m12(), matrix.m13(), matrix.m14(),
- matrix.m21(), matrix.m22(), matrix.m23(), matrix.m24(),
- matrix.m31(), matrix.m32(), matrix.m33(), matrix.m34(),
- matrix.m41(), matrix.m42(), matrix.m43(), matrix.m44()
- };
+ TransformationMatrix matrix = TransformationMatrix(modelViewMatrix)
+ .multiply(TransformationMatrix::rectToRect(FloatRect(0, 0, 1, 1), targetRect));
- const GC3Dfloat m4all[] = {
- 2, 0, 0, 0,
- 0, 2, 0, 0,
- 0, 0, 1, 0,
- -1, -1, 0, 1
- };
+ static const TransformationMatrix fullProjectionMatrix = TransformationMatrix::rectToRect(FloatRect(0, 0, 1, 1), FloatRect(-1, -1, 2, 2));
- int& stencilIndex = clipStack().current().stencilIndex;
+ int stencilIndex = clipStack().getStencilIndex();
m_context3D->enable(GraphicsContext3D::STENCIL_TEST);
@@ -1242,13 +1231,15 @@ void TextureMapperGL::beginClip(const TransformationMatrix& modelViewMatrix, con
m_context3D->stencilMask(0xff & ~(stencilIndex - 1));
// First clear the entire buffer at the current index.
- m_context3D->uniformMatrix4fv(program->matrixLocation(), 1, false, const_cast<GC3Dfloat*>(m4all));
+ program->setMatrix(program->projectionMatrixLocation(), fullProjectionMatrix);
+ program->setMatrix(program->modelViewMatrixLocation(), TransformationMatrix());
m_context3D->stencilOp(GraphicsContext3D::ZERO, GraphicsContext3D::ZERO, GraphicsContext3D::ZERO);
m_context3D->drawArrays(GraphicsContext3D::TRIANGLE_FAN, 0, 4);
// Now apply the current index to the new quad.
m_context3D->stencilOp(GraphicsContext3D::REPLACE, GraphicsContext3D::REPLACE, GraphicsContext3D::REPLACE);
- m_context3D->uniformMatrix4fv(program->matrixLocation(), 1, false, const_cast<GC3Dfloat*>(m4));
+ program->setMatrix(program->projectionMatrixLocation(), data().projectionMatrix);
+ program->setMatrix(program->modelViewMatrixLocation(), matrix);
m_context3D->drawArrays(GraphicsContext3D::TRIANGLE_FAN, 0, 4);
// Clear the state.
@@ -1256,14 +1247,19 @@ void TextureMapperGL::beginClip(const TransformationMatrix& modelViewMatrix, con
m_context3D->stencilMask(0);
// Increase stencilIndex and apply stencil testing.
- stencilIndex *= 2;
- clipStack().apply(m_context3D.get());
+ clipStack().setStencilIndex(stencilIndex * 2);
+ clipStack().applyIfNeeded(m_context3D.get());
}
void TextureMapperGL::endClip()
{
clipStack().pop();
- clipStack().apply(m_context3D.get());
+ clipStack().applyIfNeeded(m_context3D.get());
+}
+
+IntRect TextureMapperGL::clipBounds()
+{
+ return clipStack().current().scissorBox;
}
PassRefPtr<BitmapTexture> TextureMapperGL::createTexture()
@@ -1278,3 +1274,4 @@ PassOwnPtr<TextureMapper> TextureMapper::platformCreateAccelerated()
}
};
+#endif
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h b/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h
index cc556e4b1..18a5c4d6f 100644
--- a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h
@@ -20,9 +20,10 @@
#ifndef TextureMapperGL_h
#define TextureMapperGL_h
-#if USE(ACCELERATED_COMPOSITING)
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
#include "CustomFilterProgramInfo.h"
+#include "FilterOperation.h"
#include "FloatQuad.h"
#include "GraphicsContext3D.h"
#include "IntSize.h"
@@ -34,8 +35,8 @@ namespace WebCore {
class CustomFilterProgram;
class CustomFilterCompiledProgram;
class TextureMapperGLData;
-class GraphicsContext;
class TextureMapperShaderProgram;
+class FilterOperation;
// An OpenGL-ES2 implementation of TextureMapper.
class TextureMapperGL : public TextureMapper {
@@ -44,36 +45,33 @@ public:
virtual ~TextureMapperGL();
enum Flag {
- SupportsBlending = 0x01,
- ShouldFlipTexture = 0x02
+ ShouldBlend = 0x01,
+ ShouldFlipTexture = 0x02,
+ ShouldUseARBTextureRect = 0x04,
+ ShouldAntialias = 0x08
};
typedef int Flags;
// TextureMapper implementation
- virtual void drawBorder(const Color&, float borderWidth, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix = TransformationMatrix()) OVERRIDE;
- virtual void drawRepaintCounter(int value, int pointSize, const FloatPoint&, const TransformationMatrix& modelViewMatrix = TransformationMatrix()) OVERRIDE;
- virtual void drawTexture(const BitmapTexture&, const FloatRect&, const TransformationMatrix&, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges) OVERRIDE;
- virtual void drawTexture(uint32_t texture, Flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges = AllEdges);
+ virtual void drawBorder(const Color&, float borderWidth, const FloatRect&, const TransformationMatrix&) OVERRIDE;
+ virtual void drawNumber(int number, const Color&, const FloatPoint&, const TransformationMatrix&) OVERRIDE;
+ virtual void drawTexture(const BitmapTexture&, const FloatRect&, const TransformationMatrix&, float opacity, unsigned exposedEdges) OVERRIDE;
+ virtual void drawTexture(Platform3DObject texture, Flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, unsigned exposedEdges = AllEdges);
virtual void drawSolidColor(const FloatRect&, const TransformationMatrix&, const Color&) OVERRIDE;
-#if !USE(TEXMAP_OPENGL_ES_2)
- virtual void drawTextureRectangleARB(uint32_t texture, Flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture);
-#endif
-
virtual void bindSurface(BitmapTexture* surface) OVERRIDE;
virtual void beginClip(const TransformationMatrix&, const FloatRect&) OVERRIDE;
virtual void beginPainting(PaintFlags = 0) OVERRIDE;
virtual void endPainting() OVERRIDE;
virtual void endClip() OVERRIDE;
+ virtual IntRect clipBounds() OVERRIDE;
virtual IntSize maxTextureSize() const OVERRIDE { return IntSize(2000, 2000); }
virtual PassRefPtr<BitmapTexture> createTexture() OVERRIDE;
- virtual GraphicsContext* graphicsContext() OVERRIDE { return m_context; }
inline GraphicsContext3D* graphicsContext3D() const { return m_context3D.get(); }
- virtual void setGraphicsContext(GraphicsContext* context) OVERRIDE { m_context = context; }
#if ENABLE(CSS_FILTERS)
- void drawFiltered(const BitmapTexture& sourceTexture, const BitmapTexture& contentTexture, const FilterOperation&, int pass);
+ void drawFiltered(const BitmapTexture& sourceTexture, const BitmapTexture* contentTexture, const FilterOperation&, int pass);
#endif
#if ENABLE(CSS_SHADERS)
bool drawUsingCustomFilter(BitmapTexture& targetTexture, const BitmapTexture& sourceTexture, const FilterOperation&);
@@ -94,39 +92,53 @@ private:
class ClipStack {
public:
+ ClipStack()
+ : clipStateDirty(false)
+ { }
+
+ // Y-axis should be inverted only when painting into the window.
+ enum YAxisMode {
+ DefaultYAxis,
+ InvertedYAxis
+ };
+
void push();
void pop();
void apply(GraphicsContext3D*);
+ void applyIfNeeded(GraphicsContext3D*);
inline ClipState& current() { return clipState; }
- void init(const IntRect&);
+ void reset(const IntRect&, YAxisMode);
+ void intersect(const IntRect&);
+ void setStencilIndex(int);
+ inline int getStencilIndex() const
+ {
+ return clipState.stencilIndex;
+ }
+ inline bool isCurrentScissorBoxEmpty() const
+ {
+ return clipState.scissorBox.isEmpty();
+ }
private:
ClipState clipState;
Vector<ClipState> clipStack;
- };
-
- struct DrawQuad {
- DrawQuad(const FloatRect& originalTargetRect, const FloatQuad& targetRectMappedToUnitSquare = FloatRect(FloatPoint(), FloatSize(1, 1)))
- : originalTargetRect(originalTargetRect)
- , targetRectMappedToUnitSquare(targetRectMappedToUnitSquare)
- {
- }
-
- FloatRect originalTargetRect;
- FloatQuad targetRectMappedToUnitSquare;
+ bool clipStateDirty;
+ IntSize size;
+ YAxisMode yAxisMode;
};
TextureMapperGL();
- bool drawTextureWithAntialiasing(uint32_t texture, Flags, const FloatRect& originalTargetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges);
- void drawTexturedQuadWithProgram(TextureMapperShaderProgram*, uint32_t texture, Flags, const DrawQuad&, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture);
- void drawQuad(const DrawQuad&, const TransformationMatrix& modelViewMatrix, TextureMapperShaderProgram*, GC3Denum drawingMode, bool needsBlending);
+ void drawTexturedQuadWithProgram(TextureMapperShaderProgram*, uint32_t texture, Flags, const IntSize&, const FloatRect&, const TransformationMatrix& modelViewMatrix, float opacity);
+ void draw(const FloatRect&, const TransformationMatrix& modelViewMatrix, TextureMapperShaderProgram*, GC3Denum drawingMode, Flags);
+
+ void drawUnitRect(TextureMapperShaderProgram*, GC3Denum drawingMode);
+ void drawEdgeTriangles(TextureMapperShaderProgram*);
bool beginScissorClip(const TransformationMatrix&, const FloatRect&);
void bindDefaultSurface();
ClipStack& clipStack();
inline TextureMapperGLData& data() { return *m_data; }
- GraphicsContext* m_context;
RefPtr<GraphicsContext3D> m_context3D;
TextureMapperGLData* m_data;
ClipStack m_clipStack;
@@ -158,7 +170,19 @@ public:
virtual bool isBackedByOpenGL() const { return true; }
#if ENABLE(CSS_FILTERS)
- virtual PassRefPtr<BitmapTexture> applyFilters(TextureMapper*, const BitmapTexture& contentTexture, const FilterOperations&);
+ virtual PassRefPtr<BitmapTexture> applyFilters(TextureMapper*, const FilterOperations&) OVERRIDE;
+ struct FilterInfo {
+ RefPtr<FilterOperation> filter;
+ unsigned pass;
+ RefPtr<BitmapTexture> contentTexture;
+
+ FilterInfo(PassRefPtr<FilterOperation> f = 0, unsigned p = 0, PassRefPtr<BitmapTexture> t = 0)
+ : filter(f)
+ , pass(p)
+ , contentTexture(t)
+ { }
+ };
+ const FilterInfo* filterInfo() const { return &m_filterInfo; }
#endif
private:
@@ -180,6 +204,10 @@ private:
void clearIfNeeded();
void createFboIfNeeded();
+#if ENABLE(CSS_FILTERS)
+ FilterInfo m_filterInfo;
+#endif
+
friend class TextureMapperGL;
};
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.cpp
index e01ed3d9f..03273ba0f 100644
--- a/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.cpp
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.cpp
@@ -20,11 +20,11 @@
#include "config.h"
#include "TextureMapperImageBuffer.h"
-#include "FilterEffectRenderer.h"
#include "GraphicsLayer.h"
#if PLATFORM(QT)
#include "NativeImageQt.h"
#endif
+#include "NotImplemented.h"
#if USE(TEXTURE_MAPPER)
@@ -57,7 +57,7 @@ void BitmapTextureImageBuffer::updateContents(const void* data, const IntRect& t
#endif
}
-void BitmapTextureImageBuffer::updateContents(TextureMapper* textureMapper, GraphicsLayer* sourceLayer, const IntRect& targetRect, const IntPoint& sourceOffset, UpdateContentsFlag)
+void BitmapTextureImageBuffer::updateContents(TextureMapper*, GraphicsLayer* sourceLayer, const IntRect& targetRect, const IntPoint& sourceOffset, UpdateContentsFlag)
{
GraphicsContext* context = m_image->context();
@@ -66,6 +66,7 @@ void BitmapTextureImageBuffer::updateContents(TextureMapper* textureMapper, Grap
IntRect sourceRect(targetRect);
sourceRect.setLocation(sourceOffset);
context->save();
+ context->clip(targetRect);
context->translate(targetRect.x() - sourceOffset.x(), targetRect.y() - sourceOffset.y());
sourceLayer->paintGraphicsLayerContents(*context, sourceRect);
context->restore();
@@ -113,7 +114,7 @@ void TextureMapperImageBuffer::beginClip(const TransformationMatrix& matrix, con
#endif
}
-void TextureMapperImageBuffer::drawTexture(const BitmapTexture& texture, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity, const BitmapTexture* maskTexture, unsigned /* exposedEdges */)
+void TextureMapperImageBuffer::drawTexture(const BitmapTexture& texture, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity, unsigned /* exposedEdges */)
{
GraphicsContext* context = currentContext();
if (!context)
@@ -121,22 +122,8 @@ void TextureMapperImageBuffer::drawTexture(const BitmapTexture& texture, const F
const BitmapTextureImageBuffer& textureImageBuffer = static_cast<const BitmapTextureImageBuffer&>(texture);
ImageBuffer* image = textureImageBuffer.m_image.get();
- OwnPtr<ImageBuffer> maskedImage;
-
- if (maskTexture && maskTexture->isValid()) {
- const BitmapTextureImageBuffer* mask = static_cast<const BitmapTextureImageBuffer*>(maskTexture);
- maskedImage = ImageBuffer::create(maskTexture->contentSize());
- GraphicsContext* maskContext = maskedImage->context();
- maskContext->drawImageBuffer(image, ColorSpaceDeviceRGB, IntPoint::zero(), CompositeCopy);
- if (opacity < 1) {
- maskContext->setAlpha(opacity);
- opacity = 1;
- }
- maskContext->drawImageBuffer(mask->m_image.get(), ColorSpaceDeviceRGB, IntPoint::zero(), CompositeDestinationIn);
- image = maskedImage.get();
- }
-
context->save();
+ context->setCompositeOperation(isInMaskMode() ? CompositeDestinationIn : CompositeSourceOver);
context->setAlpha(opacity);
#if ENABLE(3D_RENDERING)
context->concat3DTransform(matrix);
@@ -154,6 +141,7 @@ void TextureMapperImageBuffer::drawSolidColor(const FloatRect& rect, const Trans
return;
context->save();
+ context->setCompositeOperation(isInMaskMode() ? CompositeDestinationIn : CompositeSourceOver);
#if ENABLE(3D_RENDERING)
context->concat3DTransform(matrix);
#else
@@ -164,20 +152,19 @@ void TextureMapperImageBuffer::drawSolidColor(const FloatRect& rect, const Trans
context->restore();
}
+void TextureMapperImageBuffer::drawBorder(const Color&, float /* borderWidth */, const FloatRect&, const TransformationMatrix&)
+{
+ notImplemented();
+}
+
+void TextureMapperImageBuffer::drawNumber(int /* number */, const Color&, const FloatPoint&, const TransformationMatrix&)
+{
+ notImplemented();
+}
+
#if ENABLE(CSS_FILTERS)
-PassRefPtr<BitmapTexture> BitmapTextureImageBuffer::applyFilters(TextureMapper*, const BitmapTexture& contentTexture, const FilterOperations& filters)
+PassRefPtr<BitmapTexture> BitmapTextureImageBuffer::applyFilters(TextureMapper*, const FilterOperations&)
{
- RefPtr<FilterEffectRenderer> renderer = FilterEffectRenderer::create();
- renderer->setSourceImageRect(FloatRect(FloatPoint::zero(), contentTexture.size()));
-
- // The document parameter is only needed for CSS shaders.
- if (renderer->build(0 /*document */, filters)) {
- renderer->allocateBackingStoreIfNeeded();
- GraphicsContext* context = renderer->inputContext();
- context->drawImageBuffer(static_cast<const BitmapTextureImageBuffer&>(contentTexture).m_image.get(), ColorSpaceDeviceRGB, IntPoint::zero());
- renderer->apply();
- m_image->context()->drawImageBuffer(renderer->output(), ColorSpaceDeviceRGB, renderer->outputRect());
- }
return this;
}
#endif
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.h b/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.h
index 9de6d4cbd..060713ce5 100644
--- a/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.h
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.h
@@ -38,7 +38,7 @@ public:
virtual void updateContents(TextureMapper*, GraphicsLayer*, const IntRect& target, const IntPoint& offset, UpdateContentsFlag);
virtual void updateContents(const void*, const IntRect& target, const IntPoint& sourceOffset, int bytesPerLine, UpdateContentsFlag);
#if ENABLE(CSS_FILTERS)
- PassRefPtr<BitmapTexture> applyFilters(TextureMapper*, const BitmapTexture&, const FilterOperations&);
+ PassRefPtr<BitmapTexture> applyFilters(TextureMapper*, const FilterOperations&);
#endif
private:
@@ -53,19 +53,14 @@ public:
static PassOwnPtr<TextureMapper> create() { return adoptPtr(new TextureMapperImageBuffer); }
// TextureMapper implementation
- virtual void drawBorder(const Color&, float /* borderWidth */, const FloatRect& /* targetRect */, const TransformationMatrix& modelViewMatrix = TransformationMatrix()) OVERRIDE
- {
- UNUSED_PARAM(modelViewMatrix);
- };
- virtual void drawRepaintCounter(int /* value */, int /* pointSize */, const FloatPoint&, const TransformationMatrix& modelViewMatrix = TransformationMatrix()) OVERRIDE
- {
- UNUSED_PARAM(modelViewMatrix);
- };
- virtual void drawTexture(const BitmapTexture&, const FloatRect& targetRect, const TransformationMatrix&, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges) OVERRIDE;
+ virtual void drawBorder(const Color&, float borderWidth, const FloatRect&, const TransformationMatrix&) OVERRIDE;
+ virtual void drawNumber(int number, const Color&, const FloatPoint&, const TransformationMatrix&) OVERRIDE;
+ virtual void drawTexture(const BitmapTexture&, const FloatRect& targetRect, const TransformationMatrix&, float opacity, unsigned exposedEdges) OVERRIDE;
virtual void drawSolidColor(const FloatRect&, const TransformationMatrix&, const Color&) OVERRIDE;
virtual void beginClip(const TransformationMatrix&, const FloatRect&) OVERRIDE;
virtual void bindSurface(BitmapTexture* surface) OVERRIDE { m_currentSurface = surface;}
virtual void endClip() OVERRIDE { graphicsContext()->restore(); }
+ virtual IntRect clipBounds() OVERRIDE { return currentContext()->clipBounds(); }
virtual IntSize maxTextureSize() const;
virtual PassRefPtr<BitmapTexture> createTexture() OVERRIDE { return BitmapTextureImageBuffer::create(); }
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp
index 40243335b..80c253543 100644
--- a/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp
@@ -20,16 +20,26 @@
#include "config.h"
#include "TextureMapperLayer.h"
-#if USE(ACCELERATED_COMPOSITING)
+#include "FloatQuad.h"
+#include "Region.h"
+#include <wtf/MathExtras.h>
-#include "GraphicsLayerTextureMapper.h"
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
namespace WebCore {
-TextureMapperLayer* toTextureMapperLayer(GraphicsLayer* layer)
-{
- return layer ? toGraphicsLayerTextureMapper(layer)->layer() : 0;
-}
+class TextureMapperPaintOptions {
+public:
+ RefPtr<BitmapTexture> surface;
+ float opacity;
+ TransformationMatrix transform;
+ IntSize offset;
+ TextureMapper* textureMapper;
+ TextureMapperPaintOptions()
+ : opacity(1)
+ , textureMapper(0)
+ { }
+};
const TextureMapperLayer* TextureMapperLayer::rootLayer() const
{
@@ -40,38 +50,23 @@ const TextureMapperLayer* TextureMapperLayer::rootLayer() const
return this;
}
-void TextureMapperLayer::setTransform(const TransformationMatrix& matrix)
-{
- m_transform.setLocalTransform(matrix);
-}
-
-void TextureMapperLayer::clearBackingStoresRecursive()
-{
- m_backingStore.clear();
- m_contentsLayer = 0;
- for (size_t i = 0; i < m_children.size(); ++i)
- m_children[i]->clearBackingStoresRecursive();
- if (m_state.maskLayer)
- m_state.maskLayer->clearBackingStoresRecursive();
-}
-
void TextureMapperLayer::computeTransformsRecursive()
{
- if (m_size.isEmpty() && m_state.masksToBounds)
+ if (m_state.size.isEmpty() && m_state.masksToBounds)
return;
// Compute transforms recursively on the way down to leafs.
TransformationMatrix parentTransform;
if (m_parent)
- parentTransform = m_parent->m_transform.combinedForChildren();
+ parentTransform = m_parent->m_currentTransform.combinedForChildren();
else if (m_effectTarget)
- parentTransform = m_effectTarget->m_transform.combined();
- m_transform.combineTransforms(parentTransform);
+ parentTransform = m_effectTarget->m_currentTransform.combined();
+ m_currentTransform.combineTransforms(parentTransform);
- m_state.visible = m_state.backfaceVisibility || !m_transform.combined().isBackFaceVisible();
+ m_state.visible = m_state.backfaceVisibility || !m_currentTransform.combined().isBackFaceVisible();
if (m_parent && m_parent->m_state.preserves3D)
- m_centerZ = m_transform.combined().mapPoint(FloatPoint3D(m_size.width() / 2, m_size.height() / 2, 0)).z();
+ m_centerZ = m_currentTransform.combined().mapPoint(FloatPoint3D(m_state.size.width() / 2, m_state.size.height() / 2, 0)).z();
if (m_state.maskLayer)
m_state.maskLayer->computeTransformsRecursive();
@@ -82,7 +77,7 @@ void TextureMapperLayer::computeTransformsRecursive()
// Reorder children if needed on the way back up.
if (m_state.preserves3D)
- sortByZOrder(m_children, 0, m_children.size());
+ sortByZOrder(m_children);
}
void TextureMapperLayer::paint()
@@ -95,6 +90,26 @@ void TextureMapperLayer::paint()
paintRecursive(options);
}
+static Color blendWithOpacity(const Color& color, float opacity)
+{
+ RGBA32 rgba = color.rgb();
+ // See Color::getRGBA() to know how to extract alpha from color.
+ float alpha = alphaChannel(rgba) / 255.;
+ float effectiveAlpha = alpha * opacity;
+ return Color(colorWithOverrideAlpha(rgba, effectiveAlpha));
+}
+
+void TextureMapperLayer::computePatternTransformIfNeeded()
+{
+ if (!m_patternTransformDirty)
+ return;
+
+ m_patternTransformDirty = false;
+ m_patternTransform =
+ TransformationMatrix::rectToRect(FloatRect(FloatPoint::zero(), m_state.contentsTileSize), m_state.contentsRect)
+ .multiply(TransformationMatrix().translate(m_state.contentsTilePhase.x() / m_state.contentsRect.width(), m_state.contentsTilePhase.y() / m_state.contentsRect.height()));
+}
+
void TextureMapperLayer::paintSelf(const TextureMapperPaintOptions& options)
{
if (!m_state.visible || !m_state.contentsVisible)
@@ -104,21 +119,42 @@ void TextureMapperLayer::paintSelf(const TextureMapperPaintOptions& options)
TransformationMatrix transform;
transform.translate(options.offset.width(), options.offset.height());
transform.multiply(options.transform);
- transform.multiply(m_transform.combined());
+ transform.multiply(m_currentTransform.combined());
- float opacity = options.opacity;
- RefPtr<BitmapTexture> mask = options.mask;
+ if (m_state.solidColor.isValid() && !m_state.contentsRect.isEmpty() && m_state.solidColor.alpha()) {
+ options.textureMapper->drawSolidColor(m_state.contentsRect, transform, blendWithOpacity(m_state.solidColor, options.opacity));
+ if (m_state.showDebugBorders)
+ options.textureMapper->drawBorder(m_state.debugBorderColor, m_state.debugBorderWidth, layerRect(), transform);
+ return;
+ }
+
+ options.textureMapper->setWrapMode(TextureMapper::StretchWrap);
+ options.textureMapper->setPatternTransform(TransformationMatrix());
if (m_backingStore) {
- ASSERT(m_state.drawsContent && m_state.contentsVisible && !m_size.isEmpty());
- ASSERT(!layerRect().isEmpty());
- m_backingStore->paintToTextureMapper(options.textureMapper, layerRect(), transform, opacity, mask.get());
+ FloatRect targetRect = layerRect();
+ ASSERT(!targetRect.isEmpty());
+ m_backingStore->paintToTextureMapper(options.textureMapper, targetRect, transform, options.opacity);
+ if (m_state.showDebugBorders)
+ m_backingStore->drawBorder(options.textureMapper, m_state.debugBorderColor, m_state.debugBorderWidth, targetRect, transform);
+ // Only draw repaint count for the main backing store.
+ if (m_state.showRepaintCounter)
+ m_backingStore->drawRepaintCounter(options.textureMapper, m_state.repaintCount, m_state.debugBorderColor, targetRect, transform);
}
- if (m_contentsLayer) {
- ASSERT(!layerRect().isEmpty());
- m_contentsLayer->paintToTextureMapper(options.textureMapper, m_state.contentsRect, transform, opacity, mask.get());
+ if (!m_contentsLayer)
+ return;
+
+ if (!m_state.contentsTileSize.isEmpty()) {
+ computePatternTransformIfNeeded();
+ options.textureMapper->setWrapMode(TextureMapper::RepeatWrap);
+ options.textureMapper->setPatternTransform(m_patternTransform);
}
+
+ ASSERT(!layerRect().isEmpty());
+ m_contentsLayer->paintToTextureMapper(options.textureMapper, m_state.contentsRect, transform, options.opacity);
+ if (m_state.showDebugBorders)
+ m_contentsLayer->drawBorder(options.textureMapper, m_state.debugBorderColor, m_state.debugBorderWidth, m_state.contentsRect, transform);
}
int TextureMapperLayer::compareGraphicsLayersZValue(const void* a, const void* b)
@@ -128,7 +164,7 @@ int TextureMapperLayer::compareGraphicsLayersZValue(const void* a, const void* b
return int(((*layerA)->m_centerZ - (*layerB)->m_centerZ) * 1000);
}
-void TextureMapperLayer::sortByZOrder(Vector<TextureMapperLayer* >& array, int /* first */, int /* last */)
+void TextureMapperLayer::sortByZOrder(Vector<TextureMapperLayer* >& array)
{
qsort(array.data(), array.size(), sizeof(TextureMapperLayer*), compareGraphicsLayersZValue);
}
@@ -141,8 +177,13 @@ void TextureMapperLayer::paintSelfAndChildren(const TextureMapperPaintOptions& o
return;
bool shouldClip = m_state.masksToBounds && !m_state.preserves3D;
- if (shouldClip)
- options.textureMapper->beginClip(TransformationMatrix(options.transform).multiply(m_transform.combined()), layerRect());
+ if (shouldClip) {
+ TransformationMatrix clipTransform;
+ clipTransform.translate(options.offset.width(), options.offset.height());
+ clipTransform.multiply(options.transform);
+ clipTransform.multiply(m_currentTransform.combined());
+ options.textureMapper->beginClip(clipTransform, layerRect());
+ }
for (size_t i = 0; i < m_children.size(); ++i)
m_children[i]->paintRecursive(options);
@@ -151,97 +192,26 @@ void TextureMapperLayer::paintSelfAndChildren(const TextureMapperPaintOptions& o
options.textureMapper->endClip();
}
-IntRect TextureMapperLayer::intermediateSurfaceRect()
-{
- // FIXME: Add an inverse transform to LayerTransform.
- return intermediateSurfaceRect(m_transform.combined().inverse());
-}
-
-IntRect TextureMapperLayer::intermediateSurfaceRect(const TransformationMatrix& matrix)
-{
- IntRect rect;
- TransformationMatrix localTransform = TransformationMatrix(matrix).multiply(m_transform.combined());
- rect = enclosingIntRect(localTransform.mapRect(layerRect()));
- if (!m_state.masksToBounds && !m_state.maskLayer) {
- for (size_t i = 0; i < m_children.size(); ++i)
- rect.unite(m_children[i]->intermediateSurfaceRect(matrix));
- }
-
-#if ENABLE(CSS_FILTERS)
- if (m_filters.hasOutsets()) {
- int leftOutset;
- int topOutset;
- int bottomOutset;
- int rightOutset;
- m_filters.getOutsets(topOutset, rightOutset, bottomOutset, leftOutset);
- IntRect unfilteredTargetRect(rect);
- rect.move(std::max(0, -leftOutset), std::max(0, -topOutset));
- rect.expand(leftOutset + rightOutset, topOutset + bottomOutset);
- rect.unite(unfilteredTargetRect);
- }
-#endif
-
- if (m_state.replicaLayer)
- rect.unite(m_state.replicaLayer->intermediateSurfaceRect(matrix));
-
- return rect;
-}
-
-TextureMapperLayer::ContentsLayerCount TextureMapperLayer::countPotentialLayersWithContents() const
-{
- int selfLayersWithContents = (m_state.drawsContent ? 1 : 0) + (m_contentsLayer ? 1 : 0);
- int potentialLayersWithContents = selfLayersWithContents + m_children.size();
-
- if (!potentialLayersWithContents)
- return NoLayersWithContent;
-
- if (potentialLayersWithContents > 1)
- return MultipleLayersWithContents;
-
- if (m_children.isEmpty())
- return SingleLayerWithContents;
-
- return m_children.first()->countPotentialLayersWithContents();
-}
-
-bool TextureMapperLayer::shouldPaintToIntermediateSurface() const
+bool TextureMapperLayer::shouldBlend() const
{
-#if ENABLE(CSS_FILTERS)
- if (m_filters.size())
- return true;
-#endif
- bool hasOpacity = m_opacity < 0.99;
- bool canHaveMultipleLayersWithContent = countPotentialLayersWithContents() == MultipleLayersWithContents;
- bool hasReplica = !!m_state.replicaLayer;
- bool hasMask = !!m_state.maskLayer;
-
- // We don't use two-pass blending for preserves-3d, that's in sync with Safari.
if (m_state.preserves3D)
return false;
- // We should use an intermediate surface when blending several items with an ancestor opacity.
- // Tested by compositing/reflections/reflection-opacity.html
- if (hasOpacity && (canHaveMultipleLayersWithContent || hasReplica))
- return true;
-
- // We should use an intermediate surface with a masked ancestor.
- // In the case of replicas the mask is applied before replicating.
- // Tested by compositing/masks/masked-ancestor.html
- if (hasMask && canHaveMultipleLayersWithContent && !hasReplica)
- return true;
-
- return false;
+ return m_currentOpacity < 1
+ || hasFilters()
+ || m_state.maskLayer
+ || (m_state.replicaLayer && m_state.replicaLayer->m_state.maskLayer);
}
bool TextureMapperLayer::isVisible() const
{
- if (m_size.isEmpty() && (m_state.masksToBounds || m_state.maskLayer || m_children.isEmpty()))
+ if (m_state.size.isEmpty() && (m_state.masksToBounds || m_state.maskLayer || m_children.isEmpty()))
return false;
if (!m_state.visible && m_children.isEmpty())
return false;
if (!m_state.contentsVisible && m_children.isEmpty())
return false;
- if (m_opacity < 0.01)
+ if (m_currentOpacity < 0.01)
return false;
return true;
}
@@ -250,92 +220,241 @@ void TextureMapperLayer::paintSelfAndChildrenWithReplica(const TextureMapperPain
{
if (m_state.replicaLayer) {
TextureMapperPaintOptions replicaOptions(options);
- // We choose either the content's mask or the replica's mask.
- // FIXME: blend the two if both exist.
- if (m_state.replicaLayer->m_state.maskLayer)
- replicaOptions.mask = m_state.replicaLayer->m_state.maskLayer->texture();
-
replicaOptions.transform
- .multiply(m_state.replicaLayer->m_transform.combined())
- .multiply(m_transform.combined().inverse());
+ .multiply(m_state.replicaLayer->m_currentTransform.combined())
+ .multiply(m_currentTransform.combined().inverse());
paintSelfAndChildren(replicaOptions);
}
paintSelfAndChildren(options);
}
-#if ENABLE(CSS_FILTERS)
-static bool shouldKeepContentTexture(const FilterOperations& filters)
+void TextureMapperLayer::setAnimatedTransform(const TransformationMatrix& matrix)
{
- for (size_t i = 0; i < filters.size(); ++i) {
- switch (filters.operations().at(i)->getOperationType()) {
- // The drop-shadow filter requires the content texture, because it needs to composite it
- // on top of the blurred shadow color.
- case FilterOperation::DROP_SHADOW:
- return true;
- default:
- break;
- }
- }
+ m_currentTransform.setLocalTransform(matrix);
+}
- return false;
+void TextureMapperLayer::setAnimatedOpacity(float opacity)
+{
+ m_currentOpacity = opacity;
}
-static PassRefPtr<BitmapTexture> applyFilters(const FilterOperations& filters, TextureMapper* textureMapper, BitmapTexture* source, IntRect& targetRect)
+TransformationMatrix TextureMapperLayer::replicaTransform()
{
- if (!filters.size())
- return source;
+ return TransformationMatrix(m_state.replicaLayer->m_currentTransform.combined()).multiply(m_currentTransform.combined().inverse());
+}
- RefPtr<BitmapTexture> filterSurface = shouldKeepContentTexture(filters) ? textureMapper->acquireTextureFromPool(source->size()) : source;
- return filterSurface->applyFilters(textureMapper, *source, filters);
+#if ENABLE(CSS_FILTERS)
+void TextureMapperLayer::setAnimatedFilters(const FilterOperations& filters)
+{
+ m_currentFilters = filters;
}
#endif
-void TextureMapperLayer::paintRecursive(const TextureMapperPaintOptions& options)
+static void resolveOverlaps(Region newRegion, Region& overlapRegion, Region& nonOverlapRegion)
{
- if (!isVisible())
+ Region newOverlapRegion(newRegion);
+ newOverlapRegion.intersect(nonOverlapRegion);
+ nonOverlapRegion.subtract(newOverlapRegion);
+ overlapRegion.unite(newOverlapRegion);
+ newRegion.subtract(overlapRegion);
+ nonOverlapRegion.unite(newRegion);
+}
+
+void TextureMapperLayer::computeOverlapRegions(Region& overlapRegion, Region& nonOverlapRegion, ResolveSelfOverlapMode mode)
+{
+ if (!m_state.visible || !m_state.contentsVisible)
return;
- float opacity = options.opacity * m_opacity;
- RefPtr<BitmapTexture> maskTexture = m_state.maskLayer ? m_state.maskLayer->texture() : 0;
+ FloatRect boundingRect;
+ if (m_backingStore || m_state.masksToBounds || m_state.maskLayer || hasFilters())
+ boundingRect = layerRect();
+ else if (m_contentsLayer || m_state.solidColor.alpha())
+ boundingRect = m_state.contentsRect;
- TextureMapperPaintOptions paintOptions(options);
- paintOptions.mask = maskTexture.get();
+#if ENABLE(CSS_FILTERS)
+ if (m_currentFilters.hasOutsets()) {
+ FilterOutsets outsets = m_currentFilters.outsets();
+ IntRect unfilteredTargetRect(boundingRect);
+ boundingRect.move(std::max(0, -outsets.left()), std::max(0, -outsets.top()));
+ boundingRect.expand(outsets.left() + outsets.right(), outsets.top() + outsets.bottom());
+ boundingRect.unite(unfilteredTargetRect);
+ }
+#endif
- if (!shouldPaintToIntermediateSurface()) {
- paintOptions.opacity = opacity;
- paintSelfAndChildrenWithReplica(paintOptions);
+ TransformationMatrix replicaMatrix;
+ if (m_state.replicaLayer) {
+ replicaMatrix = replicaTransform();
+ boundingRect.unite(replicaMatrix.mapRect(boundingRect));
+ }
+
+ boundingRect = m_currentTransform.combined().mapRect(boundingRect);
+
+ // Count all masks and filters as overlap layers.
+ if (hasFilters() || m_state.maskLayer || (m_state.replicaLayer && m_state.replicaLayer->m_state.maskLayer)) {
+ Region newOverlapRegion(enclosingIntRect(boundingRect));
+ nonOverlapRegion.subtract(newOverlapRegion);
+ overlapRegion.unite(newOverlapRegion);
return;
}
- // Prepare a surface to paint into.
- // We paint into the surface ignoring the opacity/transform of the current layer.
- IntRect surfaceRect = intermediateSurfaceRect();
- RefPtr<BitmapTexture> surface = options.textureMapper->acquireTextureFromPool(surfaceRect.size());
- paintOptions.surface = surface;
- options.textureMapper->bindSurface(surface.get());
- paintOptions.opacity = 1;
+ Region newOverlapRegion;
+ Region newNonOverlapRegion(enclosingIntRect(boundingRect));
- paintOptions.transform = m_transform.combined().inverse();
- paintOptions.offset = -IntSize(surfaceRect.x(), surfaceRect.y());
+ if (!m_state.masksToBounds) {
+ for (size_t i = 0; i < m_children.size(); ++i) {
+ TextureMapperLayer* child = m_children[i];
+ child->computeOverlapRegions(newOverlapRegion, newNonOverlapRegion, ResolveSelfOverlapIfNeeded);
+ }
+ }
- paintSelfAndChildrenWithReplica(paintOptions);
+ if (m_state.replicaLayer) {
+ newOverlapRegion.unite(replicaMatrix.mapRect(newOverlapRegion.bounds()));
+ Region replicaRegion(replicaMatrix.mapRect(newNonOverlapRegion.bounds()));
+ resolveOverlaps(replicaRegion, newOverlapRegion, newNonOverlapRegion);
+ }
- // If we painted the replica, the mask is already applied so we don't need to paint it again.
- if (m_state.replicaLayer)
- maskTexture = 0;
+ if ((mode != ResolveSelfOverlapAlways) && shouldBlend()) {
+ newNonOverlapRegion.unite(newOverlapRegion);
+ newOverlapRegion = Region();
+ }
+
+ overlapRegion.unite(newOverlapRegion);
+ resolveOverlaps(newNonOverlapRegion, overlapRegion, nonOverlapRegion);
+}
+
+void TextureMapperLayer::paintUsingOverlapRegions(const TextureMapperPaintOptions& options)
+{
+ Region overlapRegion;
+ Region nonOverlapRegion;
+ computeOverlapRegions(overlapRegion, nonOverlapRegion, ResolveSelfOverlapAlways);
+ if (overlapRegion.isEmpty()) {
+ paintSelfAndChildrenWithReplica(options);
+ return;
+ }
+
+ // Having both overlap and non-overlap regions carries some overhead. Avoid it if the overlap area
+ // is big anyway.
+ if (overlapRegion.bounds().size().area() > nonOverlapRegion.bounds().size().area()) {
+ overlapRegion.unite(nonOverlapRegion);
+ nonOverlapRegion = Region();
+ }
+
+ nonOverlapRegion.translate(options.offset);
+ Vector<IntRect> rects = nonOverlapRegion.rects();
+
+ for (size_t i = 0; i < rects.size(); ++i) {
+ IntRect rect = rects[i];
+ if (!rect.intersects(options.textureMapper->clipBounds()))
+ continue;
+
+ options.textureMapper->beginClip(TransformationMatrix(), rects[i]);
+ paintSelfAndChildrenWithReplica(options);
+ options.textureMapper->endClip();
+ }
+
+ rects = overlapRegion.rects();
+ static const size_t OverlapRegionConsolidationThreshold = 4;
+ if (nonOverlapRegion.isEmpty() && rects.size() > OverlapRegionConsolidationThreshold) {
+ rects.clear();
+ rects.append(overlapRegion.bounds());
+ }
+
+ IntSize maxTextureSize = options.textureMapper->maxTextureSize();
+ IntRect adjustedClipBounds(options.textureMapper->clipBounds());
+ adjustedClipBounds.move(-options.offset);
+ for (size_t i = 0; i < rects.size(); ++i) {
+ IntRect rect = rects[i];
+ for (int x = rect.x(); x < rect.maxX(); x += maxTextureSize.width()) {
+ for (int y = rect.y(); y < rect.maxY(); y += maxTextureSize.height()) {
+ IntRect tileRect(IntPoint(x, y), maxTextureSize);
+ tileRect.intersect(rect);
+ if (!tileRect.intersects(adjustedClipBounds))
+ continue;
+
+ paintWithIntermediateSurface(options, tileRect);
+ }
+ }
+ }
+}
+void TextureMapperLayer::applyMask(const TextureMapperPaintOptions& options)
+{
+ options.textureMapper->setMaskMode(true);
+ paintSelf(options);
+ options.textureMapper->setMaskMode(false);
+}
+
+PassRefPtr<BitmapTexture> TextureMapperLayer::paintIntoSurface(const TextureMapperPaintOptions& options, const IntSize& size)
+{
+ RefPtr<BitmapTexture> surface = options.textureMapper->acquireTextureFromPool(size);
+ TextureMapperPaintOptions paintOptions(options);
+ paintOptions.surface = surface;
+ options.textureMapper->bindSurface(surface.get());
+ paintSelfAndChildren(paintOptions);
+ if (m_state.maskLayer)
+ m_state.maskLayer->applyMask(options);
#if ENABLE(CSS_FILTERS)
- surface = applyFilters(m_filters, options.textureMapper, surface.get(), surfaceRect);
+ surface = surface->applyFilters(options.textureMapper, m_currentFilters);
#endif
+ options.textureMapper->bindSurface(surface.get());
+ return surface;
+}
+static void commitSurface(const TextureMapperPaintOptions& options, PassRefPtr<BitmapTexture> surface, const IntRect& rect, float opacity)
+{
options.textureMapper->bindSurface(options.surface.get());
TransformationMatrix targetTransform;
targetTransform.translate(options.offset.width(), options.offset.height());
targetTransform.multiply(options.transform);
- targetTransform.multiply(m_transform.combined());
+ options.textureMapper->drawTexture(*surface.get(), rect, targetTransform, opacity);
+}
+
+void TextureMapperLayer::paintWithIntermediateSurface(const TextureMapperPaintOptions& options, const IntRect& rect)
+{
+ RefPtr<BitmapTexture> replicaSurface;
+ RefPtr<BitmapTexture> mainSurface;
+ TextureMapperPaintOptions paintOptions(options);
+ paintOptions.offset = -IntSize(rect.x(), rect.y());
+ paintOptions.opacity = 1;
+ paintOptions.transform = TransformationMatrix();
+ if (m_state.replicaLayer) {
+ paintOptions.transform = replicaTransform();
+ replicaSurface = paintIntoSurface(paintOptions, rect.size());
+ paintOptions.transform = TransformationMatrix();
+ if (m_state.replicaLayer->m_state.maskLayer)
+ m_state.replicaLayer->m_state.maskLayer->applyMask(paintOptions);
+ }
+
+ if (replicaSurface && options.opacity == 1) {
+ commitSurface(options, replicaSurface, rect, 1);
+ replicaSurface.clear();
+ }
+
+ mainSurface = paintIntoSurface(paintOptions, rect.size());
+ if (replicaSurface) {
+ options.textureMapper->bindSurface(replicaSurface.get());
+ options.textureMapper->drawTexture(*mainSurface.get(), FloatRect(FloatPoint::zero(), rect.size()));
+ mainSurface = replicaSurface;
+ }
+
+ commitSurface(options, mainSurface, rect, options.opacity);
+}
- options.textureMapper->drawTexture(*surface.get(), surfaceRect, targetTransform, opacity, maskTexture.get());
+void TextureMapperLayer::paintRecursive(const TextureMapperPaintOptions& options)
+{
+ if (!isVisible())
+ return;
+
+ TextureMapperPaintOptions paintOptions(options);
+ paintOptions.opacity *= m_currentOpacity;
+
+ if (!shouldBlend()) {
+ paintSelfAndChildrenWithReplica(paintOptions);
+ return;
+ }
+
+ paintUsingOverlapRegions(paintOptions);
}
TextureMapperLayer::~TextureMapperLayer()
@@ -352,98 +471,195 @@ TextureMapper* TextureMapperLayer::textureMapper() const
return rootLayer()->m_textureMapper;
}
-void TextureMapperLayer::flushCompositingState(GraphicsLayerTextureMapper* graphicsLayer, int options)
+void TextureMapperLayer::setChildren(const Vector<TextureMapperLayer*>& newChildren)
{
- flushCompositingState(graphicsLayer, textureMapper(), options);
+ removeAllChildren();
+ for (size_t i = 0; i < newChildren.size(); ++i)
+ addChild(newChildren[i]);
}
-void TextureMapperLayer::flushCompositingStateSelf(GraphicsLayerTextureMapper* graphicsLayer, TextureMapper*)
+void TextureMapperLayer::addChild(TextureMapperLayer* childLayer)
{
- int changeMask = graphicsLayer->changeMask();
+ ASSERT(childLayer != this);
- if (changeMask == NoChanges && graphicsLayer->m_animations.isEmpty())
- return;
+ if (childLayer->m_parent)
+ childLayer->removeFromParent();
- graphicsLayer->updateDebugIndicators();
+ childLayer->m_parent = this;
+ m_children.append(childLayer);
+}
- if (changeMask & ParentChange) {
- TextureMapperLayer* newParent = toTextureMapperLayer(graphicsLayer->parent());
- if (newParent != m_parent) {
- // Remove layer from current from child list first.
- if (m_parent) {
- size_t index = m_parent->m_children.find(this);
- m_parent->m_children.remove(index);
- m_parent = 0;
- }
- // Set new layer parent and add layer to the parents child list.
- if (newParent) {
- m_parent = newParent;
- m_parent->m_children.append(this);
+void TextureMapperLayer::removeFromParent()
+{
+ if (m_parent) {
+ unsigned i;
+ for (i = 0; i < m_parent->m_children.size(); i++) {
+ if (this == m_parent->m_children[i]) {
+ m_parent->m_children.remove(i);
+ break;
}
}
+
+ m_parent = 0;
}
+}
- if (changeMask & ChildrenChange) {
- // Clear children parent pointer to avoid unsync and crash on layer delete.
- for (size_t i = 0; i < m_children.size(); i++)
- m_children[i]->m_parent = 0;
-
- m_children.clear();
- for (size_t i = 0; i < graphicsLayer->children().size(); ++i) {
- TextureMapperLayer* child = toTextureMapperLayer(graphicsLayer->children()[i]);
- if (!child)
- continue;
- m_children.append(child);
- child->m_parent = this;
- }
+void TextureMapperLayer::removeAllChildren()
+{
+ while (m_children.size()) {
+ TextureMapperLayer* curLayer = m_children[0];
+ ASSERT(curLayer->m_parent);
+ curLayer->removeFromParent();
}
+}
- m_size = graphicsLayer->size();
+void TextureMapperLayer::setMaskLayer(TextureMapperLayer* maskLayer)
+{
+ if (maskLayer)
+ maskLayer->m_effectTarget = this;
+ m_state.maskLayer = maskLayer;
+}
- if ((changeMask & DrawsContentChange) && graphicsLayer->drawsContent())
- graphicsLayer->setNeedsDisplay();
+void TextureMapperLayer::setReplicaLayer(TextureMapperLayer* replicaLayer)
+{
+ if (replicaLayer)
+ replicaLayer->m_effectTarget = this;
+ m_state.replicaLayer = replicaLayer;
+}
- if (changeMask & MaskLayerChange) {
- if (TextureMapperLayer* layer = toTextureMapperLayer(graphicsLayer->maskLayer()))
- layer->m_effectTarget = this;
- }
+void TextureMapperLayer::setPosition(const FloatPoint& position)
+{
+ m_state.pos = position;
+ m_currentTransform.setPosition(adjustedPosition());
+}
- if (changeMask & ReplicaLayerChange) {
- if (TextureMapperLayer* layer = toTextureMapperLayer(graphicsLayer->replicaLayer()))
- layer->m_effectTarget = this;
- }
+void TextureMapperLayer::setSize(const FloatSize& size)
+{
+ m_state.size = size;
+ m_currentTransform.setSize(size);
+}
+
+void TextureMapperLayer::setAnchorPoint(const FloatPoint3D& anchorPoint)
+{
+ m_state.anchorPoint = anchorPoint;
+ m_currentTransform.setAnchorPoint(anchorPoint);
+}
+
+void TextureMapperLayer::setPreserves3D(bool preserves3D)
+{
+ m_state.preserves3D = preserves3D;
+ m_currentTransform.setFlattening(!preserves3D);
+}
+
+void TextureMapperLayer::setTransform(const TransformationMatrix& transform)
+{
+ m_state.transform = transform;
+ m_currentTransform.setLocalTransform(transform);
+}
+
+void TextureMapperLayer::setChildrenTransform(const TransformationMatrix& childrenTransform)
+{
+ m_state.childrenTransform = childrenTransform;
+ m_currentTransform.setChildrenTransform(childrenTransform);
+}
+
+void TextureMapperLayer::setContentsRect(const IntRect& contentsRect)
+{
+ if (contentsRect == m_state.contentsRect)
+ return;
+ m_state.contentsRect = contentsRect;
+ m_patternTransformDirty = true;
+}
+
+void TextureMapperLayer::setContentsTileSize(const IntSize& size)
+{
+ if (size == m_state.contentsTileSize)
+ return;
+ m_state.contentsTileSize = size;
+ m_patternTransformDirty = true;
+}
+
+void TextureMapperLayer::setContentsTilePhase(const IntPoint& phase)
+{
+ if (phase == m_state.contentsTilePhase)
+ return;
+ m_state.contentsTilePhase = phase;
+ m_patternTransformDirty = true;
+}
+
+void TextureMapperLayer::setMasksToBounds(bool masksToBounds)
+{
+ m_state.masksToBounds = masksToBounds;
+}
+
+void TextureMapperLayer::setDrawsContent(bool drawsContent)
+{
+ m_state.drawsContent = drawsContent;
+}
+
+void TextureMapperLayer::setContentsVisible(bool contentsVisible)
+{
+ m_state.contentsVisible = contentsVisible;
+}
+
+void TextureMapperLayer::setContentsOpaque(bool contentsOpaque)
+{
+ m_state.contentsOpaque = contentsOpaque;
+}
+
+void TextureMapperLayer::setBackfaceVisibility(bool backfaceVisibility)
+{
+ m_state.backfaceVisibility = backfaceVisibility;
+}
+
+void TextureMapperLayer::setOpacity(float opacity)
+{
+ m_state.opacity = opacity;
+}
+
+void TextureMapperLayer::setSolidColor(const Color& color)
+{
+ m_state.solidColor = color;
+}
- if (changeMask & AnimationChange)
- m_animations = graphicsLayer->m_animations;
-
- m_state.maskLayer = toTextureMapperLayer(graphicsLayer->maskLayer());
- m_state.replicaLayer = toTextureMapperLayer(graphicsLayer->replicaLayer());
- m_state.pos = graphicsLayer->position();
- m_state.anchorPoint = graphicsLayer->anchorPoint();
- m_state.size = graphicsLayer->size();
- m_state.transform = graphicsLayer->transform();
- m_state.contentsRect = graphicsLayer->contentsRect();
- m_state.preserves3D = graphicsLayer->preserves3D();
- m_state.masksToBounds = graphicsLayer->masksToBounds();
- m_state.drawsContent = graphicsLayer->drawsContent();
- m_state.contentsVisible = graphicsLayer->contentsAreVisible();
- m_state.contentsOpaque = graphicsLayer->contentsOpaque();
- m_state.backfaceVisibility = graphicsLayer->backfaceVisibility();
- m_state.childrenTransform = graphicsLayer->childrenTransform();
- m_state.opacity = graphicsLayer->opacity();
#if ENABLE(CSS_FILTERS)
- if (changeMask & FilterChange)
- m_state.filters = graphicsLayer->filters();
+void TextureMapperLayer::setFilters(const FilterOperations& filters)
+{
+ m_state.filters = filters;
+}
#endif
- m_fixedToViewport = graphicsLayer->fixedToViewport();
- m_contentsLayer = graphicsLayer->platformLayer();
+void TextureMapperLayer::setDebugVisuals(bool showDebugBorders, const Color& debugBorderColor, float debugBorderWidth, bool showRepaintCounter)
+{
+ m_state.showDebugBorders = showDebugBorders;
+ m_state.debugBorderColor = debugBorderColor;
+ m_state.debugBorderWidth = debugBorderWidth;
+ m_state.showRepaintCounter = showRepaintCounter;
+}
+
+void TextureMapperLayer::setRepaintCount(int repaintCount)
+{
+ m_state.repaintCount = repaintCount;
+}
- m_transform.setPosition(adjustedPosition());
- m_transform.setAnchorPoint(m_state.anchorPoint);
- m_transform.setSize(m_state.size);
- m_transform.setFlattening(!m_state.preserves3D);
- m_transform.setChildrenTransform(m_state.childrenTransform);
+void TextureMapperLayer::setContentsLayer(TextureMapperPlatformLayer* platformLayer)
+{
+ m_contentsLayer = platformLayer;
+}
+
+void TextureMapperLayer::setAnimations(const GraphicsLayerAnimations& animations)
+{
+ m_animations = animations;
+}
+
+void TextureMapperLayer::setFixedToViewport(bool fixedToViewport)
+{
+ m_fixedToViewport = fixedToViewport;
+}
+
+void TextureMapperLayer::setBackingStore(PassRefPtr<TextureMapperBackingStore> backingStore)
+{
+ m_backingStore = backingStore;
}
bool TextureMapperLayer::descendantsOrSelfHaveRunningAnimations() const
@@ -470,48 +686,16 @@ void TextureMapperLayer::syncAnimations()
{
m_animations.apply(this);
if (!m_animations.hasActiveAnimationsOfType(AnimatedPropertyWebkitTransform))
- setTransform(m_state.transform);
+ m_currentTransform.setLocalTransform(m_state.transform);
if (!m_animations.hasActiveAnimationsOfType(AnimatedPropertyOpacity))
- setOpacity(m_state.opacity);
+ m_currentOpacity = m_state.opacity;
+
#if ENABLE(CSS_FILTERS)
if (!m_animations.hasActiveAnimationsOfType(AnimatedPropertyWebkitFilter))
- setFilters(m_state.filters);
+ m_currentFilters = m_state.filters;
#endif
}
-void TextureMapperLayer::flushCompositingState(GraphicsLayerTextureMapper* graphicsLayer, TextureMapper* textureMapper, int options)
-{
- if (!textureMapper)
- return;
-
- if (graphicsLayer && !(options & ComputationsOnly))
- flushCompositingStateSelf(graphicsLayer, textureMapper);
-
- if (graphicsLayer && m_state.maskLayer)
- m_state.maskLayer->flushCompositingState(toGraphicsLayerTextureMapper(graphicsLayer->maskLayer()), textureMapper);
-
- if (m_state.replicaLayer)
- m_state.replicaLayer->flushCompositingState(toGraphicsLayerTextureMapper(graphicsLayer->replicaLayer()), textureMapper);
-
- syncAnimations();
-
- if (!(options & TraverseDescendants))
- options = ComputationsOnly;
-
- if (graphicsLayer) {
- Vector<GraphicsLayer*> children = graphicsLayer->children();
- for (int i = children.size() - 1; i >= 0; --i) {
- TextureMapperLayer* layer = toTextureMapperLayer(children[i]);
- if (!layer)
- continue;
- layer->flushCompositingState(toGraphicsLayerTextureMapper(children[i]), textureMapper, options);
- }
- } else {
- for (int i = m_children.size() - 1; i >= 0; --i)
- m_children[i]->flushCompositingState(0, textureMapper, options);
- }
-}
-
bool TextureMapperLayer::isAncestorFixedToViewport() const
{
for (TextureMapperLayer* parent = m_parent; parent; parent = parent->m_parent) {
@@ -532,7 +716,80 @@ void TextureMapperLayer::setScrollPositionDeltaIfNeeded(const FloatSize& delta)
m_scrollPositionDelta = FloatSize();
else
m_scrollPositionDelta = delta;
- m_transform.setPosition(adjustedPosition());
+ m_currentTransform.setPosition(adjustedPosition());
+}
+
+template<class HitTestCondition> TextureMapperLayer* TextureMapperLayer::hitTest(const FloatPoint& point, HitTestCondition condition)
+{
+ if (!m_state.visible || !m_state.contentsVisible)
+ return 0;
+
+ TextureMapperLayer* result = 0;
+ for (int i = m_children.size() - 1; !result && i >= 0; --i)
+ result = m_children[i]->hitTest(point, condition);
+
+ if (result)
+ return result;
+
+ return condition(this, point) ? this : 0;
+}
+
+bool TextureMapperLayer::scrollableLayerHitTestCondition(TextureMapperLayer* layer, const FloatPoint& point)
+{
+ // scrolling layer's m_parent->m_parent, the parent of the scrolling layes, is the one that defines the
+ // rectangle to be used for hit testing.
+ if (!layer->isScrollable() || !layer->m_parent || !layer->m_parent->m_parent)
+ return false;
+
+ TextureMapperLayer* parentLayer = layer->m_parent->m_parent;
+ FloatRect rect = parentLayer->layerRect();
+ return parentLayer->m_currentTransform.combined().mapQuad(rect).containsPoint(point);
+}
+
+TextureMapperLayer* TextureMapperLayer::findScrollableContentsLayerAt(const FloatPoint& point)
+{
+ return hitTest(point, &TextureMapperLayer::scrollableLayerHitTestCondition);
+}
+
+FloatSize TextureMapperLayer::mapScrollOffset(const FloatSize& offset)
+{
+ double zeroX, zeroY, offsetX, offsetY;
+ TransformationMatrix transform = m_currentTransform.combined().inverse();
+ transform.map(0, 0, zeroX, zeroY);
+ transform.map(offset.width(), offset.height(), offsetX, offsetY);
+ return FloatSize(offsetX - zeroX, offsetY - zeroY);
+}
+
+void TextureMapperLayer::commitScrollOffset(const FloatSize& offset)
+{
+ FloatSize fullOffset = m_accumulatedScrollOffsetFractionalPart + offset;
+
+ int intWidth = round(fullOffset.width());
+ int intHeight = round(fullOffset.height());
+
+ // m_accumulatedScrollOffsetFractionalPart holds the fractional part of the user scroll offset that
+ // has not yet been synced with the web process because the web process expects an IntSize.
+ m_accumulatedScrollOffsetFractionalPart = FloatSize(fullOffset.width() - intWidth, fullOffset.height() - intHeight);
+
+ m_scrollClient->commitScrollOffset(m_id, IntSize(intWidth, intHeight));
+}
+
+void TextureMapperLayer::scrollBy(const FloatSize& offset)
+{
+ if (!isScrollable() || !m_scrollClient || offset.isZero())
+ return;
+
+ FloatSize scrollOffset = mapScrollOffset(offset);
+ m_userScrollOffset += scrollOffset;
+
+ m_currentTransform.setPosition(adjustedPosition());
+ commitScrollOffset(scrollOffset);
+}
+
+void TextureMapperLayer::didCommitScrollOffset(const IntSize& offset)
+{
+ m_userScrollOffset = FloatSize(m_userScrollOffset.width() - offset.width(), m_userScrollOffset.height() - offset.height());
+ m_currentTransform.setPosition(adjustedPosition());
}
}
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h b/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h
index 27a77f6fe..7b62b0a0b 100644
--- a/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h
@@ -20,11 +20,10 @@
#ifndef TextureMapperLayer_h
#define TextureMapperLayer_h
-#if USE(ACCELERATED_COMPOSITING)
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
#include "FilterOperations.h"
#include "FloatRect.h"
-#include "GraphicsLayer.h"
#include "GraphicsLayerAnimation.h"
#include "GraphicsLayerTransform.h"
#include "TextureMapper.h"
@@ -32,132 +31,145 @@
namespace WebCore {
+class Region;
+class TextureMapperPaintOptions;
class TextureMapperPlatformLayer;
-class GraphicsLayerTextureMapper;
-
-class TextureMapperPaintOptions {
-public:
- RefPtr<BitmapTexture> surface;
- RefPtr<BitmapTexture> mask;
- float opacity;
- TransformationMatrix transform;
- IntSize offset;
- TextureMapper* textureMapper;
- TextureMapperPaintOptions()
- : opacity(1)
- , textureMapper(0)
- { }
-};
class TextureMapperLayer : public GraphicsLayerAnimation::Client {
+ WTF_MAKE_NONCOPYABLE(TextureMapperLayer);
WTF_MAKE_FAST_ALLOCATED;
public:
- // This set of flags help us defer which properties of the layer have been
- // modified by the compositor, so we can know what to look for in the next flush.
- enum ChangeMask {
- NoChanges = 0,
-
- ParentChange = (1L << 0),
- ChildrenChange = (1L << 1),
- MaskLayerChange = (1L << 2),
- PositionChange = (1L << 3),
-
- AnchorPointChange = (1L << 4),
- SizeChange = (1L << 5),
- TransformChange = (1L << 6),
- ContentChange = (1L << 7),
-
- ContentsOrientationChange = (1L << 9),
- OpacityChange = (1L << 10),
- ContentsRectChange = (1L << 11),
-
- Preserves3DChange = (1L << 12),
- MasksToBoundsChange = (1L << 13),
- DrawsContentChange = (1L << 14),
- ContentsVisibleChange = (1L << 15),
- ContentsOpaqueChange = (1L << 16),
-
- BackfaceVisibilityChange = (1L << 17),
- ChildrenTransformChange = (1L << 18),
- DisplayChange = (1L << 19),
- BackgroundColorChange = (1L << 20),
-
- ReplicaLayerChange = (1L << 21),
- AnimationChange = (1L << 22),
- FilterChange = (1L << 23)
- };
- enum SyncOptions {
- TraverseDescendants = 1,
- ComputationsOnly = 2
+ class ScrollingClient {
+ public:
+ virtual void commitScrollOffset(uint32_t layerID, const IntSize& offset) = 0;
};
TextureMapperLayer()
: m_parent(0)
, m_effectTarget(0)
, m_contentsLayer(0)
- , m_opacity(1)
+ , m_currentOpacity(1)
, m_centerZ(0)
, m_textureMapper(0)
+ , m_fixedToViewport(false)
+ , m_id(0)
+ , m_scrollClient(0)
+ , m_isScrollable(false)
+ , m_patternTransformDirty(false)
{ }
virtual ~TextureMapperLayer();
+ void setID(uint32_t id) { m_id = id; }
+ uint32_t id() { return m_id; }
+
+ const Vector<TextureMapperLayer*>& children() const { return m_children; }
+ TextureMapperLayer* findScrollableContentsLayerAt(const FloatPoint& pos);
+
+ void setScrollClient(ScrollingClient* scrollClient) { m_scrollClient = scrollClient; }
+ void scrollBy(const WebCore::FloatSize&);
+
+ void didCommitScrollOffset(const IntSize&);
+ void setIsScrollable(bool isScrollable) { m_isScrollable = isScrollable; }
+ bool isScrollable() const { return m_isScrollable; }
+
TextureMapper* textureMapper() const;
- void flushCompositingState(GraphicsLayerTextureMapper*, int syncOptions = 0);
- void flushCompositingState(GraphicsLayerTextureMapper*, TextureMapper*, int syncOptions = 0);
- IntSize size() const { return IntSize(m_size.width(), m_size.height()); }
+ void setTextureMapper(TextureMapper* texmap) { m_textureMapper = texmap; }
+
+ void setChildren(const Vector<TextureMapperLayer*>&);
+ void setMaskLayer(TextureMapperLayer*);
+ void setReplicaLayer(TextureMapperLayer*);
+ void setPosition(const FloatPoint&);
+ void setSize(const FloatSize&);
+ void setAnchorPoint(const FloatPoint3D&);
+ void setPreserves3D(bool);
void setTransform(const TransformationMatrix&);
- void setOpacity(float value) { m_opacity = value; }
+ void setChildrenTransform(const TransformationMatrix&);
+ void setContentsRect(const IntRect&);
+ void setMasksToBounds(bool);
+ void setDrawsContent(bool);
+ bool drawsContent() const { return m_state.drawsContent; }
+ bool contentsAreVisible() const { return m_state.contentsVisible; }
+ FloatSize size() const { return m_state.size; }
+ float opacity() const { return m_state.opacity; }
+ TransformationMatrix transform() const { return m_state.transform; }
+ void setContentsVisible(bool);
+ void setContentsOpaque(bool);
+ void setBackfaceVisibility(bool);
+ void setOpacity(float);
+ void setSolidColor(const Color&);
+ void setContentsTileSize(const IntSize&);
+ void setContentsTilePhase(const IntPoint&);
#if ENABLE(CSS_FILTERS)
- void setFilters(const FilterOperations& filters) { m_filters = filters; }
+ void setFilters(const FilterOperations&);
#endif
- void setTextureMapper(TextureMapper* texmap) { m_textureMapper = texmap; }
+
+ bool hasFilters() const
+ {
+#if ENABLE(CSS_FILTERS)
+ return !m_currentFilters.isEmpty();
+#else
+ return false;
+#endif
+ }
+
+ void setDebugVisuals(bool showDebugBorders, const Color& debugBorderColor, float debugBorderWidth, bool showRepaintCounter);
+ bool isShowingRepaintCounter() const { return m_state.showRepaintCounter; }
+ void setRepaintCount(int);
+ void setContentsLayer(TextureMapperPlatformLayer*);
+ void setAnimations(const GraphicsLayerAnimations&);
+ void setFixedToViewport(bool);
+ bool fixedToViewport() const { return m_fixedToViewport; }
+ void setBackingStore(PassRefPtr<TextureMapperBackingStore>);
+
+ void syncAnimations();
bool descendantsOrSelfHaveRunningAnimations() const;
void paint();
- void setBackingStore(PassRefPtr<TextureMapperBackingStore> backingStore) { m_backingStore = backingStore; }
- PassRefPtr<TextureMapperBackingStore> backingStore() { return m_backingStore; }
- void clearBackingStoresRecursive();
-
void setScrollPositionDeltaIfNeeded(const FloatSize&);
void applyAnimationsRecursively();
+ void addChild(TextureMapperLayer*);
private:
const TextureMapperLayer* rootLayer() const;
void computeTransformsRecursive();
- void computeOverlapsIfNeeded();
- void computeTiles();
- IntRect intermediateSurfaceRect(const TransformationMatrix&);
- IntRect intermediateSurfaceRect();
- void swapContentsBuffers();
- FloatRect targetRectForTileRect(const FloatRect& totalTargetRect, const FloatRect& tileRect) const;
- void invalidateViewport(const FloatRect&);
- void notifyChange(ChangeMask);
- void flushCompositingStateSelf(GraphicsLayerTextureMapper*, TextureMapper*);
static int compareGraphicsLayersZValue(const void* a, const void* b);
- static void sortByZOrder(Vector<TextureMapperLayer* >& array, int first, int last);
+ static void sortByZOrder(Vector<TextureMapperLayer* >& array);
PassRefPtr<BitmapTexture> texture() { return m_backingStore ? m_backingStore->texture() : 0; }
- FloatPoint adjustedPosition() const { return m_state.pos + m_scrollPositionDelta; }
+ FloatPoint adjustedPosition() const { return m_state.pos + m_scrollPositionDelta - m_userScrollOffset; }
bool isAncestorFixedToViewport() const;
+ TransformationMatrix replicaTransform();
+ void removeFromParent();
+ void removeAllChildren();
+
+ enum ResolveSelfOverlapMode {
+ ResolveSelfOverlapAlways = 0,
+ ResolveSelfOverlapIfNeeded
+ };
+ void computeOverlapRegions(Region& overlapRegion, Region& nonOverlapRegion, ResolveSelfOverlapMode);
void paintRecursive(const TextureMapperPaintOptions&);
+ void paintUsingOverlapRegions(const TextureMapperPaintOptions&);
+ PassRefPtr<BitmapTexture> paintIntoSurface(const TextureMapperPaintOptions&, const IntSize&);
+ void paintWithIntermediateSurface(const TextureMapperPaintOptions&, const IntRect&);
void paintSelf(const TextureMapperPaintOptions&);
void paintSelfAndChildren(const TextureMapperPaintOptions&);
void paintSelfAndChildrenWithReplica(const TextureMapperPaintOptions&);
+ void applyMask(const TextureMapperPaintOptions&);
+ void computePatternTransformIfNeeded();
// GraphicsLayerAnimation::Client
- void setAnimatedTransform(const TransformationMatrix& matrix) { setTransform(matrix); }
- void setAnimatedOpacity(float opacity) { setOpacity(opacity); }
+ virtual void setAnimatedTransform(const TransformationMatrix&) OVERRIDE;
+ virtual void setAnimatedOpacity(float) OVERRIDE;
#if ENABLE(CSS_FILTERS)
- virtual void setAnimatedFilters(const FilterOperations& filters) { setFilters(filters); }
+ virtual void setAnimatedFilters(const FilterOperations&) OVERRIDE;
#endif
- void syncAnimations();
bool isVisible() const;
enum ContentsLayerCount {
NoLayersWithContent,
@@ -165,14 +177,11 @@ private:
MultipleLayersWithContents
};
- ContentsLayerCount countPotentialLayersWithContents() const;
- bool shouldPaintToIntermediateSurface() const;
-
- GraphicsLayerTransform m_transform;
+ bool shouldBlend() const;
inline FloatRect layerRect() const
{
- return FloatRect(FloatPoint::zero(), m_size);
+ return FloatRect(FloatPoint::zero(), m_state.size);
}
Vector<TextureMapperLayer*> m_children;
@@ -180,13 +189,18 @@ private:
TextureMapperLayer* m_effectTarget;
RefPtr<TextureMapperBackingStore> m_backingStore;
TextureMapperPlatformLayer* m_contentsLayer;
- FloatSize m_size;
- float m_opacity;
+ GraphicsLayerTransform m_currentTransform;
+ float m_currentOpacity;
#if ENABLE(CSS_FILTERS)
- FilterOperations m_filters;
+ FilterOperations m_currentFilters;
#endif
float m_centerZ;
- String m_name;
+
+ template<class HitTestCondition> TextureMapperLayer* hitTest(const FloatPoint&, HitTestCondition);
+ static bool scrollableLayerHitTestCondition(TextureMapperLayer*, const FloatPoint&);
+
+ FloatSize mapScrollOffset(const FloatSize&);
+ void commitScrollOffset(const FloatSize&);
struct State {
FloatPoint pos;
@@ -196,12 +210,17 @@ private:
TransformationMatrix childrenTransform;
float opacity;
FloatRect contentsRect;
- int descendantsWithContent;
+ IntSize contentsTileSize;
+ IntPoint contentsTilePhase;
TextureMapperLayer* maskLayer;
TextureMapperLayer* replicaLayer;
+ Color solidColor;
#if ENABLE(CSS_FILTERS)
- FilterOperations filters;
+ FilterOperations filters;
#endif
+ Color debugBorderColor;
+ float debugBorderWidth;
+ int repaintCount;
bool preserves3D : 1;
bool masksToBounds : 1;
@@ -210,21 +229,24 @@ private:
bool contentsOpaque : 1;
bool backfaceVisibility : 1;
bool visible : 1;
- bool mightHaveOverlaps : 1;
- bool needsRepaint;
+ bool showDebugBorders : 1;
+ bool showRepaintCounter : 1;
+
State()
- : opacity(1.f)
+ : opacity(1)
, maskLayer(0)
, replicaLayer(0)
+ , debugBorderWidth(0)
+ , repaintCount(0)
, preserves3D(false)
, masksToBounds(false)
, drawsContent(false)
, contentsVisible(true)
, contentsOpaque(false)
- , backfaceVisibility(false)
+ , backfaceVisibility(true)
, visible(true)
- , mightHaveOverlaps(false)
- , needsRepaint(false)
+ , showDebugBorders(false)
+ , showRepaintCounter(false)
{
}
};
@@ -234,11 +256,15 @@ private:
GraphicsLayerAnimations m_animations;
FloatSize m_scrollPositionDelta;
bool m_fixedToViewport;
+ uint32_t m_id;
+ ScrollingClient* m_scrollClient;
+ bool m_isScrollable;
+ FloatSize m_userScrollOffset;
+ FloatSize m_accumulatedScrollOffsetFractionalPart;
+ TransformationMatrix m_patternTransform;
+ bool m_patternTransformDirty;
};
-
-TextureMapperLayer* toTextureMapperLayer(GraphicsLayer*);
-
}
#endif
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayer.h b/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayer.h
index 38af03e89..0cab98da4 100644
--- a/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayer.h
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayer.h
@@ -24,23 +24,42 @@
#include "GraphicsSurface.h"
#endif
+#include "TextureMapper.h"
#include "TransformationMatrix.h"
namespace WebCore {
-class TextureMapper;
-class BitmapTexture;
-
class TextureMapperPlatformLayer {
public:
+ class Client {
+ public:
+ virtual void setPlatformLayerNeedsDisplay() = 0;
+ };
+
+ TextureMapperPlatformLayer() : m_client(0) { }
virtual ~TextureMapperPlatformLayer() { }
- virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix& modelViewMatrix = TransformationMatrix(), float opacity = 1.0, BitmapTexture* mask = 0) = 0;
+ virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix& modelViewMatrix = TransformationMatrix(), float opacity = 1.0) = 0;
virtual void swapBuffers() { }
+ virtual void drawBorder(TextureMapper* textureMapper, const Color& color, float borderWidth, const FloatRect& targetRect, const TransformationMatrix& transform)
+ {
+ textureMapper->drawBorder(color, borderWidth, targetRect, transform);
+ }
+ void setClient(TextureMapperPlatformLayer::Client* client)
+ {
+ m_client = client;
+ }
#if USE(GRAPHICS_SURFACE)
virtual IntSize platformLayerSize() const { return IntSize(); }
virtual uint32_t copyToGraphicsSurface() { return 0; }
virtual GraphicsSurfaceToken graphicsSurfaceToken() const { return GraphicsSurfaceToken(); }
+ virtual GraphicsSurface::Flags graphicsSurfaceFlags() const { return GraphicsSurface::SupportsTextureTarget | GraphicsSurface::SupportsSharing; }
#endif
+
+protected:
+ TextureMapperPlatformLayer::Client* client() { return m_client; }
+
+private:
+ TextureMapperPlatformLayer::Client* m_client;
};
};
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.cpp
deleted file mode 100644
index c8e1ae461..000000000
--- a/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.cpp
+++ /dev/null
@@ -1,533 +0,0 @@
-/*
- Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
- Copyright (C) 2012 Igalia S.L.
- Copyright (C) 2011 Google Inc. All rights reserved.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "TextureMapperShaderManager.h"
-
-#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
-
-#include "LengthFunctions.h"
-#include "Logging.h"
-#include "TextureMapperGL.h"
-
-#define STRINGIFY(...) #__VA_ARGS__
-
-namespace WebCore {
-
-
-static inline bool compositingLogEnabled()
-{
-#if !LOG_DISABLED
- return LogCompositing.state == WTFLogChannelOn;
-#else
- return false;
-#endif
-}
-
-TextureMapperShaderProgram::TextureMapperShaderProgram(PassRefPtr<GraphicsContext3D> context, const String& vertex, const String& fragment)
- : m_context(context)
-{
- m_vertexShader = m_context->createShader(GraphicsContext3D::VERTEX_SHADER);
- m_fragmentShader = m_context->createShader(GraphicsContext3D::FRAGMENT_SHADER);
- m_context->shaderSource(m_vertexShader, vertex);
- m_context->shaderSource(m_fragmentShader, fragment);
- m_id = m_context->createProgram();
- m_context->compileShader(m_vertexShader);
- m_context->compileShader(m_fragmentShader);
- m_context->attachShader(m_id, m_vertexShader);
- m_context->attachShader(m_id, m_fragmentShader);
- m_context->linkProgram(m_id);
-
- if (!compositingLogEnabled())
- return;
-
- if (m_context->getError() == GraphicsContext3D::NO_ERROR)
- return;
-
- String log = m_context->getShaderInfoLog(m_vertexShader);
- LOG(Compositing, "Vertex shader log: %s\n", log.utf8().data());
- log = m_context->getShaderInfoLog(m_fragmentShader);
- LOG(Compositing, "Fragment shader log: %s\n", log.utf8().data());
- log = m_context->getProgramInfoLog(m_id);
- LOG(Compositing, "Program log: %s\n", log.utf8().data());
-}
-
-GC3Duint TextureMapperShaderProgram::getLocation(const AtomicString& name, VariableType type)
-{
- HashMap<AtomicString, GC3Duint>::iterator it = m_variables.find(name);
- if (it != m_variables.end())
- return it->value;
-
- GC3Duint location = 0;
- switch (type) {
- case UniformVariable:
- location = m_context->getUniformLocation(m_id, name);
- break;
- case AttribVariable:
- location = m_context->getAttribLocation(m_id, name);
- break;
- default:
- ASSERT_NOT_REACHED();
- break;
- }
-
- m_variables.add(name, location);
- return location;
-}
-
-TextureMapperShaderProgram::~TextureMapperShaderProgram()
-{
- Platform3DObject programID = m_id;
- if (!programID)
- return;
-
- m_context->detachShader(programID, m_vertexShader);
- m_context->deleteShader(m_vertexShader);
- m_context->detachShader(programID, m_fragmentShader);
- m_context->deleteShader(m_fragmentShader);
- m_context->deleteProgram(programID);
-}
-
-struct ShaderSpec {
- String vertexShader;
- String fragmentShader;
- ShaderSpec(const char* vertex = 0, const char* fragment = 0)
- : vertexShader(vertex ? String(ASCIILiteral(vertex)) : String())
- , fragmentShader(fragment ? String(ASCIILiteral(fragment)) : String())
- {
- }
-};
-
-static void getShaderSpec(TextureMapperShaderManager::ShaderKey key, String& vertexSource, String& fragmentSource)
-{
- static Vector<ShaderSpec> specs = Vector<ShaderSpec>();
- static const char* fragmentOpacityAndMask =
- STRINGIFY(
- precision mediump float;
- uniform sampler2D s_sampler;
- uniform sampler2D s_mask;
- uniform lowp float u_opacity;
- varying highp vec2 v_sourceTexCoord;
- varying highp vec2 v_maskTexCoord;
- void main(void)
- {
- lowp vec4 color = texture2D(s_sampler, v_sourceTexCoord);
- lowp vec4 maskColor = texture2D(s_mask, v_maskTexCoord);
- lowp float fragmentAlpha = u_opacity * maskColor.a;
- gl_FragColor = vec4(color.rgb * fragmentAlpha, color.a * fragmentAlpha);
- }
- );
-
- static const char* fragmentRectOpacityAndMask =
- STRINGIFY(
- precision mediump float;
- uniform sampler2DRect s_sampler;
- uniform sampler2DRect s_mask;
- uniform lowp float u_opacity;
- varying highp vec2 v_sourceTexCoord;
- varying highp vec2 v_maskTexCoord;
- void main(void)
- {
- lowp vec4 color = texture2DRect(s_sampler, v_sourceTexCoord);
- lowp vec4 maskColor = texture2DRect(s_mask, v_maskTexCoord);
- lowp float fragmentAlpha = u_opacity * maskColor.a;
- gl_FragColor = vec4(color.rgb * fragmentAlpha, color.a * fragmentAlpha);
- }
- );
-
- static const char* vertexOpacityAndMask =
- STRINGIFY(
- uniform mat4 u_matrix;
- uniform lowp float u_flip;
- attribute vec4 a_vertex;
- varying highp vec2 v_sourceTexCoord;
- varying highp vec2 v_maskTexCoord;
- void main(void)
- {
- v_sourceTexCoord = vec2(a_vertex.x, mix(a_vertex.y, 1. - a_vertex.y, u_flip));
- v_maskTexCoord = vec2(a_vertex);
- gl_Position = u_matrix * a_vertex;
- }
- );
-
- static const char* fragmentSimple =
- STRINGIFY(
- precision mediump float;
- uniform sampler2D s_sampler;
- uniform lowp float u_opacity;
- varying highp vec2 v_sourceTexCoord;
- void main(void)
- {
- lowp vec4 color = texture2D(s_sampler, v_sourceTexCoord);
- gl_FragColor = vec4(color.rgb * u_opacity, color.a * u_opacity);
- }
- );
-
- static const char* fragmentAntialiasingNoMask =
- STRINGIFY(
- precision mediump float;
- uniform sampler2D s_sampler;
- varying highp vec2 v_sourceTexCoord;
- uniform lowp float u_opacity;
- uniform vec3 u_expandedQuadEdgesInScreenSpace[8];
- void main()
- {
- vec4 sampledColor = texture2D(s_sampler, clamp(v_sourceTexCoord, 0.0, 1.0));
- vec3 pos = vec3(gl_FragCoord.xy, 1);
-
- // The data passed in u_expandedQuadEdgesInScreenSpace is merely the
- // pre-scaled coeffecients of the line equations describing the four edges
- // of the expanded quad in screen space and the rectangular bounding box
- // of the expanded quad.
- //
- // We are doing a simple distance calculation here according to the formula:
- // (A*p.x + B*p.y + C) / sqrt(A^2 + B^2) = distance from line to p
- // Note that A, B and C have already been scaled by 1 / sqrt(A^2 + B^2).
- float a0 = clamp(dot(u_expandedQuadEdgesInScreenSpace[0], pos), 0.0, 1.0);
- float a1 = clamp(dot(u_expandedQuadEdgesInScreenSpace[1], pos), 0.0, 1.0);
- float a2 = clamp(dot(u_expandedQuadEdgesInScreenSpace[2], pos), 0.0, 1.0);
- float a3 = clamp(dot(u_expandedQuadEdgesInScreenSpace[3], pos), 0.0, 1.0);
- float a4 = clamp(dot(u_expandedQuadEdgesInScreenSpace[4], pos), 0.0, 1.0);
- float a5 = clamp(dot(u_expandedQuadEdgesInScreenSpace[5], pos), 0.0, 1.0);
- float a6 = clamp(dot(u_expandedQuadEdgesInScreenSpace[6], pos), 0.0, 1.0);
- float a7 = clamp(dot(u_expandedQuadEdgesInScreenSpace[7], pos), 0.0, 1.0);
-
- // Now we want to reduce the alpha value of the fragment if it is close to the
- // edges of the expanded quad (or rectangular bounding box -- which seems to be
- // important for backfacing quads). Note that we are combining the contribution
- // from the (top || bottom) and (left || right) edge by simply multiplying. This follows
- // the approach described at: http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter22.html,
- // in this case without using Gaussian weights.
- gl_FragColor = sampledColor * u_opacity * min(min(a0, a2) * min(a1, a3), min(a4, a6) * min(a5, a7));
- }
- );
-
- static const char* fragmentRectSimple =
- STRINGIFY(
- precision mediump float;
- uniform sampler2DRect s_sampler;
- uniform lowp vec2 u_samplerSize;
- uniform lowp float u_opacity;
- varying highp vec2 v_sourceTexCoord;
- void main(void)
- {
- lowp vec4 color = texture2DRect(s_sampler, u_samplerSize * v_sourceTexCoord);
- gl_FragColor = vec4(color.rgb * u_opacity, color.a * u_opacity);
- }
- );
-
- static const char* vertexSimple =
- STRINGIFY(
- uniform mat4 u_matrix;
- uniform lowp float u_flip;
- attribute vec4 a_vertex;
- varying highp vec2 v_sourceTexCoord;
- void main(void)
- {
- v_sourceTexCoord = vec2(a_vertex.x, mix(a_vertex.y, 1. - a_vertex.y, u_flip));
- gl_Position = u_matrix * a_vertex;
- }
- );
-
- static const char* vertexSolidColor =
- STRINGIFY(
- uniform mat4 u_matrix;
- attribute vec4 a_vertex;
- void main(void)
- {
- gl_Position = u_matrix * a_vertex;
- }
- );
-
-
- static const char* fragmentSolidColor =
- STRINGIFY(
- precision mediump float;
- uniform vec4 u_color;
- void main(void)
- {
- gl_FragColor = u_color;
- }
- );
-
- static const char* vertexFilter =
- STRINGIFY(
- attribute vec4 a_vertex;
- attribute vec4 a_texCoord;
- varying highp vec2 v_texCoord;
- void main(void)
- {
- v_texCoord = vec2(a_texCoord);
- gl_Position = a_vertex;
- }
- );
-
-#define STANDARD_FILTER(...) \
- "precision mediump float;\n"\
- "varying highp vec2 v_texCoord;\n"\
- "uniform highp float u_amount;\n"\
- "uniform sampler2D s_sampler;\n"#__VA_ARGS__ \
- "void main(void)\n { gl_FragColor = shade(texture2D(s_sampler, v_texCoord)); }"
-
- static const char* fragmentGrayscaleFilter =
- STANDARD_FILTER(
- lowp vec4 shade(lowp vec4 color)
- {
- lowp float amount = 1.0 - u_amount;
- return vec4((0.2126 + 0.7874 * amount) * color.r + (0.7152 - 0.7152 * amount) * color.g + (0.0722 - 0.0722 * amount) * color.b,
- (0.2126 - 0.2126 * amount) * color.r + (0.7152 + 0.2848 * amount) * color.g + (0.0722 - 0.0722 * amount) * color.b,
- (0.2126 - 0.2126 * amount) * color.r + (0.7152 - 0.7152 * amount) * color.g + (0.0722 + 0.9278 * amount) * color.b,
- color.a);
- }
- );
-
- static const char* fragmentSepiaFilter =
- STANDARD_FILTER(
- lowp vec4 shade(lowp vec4 color)
- {
- lowp float amount = 1.0 - u_amount;
- return vec4((0.393 + 0.607 * amount) * color.r + (0.769 - 0.769 * amount) * color.g + (0.189 - 0.189 * amount) * color.b,
- (0.349 - 0.349 * amount) * color.r + (0.686 + 0.314 * amount) * color.g + (0.168 - 0.168 * amount) * color.b,
- (0.272 - 0.272 * amount) * color.r + (0.534 - 0.534 * amount) * color.g + (0.131 + 0.869 * amount) * color.b,
- color.a);
- }
- );
-
- static const char* fragmentSaturateFilter =
- STANDARD_FILTER(
- lowp vec4 shade(lowp vec4 color)
- {
- return vec4((0.213 + 0.787 * u_amount) * color.r + (0.715 - 0.715 * u_amount) * color.g + (0.072 - 0.072 * u_amount) * color.b,
- (0.213 - 0.213 * u_amount) * color.r + (0.715 + 0.285 * u_amount) * color.g + (0.072 - 0.072 * u_amount) * color.b,
- (0.213 - 0.213 * u_amount) * color.r + (0.715 - 0.715 * u_amount) * color.g + (0.072 + 0.928 * u_amount) * color.b,
- color.a);
- }
- );
-
- static const char* fragmentHueRotateFilter =
- STANDARD_FILTER(
- lowp vec4 shade(lowp vec4 color)
- {
- highp float pi = 3.14159265358979323846;
- highp float c = cos(u_amount * pi / 180.0);
- highp float s = sin(u_amount * pi / 180.0);
- return vec4(color.r * (0.213 + c * 0.787 - s * 0.213) + color.g * (0.715 - c * 0.715 - s * 0.715) + color.b * (0.072 - c * 0.072 + s * 0.928),
- color.r * (0.213 - c * 0.213 + s * 0.143) + color.g * (0.715 + c * 0.285 + s * 0.140) + color.b * (0.072 - c * 0.072 - s * 0.283),
- color.r * (0.213 - c * 0.213 - s * 0.787) + color.g * (0.715 - c * 0.715 + s * 0.715) + color.b * (0.072 + c * 0.928 + s * 0.072),
- color.a);
- }
- );
-
- static const char* fragmentInvertFilter =
- STANDARD_FILTER(
- lowp float invert(lowp float n) { return (1.0 - n) * u_amount + n * (1.0 - u_amount); }
- lowp vec4 shade(lowp vec4 color)
- {
- return vec4(invert(color.r), invert(color.g), invert(color.b), color.a);
- }
- );
-
- static const char* fragmentBrightnessFilter =
- STANDARD_FILTER(
- lowp vec4 shade(lowp vec4 color)
- {
- return vec4(color.rgb * (1.0 + u_amount), color.a);
- }
- );
-
- static const char* fragmentContrastFilter =
- STANDARD_FILTER(
- lowp float contrast(lowp float n) { return (n - 0.5) * u_amount + 0.5; }
- lowp vec4 shade(lowp vec4 color)
- {
- return vec4(contrast(color.r), contrast(color.g), contrast(color.b), color.a);
- }
- );
-
- static const char* fragmentOpacityFilter =
- STANDARD_FILTER(
- lowp vec4 shade(lowp vec4 color)
- {
- return vec4(color.r, color.g, color.b, color.a * u_amount);
- }
- );
-
-#define BLUR_CONSTANTS "#define GAUSSIAN_KERNEL_HALF_WIDTH 11\n#define GAUSSIAN_KERNEL_STEP 0.2\n"
-
- static const char* fragmentBlurFilter =
- BLUR_CONSTANTS
- STRINGIFY(
- // Create a normal distribution of 21 values between -2 and 2.
- precision mediump float;
- varying highp vec2 v_texCoord;
- uniform lowp vec2 u_blurRadius;
- uniform sampler2D s_sampler;
- uniform float u_gaussianKernel[GAUSSIAN_KERNEL_HALF_WIDTH];
-
- lowp vec4 sampleColor(float radius)
- {
- vec2 coord = v_texCoord + radius * u_blurRadius;
- return texture2D(s_sampler, coord) * float(coord.x > 0. && coord.y > 0. && coord.x < 1. && coord.y < 1.);
- }
-
- vec4 blur()
- {
- vec4 total = sampleColor(0.) * u_gaussianKernel[0];
- for (int i = 1; i < GAUSSIAN_KERNEL_HALF_WIDTH; i++) {
- total += sampleColor(float(i) * GAUSSIAN_KERNEL_STEP) * u_gaussianKernel[i];
- total += sampleColor(float(-1 * i) * GAUSSIAN_KERNEL_STEP) * u_gaussianKernel[i];
- }
-
- return total;
- }
-
- void main(void)
- {
- gl_FragColor = blur();
- }
- );
-
- static const char* fragmentShadowFilter1 =
- BLUR_CONSTANTS
- STRINGIFY(
- precision mediump float;
- varying highp vec2 v_texCoord;
- uniform lowp float u_blurRadius;
- uniform lowp vec2 u_shadowOffset;
- uniform sampler2D s_sampler;
- uniform float u_gaussianKernel[GAUSSIAN_KERNEL_HALF_WIDTH];
-
- lowp float sampleAlpha(float radius)
- {
- vec2 coord = v_texCoord - u_shadowOffset + vec2(radius * u_blurRadius, 0.);
- return texture2D(s_sampler, coord).a * float(coord.x > 0. && coord.y > 0. && coord.x < 1. && coord.y < 1.);
- }
-
- lowp float shadowBlurHorizontal()
- {
- float total = sampleAlpha(0.) * u_gaussianKernel[0];
- for (int i = 1; i < GAUSSIAN_KERNEL_HALF_WIDTH; i++) {
- total += sampleAlpha(float(i) * GAUSSIAN_KERNEL_STEP) * u_gaussianKernel[i];
- total += sampleAlpha(float(-1 * i) * GAUSSIAN_KERNEL_STEP) * u_gaussianKernel[i];
- }
-
- return total;
- }
-
- void main(void)
- {
- gl_FragColor = vec4(1., 1., 1., 1.) * shadowBlurHorizontal();
- }
- );
-
- // Second pass: vertical alpha blur and composite with origin.
- static const char* fragmentShadowFilter2 =
- BLUR_CONSTANTS
- STRINGIFY(
- precision mediump float;
- varying highp vec2 v_texCoord;
- uniform lowp float u_blurRadius;
- uniform lowp vec4 u_shadowColor;
- uniform sampler2D s_sampler;
- uniform sampler2D s_contentTexture;
- uniform float u_gaussianKernel[GAUSSIAN_KERNEL_HALF_WIDTH];
-
- lowp float sampleAlpha(float r)
- {
- vec2 coord = v_texCoord + vec2(0., r * u_blurRadius);
- return texture2D(s_sampler, coord).a * float(coord.x > 0. && coord.y > 0. && coord.x < 1. && coord.y < 1.);
- }
-
- lowp float shadowBlurVertical()
- {
- float total = sampleAlpha(0.) * u_gaussianKernel[0];
- for (int i = 1; i < GAUSSIAN_KERNEL_HALF_WIDTH; i++) {
- total += sampleAlpha(float(i) * GAUSSIAN_KERNEL_STEP) * u_gaussianKernel[i];
- total += sampleAlpha(float(-1 * i) * GAUSSIAN_KERNEL_STEP) * u_gaussianKernel[i];
- }
-
- return total;
- }
-
- lowp vec4 sourceOver(lowp vec4 source, lowp vec4 destination)
- {
- // Composite the shadow with the original texture.
- return source + destination * (1. - source.a);
- }
-
- void main(void)
- {
- gl_FragColor = sourceOver(texture2D(s_contentTexture, v_texCoord), shadowBlurVertical() * u_shadowColor);
- }
- );
-
- if (specs.isEmpty()) {
- specs.resize(TextureMapperShaderManager::LastFilter);
- specs[TextureMapperShaderManager::Default] = ShaderSpec(vertexSimple, fragmentSimple);
- specs[TextureMapperShaderManager::SolidColor] = ShaderSpec(vertexSolidColor, fragmentSolidColor);
- specs[TextureMapperShaderManager::Rect] = ShaderSpec(vertexSimple, fragmentRectSimple);
- specs[TextureMapperShaderManager::Masked] = ShaderSpec(vertexOpacityAndMask, fragmentOpacityAndMask);
- specs[TextureMapperShaderManager::MaskedRect] = ShaderSpec(vertexOpacityAndMask, fragmentRectOpacityAndMask);
- specs[TextureMapperShaderManager::Antialiased] = ShaderSpec(vertexSimple, fragmentAntialiasingNoMask);
- specs[TextureMapperShaderManager::GrayscaleFilter] = ShaderSpec(vertexFilter, fragmentGrayscaleFilter);
- specs[TextureMapperShaderManager::SepiaFilter] = ShaderSpec(vertexFilter, fragmentSepiaFilter);
- specs[TextureMapperShaderManager::SaturateFilter] = ShaderSpec(vertexFilter, fragmentSaturateFilter);
- specs[TextureMapperShaderManager::HueRotateFilter] = ShaderSpec(vertexFilter, fragmentHueRotateFilter);
- specs[TextureMapperShaderManager::BrightnessFilter] = ShaderSpec(vertexFilter, fragmentBrightnessFilter);
- specs[TextureMapperShaderManager::ContrastFilter] = ShaderSpec(vertexFilter, fragmentContrastFilter);
- specs[TextureMapperShaderManager::InvertFilter] = ShaderSpec(vertexFilter, fragmentInvertFilter);
- specs[TextureMapperShaderManager::OpacityFilter] = ShaderSpec(vertexFilter, fragmentOpacityFilter);
- specs[TextureMapperShaderManager::BlurFilter] = ShaderSpec(vertexFilter, fragmentBlurFilter);
- specs[TextureMapperShaderManager::ShadowFilterPass1] = ShaderSpec(vertexFilter, fragmentShadowFilter1);
- specs[TextureMapperShaderManager::ShadowFilterPass2] = ShaderSpec(vertexFilter, fragmentShadowFilter2);
- }
-
- ASSERT(specs.size() > key);
- ShaderSpec& spec = specs[key];
- vertexSource = spec.vertexShader;
- fragmentSource = spec.fragmentShader;
-}
-
-TextureMapperShaderManager::TextureMapperShaderManager(GraphicsContext3D* context)
- : m_context(context)
-{
-}
-
-TextureMapperShaderManager::~TextureMapperShaderManager()
-{
-}
-
-PassRefPtr<TextureMapperShaderProgram> TextureMapperShaderManager::getShaderProgram(ShaderKey key)
-{
- TextureMapperShaderProgramMap::iterator it = m_programs.find(key);
- if (it != m_programs.end())
- return it->value;
-
- String vertexShader;
- String fragmentShader;
- getShaderSpec(key, vertexShader, fragmentShader);
- RefPtr<TextureMapperShaderProgram> program = TextureMapperShaderProgram::create(m_context, vertexShader, fragmentShader);
- m_programs.add(key, program);
- return program;
-}
-};
-
-#endif
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.cpp
new file mode 100644
index 000000000..3f64c4b8a
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.cpp
@@ -0,0 +1,382 @@
+/*
+ Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2012 Igalia S.L.
+ Copyright (C) 2011 Google Inc. All rights reserved.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "TextureMapperShaderProgram.h"
+
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
+#include "LengthFunctions.h"
+#include "Logging.h"
+#include "TextureMapperGL.h"
+
+#include <wtf/text/StringBuilder.h>
+
+#define STRINGIFY(...) #__VA_ARGS__
+
+namespace WebCore {
+
+static inline bool compositingLogEnabled()
+{
+#if !LOG_DISABLED
+ return LogCompositing.state == WTFLogChannelOn;
+#else
+ return false;
+#endif
+}
+
+TextureMapperShaderProgram::TextureMapperShaderProgram(PassRefPtr<GraphicsContext3D> context, const String& vertex, const String& fragment)
+ : m_context(context)
+{
+ m_vertexShader = m_context->createShader(GraphicsContext3D::VERTEX_SHADER);
+ m_fragmentShader = m_context->createShader(GraphicsContext3D::FRAGMENT_SHADER);
+ m_context->shaderSource(m_vertexShader, vertex);
+ m_context->shaderSource(m_fragmentShader, fragment);
+ m_id = m_context->createProgram();
+ m_context->compileShader(m_vertexShader);
+ m_context->compileShader(m_fragmentShader);
+ m_context->attachShader(m_id, m_vertexShader);
+ m_context->attachShader(m_id, m_fragmentShader);
+ m_context->linkProgram(m_id);
+
+ if (!compositingLogEnabled())
+ return;
+
+ if (m_context->getError() == GraphicsContext3D::NO_ERROR)
+ return;
+
+ String log = m_context->getShaderInfoLog(m_vertexShader);
+ LOG(Compositing, "Vertex shader log: %s\n", log.utf8().data());
+ log = m_context->getShaderInfoLog(m_fragmentShader);
+ LOG(Compositing, "Fragment shader log: %s\n", log.utf8().data());
+ log = m_context->getProgramInfoLog(m_id);
+ LOG(Compositing, "Program log: %s\n", log.utf8().data());
+}
+
+void TextureMapperShaderProgram::setMatrix(GC3Duint location, const TransformationMatrix& matrix)
+{
+ GC3Dfloat matrixAsFloats[] = {
+ GC3Dfloat(matrix.m11()), GC3Dfloat(matrix.m12()), GC3Dfloat(matrix.m13()), GC3Dfloat(matrix.m14()),
+ GC3Dfloat(matrix.m21()), GC3Dfloat(matrix.m22()), GC3Dfloat(matrix.m23()), GC3Dfloat(matrix.m24()),
+ GC3Dfloat(matrix.m31()), GC3Dfloat(matrix.m32()), GC3Dfloat(matrix.m33()), GC3Dfloat(matrix.m34()),
+ GC3Dfloat(matrix.m41()), GC3Dfloat(matrix.m42()), GC3Dfloat(matrix.m43()), GC3Dfloat(matrix.m44())
+ };
+
+ m_context->uniformMatrix4fv(location, 1, false, matrixAsFloats);
+}
+
+GC3Duint TextureMapperShaderProgram::getLocation(const AtomicString& name, VariableType type)
+{
+ HashMap<AtomicString, GC3Duint>::iterator it = m_variables.find(name);
+ if (it != m_variables.end())
+ return it->value;
+
+ GC3Duint location = 0;
+ switch (type) {
+ case UniformVariable:
+ location = m_context->getUniformLocation(m_id, name);
+ break;
+ case AttribVariable:
+ location = m_context->getAttribLocation(m_id, name);
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ break;
+ }
+
+ m_variables.add(name, location);
+ return location;
+}
+
+TextureMapperShaderProgram::~TextureMapperShaderProgram()
+{
+ Platform3DObject programID = m_id;
+ if (!programID)
+ return;
+
+ m_context->detachShader(programID, m_vertexShader);
+ m_context->deleteShader(m_vertexShader);
+ m_context->detachShader(programID, m_fragmentShader);
+ m_context->deleteShader(m_fragmentShader);
+ m_context->deleteProgram(programID);
+}
+
+#define GLSL_DIRECTIVE(...) "#"#__VA_ARGS__"\n"
+static const char* vertexTemplate =
+ STRINGIFY(
+ attribute vec4 a_vertex;
+ uniform mat4 u_modelViewMatrix;
+ uniform mat4 u_projectionMatrix;
+ uniform mat4 u_textureSpaceMatrix;
+
+ varying vec2 v_texCoord;
+ varying float v_antialias;
+
+ void noop(inout vec2 dummyParameter) { }
+
+ vec4 toViewportSpace(vec2 pos) { return vec4(pos, 0., 1.) * u_modelViewMatrix; }
+
+ // This function relies on the assumption that we get edge triangles with control points,
+ // a control point being the nearest point to the coordinate that is on the edge.
+ void applyAntialiasing(inout vec2 position)
+ {
+ // We count on the fact that quad passed in is always a unit rect,
+ // and the transformation matrix applies the real rect.
+ const vec2 center = vec2(0.5, 0.5);
+ const float antialiasInflationDistance = 1.;
+
+ // We pass the control point as the zw coordinates of the vertex.
+ // The control point is the point on the edge closest to the current position.
+ // The control point is used to compute the antialias value.
+ vec2 controlPoint = a_vertex.zw;
+
+ // First we calculate the distance in viewport space.
+ vec4 centerInViewportCoordinates = toViewportSpace(center);
+ vec4 controlPointInViewportCoordinates = toViewportSpace(controlPoint);
+ float viewportSpaceDistance = distance(centerInViewportCoordinates, controlPointInViewportCoordinates);
+
+ // We add the inflation distance to the computed distance, and compute the ratio.
+ float inflationRatio = (viewportSpaceDistance + antialiasInflationDistance) / viewportSpaceDistance;
+
+ // v_antialias needs to be 0 for the outer edge and 1. for the inner edge.
+ // Since the controlPoint is equal to the position in the edge vertices, the value is always 0 for those.
+ // For the center point, the distance is always 0.5, so we normalize to 1. by multiplying by 2.
+ // By multplying by inflationRatio and dividing by (inflationRatio - 1),
+ // We make sure that the varying interpolates between 0 (outer edge), 1 (inner edge) and n > 1 (center).
+ v_antialias = distance(controlPoint, position) * 2. * inflationRatio / (inflationRatio - 1.);
+
+ // Now inflate the actual position. By using this formula instead of inflating position directly,
+ // we ensure that the center vertex is never inflated.
+ position = center + (position - center) * inflationRatio;
+ }
+
+ void main(void)
+ {
+ vec2 position = a_vertex.xy;
+ applyAntialiasingIfNeeded(position);
+
+ // The texture position needs to be clamped to 0..1 before the texture matrix is applied.
+ vec4 clampedPosition = clamp(vec4(position, 0., 1.), 0., 1.);
+ v_texCoord = (u_textureSpaceMatrix * clampedPosition).xy;
+ gl_Position = u_projectionMatrix * u_modelViewMatrix * vec4(position, 0., 1.);
+ }
+ );
+
+#define RECT_TEXTURE_DIRECTIVE \
+ GLSL_DIRECTIVE(ifdef ENABLE_Rect) \
+ GLSL_DIRECTIVE(define SamplerType sampler2DRect) \
+ GLSL_DIRECTIVE(define SamplerFunction texture2DRect) \
+ GLSL_DIRECTIVE(else) \
+ GLSL_DIRECTIVE(define SamplerType sampler2D) \
+ GLSL_DIRECTIVE(define SamplerFunction texture2D) \
+ GLSL_DIRECTIVE(endif)
+
+#define ENABLE_APPLIER(Name) "#define ENABLE_"#Name"\n#define apply"#Name"IfNeeded apply"#Name"\n"
+#define DISABLE_APPLIER(Name) "#define apply"#Name"IfNeeded noop\n"
+#define BLUR_CONSTANTS \
+ GLSL_DIRECTIVE(define GAUSSIAN_KERNEL_HALF_WIDTH 11) \
+ GLSL_DIRECTIVE(define GAUSSIAN_KERNEL_STEP 0.2)
+
+
+static const char* fragmentTemplate =
+ RECT_TEXTURE_DIRECTIVE
+ BLUR_CONSTANTS
+ STRINGIFY(
+ precision mediump float;
+ uniform SamplerType s_sampler;
+ uniform sampler2D s_contentTexture;
+ uniform float u_opacity;
+ varying float v_antialias;
+ varying vec2 v_texCoord;
+ uniform float u_filterAmount;
+ uniform vec2 u_blurRadius;
+ uniform vec2 u_shadowOffset;
+ uniform vec4 u_color;
+ uniform float u_gaussianKernel[GAUSSIAN_KERNEL_HALF_WIDTH];
+
+ void noop(inout vec4 dummyParameter) { }
+
+ float antialias() { return smoothstep(v_antialias, 0., 1.); }
+
+ void applyTexture(inout vec4 color) { color = SamplerFunction(s_sampler, v_texCoord); }
+ void applyOpacity(inout vec4 color) { color *= u_opacity; }
+ void applyAntialiasing(inout vec4 color) { color *= antialias(); }
+
+ void applyGrayscaleFilter(inout vec4 color)
+ {
+ float amount = 1.0 - u_filterAmount;
+ color = vec4((0.2126 + 0.7874 * amount) * color.r + (0.7152 - 0.7152 * amount) * color.g + (0.0722 - 0.0722 * amount) * color.b,
+ (0.2126 - 0.2126 * amount) * color.r + (0.7152 + 0.2848 * amount) * color.g + (0.0722 - 0.0722 * amount) * color.b,
+ (0.2126 - 0.2126 * amount) * color.r + (0.7152 - 0.7152 * amount) * color.g + (0.0722 + 0.9278 * amount) * color.b,
+ color.a);
+ }
+
+ void applySepiaFilter(inout vec4 color)
+ {
+ float amount = 1.0 - u_filterAmount;
+ color = vec4((0.393 + 0.607 * amount) * color.r + (0.769 - 0.769 * amount) * color.g + (0.189 - 0.189 * amount) * color.b,
+ (0.349 - 0.349 * amount) * color.r + (0.686 + 0.314 * amount) * color.g + (0.168 - 0.168 * amount) * color.b,
+ (0.272 - 0.272 * amount) * color.r + (0.534 - 0.534 * amount) * color.g + (0.131 + 0.869 * amount) * color.b,
+ color.a);
+ }
+
+ void applySaturateFilter(inout vec4 color)
+ {
+ color = vec4((0.213 + 0.787 * u_filterAmount) * color.r + (0.715 - 0.715 * u_filterAmount) * color.g + (0.072 - 0.072 * u_filterAmount) * color.b,
+ (0.213 - 0.213 * u_filterAmount) * color.r + (0.715 + 0.285 * u_filterAmount) * color.g + (0.072 - 0.072 * u_filterAmount) * color.b,
+ (0.213 - 0.213 * u_filterAmount) * color.r + (0.715 - 0.715 * u_filterAmount) * color.g + (0.072 + 0.928 * u_filterAmount) * color.b,
+ color.a);
+ }
+
+ void applyHueRotateFilter(inout vec4 color)
+ {
+ float pi = 3.14159265358979323846;
+ float c = cos(u_filterAmount * pi / 180.0);
+ float s = sin(u_filterAmount * pi / 180.0);
+ color = vec4(color.r * (0.213 + c * 0.787 - s * 0.213) + color.g * (0.715 - c * 0.715 - s * 0.715) + color.b * (0.072 - c * 0.072 + s * 0.928),
+ color.r * (0.213 - c * 0.213 + s * 0.143) + color.g * (0.715 + c * 0.285 + s * 0.140) + color.b * (0.072 - c * 0.072 - s * 0.283),
+ color.r * (0.213 - c * 0.213 - s * 0.787) + color.g * (0.715 - c * 0.715 + s * 0.715) + color.b * (0.072 + c * 0.928 + s * 0.072),
+ color.a);
+ }
+
+ float invert(float n) { return (1.0 - n) * u_filterAmount + n * (1.0 - u_filterAmount); }
+ void applyInvertFilter(inout vec4 color)
+ {
+ color = vec4(invert(color.r), invert(color.g), invert(color.b), color.a);
+ }
+
+ void applyBrightnessFilter(inout vec4 color)
+ {
+ color = vec4(color.rgb * u_filterAmount, color.a);
+ }
+
+ float contrast(float n) { return (n - 0.5) * u_filterAmount + 0.5; }
+ void applyContrastFilter(inout vec4 color)
+ {
+ color = vec4(contrast(color.r), contrast(color.g), contrast(color.b), color.a);
+ }
+
+ void applyOpacityFilter(inout vec4 color)
+ {
+ color = vec4(color.r, color.g, color.b, color.a * u_filterAmount);
+ }
+
+ vec4 sampleColorAtRadius(float radius)
+ {
+ vec2 coord = v_texCoord + radius * u_blurRadius;
+ return SamplerFunction(s_sampler, coord) * float(coord.x > 0. && coord.y > 0. && coord.x < 1. && coord.y < 1.);
+ }
+
+ float sampleAlphaAtRadius(float radius)
+ {
+ vec2 coord = v_texCoord - u_shadowOffset + radius * u_blurRadius;
+ return SamplerFunction(s_sampler, coord).a * float(coord.x > 0. && coord.y > 0. && coord.x < 1. && coord.y < 1.);
+ }
+
+ void applyBlurFilter(inout vec4 color)
+ {
+ vec4 total = sampleColorAtRadius(0.) * u_gaussianKernel[0];
+ for (int i = 1; i < GAUSSIAN_KERNEL_HALF_WIDTH; i++) {
+ total += sampleColorAtRadius(float(i) * GAUSSIAN_KERNEL_STEP) * u_gaussianKernel[i];
+ total += sampleColorAtRadius(float(-1 * i) * GAUSSIAN_KERNEL_STEP) * u_gaussianKernel[i];
+ }
+
+ color = total;
+ }
+
+ void applyAlphaBlur(inout vec4 color)
+ {
+ float total = sampleAlphaAtRadius(0.) * u_gaussianKernel[0];
+ for (int i = 1; i < GAUSSIAN_KERNEL_HALF_WIDTH; i++) {
+ total += sampleAlphaAtRadius(float(i) * GAUSSIAN_KERNEL_STEP) * u_gaussianKernel[i];
+ total += sampleAlphaAtRadius(float(-1 * i) * GAUSSIAN_KERNEL_STEP) * u_gaussianKernel[i];
+ }
+
+ color *= total;
+ }
+
+ vec4 sourceOver(vec4 src, vec4 dst) { return src + dst * (1. - dst.a); }
+
+ void applyContentTexture(inout vec4 color)
+ {
+ vec4 contentColor = texture2D(s_contentTexture, v_texCoord);
+ color = sourceOver(contentColor, color);
+ }
+
+ void applySolidColor(inout vec4 color) { color *= u_color; }
+
+ void main(void)
+ {
+ vec4 color = vec4(1., 1., 1., 1.);
+ applyTextureIfNeeded(color);
+ applySolidColorIfNeeded(color);
+ applyAntialiasingIfNeeded(color);
+ applyOpacityIfNeeded(color);
+ applyGrayscaleFilterIfNeeded(color);
+ applySepiaFilterIfNeeded(color);
+ applySaturateFilterIfNeeded(color);
+ applyHueRotateFilterIfNeeded(color);
+ applyInvertFilterIfNeeded(color);
+ applyBrightnessFilterIfNeeded(color);
+ applyContrastFilterIfNeeded(color);
+ applyOpacityFilterIfNeeded(color);
+ applyBlurFilterIfNeeded(color);
+ applyAlphaBlurIfNeeded(color);
+ applyContentTextureIfNeeded(color);
+ gl_FragColor = color;
+ }
+ );
+
+PassRefPtr<TextureMapperShaderProgram> TextureMapperShaderProgram::create(PassRefPtr<GraphicsContext3D> context, TextureMapperShaderProgram::Options options)
+{
+ StringBuilder shaderBuilder;
+#define SET_APPLIER_FROM_OPTIONS(Applier) \
+ shaderBuilder.append(\
+ (options & TextureMapperShaderProgram::Applier) ? ENABLE_APPLIER(Applier) : DISABLE_APPLIER(Applier))
+
+ SET_APPLIER_FROM_OPTIONS(Texture);
+ SET_APPLIER_FROM_OPTIONS(Rect);
+ SET_APPLIER_FROM_OPTIONS(SolidColor);
+ SET_APPLIER_FROM_OPTIONS(Opacity);
+ SET_APPLIER_FROM_OPTIONS(Antialiasing);
+ SET_APPLIER_FROM_OPTIONS(GrayscaleFilter);
+ SET_APPLIER_FROM_OPTIONS(SepiaFilter);
+ SET_APPLIER_FROM_OPTIONS(SaturateFilter);
+ SET_APPLIER_FROM_OPTIONS(HueRotateFilter);
+ SET_APPLIER_FROM_OPTIONS(BrightnessFilter);
+ SET_APPLIER_FROM_OPTIONS(ContrastFilter);
+ SET_APPLIER_FROM_OPTIONS(InvertFilter);
+ SET_APPLIER_FROM_OPTIONS(OpacityFilter);
+ SET_APPLIER_FROM_OPTIONS(BlurFilter);
+ SET_APPLIER_FROM_OPTIONS(AlphaBlur);
+ SET_APPLIER_FROM_OPTIONS(ContentTexture);
+ StringBuilder vertexBuilder;
+ vertexBuilder.append(shaderBuilder.toString());
+ vertexBuilder.append(vertexTemplate);
+ shaderBuilder.append(fragmentTemplate);
+
+ String vertexSource = vertexBuilder.toString();
+ String fragmentSource = shaderBuilder.toString();
+
+ return adoptRef(new TextureMapperShaderProgram(context, vertexSource, fragmentSource));
+}
+
+}
+#endif
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.h b/Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.h
index 496b7e81b..3345fc9fe 100644
--- a/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.h
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.h
@@ -18,12 +18,12 @@
Boston, MA 02110-1301, USA.
*/
-#ifndef TextureMapperShaderManager_h
-#define TextureMapperShaderManager_h
+#ifndef TextureMapperShaderProgram_h
+#define TextureMapperShaderProgram_h
#if USE(TEXTURE_MAPPER)
#include "GraphicsContext3D.h"
-#include "TextureMapperGL.h"
+#include "TransformationMatrix.h"
#include <wtf/HashMap.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefPtr.h>
@@ -37,21 +37,37 @@ namespace WebCore {
class TextureMapperShaderProgram : public RefCounted<TextureMapperShaderProgram> {
public:
- Platform3DObject programID() const { return m_id; }
- GraphicsContext3D* context() { return m_context.get(); }
- static PassRefPtr<TextureMapperShaderProgram> create(PassRefPtr<GraphicsContext3D> context, const String& vertex, const String& fragment)
- {
- return adoptRef(new TextureMapperShaderProgram(context, vertex, fragment));
- }
+ enum Option {
+ Texture = 1L << 0,
+ Rect = 1L << 1,
+ SolidColor = 1L << 2,
+ Opacity = 1L << 3,
+ Antialiasing = 1L << 5,
+ GrayscaleFilter = 1L << 6,
+ SepiaFilter = 1L << 7,
+ SaturateFilter = 1L << 8,
+ HueRotateFilter = 1L << 9,
+ BrightnessFilter = 1L << 10,
+ ContrastFilter = 1L << 11,
+ InvertFilter = 1L << 12,
+ OpacityFilter = 1L << 13,
+ BlurFilter = 1L << 14,
+ AlphaBlur = 1L << 15,
+ ContentTexture = 1L << 16
+ };
+
+ typedef unsigned Options;
+ static PassRefPtr<TextureMapperShaderProgram> create(PassRefPtr<GraphicsContext3D>, Options);
virtual ~TextureMapperShaderProgram();
+ Platform3DObject programID() const { return m_id; }
+ GraphicsContext3D* context() { return m_context.get(); }
TEXMAP_DECLARE_ATTRIBUTE(vertex)
- TEXMAP_DECLARE_ATTRIBUTE(texCoord)
- TEXMAP_DECLARE_UNIFORM(matrix)
- TEXMAP_DECLARE_UNIFORM(flip)
- TEXMAP_DECLARE_UNIFORM(samplerSize)
+ TEXMAP_DECLARE_UNIFORM(modelViewMatrix)
+ TEXMAP_DECLARE_UNIFORM(projectionMatrix)
+ TEXMAP_DECLARE_UNIFORM(textureSpaceMatrix)
TEXMAP_DECLARE_UNIFORM(opacity)
TEXMAP_DECLARE_UNIFORM(color)
TEXMAP_DECLARE_UNIFORM(expandedQuadEdgesInScreenSpace)
@@ -59,14 +75,15 @@ public:
TEXMAP_DECLARE_SAMPLER(mask)
#if ENABLE(CSS_FILTERS)
- TEXMAP_DECLARE_UNIFORM(amount)
+ TEXMAP_DECLARE_UNIFORM(filterAmount)
TEXMAP_DECLARE_UNIFORM(gaussianKernel)
TEXMAP_DECLARE_UNIFORM(blurRadius)
- TEXMAP_DECLARE_UNIFORM(shadowColor)
TEXMAP_DECLARE_UNIFORM(shadowOffset)
TEXMAP_DECLARE_SAMPLER(contentTexture)
#endif
+ void setMatrix(GC3Duint, const TransformationMatrix&);
+
private:
TextureMapperShaderProgram(PassRefPtr<GraphicsContext3D>, const String& vertexShaderSource, const String& fragmentShaderSource);
Platform3DObject m_vertexShader;
@@ -80,43 +97,7 @@ private:
HashMap<AtomicString, GC3Duint> m_variables;
};
-class TextureMapperShaderManager {
-public:
- enum ShaderKey {
- Invalid = 0,
- Default,
- Rect,
- Masked,
- MaskedRect,
- SolidColor,
- Antialiased,
- GrayscaleFilter,
- SepiaFilter,
- SaturateFilter,
- HueRotateFilter,
- BrightnessFilter,
- ContrastFilter,
- OpacityFilter,
- InvertFilter,
- BlurFilter,
- ShadowFilterPass1,
- ShadowFilterPass2,
- LastFilter
- };
-
- TextureMapperShaderManager() { }
- explicit TextureMapperShaderManager(GraphicsContext3D*);
- virtual ~TextureMapperShaderManager();
-
- PassRefPtr<TextureMapperShaderProgram> getShaderProgram(ShaderKey);
-
-private:
- typedef HashMap<ShaderKey, RefPtr<TextureMapperShaderProgram>, DefaultHash<int>::Hash, HashTraits<int> > TextureMapperShaderProgramMap;
- TextureMapperShaderProgramMap m_programs;
- RefPtr<GraphicsContext3D> m_context;
-};
-
}
#endif
-#endif // TextureMapperShaderManager_h
+#endif // TextureMapperShaderProgram_h
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperSurfaceBackingStore.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperSurfaceBackingStore.cpp
new file mode 100644
index 000000000..8d38776e9
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperSurfaceBackingStore.cpp
@@ -0,0 +1,54 @@
+/*
+ Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#if USE(ACCELERATED_COMPOSITING) && USE(GRAPHICS_SURFACE)
+#include "TextureMapperSurfaceBackingStore.h"
+
+#include "GraphicsSurface.h"
+
+namespace WebCore {
+
+void TextureMapperSurfaceBackingStore::setGraphicsSurface(PassRefPtr<GraphicsSurface> surface)
+{
+ m_graphicsSurface = surface;
+}
+
+void TextureMapperSurfaceBackingStore::swapBuffersIfNeeded(uint32_t)
+{
+ if (m_graphicsSurface)
+ m_graphicsSurface->swapBuffers();
+}
+
+PassRefPtr<BitmapTexture> TextureMapperSurfaceBackingStore::texture() const
+{
+ // FIXME: Instead of just returning an empty texture, we should wrap the texture contents into a BitmapTexture.
+ RefPtr<BitmapTexture> emptyTexture;
+ return emptyTexture;
+}
+
+void TextureMapperSurfaceBackingStore::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity)
+{
+ if (m_graphicsSurface)
+ m_graphicsSurface->paintToTextureMapper(textureMapper, targetRect, transform, opacity);
+}
+
+} // namespace WebCore
+#endif
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperSurfaceBackingStore.h b/Source/WebCore/platform/graphics/texmap/TextureMapperSurfaceBackingStore.h
new file mode 100644
index 000000000..793c61dc3
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperSurfaceBackingStore.h
@@ -0,0 +1,55 @@
+/*
+ Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#ifndef TextureMapperSurfaceBackingStore_h
+#define TextureMapperSurfaceBackingStore_h
+
+#if USE(ACCELERATED_COMPOSITING) && USE(GRAPHICS_SURFACE)
+
+#include "GraphicsSurface.h"
+#include "TextureMapperBackingStore.h"
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class TextureMapper;
+class FloatRect;
+
+class TextureMapperSurfaceBackingStore : public TextureMapperBackingStore {
+public:
+ static PassRefPtr<TextureMapperSurfaceBackingStore> create() { return adoptRef(new TextureMapperSurfaceBackingStore); }
+ void setGraphicsSurface(PassRefPtr<GraphicsSurface>);
+ void swapBuffersIfNeeded(uint32_t frontBuffer);
+ virtual PassRefPtr<BitmapTexture> texture() const;
+ virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float);
+ virtual ~TextureMapperSurfaceBackingStore() { }
+
+private:
+ TextureMapperSurfaceBackingStore()
+ : TextureMapperBackingStore()
+ { }
+
+ RefPtr<GraphicsSurface> m_graphicsSurface;
+};
+
+}
+
+#endif
+
+#endif
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperTile.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperTile.cpp
new file mode 100644
index 000000000..2ea7fb6ed
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperTile.cpp
@@ -0,0 +1,79 @@
+/*
+ Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+#include "config.h"
+
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
+#include "TextureMapperTile.h"
+
+#include "Image.h"
+#include "TextureMapper.h"
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class GraphicsLayer;
+
+void TextureMapperTile::updateContents(TextureMapper* textureMapper, Image* image, const IntRect& dirtyRect, BitmapTexture::UpdateContentsFlag updateContentsFlag)
+{
+ IntRect targetRect = enclosingIntRect(m_rect);
+ targetRect.intersect(dirtyRect);
+ if (targetRect.isEmpty())
+ return;
+ IntPoint sourceOffset = targetRect.location();
+
+ // Normalize sourceRect to the buffer's coordinates.
+ sourceOffset.move(-dirtyRect.x(), -dirtyRect.y());
+
+ // Normalize targetRect to the texture's coordinates.
+ targetRect.move(-m_rect.x(), -m_rect.y());
+ if (!m_texture) {
+ m_texture = textureMapper->createTexture();
+ m_texture->reset(targetRect.size(), image->currentFrameKnownToBeOpaque() ? 0 : BitmapTexture::SupportsAlpha);
+ }
+
+ m_texture->updateContents(image, targetRect, sourceOffset, updateContentsFlag);
+}
+
+void TextureMapperTile::updateContents(TextureMapper* textureMapper, GraphicsLayer* sourceLayer, const IntRect& dirtyRect, BitmapTexture::UpdateContentsFlag updateContentsFlag)
+{
+ IntRect targetRect = enclosingIntRect(m_rect);
+ targetRect.intersect(dirtyRect);
+ if (targetRect.isEmpty())
+ return;
+ IntPoint sourceOffset = targetRect.location();
+
+ // Normalize targetRect to the texture's coordinates.
+ targetRect.move(-m_rect.x(), -m_rect.y());
+
+ if (!m_texture) {
+ m_texture = textureMapper->createTexture();
+ m_texture->reset(targetRect.size(), BitmapTexture::SupportsAlpha);
+ }
+
+ m_texture->updateContents(textureMapper, sourceLayer, targetRect, sourceOffset, updateContentsFlag);
+}
+
+void TextureMapperTile::paint(TextureMapper* textureMapper, const TransformationMatrix& transform, float opacity, const unsigned exposedEdges)
+{
+ if (texture().get())
+ textureMapper->drawTexture(*texture().get(), rect(), transform, opacity, exposedEdges);
+}
+
+} // namespace WebCore
+#endif
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperTile.h b/Source/WebCore/platform/graphics/texmap/TextureMapperTile.h
new file mode 100644
index 000000000..ee6809f20
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperTile.h
@@ -0,0 +1,60 @@
+/*
+ Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#ifndef TextureMapperTile_h
+#define TextureMapperTile_h
+
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
+
+#include "FloatRect.h"
+#include "Image.h"
+#include "TextureMapper.h"
+#include "TextureMapperPlatformLayer.h"
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class GraphicsLayer;
+
+class TextureMapperTile {
+public:
+ inline PassRefPtr<BitmapTexture> texture() const { return m_texture; }
+ inline FloatRect rect() const { return m_rect; }
+ inline void setTexture(BitmapTexture* texture) { m_texture = texture; }
+ inline void setRect(const FloatRect& rect) { m_rect = rect; }
+
+ void updateContents(TextureMapper*, Image*, const IntRect&, BitmapTexture::UpdateContentsFlag UpdateCanModifyOriginalImageData);
+ void updateContents(TextureMapper*, GraphicsLayer*, const IntRect&, BitmapTexture::UpdateContentsFlag UpdateCanModifyOriginalImageData);
+ virtual void paint(TextureMapper*, const TransformationMatrix&, float, const unsigned exposedEdges);
+ virtual ~TextureMapperTile() { }
+
+ explicit TextureMapperTile(const FloatRect& rect)
+ : m_rect(rect)
+ {
+ }
+
+private:
+ RefPtr<BitmapTexture> m_texture;
+ FloatRect m_rect;
+};
+
+}
+#endif
+
+#endif
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.cpp
new file mode 100644
index 000000000..ef564023d
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.cpp
@@ -0,0 +1,162 @@
+/*
+ Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
+#include "TextureMapperTiledBackingStore.h"
+
+#include "ImageBuffer.h"
+#include "TextureMapper.h"
+
+namespace WebCore {
+
+class GraphicsLayer;
+
+TextureMapperTiledBackingStore::TextureMapperTiledBackingStore()
+{
+}
+
+void TextureMapperTiledBackingStore::updateContentsFromImageIfNeeded(TextureMapper* textureMapper)
+{
+ if (!m_image)
+ return;
+
+ updateContents(textureMapper, m_image.get(), m_image->size(), m_image->rect(), BitmapTexture::UpdateCannotModifyOriginalImageData);
+ m_image.clear();
+}
+
+TransformationMatrix TextureMapperTiledBackingStore::adjustedTransformForRect(const FloatRect& targetRect)
+{
+ return TransformationMatrix::rectToRect(rect(), targetRect);
+}
+
+void TextureMapperTiledBackingStore::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity)
+{
+ updateContentsFromImageIfNeeded(textureMapper);
+ TransformationMatrix adjustedTransform = transform * adjustedTransformForRect(targetRect);
+ for (size_t i = 0; i < m_tiles.size(); ++i)
+ m_tiles[i].paint(textureMapper, adjustedTransform, opacity, calculateExposedTileEdges(rect(), m_tiles[i].rect()));
+}
+
+void TextureMapperTiledBackingStore::drawBorder(TextureMapper* textureMapper, const Color& borderColor, float borderWidth, const FloatRect& targetRect, const TransformationMatrix& transform)
+{
+ TransformationMatrix adjustedTransform = transform * adjustedTransformForRect(targetRect);
+ for (size_t i = 0; i < m_tiles.size(); ++i)
+ textureMapper->drawBorder(borderColor, borderWidth, m_tiles[i].rect(), adjustedTransform);
+}
+
+void TextureMapperTiledBackingStore::drawRepaintCounter(TextureMapper* textureMapper, int repaintCount, const Color& borderColor, const FloatRect& targetRect, const TransformationMatrix& transform)
+{
+ TransformationMatrix adjustedTransform = transform * adjustedTransformForRect(targetRect);
+ for (size_t i = 0; i < m_tiles.size(); ++i)
+ textureMapper->drawNumber(repaintCount, borderColor, m_tiles[i].rect().location(), adjustedTransform);
+}
+
+void TextureMapperTiledBackingStore::createOrDestroyTilesIfNeeded(const FloatSize& size, const IntSize& tileSize, bool hasAlpha)
+{
+ if (size == m_size)
+ return;
+
+ m_size = size;
+
+ Vector<FloatRect> tileRectsToAdd;
+ Vector<int> tileIndicesToRemove;
+ static const size_t TileEraseThreshold = 6;
+
+ // This method recycles tiles. We check which tiles we need to add, which to remove, and use as many
+ // removable tiles as replacement for new tiles when possible.
+ for (float y = 0; y < m_size.height(); y += tileSize.height()) {
+ for (float x = 0; x < m_size.width(); x += tileSize.width()) {
+ FloatRect tileRect(x, y, tileSize.width(), tileSize.height());
+ tileRect.intersect(rect());
+ tileRectsToAdd.append(tileRect);
+ }
+ }
+
+ // Check which tiles need to be removed, and which already exist.
+ for (int i = m_tiles.size() - 1; i >= 0; --i) {
+ FloatRect oldTile = m_tiles[i].rect();
+ bool existsAlready = false;
+
+ for (int j = tileRectsToAdd.size() - 1; j >= 0; --j) {
+ FloatRect newTile = tileRectsToAdd[j];
+ if (oldTile != newTile)
+ continue;
+
+ // A tile that we want to add already exists, no need to add or remove it.
+ existsAlready = true;
+ tileRectsToAdd.remove(j);
+ break;
+ }
+
+ // This tile is not needed.
+ if (!existsAlready)
+ tileIndicesToRemove.append(i);
+ }
+
+ // Recycle removable tiles to be used for newly requested tiles.
+ for (size_t i = 0; i < tileRectsToAdd.size(); ++i) {
+ if (!tileIndicesToRemove.isEmpty()) {
+ // We recycle an existing tile for usage with a new tile rect.
+ TextureMapperTile& tile = m_tiles[tileIndicesToRemove.last()];
+ tileIndicesToRemove.removeLast();
+ tile.setRect(tileRectsToAdd[i]);
+
+ if (tile.texture())
+ tile.texture()->reset(enclosingIntRect(tile.rect()).size(), hasAlpha ? BitmapTexture::SupportsAlpha : 0);
+ continue;
+ }
+
+ m_tiles.append(TextureMapperTile(tileRectsToAdd[i]));
+ }
+
+ // Remove unnecessary tiles, if they weren't recycled.
+ // We use a threshold to make sure we don't create/destroy tiles too eagerly.
+ for (size_t i = 0; i < tileIndicesToRemove.size() && m_tiles.size() > TileEraseThreshold; ++i)
+ m_tiles.remove(tileIndicesToRemove[i]);
+}
+
+void TextureMapperTiledBackingStore::updateContents(TextureMapper* textureMapper, Image* image, const FloatSize& totalSize, const IntRect& dirtyRect, BitmapTexture::UpdateContentsFlag updateContentsFlag)
+{
+ createOrDestroyTilesIfNeeded(totalSize, textureMapper->maxTextureSize(), !image->currentFrameKnownToBeOpaque());
+ for (size_t i = 0; i < m_tiles.size(); ++i)
+ m_tiles[i].updateContents(textureMapper, image, dirtyRect, updateContentsFlag);
+}
+
+void TextureMapperTiledBackingStore::updateContents(TextureMapper* textureMapper, GraphicsLayer* sourceLayer, const FloatSize& totalSize, const IntRect& dirtyRect, BitmapTexture::UpdateContentsFlag updateContentsFlag)
+{
+ createOrDestroyTilesIfNeeded(totalSize, textureMapper->maxTextureSize(), true);
+ for (size_t i = 0; i < m_tiles.size(); ++i)
+ m_tiles[i].updateContents(textureMapper, sourceLayer, dirtyRect, updateContentsFlag);
+}
+
+PassRefPtr<BitmapTexture> TextureMapperTiledBackingStore::texture() const
+{
+ for (size_t i = 0; i < m_tiles.size(); ++i) {
+ RefPtr<BitmapTexture> texture = m_tiles[i].texture();
+ if (texture)
+ return texture;
+ }
+
+ return PassRefPtr<BitmapTexture>();
+}
+
+} // namespace WebCore
+#endif
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.h b/Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.h
new file mode 100644
index 000000000..9b8568463
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.h
@@ -0,0 +1,64 @@
+/*
+ Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#ifndef TextureMapperTiledBackingStore_h
+#define TextureMapperTiledBackingStore_h
+
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
+
+#include "FloatRect.h"
+#include "Image.h"
+#include "TextureMapperBackingStore.h"
+#include "TextureMapperTile.h"
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class TextureMapper;
+
+class TextureMapperTiledBackingStore : public TextureMapperBackingStore {
+public:
+ static PassRefPtr<TextureMapperTiledBackingStore> create() { return adoptRef(new TextureMapperTiledBackingStore); }
+ virtual ~TextureMapperTiledBackingStore() { }
+
+ virtual PassRefPtr<BitmapTexture> texture() const OVERRIDE;
+ virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float) OVERRIDE;
+ virtual void drawBorder(TextureMapper*, const Color&, float borderWidth, const FloatRect&, const TransformationMatrix&) OVERRIDE;
+ virtual void drawRepaintCounter(TextureMapper*, int repaintCount, const Color&, const FloatRect&, const TransformationMatrix&) OVERRIDE;
+ void updateContents(TextureMapper*, Image*, const FloatSize&, const IntRect&, BitmapTexture::UpdateContentsFlag);
+ void updateContents(TextureMapper*, GraphicsLayer*, const FloatSize&, const IntRect&, BitmapTexture::UpdateContentsFlag);
+
+ void setContentsToImage(Image* image) { m_image = image; }
+
+private:
+ TextureMapperTiledBackingStore();
+ void createOrDestroyTilesIfNeeded(const FloatSize& backingStoreSize, const IntSize& tileSize, bool hasAlpha);
+ void updateContentsFromImageIfNeeded(TextureMapper*);
+ TransformationMatrix adjustedTransformForRect(const FloatRect&);
+ inline FloatRect rect() const { return FloatRect(FloatPoint::zero(), m_size); }
+
+ Vector<TextureMapperTile> m_tiles;
+ FloatSize m_size;
+ RefPtr<Image> m_image;
+};
+
+} // namespace WebCore
+#endif
+
+#endif
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/AreaAllocator.cpp b/Source/WebCore/platform/graphics/texmap/coordinated/AreaAllocator.cpp
new file mode 100644
index 000000000..9f54185b9
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/coordinated/AreaAllocator.cpp
@@ -0,0 +1,335 @@
+/*
+ * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#include "config.h"
+
+#if USE(COORDINATED_GRAPHICS)
+
+#include "AreaAllocator.h"
+
+namespace WebCore {
+
+AreaAllocator::AreaAllocator(const IntSize& size)
+ : m_size(size)
+ , m_minAlloc(1, 1)
+ , m_margin(0, 0)
+{
+}
+
+AreaAllocator::~AreaAllocator()
+{
+}
+
+void AreaAllocator::expand(const IntSize& size)
+{
+ m_size = m_size.expandedTo(size);
+}
+
+void AreaAllocator::expandBy(const IntSize& size)
+{
+ m_size += size;
+}
+
+void AreaAllocator::release(const IntRect&)
+{
+}
+
+int AreaAllocator::overhead() const
+{
+ return 0;
+}
+
+IntSize AreaAllocator::roundAllocation(const IntSize& size) const
+{
+ int width = size.width() + m_margin.width();
+ int height = size.height() + m_margin.height();
+ int extra = width % m_minAlloc.width();
+ if (extra)
+ width += m_minAlloc.width() - extra;
+ extra = height % m_minAlloc.height();
+ if (extra)
+ height += m_minAlloc.height() - extra;
+
+ return IntSize(width, height);
+}
+
+GeneralAreaAllocator::GeneralAreaAllocator(const IntSize& size)
+ : AreaAllocator(nextPowerOfTwo(size))
+{
+ m_root = new Node();
+ m_root->rect = IntRect(0, 0, m_size.width(), m_size.height());
+ m_root->largestFree = m_size;
+ m_root->parent = 0;
+ m_root->left = 0;
+ m_root->right = 0;
+ m_nodeCount = 1;
+ setMinimumAllocation(IntSize(8, 8));
+}
+
+GeneralAreaAllocator::~GeneralAreaAllocator()
+{
+ freeNode(m_root);
+}
+
+void GeneralAreaAllocator::freeNode(Node* node)
+{
+ if (node) {
+ freeNode(node->left);
+ freeNode(node->right);
+ }
+ delete node;
+}
+
+void GeneralAreaAllocator::expand(const IntSize& size)
+{
+ AreaAllocator::expand(nextPowerOfTwo(size));
+
+ if (m_root->rect.size() == m_size)
+ return; // No change.
+
+ if (!m_root->left && m_root->largestFree.width() > 0) {
+ // No allocations have occurred, so just adjust the root size.
+ m_root->rect = IntRect(0, 0, m_size.width(), m_size.height());
+ m_root->largestFree = m_size;
+ return;
+ }
+
+ // Add extra nodes above the current root to expand the tree.
+ Node* oldRoot = m_root;
+ Split split;
+ if (m_size.width() >= m_size.height())
+ split = SplitOnX;
+ else
+ split = SplitOnY;
+
+ while (m_root->rect.size() != m_size) {
+ if (m_root->rect.width() == m_size.width())
+ split = SplitOnY;
+ else if (m_root->rect.height() == m_size.height())
+ split = SplitOnX;
+ Node* parent = new Node();
+ Node* right = new Node();
+ m_nodeCount += 2;
+ m_root->parent = parent;
+ parent->parent = 0;
+ parent->left = m_root;
+ parent->right = right;
+ parent->largestFree = m_root->rect.size();
+ right->parent = parent;
+ right->left = 0;
+ right->right = 0;
+ right->largestFree = m_root->rect.size();
+ if (split == SplitOnX) {
+ parent->rect = IntRect(m_root->rect.x(), m_root->rect.y(),
+ m_root->rect.width() * 2, m_root->rect.height());
+ right->rect = IntRect(m_root->rect.x() + m_root->rect.width(), m_root->rect.y(),
+ m_root->rect.width(), m_root->rect.height());
+ } else {
+ parent->rect = IntRect(m_root->rect.x(), m_root->rect.y(),
+ m_root->rect.width(), m_root->rect.height() * 2);
+ right->rect = IntRect(m_root->rect.x(), m_root->rect.y() + m_root->rect.width(),
+ m_root->rect.width(), m_root->rect.height());
+ }
+ split = (split == SplitOnX ? SplitOnY : SplitOnX);
+ m_root = parent;
+ }
+ updateLargestFree(oldRoot);
+}
+
+static inline bool fitsWithin(const IntSize& size1, const IntSize& size2)
+{
+ return size1.width() <= size2.width() && size1.height() <= size2.height();
+}
+
+IntRect GeneralAreaAllocator::allocate(const IntSize& size)
+{
+ IntSize rounded = roundAllocation(size);
+ rounded = nextPowerOfTwo(rounded);
+ if (rounded.width() <= 0 || rounded.width() > m_size.width()
+ || rounded.height() <= 0 || rounded.height() > m_size.height())
+ return IntRect();
+
+ IntPoint point = allocateFromNode(rounded, m_root);
+ if (point.x() >= 0)
+ return IntRect(point, size);
+ return IntRect();
+}
+
+IntPoint GeneralAreaAllocator::allocateFromNode(const IntSize& size, Node* node)
+{
+ // Find the best node to insert into, which should be
+ // a node with the least amount of unused space that is
+ // big enough to contain the requested size.
+ while (node) {
+ // Go down a level and determine if the left or right
+ // sub-tree contains the best chance of allocation.
+ Node* left = node->left;
+ Node* right = node->right;
+ if (left && fitsWithin(size, left->largestFree)) {
+ if (right && fitsWithin(size, right->largestFree)) {
+ if (left->largestFree.width() < right->largestFree.width()
+ || left->largestFree.height() < right->largestFree.height()) {
+ // The largestFree values may be a little oversized,
+ // so try the left sub-tree and then the right sub-tree.
+ IntPoint point = allocateFromNode(size, left);
+ if (point.x() >= 0)
+ return point;
+ return allocateFromNode(size, right);
+ }
+ node = right;
+ } else
+ node = left;
+ } else if (right && fitsWithin(size, right->largestFree))
+ node = right;
+ else if (left || right) {
+ // Neither sub-node has enough space to allocate from.
+ return IntPoint(-1, -1);
+ } else if (fitsWithin(size, node->largestFree)) {
+ // Do we need to split this node into smaller pieces?
+ Split split;
+ if (fitsWithin(IntSize(size.width() * 2, size.height() * 2), node->largestFree)) {
+ // Split in either direction: choose the inverse of
+ // the parent node's split direction to try to balance
+ // out the wasted space as further subdivisions happen.
+ if (node->parent
+ && node->parent->left->rect.x() == node->parent->right->rect.x())
+ split = SplitOnX;
+ else if (node->parent)
+ split = SplitOnY;
+ else if (node->rect.width() >= node->rect.height())
+ split = SplitOnX;
+ else
+ split = SplitOnY;
+ } else if (fitsWithin(IntSize(size.width() * 2, size.height()), node->largestFree)) {
+ // Split along the X direction.
+ split = SplitOnX;
+ } else if (fitsWithin(IntSize(size.width(), size.height() * 2), node->largestFree)) {
+ // Split along the Y direction.
+ split = SplitOnY;
+ } else {
+ // Cannot split further - allocate this node.
+ node->largestFree = IntSize(0, 0);
+ updateLargestFree(node);
+ return node->rect.location();
+ }
+
+ // Split the node, then go around again using the left sub-tree.
+ node = splitNode(node, split);
+ } else {
+ // Cannot possibly fit into this node.
+ break;
+ }
+ }
+ return IntPoint(-1, -1);
+}
+
+GeneralAreaAllocator::Node* GeneralAreaAllocator::splitNode
+ (Node* node, Split split)
+{
+ Node* left = new Node();
+ Node* right = new Node();
+ m_nodeCount += 2;
+ left->parent = node;
+ left->left = 0;
+ left->right = 0;
+ right->parent = node;
+ right->left = 0;
+ right->right = 0;
+ node->left = left;
+ node->right = right;
+
+ if (split == SplitOnX) {
+ left->rect = IntRect(node->rect.x(), node->rect.y(),
+ node->rect.width() / 2, node->rect.height());
+ right->rect = IntRect(left->rect.maxX(), node->rect.y(),
+ node->rect.width() / 2, node->rect.height());
+ } else {
+ left->rect = IntRect(node->rect.x(), node->rect.y(),
+ node->rect.width(), node->rect.height() / 2);
+ right->rect = IntRect(node->rect.x(), left->rect.maxY(),
+ node->rect.width(), node->rect.height() / 2);
+ }
+
+ left->largestFree = left->rect.size();
+ right->largestFree = right->rect.size();
+ node->largestFree = right->largestFree;
+ return left;
+}
+
+void GeneralAreaAllocator::updateLargestFree(Node* node)
+{
+ while ((node = node->parent)) {
+ node->largestFree = IntSize(
+ std::max(node->left->largestFree.width(), node->right->largestFree.width()),
+ std::max(node->left->largestFree.height(), node->right->largestFree.height())
+ );
+ }
+}
+
+void GeneralAreaAllocator::release(const IntRect& rect)
+{
+ // Locate the node that contains the allocated region.
+ Node* node = m_root;
+ IntPoint point = rect.location();
+ while (node) {
+ if (node->left && node->left->rect.contains(point))
+ node = node->left;
+ else if (node->right && node->right->rect.contains(point))
+ node = node->right;
+ else if (node->rect.contains(point))
+ break;
+ else
+ return; // Point is completely outside the tree.
+ }
+ if (!node)
+ return;
+
+ // Mark the node as free and then work upwards through the tree
+ // recombining and deleting nodes until we reach a sibling
+ // that is still allocated.
+ node->largestFree = node->rect.size();
+ while (node->parent) {
+ if (node->parent->left == node) {
+ if (node->parent->right->largestFree != node->parent->right->rect.size())
+ break;
+ } else {
+ if (node->parent->left->largestFree != node->parent->left->rect.size())
+ break;
+ }
+ node = node->parent;
+ freeNode(node->left);
+ freeNode(node->right);
+ m_nodeCount -= 2;
+ node->left = 0;
+ node->right = 0;
+ node->largestFree = node->rect.size();
+ }
+
+ // Make the rest of our ancestors have the correct "largest free size".
+ updateLargestFree(node);
+}
+
+int GeneralAreaAllocator::overhead() const
+{
+ return m_nodeCount * sizeof(Node);
+}
+
+} // namespace WebCore
+
+#endif // USE(COORDINATED_GRAPHICS)
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/AreaAllocator.h b/Source/WebCore/platform/graphics/texmap/coordinated/AreaAllocator.h
new file mode 100644
index 000000000..4180cae23
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/coordinated/AreaAllocator.h
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifndef AreaAllocator_h
+#define AreaAllocator_h
+
+#include "IntPoint.h"
+#include "IntRect.h"
+#include "IntSize.h"
+
+#if USE(COORDINATED_GRAPHICS)
+
+namespace WebCore {
+
+inline int nextPowerOfTwo(int number)
+{
+ // This is a fast trick to get nextPowerOfTwo for an integer.
+ --number;
+ number |= number >> 1;
+ number |= number >> 2;
+ number |= number >> 4;
+ number |= number >> 8;
+ number |= number >> 16;
+ number++;
+ return number;
+}
+
+inline IntSize nextPowerOfTwo(const IntSize& size)
+{
+ return IntSize(nextPowerOfTwo(size.width()), nextPowerOfTwo(size.height()));
+}
+
+class AreaAllocator {
+public:
+ explicit AreaAllocator(const IntSize&);
+ virtual ~AreaAllocator();
+
+ IntSize size() const { return m_size; }
+
+ IntSize minimumAllocation() const { return m_minAlloc; }
+ void setMinimumAllocation(const IntSize& size) { m_minAlloc = size; }
+
+ IntSize margin() const { return m_margin; }
+ void setMargin(const IntSize &margin) { m_margin = margin; }
+
+ virtual void expand(const IntSize&);
+ void expandBy(const IntSize&);
+
+ virtual IntRect allocate(const IntSize&) = 0;
+ virtual void release(const IntRect&);
+
+ virtual int overhead() const;
+
+protected:
+ IntSize m_size;
+ IntSize m_minAlloc;
+ IntSize m_margin;
+
+ IntSize roundAllocation(const IntSize&) const;
+};
+
+class GeneralAreaAllocator : public AreaAllocator {
+public:
+ explicit GeneralAreaAllocator(const IntSize&);
+ virtual ~GeneralAreaAllocator();
+
+ void expand(const IntSize&);
+ IntRect allocate(const IntSize&);
+ void release(const IntRect&);
+ int overhead() const;
+
+private:
+ enum Split { SplitOnX, SplitOnY };
+
+ struct Node {
+ IntRect rect;
+ IntSize largestFree;
+ Node* parent;
+ Node* left;
+ Node* right;
+ };
+
+ Node* m_root;
+ int m_nodeCount;
+
+ static void freeNode(Node*);
+ IntPoint allocateFromNode(const IntSize&, Node*);
+ Node* splitNode(Node*, Split);
+ static void updateLargestFree(Node*);
+};
+
+} // namespace WebCore
+
+#endif // USE(COORDINATED_GRAPHICS)
+
+#endif // AreaAllocator_h
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.cpp b/Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.cpp
new file mode 100644
index 000000000..74cd528ec
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.cpp
@@ -0,0 +1,434 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+ * Copyright (C) 2013 Company 100, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if USE(COORDINATED_GRAPHICS)
+#include "CompositingCoordinator.h"
+
+#include "Frame.h"
+#include "FrameView.h"
+#include "GraphicsContext.h"
+#include "InspectorController.h"
+#include "Page.h"
+#include "Settings.h"
+#include <wtf/CurrentTime.h>
+#include <wtf/TemporaryChange.h>
+
+namespace WebCore {
+
+PassOwnPtr<CompositingCoordinator> CompositingCoordinator::create(Page* page, CompositingCoordinator::Client* client)
+{
+ return adoptPtr(new CompositingCoordinator(page, client));
+}
+
+CompositingCoordinator::~CompositingCoordinator()
+{
+ purgeBackingStores();
+
+ LayerMap::iterator end = m_registeredLayers.end();
+ for (LayerMap::iterator it = m_registeredLayers.begin(); it != end; ++it)
+ it->value->setCoordinator(0);
+}
+
+CompositingCoordinator::CompositingCoordinator(Page* page, CompositingCoordinator::Client* client)
+ : m_page(page)
+ , m_client(client)
+ , m_rootCompositingLayer(0)
+ , m_isPurging(false)
+ , m_isFlushingLayerChanges(false)
+ , m_shouldSyncFrame(false)
+ , m_didInitializeRootCompositingLayer(false)
+ , m_releaseInactiveAtlasesTimer(this, &CompositingCoordinator::releaseInactiveAtlasesTimerFired)
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+ , m_lastAnimationServiceTime(0)
+#endif
+{
+ m_page->settings()->setApplyDeviceScaleFactorInCompositor(true);
+
+ // This is a temporary way to enable this only in the GL case, until TextureMapperImageBuffer is removed.
+ // See https://bugs.webkit.org/show_bug.cgi?id=114869
+ CoordinatedGraphicsLayer::setShouldSupportContentsTiling(true);
+}
+
+void CompositingCoordinator::setRootCompositingLayer(GraphicsLayer* layer)
+{
+ if (m_rootCompositingLayer)
+ m_rootCompositingLayer->removeFromParent();
+
+ m_rootCompositingLayer = layer;
+ if (m_rootCompositingLayer)
+ m_rootLayer->addChildAtIndex(m_rootCompositingLayer, 0);
+}
+
+void CompositingCoordinator::sizeDidChange(const IntSize& newSize)
+{
+ m_rootLayer->setSize(newSize);
+ m_client->notifyFlushRequired();
+}
+
+bool CompositingCoordinator::flushPendingLayerChanges()
+{
+ TemporaryChange<bool> protector(m_isFlushingLayerChanges, true);
+
+ initializeRootCompositingLayerIfNeeded();
+
+ m_rootLayer->flushCompositingStateForThisLayerOnly();
+ m_client->didFlushRootLayer();
+
+ bool didSync = m_page->mainFrame()->view()->flushCompositingStateIncludingSubframes();
+
+ toCoordinatedGraphicsLayer(m_rootLayer.get())->updateContentBuffersIncludingSubLayers();
+ toCoordinatedGraphicsLayer(m_rootLayer.get())->syncPendingStateChangesIncludingSubLayers();
+
+ flushPendingImageBackingChanges();
+
+ if (m_shouldSyncFrame) {
+ didSync = true;
+
+ if (m_rootCompositingLayer) {
+ m_state.contentsSize = roundedIntSize(m_rootCompositingLayer->size());
+ if (CoordinatedGraphicsLayer* contentsLayer = mainContentsLayer())
+ m_state.coveredRect = contentsLayer->coverRect();
+ }
+ m_state.scrollPosition = m_visibleContentsRect.location();
+
+ m_client->commitSceneState(m_state);
+
+ clearPendingStateChanges();
+ m_shouldSyncFrame = false;
+ }
+
+ return didSync;
+}
+
+void CompositingCoordinator::syncDisplayState()
+{
+#if ENABLE(INSPECTOR)
+ m_page->inspectorController()->didBeginFrame();
+#endif
+
+#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER) && !USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
+ // Make sure that any previously registered animation callbacks are being executed before we flush the layers.
+ m_lastAnimationServiceTime = WTF::monotonicallyIncreasingTime();
+ m_page->mainFrame()->view()->serviceScriptedAnimations(m_lastAnimationServiceTime);
+#endif
+ m_page->mainFrame()->view()->updateLayoutAndStyleIfNeededRecursive();
+}
+
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+double CompositingCoordinator::nextAnimationServiceTime() const
+{
+ // According to the requestAnimationFrame spec, rAF callbacks should not be faster than 60FPS.
+ static const double MinimalTimeoutForAnimations = 1. / 60.;
+ return std::max<double>(0., MinimalTimeoutForAnimations - WTF::monotonicallyIncreasingTime() + m_lastAnimationServiceTime);
+}
+#endif
+
+void CompositingCoordinator::clearPendingStateChanges()
+{
+ m_state.layersToCreate.clear();
+ m_state.layersToUpdate.clear();
+ m_state.layersToRemove.clear();
+
+ m_state.imagesToCreate.clear();
+ m_state.imagesToRemove.clear();
+ m_state.imagesToUpdate.clear();
+ m_state.imagesToClear.clear();
+
+ m_state.updateAtlasesToCreate.clear();
+ m_state.updateAtlasesToRemove.clear();
+
+#if ENABLE(CSS_SHADERS)
+ m_state.customFiltersToCreate.clear();
+ m_state.customFiltersToRemove.clear();
+#endif
+}
+
+void CompositingCoordinator::initializeRootCompositingLayerIfNeeded()
+{
+ if (m_didInitializeRootCompositingLayer)
+ return;
+
+ m_state.rootCompositingLayer = toCoordinatedGraphicsLayer(m_rootLayer.get())->id();
+ m_didInitializeRootCompositingLayer = true;
+ m_shouldSyncFrame = true;
+}
+
+void CompositingCoordinator::createRootLayer(const IntSize& size)
+{
+ ASSERT(!m_rootLayer);
+ // Create a root layer.
+ m_rootLayer = GraphicsLayer::create(this, this);
+#ifndef NDEBUG
+ m_rootLayer->setName("CompositingCoordinator root layer");
+#endif
+ m_rootLayer->setDrawsContent(false);
+ m_rootLayer->setSize(size);
+}
+
+void CompositingCoordinator::syncLayerState(CoordinatedLayerID id, CoordinatedGraphicsLayerState& state)
+{
+ m_shouldSyncFrame = true;
+ m_client->willSyncLayerState(state);
+ m_state.layersToUpdate.append(std::make_pair(id, state));
+}
+
+PassRefPtr<CoordinatedImageBacking> CompositingCoordinator::createImageBackingIfNeeded(Image* image)
+{
+ CoordinatedImageBackingID imageID = CoordinatedImageBacking::getCoordinatedImageBackingID(image);
+ ImageBackingMap::iterator it = m_imageBackings.find(imageID);
+ RefPtr<CoordinatedImageBacking> imageBacking;
+ if (it == m_imageBackings.end()) {
+ imageBacking = CoordinatedImageBacking::create(this, image);
+ m_imageBackings.add(imageID, imageBacking);
+ } else
+ imageBacking = it->value;
+
+ return imageBacking;
+}
+
+void CompositingCoordinator::createImageBacking(CoordinatedImageBackingID imageID)
+{
+ m_state.imagesToCreate.append(imageID);
+}
+
+void CompositingCoordinator::updateImageBacking(CoordinatedImageBackingID imageID, PassRefPtr<CoordinatedSurface> coordinatedSurface)
+{
+ m_shouldSyncFrame = true;
+ m_state.imagesToUpdate.append(std::make_pair(imageID, coordinatedSurface));
+}
+
+void CompositingCoordinator::clearImageBackingContents(CoordinatedImageBackingID imageID)
+{
+ m_shouldSyncFrame = true;
+ m_state.imagesToClear.append(imageID);
+}
+
+void CompositingCoordinator::removeImageBacking(CoordinatedImageBackingID imageID)
+{
+ if (m_isPurging)
+ return;
+
+ ASSERT(m_imageBackings.contains(imageID));
+ m_imageBackings.remove(imageID);
+
+ m_state.imagesToRemove.append(imageID);
+}
+
+void CompositingCoordinator::flushPendingImageBackingChanges()
+{
+ ImageBackingMap::iterator end = m_imageBackings.end();
+ for (ImageBackingMap::iterator iter = m_imageBackings.begin(); iter != end; ++iter)
+ iter->value->update();
+}
+
+void CompositingCoordinator::notifyAnimationStarted(const GraphicsLayer*, double /* time */)
+{
+}
+
+void CompositingCoordinator::notifyFlushRequired(const GraphicsLayer*)
+{
+ m_client->notifyFlushRequired();
+}
+
+
+void CompositingCoordinator::paintContents(const GraphicsLayer* graphicsLayer, GraphicsContext& graphicsContext, GraphicsLayerPaintingPhase, const IntRect& clipRect)
+{
+ m_client->paintLayerContents(graphicsLayer, graphicsContext, clipRect);
+}
+
+PassOwnPtr<GraphicsLayer> CompositingCoordinator::createGraphicsLayer(GraphicsLayerClient* client)
+{
+ CoordinatedGraphicsLayer* layer = new CoordinatedGraphicsLayer(client);
+ layer->setCoordinator(this);
+ m_registeredLayers.add(layer->id(), layer);
+ m_state.layersToCreate.append(layer->id());
+ layer->setNeedsVisibleRectAdjustment();
+ m_client->notifyFlushRequired();
+ return adoptPtr(layer);
+}
+
+float CompositingCoordinator::deviceScaleFactor() const
+{
+ return m_page->deviceScaleFactor();
+}
+
+float CompositingCoordinator::pageScaleFactor() const
+{
+ return m_page->pageScaleFactor();
+}
+
+void CompositingCoordinator::createUpdateAtlas(uint32_t atlasID, PassRefPtr<CoordinatedSurface> coordinatedSurface)
+{
+ m_state.updateAtlasesToCreate.append(std::make_pair(atlasID, coordinatedSurface));
+}
+
+void CompositingCoordinator::removeUpdateAtlas(uint32_t atlasID)
+{
+ if (m_isPurging)
+ return;
+ m_state.updateAtlasesToRemove.append(atlasID);
+}
+
+FloatRect CompositingCoordinator::visibleContentsRect() const
+{
+ return m_visibleContentsRect;
+}
+
+CoordinatedGraphicsLayer* CompositingCoordinator::mainContentsLayer()
+{
+ if (!m_rootCompositingLayer)
+ return 0;
+
+ return toCoordinatedGraphicsLayer(m_rootCompositingLayer)->findFirstDescendantWithContentsRecursively();
+}
+
+void CompositingCoordinator::setVisibleContentsRect(const FloatRect& rect, const FloatPoint& trajectoryVector)
+{
+ // A zero trajectoryVector indicates that tiles all around the viewport are requested.
+ if (CoordinatedGraphicsLayer* contentsLayer = mainContentsLayer())
+ contentsLayer->setVisibleContentRectTrajectoryVector(trajectoryVector);
+
+ bool contentsRectDidChange = rect != m_visibleContentsRect;
+ if (contentsRectDidChange) {
+ m_visibleContentsRect = rect;
+
+ LayerMap::iterator end = m_registeredLayers.end();
+ for (LayerMap::iterator it = m_registeredLayers.begin(); it != end; ++it)
+ it->value->setNeedsVisibleRectAdjustment();
+ }
+
+ FrameView* view = m_page->mainFrame()->view();
+ if (view->useFixedLayout()) {
+ // Round the rect instead of enclosing it to make sure that its size stays
+ // the same while panning. This can have nasty effects on layout.
+ view->setFixedVisibleContentRect(roundedIntRect(rect));
+ }
+}
+
+void CompositingCoordinator::deviceOrPageScaleFactorChanged()
+{
+ m_rootLayer->deviceOrPageScaleFactorChanged();
+}
+
+void CompositingCoordinator::detachLayer(CoordinatedGraphicsLayer* layer)
+{
+ if (m_isPurging)
+ return;
+
+ m_registeredLayers.remove(layer->id());
+
+ size_t index = m_state.layersToCreate.find(layer->id());
+ if (index != notFound) {
+ m_state.layersToCreate.remove(index);
+ return;
+ }
+
+ m_state.layersToRemove.append(layer->id());
+ m_client->notifyFlushRequired();
+}
+
+void CompositingCoordinator::commitScrollOffset(uint32_t layerID, const WebCore::IntSize& offset)
+{
+ LayerMap::iterator i = m_registeredLayers.find(layerID);
+ if (i == m_registeredLayers.end())
+ return;
+
+ i->value->commitScrollOffset(offset);
+}
+
+void CompositingCoordinator::renderNextFrame()
+{
+ for (unsigned i = 0; i < m_updateAtlases.size(); ++i)
+ m_updateAtlases[i]->didSwapBuffers();
+}
+
+void CompositingCoordinator::purgeBackingStores()
+{
+ TemporaryChange<bool> purgingToggle(m_isPurging, true);
+
+ LayerMap::iterator end = m_registeredLayers.end();
+ for (LayerMap::iterator it = m_registeredLayers.begin(); it != end; ++it)
+ it->value->purgeBackingStores();
+
+ m_imageBackings.clear();
+ m_updateAtlases.clear();
+}
+
+bool CompositingCoordinator::paintToSurface(const IntSize& size, CoordinatedSurface::Flags flags, uint32_t& atlasID, IntPoint& offset, CoordinatedSurface::Client* client)
+{
+ for (unsigned i = 0; i < m_updateAtlases.size(); ++i) {
+ UpdateAtlas* atlas = m_updateAtlases[i].get();
+ if (atlas->supportsAlpha() == (flags & CoordinatedSurface::SupportsAlpha)) {
+ // This will be false if there is no available buffer space.
+ if (atlas->paintOnAvailableBuffer(size, atlasID, offset, client))
+ return true;
+ }
+ }
+
+ static const int ScratchBufferDimension = 1024; // Should be a power of two.
+ m_updateAtlases.append(adoptPtr(new UpdateAtlas(this, ScratchBufferDimension, flags)));
+ scheduleReleaseInactiveAtlases();
+ return m_updateAtlases.last()->paintOnAvailableBuffer(size, atlasID, offset, client);
+}
+
+const double ReleaseInactiveAtlasesTimerInterval = 0.5;
+
+void CompositingCoordinator::scheduleReleaseInactiveAtlases()
+{
+ if (!m_releaseInactiveAtlasesTimer.isActive())
+ m_releaseInactiveAtlasesTimer.startRepeating(ReleaseInactiveAtlasesTimerInterval);
+}
+
+void CompositingCoordinator::releaseInactiveAtlasesTimerFired(Timer<CompositingCoordinator>*)
+{
+ // We always want to keep one atlas for root contents layer.
+ OwnPtr<UpdateAtlas> atlasToKeepAnyway;
+ bool foundActiveAtlasForRootContentsLayer = false;
+ for (int i = m_updateAtlases.size() - 1; i >= 0; --i) {
+ UpdateAtlas* atlas = m_updateAtlases[i].get();
+ if (!atlas->isInUse())
+ atlas->addTimeInactive(ReleaseInactiveAtlasesTimerInterval);
+ bool usableForRootContentsLayer = !atlas->supportsAlpha();
+ if (atlas->isInactive()) {
+ if (!foundActiveAtlasForRootContentsLayer && !atlasToKeepAnyway && usableForRootContentsLayer)
+ atlasToKeepAnyway = m_updateAtlases[i].release();
+ m_updateAtlases.remove(i);
+ } else if (usableForRootContentsLayer)
+ foundActiveAtlasForRootContentsLayer = true;
+ }
+
+ if (!foundActiveAtlasForRootContentsLayer && atlasToKeepAnyway)
+ m_updateAtlases.append(atlasToKeepAnyway.release());
+
+ if (m_updateAtlases.size() <= 1)
+ m_releaseInactiveAtlasesTimer.stop();
+}
+
+} // namespace WebCore
+
+#endif // USE(COORDINATED_GRAPHICS)
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.h b/Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.h
new file mode 100644
index 000000000..fd41cb873
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.h
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2013 Company 100, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CompositingCoordinator_h
+#define CompositingCoordinator_h
+
+#if USE(COORDINATED_GRAPHICS)
+
+#include "CoordinatedGraphicsLayer.h"
+#include "CoordinatedGraphicsState.h"
+#include "CoordinatedImageBacking.h"
+#include "FloatPoint.h"
+#include "GraphicsLayerClient.h"
+#include "GraphicsLayerFactory.h"
+#include "IntRect.h"
+#include "Timer.h"
+#include "UpdateAtlas.h"
+#include <wtf/OwnPtr.h>
+
+#if ENABLE(CSS_SHADERS)
+#include "FilterOperations.h"
+#endif
+
+namespace WebCore {
+
+class Page;
+class GraphicsContext;
+class GraphicsLayer;
+class CoordinatedSurface;
+
+class CompositingCoordinator : public GraphicsLayerClient
+ , public CoordinatedGraphicsLayerClient
+ , public CoordinatedImageBacking::Client
+ , public UpdateAtlas::Client
+ , public GraphicsLayerFactory {
+ WTF_MAKE_NONCOPYABLE(CompositingCoordinator); WTF_MAKE_FAST_ALLOCATED;
+public:
+ class Client {
+ public:
+ virtual void didFlushRootLayer() = 0;
+ virtual void willSyncLayerState(CoordinatedGraphicsLayerState&) = 0;
+ virtual void notifyFlushRequired() = 0;
+ virtual void commitSceneState(const CoordinatedGraphicsState&) = 0;
+ virtual void paintLayerContents(const GraphicsLayer*, GraphicsContext&, const IntRect& clipRect) = 0;
+ };
+
+ static PassOwnPtr<CompositingCoordinator> create(Page*, CompositingCoordinator::Client*);
+ virtual ~CompositingCoordinator();
+
+ void setRootCompositingLayer(GraphicsLayer*);
+ void sizeDidChange(const IntSize& newSize);
+ void deviceOrPageScaleFactorChanged();
+
+ void setVisibleContentsRect(const FloatRect&, const FloatPoint&);
+ void renderNextFrame();
+ void purgeBackingStores();
+ void commitScrollOffset(uint32_t layerID, const IntSize& offset);
+
+ void createRootLayer(const IntSize&);
+ void clearRootLayer() { m_rootLayer = nullptr; }
+ GraphicsLayer* rootLayer() const { return m_rootLayer.get(); }
+ CoordinatedGraphicsLayer* mainContentsLayer();
+
+ bool flushPendingLayerChanges();
+ CoordinatedGraphicsState& state() { return m_state; }
+
+ void syncDisplayState();
+
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+ double nextAnimationServiceTime() const;
+#endif
+
+private:
+ CompositingCoordinator(Page*, CompositingCoordinator::Client*);
+
+ // GraphicsLayerClient
+ virtual void notifyAnimationStarted(const GraphicsLayer*, double time) OVERRIDE;
+ virtual void notifyFlushRequired(const GraphicsLayer*) OVERRIDE;
+ virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& clipRect) OVERRIDE;
+ virtual float deviceScaleFactor() const OVERRIDE;
+ virtual float pageScaleFactor() const OVERRIDE;
+
+ // CoordinatedImageBacking::Client
+ virtual void createImageBacking(CoordinatedImageBackingID) OVERRIDE;
+ virtual void updateImageBacking(CoordinatedImageBackingID, PassRefPtr<CoordinatedSurface>) OVERRIDE;
+ virtual void clearImageBackingContents(CoordinatedImageBackingID) OVERRIDE;
+ virtual void removeImageBacking(CoordinatedImageBackingID) OVERRIDE;
+
+ // CoordinatedGraphicsLayerClient
+ virtual bool isFlushingLayerChanges() const OVERRIDE { return m_isFlushingLayerChanges; }
+ virtual FloatRect visibleContentsRect() const OVERRIDE;
+ virtual PassRefPtr<CoordinatedImageBacking> createImageBackingIfNeeded(Image*) OVERRIDE;
+ virtual void detachLayer(CoordinatedGraphicsLayer*) OVERRIDE;
+ virtual bool paintToSurface(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags, uint32_t& /* atlasID */, WebCore::IntPoint&, WebCore::CoordinatedSurface::Client*) OVERRIDE;
+ virtual void syncLayerState(CoordinatedLayerID, CoordinatedGraphicsLayerState&) OVERRIDE;
+
+ // UpdateAtlas::Client
+ virtual void createUpdateAtlas(uint32_t atlasID, PassRefPtr<CoordinatedSurface>) OVERRIDE;
+ virtual void removeUpdateAtlas(uint32_t atlasID) OVERRIDE;
+
+ // GraphicsLayerFactory
+ virtual PassOwnPtr<GraphicsLayer> createGraphicsLayer(GraphicsLayerClient*) OVERRIDE;
+
+ void initializeRootCompositingLayerIfNeeded();
+ void flushPendingImageBackingChanges();
+ void clearPendingStateChanges();
+
+ void scheduleReleaseInactiveAtlases();
+
+ void releaseInactiveAtlasesTimerFired(Timer<CompositingCoordinator>*);
+
+ Page* m_page;
+ CompositingCoordinator::Client* m_client;
+
+ OwnPtr<GraphicsLayer> m_rootLayer;
+ GraphicsLayer* m_rootCompositingLayer;
+
+ CoordinatedGraphicsState m_state;
+
+ typedef HashMap<CoordinatedLayerID, CoordinatedGraphicsLayer*> LayerMap;
+ LayerMap m_registeredLayers;
+ typedef HashMap<CoordinatedImageBackingID, RefPtr<CoordinatedImageBacking> > ImageBackingMap;
+ ImageBackingMap m_imageBackings;
+ Vector<OwnPtr<UpdateAtlas> > m_updateAtlases;
+
+ // We don't send the messages related to releasing resources to renderer during purging, because renderer already had removed all resources.
+ bool m_isPurging;
+ bool m_isFlushingLayerChanges;
+
+ FloatRect m_visibleContentsRect;
+
+ bool m_shouldSyncFrame;
+ bool m_didInitializeRootCompositingLayer;
+ Timer<CompositingCoordinator> m_releaseInactiveAtlasesTimer;
+
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+ double m_lastAnimationServiceTime;
+#endif
+};
+
+}
+
+#endif
+
+#endif // CompositingCoordinator_h
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedBackingStore.cpp b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedBackingStore.cpp
new file mode 100644
index 000000000..2737ec125
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedBackingStore.cpp
@@ -0,0 +1,194 @@
+/*
+ Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "CoordinatedBackingStore.h"
+
+#if USE(COORDINATED_GRAPHICS)
+#include "CoordinatedSurface.h"
+#include "GraphicsLayer.h"
+#include "TextureMapper.h"
+#include "TextureMapperGL.h"
+
+namespace WebCore {
+
+void CoordinatedBackingStoreTile::swapBuffers(TextureMapper* textureMapper)
+{
+ if (!m_surface)
+ return;
+
+ FloatRect tileRect(m_tileRect);
+ tileRect.scale(1. / m_scale);
+ bool shouldReset = false;
+ if (tileRect != rect()) {
+ setRect(tileRect);
+ shouldReset = true;
+ }
+ RefPtr<BitmapTexture> texture = this->texture();
+ if (!texture) {
+ texture = textureMapper->createTexture();
+ setTexture(texture.get());
+ shouldReset = true;
+ }
+
+ ASSERT(textureMapper->maxTextureSize().width() >= m_tileRect.size().width());
+ ASSERT(textureMapper->maxTextureSize().height() >= m_tileRect.size().height());
+ if (shouldReset)
+ texture->reset(m_tileRect.size(), m_surface->supportsAlpha());
+
+ m_surface->copyToTexture(texture, m_sourceRect, m_surfaceOffset);
+ m_surface.clear();
+}
+
+void CoordinatedBackingStoreTile::setBackBuffer(const IntRect& tileRect, const IntRect& sourceRect, PassRefPtr<CoordinatedSurface> buffer, const IntPoint& offset)
+{
+ m_sourceRect = sourceRect;
+ m_tileRect = tileRect;
+ m_surfaceOffset = offset;
+ m_surface = buffer;
+}
+
+void CoordinatedBackingStore::createTile(uint32_t id, float scale)
+{
+ m_tiles.add(id, CoordinatedBackingStoreTile(scale));
+ m_scale = scale;
+}
+
+void CoordinatedBackingStore::removeTile(uint32_t id)
+{
+ ASSERT(m_tiles.contains(id));
+ m_tilesToRemove.add(id);
+}
+
+void CoordinatedBackingStore::removeAllTiles()
+{
+ CoordinatedBackingStoreTileMap::iterator end = m_tiles.end();
+ for (CoordinatedBackingStoreTileMap::iterator it = m_tiles.begin(); it != end; ++it)
+ m_tilesToRemove.add(it->key);
+}
+
+void CoordinatedBackingStore::updateTile(uint32_t id, const IntRect& sourceRect, const IntRect& tileRect, PassRefPtr<CoordinatedSurface> backBuffer, const IntPoint& offset)
+{
+ CoordinatedBackingStoreTileMap::iterator it = m_tiles.find(id);
+ ASSERT(it != m_tiles.end());
+ it->value.setBackBuffer(tileRect, sourceRect, backBuffer, offset);
+}
+
+PassRefPtr<BitmapTexture> CoordinatedBackingStore::texture() const
+{
+ CoordinatedBackingStoreTileMap::const_iterator end = m_tiles.end();
+ for (CoordinatedBackingStoreTileMap::const_iterator it = m_tiles.begin(); it != end; ++it) {
+ RefPtr<BitmapTexture> texture = it->value.texture();
+ if (texture)
+ return texture;
+ }
+
+ return PassRefPtr<BitmapTexture>();
+}
+
+void CoordinatedBackingStore::setSize(const FloatSize& size)
+{
+ m_pendingSize = size;
+}
+
+void CoordinatedBackingStore::paintTilesToTextureMapper(Vector<TextureMapperTile*>& tiles, TextureMapper* textureMapper, const TransformationMatrix& transform, float opacity, const FloatRect& rect)
+{
+ for (size_t i = 0; i < tiles.size(); ++i)
+ tiles[i]->paint(textureMapper, transform, opacity, calculateExposedTileEdges(rect, tiles[i]->rect()));
+}
+
+TransformationMatrix CoordinatedBackingStore::adjustedTransformForRect(const FloatRect& targetRect)
+{
+ return TransformationMatrix::rectToRect(rect(), targetRect);
+}
+
+void CoordinatedBackingStore::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity)
+{
+ if (m_tiles.isEmpty())
+ return;
+ ASSERT(!m_size.isZero());
+
+ Vector<TextureMapperTile*> tilesToPaint;
+ Vector<TextureMapperTile*> previousTilesToPaint;
+
+ // We have to do this every time we paint, in case the opacity has changed.
+ CoordinatedBackingStoreTileMap::iterator end = m_tiles.end();
+ FloatRect coveredRect;
+ for (CoordinatedBackingStoreTileMap::iterator it = m_tiles.begin(); it != end; ++it) {
+ CoordinatedBackingStoreTile& tile = it->value;
+ if (!tile.texture())
+ continue;
+
+ if (tile.scale() == m_scale) {
+ tilesToPaint.append(&tile);
+ coveredRect.unite(tile.rect());
+ continue;
+ }
+
+ // Only show the previous tile if the opacity is high, otherwise effect looks like a bug.
+ // We show the previous-scale tile anyway if it doesn't intersect with any current-scale tile.
+ if (opacity < 0.95 && coveredRect.intersects(tile.rect()))
+ continue;
+
+ previousTilesToPaint.append(&tile);
+ }
+
+ // targetRect is on the contents coordinate system, so we must compare two rects on the contents coordinate system.
+ // See TiledBackingStore.
+ TransformationMatrix adjustedTransform = transform * adjustedTransformForRect(targetRect);
+
+ paintTilesToTextureMapper(previousTilesToPaint, textureMapper, adjustedTransform, opacity, rect());
+ paintTilesToTextureMapper(tilesToPaint, textureMapper, adjustedTransform, opacity, rect());
+}
+
+void CoordinatedBackingStore::drawBorder(TextureMapper* textureMapper, const Color& borderColor, float borderWidth, const FloatRect& targetRect, const TransformationMatrix& transform)
+{
+ TransformationMatrix adjustedTransform = transform * adjustedTransformForRect(targetRect);
+ CoordinatedBackingStoreTileMap::iterator end = m_tiles.end();
+ for (CoordinatedBackingStoreTileMap::iterator it = m_tiles.begin(); it != end; ++it)
+ textureMapper->drawBorder(borderColor, borderWidth, it->value.rect(), adjustedTransform);
+}
+
+void CoordinatedBackingStore::drawRepaintCounter(TextureMapper* textureMapper, int repaintCount, const Color& borderColor, const FloatRect& targetRect, const TransformationMatrix& transform)
+{
+ TransformationMatrix adjustedTransform = transform * adjustedTransformForRect(targetRect);
+ CoordinatedBackingStoreTileMap::iterator end = m_tiles.end();
+ for (CoordinatedBackingStoreTileMap::iterator it = m_tiles.begin(); it != end; ++it)
+ textureMapper->drawNumber(repaintCount, borderColor, it->value.rect().location(), adjustedTransform);
+}
+
+void CoordinatedBackingStore::commitTileOperations(TextureMapper* textureMapper)
+{
+ if (!m_pendingSize.isZero()) {
+ m_size = m_pendingSize;
+ m_pendingSize = FloatSize();
+ }
+
+ HashSet<uint32_t>::iterator tilesToRemoveEnd = m_tilesToRemove.end();
+ for (HashSet<uint32_t>::iterator it = m_tilesToRemove.begin(); it != tilesToRemoveEnd; ++it)
+ m_tiles.remove(*it);
+ m_tilesToRemove.clear();
+
+ CoordinatedBackingStoreTileMap::iterator tilesEnd = m_tiles.end();
+ for (CoordinatedBackingStoreTileMap::iterator it = m_tiles.begin(); it != tilesEnd; ++it)
+ it->value.swapBuffers(textureMapper);
+}
+
+} // namespace WebCore
+#endif // USE(COORDINATED_GRAPHICS)
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedBackingStore.h b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedBackingStore.h
new file mode 100644
index 000000000..4201454bd
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedBackingStore.h
@@ -0,0 +1,90 @@
+/*
+ Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#ifndef CoordinatedBackingStore_h
+#define CoordinatedBackingStore_h
+
+#if USE(COORDINATED_GRAPHICS)
+
+#include "TextureMapper.h"
+#include "TextureMapperBackingStore.h"
+#include "TextureMapperTile.h"
+#include <wtf/HashMap.h>
+#include <wtf/HashSet.h>
+
+namespace WebCore {
+
+class CoordinatedSurface;
+
+class CoordinatedBackingStoreTile : public TextureMapperTile {
+public:
+ explicit CoordinatedBackingStoreTile(float scale = 1)
+ : TextureMapperTile(FloatRect())
+ , m_scale(scale)
+ {
+ }
+
+ inline float scale() const { return m_scale; }
+ void swapBuffers(TextureMapper*);
+ void setBackBuffer(const IntRect&, const IntRect&, PassRefPtr<CoordinatedSurface> buffer, const IntPoint&);
+
+private:
+ RefPtr<CoordinatedSurface> m_surface;
+ IntRect m_sourceRect;
+ IntRect m_tileRect;
+ IntPoint m_surfaceOffset;
+ float m_scale;
+};
+
+class CoordinatedBackingStore : public TextureMapperBackingStore {
+public:
+ void createTile(uint32_t tileID, float);
+ void removeTile(uint32_t tileID);
+ void removeAllTiles();
+ void updateTile(uint32_t tileID, const IntRect&, const IntRect&, PassRefPtr<CoordinatedSurface>, const IntPoint&);
+ static PassRefPtr<CoordinatedBackingStore> create() { return adoptRef(new CoordinatedBackingStore); }
+ void commitTileOperations(TextureMapper*);
+ PassRefPtr<BitmapTexture> texture() const;
+ void setSize(const FloatSize&);
+ virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float);
+ virtual void drawBorder(TextureMapper*, const Color&, float borderWidth, const FloatRect&, const TransformationMatrix&) OVERRIDE;
+ virtual void drawRepaintCounter(TextureMapper*, int repaintCount, const Color&, const FloatRect&, const TransformationMatrix&) OVERRIDE;
+
+private:
+ CoordinatedBackingStore()
+ : m_scale(1.)
+ { }
+ void paintTilesToTextureMapper(Vector<TextureMapperTile*>&, TextureMapper*, const TransformationMatrix&, float, const FloatRect&);
+ TransformationMatrix adjustedTransformForRect(const FloatRect&);
+ FloatRect rect() const { return FloatRect(FloatPoint::zero(), m_size); }
+
+ typedef HashMap<uint32_t, CoordinatedBackingStoreTile> CoordinatedBackingStoreTileMap;
+ CoordinatedBackingStoreTileMap m_tiles;
+ HashSet<uint32_t> m_tilesToRemove;
+ // FIXME: m_pendingSize should be removed after the following bug is fixed: https://bugs.webkit.org/show_bug.cgi?id=108294
+ FloatSize m_pendingSize;
+ FloatSize m_size;
+ float m_scale;
+};
+
+} // namespace WebCore
+
+#endif // USE(COORDINATED_GRAPHICS)
+
+#endif // CoordinatedBackingStore_h
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedCustomFilterOperation.h b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedCustomFilterOperation.h
new file mode 100644
index 000000000..17a7182b4
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedCustomFilterOperation.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef CoordinatedCustomFilterOperation_h
+#define CoordinatedCustomFilterOperation_h
+
+#if ENABLE(CSS_SHADERS)
+#include "CustomFilterOperation.h"
+
+namespace WebCore {
+
+// This class is only adding the programId on top of CustomFilterOperation. The argument decoder has no
+// context, so we cannot search in our cached CustomFilterPrograms while decoding. In that case
+// it will just store the programId and no CustomFilterProgram instance. The receiver is supposed to
+// iterate on this structure and inject the right CustomFilterPrograms.
+
+class CoordinatedCustomFilterOperation : public CustomFilterOperation {
+public:
+ static PassRefPtr<CoordinatedCustomFilterOperation> create(PassRefPtr<CustomFilterProgram> program, int programID, const CustomFilterParameterList& sortedParameters, unsigned meshRows, unsigned meshColumns)
+ {
+ return adoptRef(new CoordinatedCustomFilterOperation(program, programID, sortedParameters, meshRows, meshColumns));
+ }
+
+ int programID() const { return m_programID; }
+
+private:
+ CoordinatedCustomFilterOperation(PassRefPtr<CustomFilterProgram> program, int programID, const CustomFilterParameterList& sortedParameters, unsigned meshRows, unsigned meshColumns)
+ : CustomFilterOperation(program, sortedParameters, meshRows, meshColumns)
+ , m_programID(programID)
+ {
+ }
+
+ int m_programID;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(CSS_SHADERS)
+
+#endif // CoordinatedCustomFilterOperation_h
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedCustomFilterProgram.h b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedCustomFilterProgram.h
new file mode 100644
index 000000000..7f4f154c9
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedCustomFilterProgram.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2012 Company 100, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CoordinatedCustomFilterProgram_h
+#define CoordinatedCustomFilterProgram_h
+
+#if USE(COORDINATED_GRAPHICS) && ENABLE(CSS_SHADERS)
+#include "CustomFilterConstants.h"
+#include "CustomFilterProgram.h"
+
+namespace WebCore {
+
+class CoordinatedCustomFilterProgram : public CustomFilterProgram {
+public:
+ static PassRefPtr<CoordinatedCustomFilterProgram> create(String vertexShaderString, String m_fragmentShaderString, CustomFilterProgramType programType, CustomFilterProgramMixSettings mixSettings, CustomFilterMeshType meshType)
+ {
+ return adoptRef(new CoordinatedCustomFilterProgram(vertexShaderString, m_fragmentShaderString, programType, mixSettings, meshType));
+ }
+
+ virtual bool isLoaded() const OVERRIDE { return true; }
+
+protected:
+ virtual String vertexShaderString() const OVERRIDE { return m_vertexShaderString; }
+ virtual String fragmentShaderString() const OVERRIDE { return m_fragmentShaderString; }
+
+ virtual void willHaveClients() OVERRIDE { notifyClients(); }
+ virtual void didRemoveLastClient() OVERRIDE { }
+
+private:
+ CoordinatedCustomFilterProgram(String vertexShaderString, String fragmentShaderString, CustomFilterProgramType programType, CustomFilterProgramMixSettings mixSettings, CustomFilterMeshType meshType)
+ : CustomFilterProgram(programType, mixSettings, meshType)
+ , m_vertexShaderString(vertexShaderString)
+ , m_fragmentShaderString(fragmentShaderString)
+ {
+ }
+
+ String m_vertexShaderString;
+ String m_fragmentShaderString;
+};
+
+} // namespace WebCore
+
+#endif // USE(COORDINATED_GRAPHICS) && ENABLE(CSS_SHADERS)
+
+#endif // CoordinatedCustomFilterProgram_h
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp
new file mode 100644
index 000000000..7e70bbb0d
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp
@@ -0,0 +1,1255 @@
+/*
+ Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2010 Apple Inc. All rights reserved.
+ Copyright (C) 2012 Company 100, Inc.
+ Copyright (C) 2012 Intel Corporation. All rights reserved.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#if USE(COORDINATED_GRAPHICS)
+#include "CoordinatedGraphicsLayer.h"
+
+#include "CoordinatedTile.h"
+#include "FloatQuad.h"
+#include "Frame.h"
+#include "FrameView.h"
+#include "GraphicsContext.h"
+#include "GraphicsLayer.h"
+#include "Page.h"
+#include "ScrollableArea.h"
+#include "TextureMapperPlatformLayer.h"
+#include <wtf/CurrentTime.h>
+#include <wtf/HashMap.h>
+#ifndef NDEBUG
+#include <wtf/TemporaryChange.h>
+#endif
+#include <wtf/text/CString.h>
+
+namespace WebCore {
+
+static CoordinatedLayerID toCoordinatedLayerID(GraphicsLayer* layer)
+{
+ return layer ? toCoordinatedGraphicsLayer(layer)->id() : 0;
+}
+
+void CoordinatedGraphicsLayer::didChangeLayerState()
+{
+ m_shouldSyncLayerState = true;
+ if (client())
+ client()->notifyFlushRequired(this);
+}
+
+void CoordinatedGraphicsLayer::didChangeAnimations()
+{
+ m_shouldSyncAnimations = true;
+ if (client())
+ client()->notifyFlushRequired(this);
+}
+
+void CoordinatedGraphicsLayer::didChangeChildren()
+{
+ m_shouldSyncChildren = true;
+ if (client())
+ client()->notifyFlushRequired(this);
+}
+
+#if ENABLE(CSS_FILTERS)
+void CoordinatedGraphicsLayer::didChangeFilters()
+{
+ m_shouldSyncFilters = true;
+ if (client())
+ client()->notifyFlushRequired(this);
+}
+#endif
+
+void CoordinatedGraphicsLayer::didChangeImageBacking()
+{
+ m_shouldSyncImageBacking = true;
+ if (client())
+ client()->notifyFlushRequired(this);
+}
+
+void CoordinatedGraphicsLayer::setShouldUpdateVisibleRect()
+{
+ m_shouldUpdateVisibleRect = true;
+ for (size_t i = 0; i < children().size(); ++i)
+ toCoordinatedGraphicsLayer(children()[i])->setShouldUpdateVisibleRect();
+ if (replicaLayer())
+ toCoordinatedGraphicsLayer(replicaLayer())->setShouldUpdateVisibleRect();
+}
+
+void CoordinatedGraphicsLayer::didChangeGeometry()
+{
+ didChangeLayerState();
+ setShouldUpdateVisibleRect();
+}
+
+CoordinatedGraphicsLayer::CoordinatedGraphicsLayer(GraphicsLayerClient* client)
+ : GraphicsLayer(client)
+#ifndef NDEBUG
+ , m_isPurging(false)
+#endif
+ , m_shouldUpdateVisibleRect(true)
+ , m_shouldSyncLayerState(true)
+ , m_shouldSyncChildren(true)
+ , m_shouldSyncFilters(true)
+ , m_shouldSyncImageBacking(true)
+ , m_shouldSyncAnimations(true)
+ , m_fixedToViewport(false)
+ , m_movingVisibleRect(false)
+ , m_pendingContentsScaleAdjustment(false)
+ , m_pendingVisibleRectAdjustment(false)
+#if USE(GRAPHICS_SURFACE)
+ , m_isValidCanvas(false)
+ , m_pendingCanvasOperation(None)
+#endif
+ , m_coordinator(0)
+ , m_compositedNativeImagePtr(0)
+ , m_canvasPlatformLayer(0)
+ , m_animationStartedTimer(this, &CoordinatedGraphicsLayer::animationStartedTimerFired)
+ , m_scrollableArea(0)
+{
+ static CoordinatedLayerID nextLayerID = 1;
+ m_id = nextLayerID++;
+}
+
+CoordinatedGraphicsLayer::~CoordinatedGraphicsLayer()
+{
+ if (m_coordinator) {
+ purgeBackingStores();
+ m_coordinator->detachLayer(this);
+ }
+ ASSERT(!m_coordinatedImageBacking);
+ ASSERT(!m_mainBackingStore);
+ willBeDestroyed();
+}
+
+bool CoordinatedGraphicsLayer::setChildren(const Vector<GraphicsLayer*>& children)
+{
+ bool ok = GraphicsLayer::setChildren(children);
+ if (!ok)
+ return false;
+ didChangeChildren();
+ return true;
+}
+
+void CoordinatedGraphicsLayer::addChild(GraphicsLayer* layer)
+{
+ GraphicsLayer::addChild(layer);
+ didChangeChildren();
+}
+
+void CoordinatedGraphicsLayer::addChildAtIndex(GraphicsLayer* layer, int index)
+{
+ GraphicsLayer::addChildAtIndex(layer, index);
+ didChangeChildren();
+}
+
+void CoordinatedGraphicsLayer::addChildAbove(GraphicsLayer* layer, GraphicsLayer* sibling)
+{
+ GraphicsLayer::addChildAbove(layer, sibling);
+ didChangeChildren();
+}
+
+void CoordinatedGraphicsLayer::addChildBelow(GraphicsLayer* layer, GraphicsLayer* sibling)
+{
+ GraphicsLayer::addChildBelow(layer, sibling);
+ didChangeChildren();
+}
+
+bool CoordinatedGraphicsLayer::replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild)
+{
+ bool ok = GraphicsLayer::replaceChild(oldChild, newChild);
+ if (!ok)
+ return false;
+ didChangeChildren();
+ return true;
+}
+
+void CoordinatedGraphicsLayer::removeFromParent()
+{
+ if (CoordinatedGraphicsLayer* parentLayer = toCoordinatedGraphicsLayer(parent()))
+ parentLayer->didChangeChildren();
+ GraphicsLayer::removeFromParent();
+}
+
+void CoordinatedGraphicsLayer::setPosition(const FloatPoint& p)
+{
+ if (position() == p)
+ return;
+
+ GraphicsLayer::setPosition(p);
+ m_layerState.positionChanged = true;
+ didChangeGeometry();
+}
+
+void CoordinatedGraphicsLayer::setAnchorPoint(const FloatPoint3D& p)
+{
+ if (anchorPoint() == p)
+ return;
+
+ GraphicsLayer::setAnchorPoint(p);
+ m_layerState.anchorPointChanged = true;
+ didChangeGeometry();
+}
+
+void CoordinatedGraphicsLayer::setSize(const FloatSize& size)
+{
+ if (this->size() == size)
+ return;
+
+ GraphicsLayer::setSize(size);
+ m_layerState.sizeChanged = true;
+
+ if (maskLayer())
+ maskLayer()->setSize(size);
+ didChangeGeometry();
+}
+
+void CoordinatedGraphicsLayer::setTransform(const TransformationMatrix& t)
+{
+ if (transform() == t)
+ return;
+
+ GraphicsLayer::setTransform(t);
+ m_layerState.transformChanged = true;
+
+ didChangeGeometry();
+}
+
+void CoordinatedGraphicsLayer::setChildrenTransform(const TransformationMatrix& t)
+{
+ if (childrenTransform() == t)
+ return;
+
+ GraphicsLayer::setChildrenTransform(t);
+ m_layerState.childrenTransformChanged = true;
+
+ didChangeGeometry();
+}
+
+void CoordinatedGraphicsLayer::setPreserves3D(bool b)
+{
+ if (preserves3D() == b)
+ return;
+
+ GraphicsLayer::setPreserves3D(b);
+ m_layerState.preserves3D = b;
+ m_layerState.flagsChanged = true;
+
+ didChangeGeometry();
+}
+
+void CoordinatedGraphicsLayer::setMasksToBounds(bool b)
+{
+ if (masksToBounds() == b)
+ return;
+ GraphicsLayer::setMasksToBounds(b);
+ m_layerState.masksToBounds = b;
+ m_layerState.flagsChanged = true;
+
+ didChangeGeometry();
+}
+
+void CoordinatedGraphicsLayer::setDrawsContent(bool b)
+{
+ if (drawsContent() == b)
+ return;
+ GraphicsLayer::setDrawsContent(b);
+ m_layerState.drawsContent = b;
+ m_layerState.flagsChanged = true;
+
+ didChangeLayerState();
+}
+
+void CoordinatedGraphicsLayer::setContentsVisible(bool b)
+{
+ if (contentsAreVisible() == b)
+ return;
+ GraphicsLayer::setContentsVisible(b);
+ m_layerState.contentsVisible = b;
+ m_layerState.flagsChanged = true;
+
+ if (maskLayer())
+ maskLayer()->setContentsVisible(b);
+
+ didChangeLayerState();
+}
+
+void CoordinatedGraphicsLayer::setContentsOpaque(bool b)
+{
+ if (contentsOpaque() == b)
+ return;
+ if (m_mainBackingStore)
+ m_mainBackingStore->setSupportsAlpha(!b);
+ GraphicsLayer::setContentsOpaque(b);
+ m_layerState.contentsOpaque = b;
+ m_layerState.flagsChanged = true;
+
+ didChangeLayerState();
+}
+
+void CoordinatedGraphicsLayer::setBackfaceVisibility(bool b)
+{
+ if (backfaceVisibility() == b)
+ return;
+
+ GraphicsLayer::setBackfaceVisibility(b);
+ m_layerState.backfaceVisible = b;
+ m_layerState.flagsChanged = true;
+
+ didChangeLayerState();
+}
+
+void CoordinatedGraphicsLayer::setOpacity(float opacity)
+{
+ if (this->opacity() == opacity)
+ return;
+
+ GraphicsLayer::setOpacity(opacity);
+ m_layerState.opacity = opacity;
+ m_layerState.opacityChanged = true;
+
+ didChangeLayerState();
+}
+
+void CoordinatedGraphicsLayer::setContentsRect(const IntRect& r)
+{
+ if (contentsRect() == r)
+ return;
+
+ GraphicsLayer::setContentsRect(r);
+ m_layerState.contentsRect = r;
+ m_layerState.contentsRectChanged = true;
+
+ didChangeLayerState();
+}
+
+void CoordinatedGraphicsLayer::setContentsTileSize(const IntSize& s)
+{
+ if (contentsTileSize() == s)
+ return;
+
+ GraphicsLayer::setContentsTileSize(s);
+ m_layerState.contentsTileSize = s;
+ m_layerState.contentsTilingChanged = true;
+ didChangeLayerState();
+}
+
+void CoordinatedGraphicsLayer::setContentsTilePhase(const IntPoint& p)
+{
+ if (contentsTilePhase() == p)
+ return;
+
+ GraphicsLayer::setContentsTilePhase(p);
+ m_layerState.contentsTilePhase = p;
+ m_layerState.contentsTilingChanged = true;
+ didChangeLayerState();
+}
+
+static bool s_shouldSupportContentsTiling = false;
+
+void CoordinatedGraphicsLayer::setShouldSupportContentsTiling(bool s)
+{
+ s_shouldSupportContentsTiling = s;
+}
+
+bool GraphicsLayer::supportsContentsTiling()
+{
+ return s_shouldSupportContentsTiling;
+}
+
+void CoordinatedGraphicsLayer::setContentsNeedsDisplay()
+{
+#if USE(GRAPHICS_SURFACE)
+ if (m_canvasPlatformLayer)
+ m_pendingCanvasOperation |= SyncCanvas;
+#endif
+
+ if (client())
+ client()->notifyFlushRequired(this);
+
+ addRepaintRect(contentsRect());
+}
+
+void CoordinatedGraphicsLayer::setContentsToCanvas(PlatformLayer* platformLayer)
+{
+#if USE(GRAPHICS_SURFACE)
+ if (m_canvasPlatformLayer) {
+ ASSERT(m_canvasToken.isValid());
+ if (!platformLayer) {
+ m_pendingCanvasOperation |= DestroyCanvas;
+ m_pendingCanvasOperation &= ~CreateCanvas;
+ } else if ((m_canvasSize != platformLayer->platformLayerSize()) || (m_canvasToken != platformLayer->graphicsSurfaceToken())) {
+ // m_canvasToken can be different to platformLayer->graphicsSurfaceToken(), even if m_canvasPlatformLayer equals platformLayer.
+ m_pendingCanvasOperation |= RecreateCanvas;
+ }
+ } else {
+ if (platformLayer)
+ m_pendingCanvasOperation |= CreateAndSyncCanvas;
+ }
+
+ m_canvasPlatformLayer = platformLayer;
+ // m_canvasToken is updated only here. In detail, when GraphicsContext3D is changed or reshaped, m_canvasToken is changed and setContentsToCanvas() is always called.
+ m_canvasSize = m_canvasPlatformLayer ? m_canvasPlatformLayer->platformLayerSize() : IntSize();
+ m_canvasToken = m_canvasPlatformLayer ? m_canvasPlatformLayer->graphicsSurfaceToken() : GraphicsSurfaceToken();
+ ASSERT(!(!m_canvasToken.isValid() && m_canvasPlatformLayer));
+
+ if (client())
+ client()->notifyFlushRequired(this);
+#else
+ UNUSED_PARAM(platformLayer);
+#endif
+}
+
+#if ENABLE(CSS_FILTERS)
+bool CoordinatedGraphicsLayer::setFilters(const FilterOperations& newFilters)
+{
+ if (filters() == newFilters)
+ return true;
+
+ if (!GraphicsLayer::setFilters(newFilters))
+ return false;
+
+ didChangeFilters();
+ return true;
+}
+#endif
+
+void CoordinatedGraphicsLayer::setContentsToSolidColor(const Color& color)
+{
+ if (m_layerState.solidColor == color)
+ return;
+
+ m_layerState.solidColor = color;
+ m_layerState.solidColorChanged = true;
+
+ didChangeLayerState();
+}
+
+void CoordinatedGraphicsLayer::setShowDebugBorder(bool show)
+{
+ if (isShowingDebugBorder() == show)
+ return;
+
+ GraphicsLayer::setShowDebugBorder(show);
+ m_layerState.showDebugBorders = true;
+ m_layerState.flagsChanged = true;
+
+ didChangeLayerState();
+}
+
+void CoordinatedGraphicsLayer::setShowRepaintCounter(bool show)
+{
+ if (isShowingRepaintCounter() == show)
+ return;
+
+ GraphicsLayer::setShowRepaintCounter(show);
+ m_layerState.showRepaintCounter = true;
+ m_layerState.flagsChanged = true;
+
+ didChangeLayerState();
+}
+
+void CoordinatedGraphicsLayer::setContentsToImage(Image* image)
+{
+ NativeImagePtr newNativeImagePtr = image ? image->nativeImageForCurrentFrame() : 0;
+ if (newNativeImagePtr) {
+ // This code makes the assumption that pointer equality on a NativeImagePtr is a valid way to tell if the image is changed.
+ // This assumption is true in Qt, GTK and EFL.
+ if (newNativeImagePtr == m_compositedNativeImagePtr)
+ return;
+
+ m_compositedImage = image;
+ m_compositedNativeImagePtr = newNativeImagePtr;
+ } else {
+ m_compositedImage = 0;
+ m_compositedNativeImagePtr = 0;
+ }
+
+ GraphicsLayer::setContentsToImage(image);
+ didChangeImageBacking();
+}
+
+void CoordinatedGraphicsLayer::setMaskLayer(GraphicsLayer* layer)
+{
+ if (layer == maskLayer())
+ return;
+
+ GraphicsLayer::setMaskLayer(layer);
+
+ if (!layer)
+ return;
+
+ layer->setSize(size());
+ layer->setContentsVisible(contentsAreVisible());
+ CoordinatedGraphicsLayer* coordinatedLayer = toCoordinatedGraphicsLayer(layer);
+ coordinatedLayer->didChangeLayerState();
+
+ m_layerState.mask = coordinatedLayer->id();
+ m_layerState.maskChanged = true;
+
+ didChangeLayerState();
+}
+
+bool CoordinatedGraphicsLayer::shouldDirectlyCompositeImage(Image* image) const
+{
+ if (!image || !image->isBitmapImage())
+ return false;
+
+ enum { MaxDimenstionForDirectCompositing = 2000 };
+ if (image->width() > MaxDimenstionForDirectCompositing || image->height() > MaxDimenstionForDirectCompositing)
+ return false;
+
+ return true;
+}
+
+void CoordinatedGraphicsLayer::setReplicatedByLayer(GraphicsLayer* layer)
+{
+ if (layer == replicaLayer())
+ return;
+
+ GraphicsLayer::setReplicatedByLayer(layer);
+ m_layerState.replica = toCoordinatedLayerID(layer);
+ m_layerState.replicaChanged = true;
+ didChangeLayerState();
+}
+
+void CoordinatedGraphicsLayer::setNeedsDisplay()
+{
+ setNeedsDisplayInRect(FloatRect(FloatPoint(), size()));
+}
+
+void CoordinatedGraphicsLayer::setNeedsDisplayInRect(const FloatRect& rect)
+{
+ if (m_mainBackingStore)
+ m_mainBackingStore->invalidate(IntRect(rect));
+
+ didChangeLayerState();
+
+ addRepaintRect(rect);
+}
+
+CoordinatedLayerID CoordinatedGraphicsLayer::id() const
+{
+ return m_id;
+}
+
+void CoordinatedGraphicsLayer::setScrollableArea(ScrollableArea* scrollableArea)
+{
+ bool oldScrollable = isScrollable();
+ m_scrollableArea = scrollableArea;
+ if (oldScrollable == isScrollable())
+ return;
+
+ m_layerState.isScrollable = isScrollable();
+ m_layerState.flagsChanged = true;
+ didChangeLayerState();
+}
+
+void CoordinatedGraphicsLayer::commitScrollOffset(const IntSize& offset)
+{
+ if (!isScrollable() || offset.isZero())
+ return;
+
+ m_scrollableArea->notifyScrollPositionChanged(m_scrollableArea->scrollPosition() + offset);
+ m_layerState.committedScrollOffset += offset;
+ m_layerState.committedScrollOffsetChanged = true;
+ didChangeLayerState();
+}
+
+void CoordinatedGraphicsLayer::setFixedToViewport(bool isFixed)
+{
+ if (m_fixedToViewport == isFixed)
+ return;
+
+ m_fixedToViewport = isFixed;
+ m_layerState.fixedToViewport = isFixed;
+ m_layerState.flagsChanged = true;
+
+ didChangeLayerState();
+}
+
+void CoordinatedGraphicsLayer::flushCompositingState(const FloatRect& rect)
+{
+ if (!m_coordinator->isFlushingLayerChanges()) {
+ if (client())
+ client()->notifyFlushRequired(this);
+ return;
+ }
+
+ if (CoordinatedGraphicsLayer* mask = toCoordinatedGraphicsLayer(maskLayer()))
+ mask->flushCompositingStateForThisLayerOnly();
+
+ if (CoordinatedGraphicsLayer* replica = toCoordinatedGraphicsLayer(replicaLayer()))
+ replica->flushCompositingStateForThisLayerOnly();
+
+ flushCompositingStateForThisLayerOnly();
+
+ for (size_t i = 0; i < children().size(); ++i)
+ children()[i]->flushCompositingState(rect);
+}
+
+CoordinatedGraphicsLayer* toCoordinatedGraphicsLayer(GraphicsLayer* layer)
+{
+ return static_cast<CoordinatedGraphicsLayer*>(layer);
+}
+
+void CoordinatedGraphicsLayer::syncChildren()
+{
+ if (!m_shouldSyncChildren)
+ return;
+ m_shouldSyncChildren = false;
+ m_layerState.childrenChanged = true;
+ m_layerState.children.clear();
+ for (size_t i = 0; i < children().size(); ++i)
+ m_layerState.children.append(toCoordinatedLayerID(children()[i]));
+}
+
+#if ENABLE(CSS_FILTERS)
+void CoordinatedGraphicsLayer::syncFilters()
+{
+ if (!m_shouldSyncFilters)
+ return;
+ m_shouldSyncFilters = false;
+
+ m_layerState.filters = GraphicsLayer::filters();
+ m_layerState.filtersChanged = true;
+}
+#endif
+
+void CoordinatedGraphicsLayer::syncImageBacking()
+{
+ if (!m_shouldSyncImageBacking)
+ return;
+ m_shouldSyncImageBacking = false;
+
+ if (m_compositedNativeImagePtr) {
+ ASSERT(!shouldHaveBackingStore());
+ ASSERT(m_compositedImage);
+
+ bool imageInstanceReplaced = m_coordinatedImageBacking && (m_coordinatedImageBacking->id() != CoordinatedImageBacking::getCoordinatedImageBackingID(m_compositedImage.get()));
+ if (imageInstanceReplaced)
+ releaseImageBackingIfNeeded();
+
+ if (!m_coordinatedImageBacking) {
+ m_coordinatedImageBacking = m_coordinator->createImageBackingIfNeeded(m_compositedImage.get());
+ m_coordinatedImageBacking->addHost(this);
+ m_layerState.imageID = m_coordinatedImageBacking->id();
+ }
+
+ m_coordinatedImageBacking->markDirty();
+ m_layerState.imageChanged = true;
+ } else
+ releaseImageBackingIfNeeded();
+
+ // syncImageBacking() changed m_layerState.imageID.
+ didChangeLayerState();
+}
+
+void CoordinatedGraphicsLayer::syncLayerState()
+{
+ if (!m_shouldSyncLayerState)
+ return;
+ m_shouldSyncLayerState = false;
+
+ m_layerState.childrenTransform = childrenTransform();
+ m_layerState.contentsRect = contentsRect();
+ m_layerState.mask = toCoordinatedLayerID(maskLayer());
+ m_layerState.opacity = opacity();
+ m_layerState.replica = toCoordinatedLayerID(replicaLayer());
+ m_layerState.transform = transform();
+
+ m_layerState.anchorPoint = m_adjustedAnchorPoint;
+ m_layerState.pos = m_adjustedPosition;
+ m_layerState.size = m_adjustedSize;
+
+ if (m_layerState.flagsChanged) {
+ m_layerState.drawsContent = drawsContent();
+ m_layerState.contentsVisible = contentsAreVisible();
+ m_layerState.backfaceVisible = backfaceVisibility();
+ m_layerState.masksToBounds = masksToBounds();
+ m_layerState.preserves3D = preserves3D();
+ m_layerState.fixedToViewport = fixedToViewport();
+ m_layerState.showDebugBorders = isShowingDebugBorder();
+ m_layerState.showRepaintCounter = isShowingRepaintCounter();
+ m_layerState.isScrollable = isScrollable();
+ }
+
+ if (m_layerState.showDebugBorders)
+ updateDebugIndicators();
+}
+
+void CoordinatedGraphicsLayer::setDebugBorder(const Color& color, float width)
+{
+ ASSERT(m_layerState.showDebugBorders);
+ if (m_layerState.debugBorderColor != color) {
+ m_layerState.debugBorderColor = color;
+ m_layerState.debugBorderColorChanged = true;
+ }
+
+ if (m_layerState.debugBorderWidth != width) {
+ m_layerState.debugBorderWidth = width;
+ m_layerState.debugBorderWidthChanged = true;
+ }
+}
+
+void CoordinatedGraphicsLayer::syncAnimations()
+{
+ if (!m_shouldSyncAnimations)
+ return;
+
+ m_shouldSyncAnimations = false;
+ m_layerState.animations = m_animations.getActiveAnimations();
+ m_layerState.animationsChanged = true;
+}
+
+#if USE(GRAPHICS_SURFACE)
+void CoordinatedGraphicsLayer::syncCanvas()
+{
+ destroyCanvasIfNeeded();
+ createCanvasIfNeeded();
+
+ if (!(m_pendingCanvasOperation & SyncCanvas))
+ return;
+
+ m_pendingCanvasOperation &= ~SyncCanvas;
+
+ if (!m_isValidCanvas)
+ return;
+
+ ASSERT(m_canvasPlatformLayer);
+ m_layerState.canvasFrontBuffer = m_canvasPlatformLayer->copyToGraphicsSurface();
+ m_layerState.canvasShouldSwapBuffers = true;
+}
+
+void CoordinatedGraphicsLayer::destroyCanvasIfNeeded()
+{
+ if (!(m_pendingCanvasOperation & DestroyCanvas))
+ return;
+
+ if (m_isValidCanvas) {
+ m_isValidCanvas = false;
+ m_layerState.canvasToken = GraphicsSurfaceToken();
+ m_layerState.canvasChanged = true;
+ }
+
+ m_pendingCanvasOperation &= ~DestroyCanvas;
+}
+
+void CoordinatedGraphicsLayer::createCanvasIfNeeded()
+{
+ if (!(m_pendingCanvasOperation & CreateCanvas))
+ return;
+
+ ASSERT(m_canvasPlatformLayer);
+ if (!m_isValidCanvas) {
+ m_layerState.canvasSize = m_canvasPlatformLayer->platformLayerSize();
+ m_layerState.canvasToken = m_canvasPlatformLayer->graphicsSurfaceToken();
+ m_layerState.canvasSurfaceFlags = m_canvasPlatformLayer->graphicsSurfaceFlags();
+ m_layerState.canvasChanged = true;
+ m_isValidCanvas = true;
+ }
+
+ m_pendingCanvasOperation &= ~CreateCanvas;
+}
+#endif
+
+void CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly()
+{
+ ASSERT(m_coordinator->isFlushingLayerChanges());
+
+ // When we have a transform animation, we need to update visible rect every frame to adjust the visible rect of a backing store.
+ bool hasActiveTransformAnimation = selfOrAncestorHasActiveTransformAnimation();
+ if (hasActiveTransformAnimation)
+ m_movingVisibleRect = true;
+
+ // Sets the values.
+ computePixelAlignment(m_adjustedPosition, m_adjustedSize, m_adjustedAnchorPoint, m_pixelAlignmentOffset);
+
+ syncImageBacking();
+ syncLayerState();
+ syncAnimations();
+ computeTransformedVisibleRect();
+ syncChildren();
+#if ENABLE(CSS_FILTERS)
+ syncFilters();
+#endif
+#if USE(GRAPHICS_SURFACE)
+ syncCanvas();
+#endif
+
+ // Only unset m_movingVisibleRect after we have updated the visible rect after the animation stopped.
+ if (!hasActiveTransformAnimation)
+ m_movingVisibleRect = false;
+}
+
+void CoordinatedGraphicsLayer::syncPendingStateChangesIncludingSubLayers()
+{
+ if (m_layerState.hasPendingChanges()) {
+ m_coordinator->syncLayerState(m_id, m_layerState);
+ resetLayerState();
+ }
+
+ for (size_t i = 0; i < children().size(); ++i)
+ toCoordinatedGraphicsLayer(children()[i])->syncPendingStateChangesIncludingSubLayers();
+}
+
+void CoordinatedGraphicsLayer::resetLayerState()
+{
+ m_layerState.changeMask = 0;
+ m_layerState.tilesToCreate.clear();
+ m_layerState.tilesToRemove.clear();
+ m_layerState.tilesToUpdate.clear();
+ m_layerState.committedScrollOffset = IntSize();
+}
+
+bool CoordinatedGraphicsLayer::imageBackingVisible()
+{
+ ASSERT(m_coordinatedImageBacking);
+ return tiledBackingStoreVisibleRect().intersects(contentsRect());
+}
+
+void CoordinatedGraphicsLayer::releaseImageBackingIfNeeded()
+{
+ if (!m_coordinatedImageBacking)
+ return;
+
+ ASSERT(m_coordinator);
+ m_coordinatedImageBacking->removeHost(this);
+ m_coordinatedImageBacking.clear();
+ m_layerState.imageID = InvalidCoordinatedImageBackingID;
+ m_layerState.imageChanged = true;
+}
+
+void CoordinatedGraphicsLayer::tiledBackingStorePaintBegin()
+{
+}
+
+CoordinatedGraphicsLayer* CoordinatedGraphicsLayer::findFirstDescendantWithContentsRecursively()
+{
+ if (shouldHaveBackingStore())
+ return this;
+
+ for (size_t i = 0; i < children().size(); ++i) {
+ CoordinatedGraphicsLayer* layer = toCoordinatedGraphicsLayer(children()[i])->findFirstDescendantWithContentsRecursively();
+ if (layer)
+ return layer;
+ }
+
+ return 0;
+}
+
+void CoordinatedGraphicsLayer::setVisibleContentRectTrajectoryVector(const FloatPoint& trajectoryVector)
+{
+ if (!m_mainBackingStore)
+ return;
+
+ m_mainBackingStore->setTrajectoryVector(trajectoryVector);
+ setNeedsVisibleRectAdjustment();
+}
+
+void CoordinatedGraphicsLayer::deviceOrPageScaleFactorChanged()
+{
+ if (shouldHaveBackingStore())
+ m_pendingContentsScaleAdjustment = true;
+}
+
+float CoordinatedGraphicsLayer::effectiveContentsScale()
+{
+ return selfOrAncestorHaveNonAffineTransforms() ? 1 : deviceScaleFactor() * pageScaleFactor();
+}
+
+void CoordinatedGraphicsLayer::adjustContentsScale()
+{
+ ASSERT(shouldHaveBackingStore());
+ if (!m_mainBackingStore || m_mainBackingStore->contentsScale() == effectiveContentsScale())
+ return;
+
+ // Between creating the new backing store and painting the content,
+ // we do not want to drop the previous one as that might result in
+ // briefly seeing flickering as the old tiles may be dropped before
+ // something replaces them.
+ m_previousBackingStore = m_mainBackingStore.release();
+
+ // No reason to save the previous backing store for non-visible areas.
+ m_previousBackingStore->removeAllNonVisibleTiles();
+}
+
+void CoordinatedGraphicsLayer::createBackingStore()
+{
+ m_mainBackingStore = adoptPtr(new TiledBackingStore(this, CoordinatedTileBackend::create(this)));
+ m_mainBackingStore->setSupportsAlpha(!contentsOpaque());
+ m_mainBackingStore->setContentsScale(effectiveContentsScale());
+}
+
+void CoordinatedGraphicsLayer::tiledBackingStorePaint(GraphicsContext* context, const IntRect& rect)
+{
+ if (rect.isEmpty())
+ return;
+ paintGraphicsLayerContents(*context, rect);
+}
+
+void CoordinatedGraphicsLayer::tiledBackingStorePaintEnd(const Vector<IntRect>& updatedRects)
+{
+ if (!isShowingRepaintCounter() || updatedRects.isEmpty())
+ return;
+
+ m_layerState.repaintCount = incrementRepaintCount();
+ m_layerState.repaintCountChanged = true;
+}
+
+void CoordinatedGraphicsLayer::tiledBackingStoreHasPendingTileCreation()
+{
+ setNeedsVisibleRectAdjustment();
+ if (client())
+ client()->notifyFlushRequired(this);
+}
+
+IntRect CoordinatedGraphicsLayer::tiledBackingStoreContentsRect()
+{
+ return IntRect(0, 0, size().width(), size().height());
+}
+
+static void clampToContentsRectIfRectIsInfinite(FloatRect& rect, const IntRect& contentsRect)
+{
+ if (rect.width() >= LayoutUnit::nearlyMax() || rect.width() <= LayoutUnit::nearlyMin()) {
+ rect.setX(contentsRect.x());
+ rect.setWidth(contentsRect.width());
+ }
+
+ if (rect.height() >= LayoutUnit::nearlyMax() || rect.height() <= LayoutUnit::nearlyMin()) {
+ rect.setY(contentsRect.y());
+ rect.setHeight(contentsRect.height());
+ }
+}
+
+IntRect CoordinatedGraphicsLayer::tiledBackingStoreVisibleRect()
+{
+ // Non-invertible layers are not visible.
+ if (!m_layerTransform.combined().isInvertible())
+ return IntRect();
+
+ // Return a projection of the visible rect (surface coordinates) onto the layer's plane (layer coordinates).
+ // The resulting quad might be squewed and the visible rect is the bounding box of this quad,
+ // so it might spread further than the real visible area (and then even more amplified by the cover rect multiplier).
+ ASSERT(m_cachedInverseTransform == m_layerTransform.combined().inverse());
+ FloatRect rect = m_cachedInverseTransform.clampedBoundsOfProjectedQuad(FloatQuad(m_coordinator->visibleContentsRect()));
+ clampToContentsRectIfRectIsInfinite(rect, tiledBackingStoreContentsRect());
+ return enclosingIntRect(rect);
+}
+
+Color CoordinatedGraphicsLayer::tiledBackingStoreBackgroundColor() const
+{
+ return contentsOpaque() ? Color::white : Color::transparent;
+}
+
+bool CoordinatedGraphicsLayer::paintToSurface(const IntSize& size, uint32_t& atlas, IntPoint& offset, CoordinatedSurface::Client* client)
+{
+ ASSERT(m_coordinator);
+ ASSERT(m_coordinator->isFlushingLayerChanges());
+ return m_coordinator->paintToSurface(size, contentsOpaque() ? CoordinatedSurface::NoFlags : CoordinatedSurface::SupportsAlpha, atlas, offset, client);
+}
+
+void CoordinatedGraphicsLayer::createTile(uint32_t tileID, const SurfaceUpdateInfo& updateInfo, const IntRect& tileRect)
+{
+ ASSERT(m_coordinator);
+ ASSERT(m_coordinator->isFlushingLayerChanges());
+
+ TileCreationInfo creationInfo;
+ creationInfo.tileID = tileID;
+ creationInfo.scale = updateInfo.scaleFactor;
+
+ m_layerState.tilesToCreate.append(creationInfo);
+ updateTile(tileID, updateInfo, tileRect);
+}
+
+void CoordinatedGraphicsLayer::updateTile(uint32_t tileID, const SurfaceUpdateInfo& updateInfo, const IntRect& tileRect)
+{
+ ASSERT(m_coordinator);
+ ASSERT(m_coordinator->isFlushingLayerChanges());
+
+ TileUpdateInfo tileUpdateInfo;
+ tileUpdateInfo.tileID = tileID;
+ tileUpdateInfo.tileRect = tileRect;
+ tileUpdateInfo.updateInfo = updateInfo;
+ m_layerState.tilesToUpdate.append(tileUpdateInfo);
+}
+
+void CoordinatedGraphicsLayer::removeTile(uint32_t tileID)
+{
+ ASSERT(m_coordinator);
+ ASSERT(m_coordinator->isFlushingLayerChanges() || m_isPurging);
+ m_layerState.tilesToRemove.append(tileID);
+}
+
+void CoordinatedGraphicsLayer::updateContentBuffersIncludingSubLayers()
+{
+ if (CoordinatedGraphicsLayer* mask = toCoordinatedGraphicsLayer(maskLayer()))
+ mask->updateContentBuffers();
+
+ if (CoordinatedGraphicsLayer* replica = toCoordinatedGraphicsLayer(replicaLayer()))
+ replica->updateContentBuffers();
+
+ updateContentBuffers();
+
+ for (size_t i = 0; i < children().size(); ++i)
+ toCoordinatedGraphicsLayer(children()[i])->updateContentBuffersIncludingSubLayers();
+}
+
+void CoordinatedGraphicsLayer::updateContentBuffers()
+{
+ if (!shouldHaveBackingStore()) {
+ m_mainBackingStore.clear();
+ m_previousBackingStore.clear();
+ return;
+ }
+
+ if (m_pendingContentsScaleAdjustment) {
+ adjustContentsScale();
+ m_pendingContentsScaleAdjustment = false;
+ }
+
+ // This is the only place we (re)create the main tiled backing store, once we
+ // have a remote client and we are ready to send our data to the UI process.
+ if (!m_mainBackingStore)
+ createBackingStore();
+
+ if (m_pendingVisibleRectAdjustment) {
+ m_pendingVisibleRectAdjustment = false;
+ m_mainBackingStore->coverWithTilesIfNeeded();
+ }
+
+ m_mainBackingStore->updateTileBuffers();
+
+ // The previous backing store is kept around to avoid flickering between
+ // removing the existing tiles and painting the new ones. The first time
+ // the visibleRect is full painted we remove the previous backing store.
+ if (m_mainBackingStore->visibleAreaIsCovered())
+ m_previousBackingStore.clear();
+}
+
+void CoordinatedGraphicsLayer::purgeBackingStores()
+{
+#ifndef NDEBUG
+ TemporaryChange<bool> updateModeProtector(m_isPurging, true);
+#endif
+ m_mainBackingStore.clear();
+ m_previousBackingStore.clear();
+
+ releaseImageBackingIfNeeded();
+
+ didChangeLayerState();
+}
+
+void CoordinatedGraphicsLayer::setCoordinator(CoordinatedGraphicsLayerClient* coordinator)
+{
+ m_coordinator = coordinator;
+}
+
+void CoordinatedGraphicsLayer::setNeedsVisibleRectAdjustment()
+{
+ if (shouldHaveBackingStore())
+ m_pendingVisibleRectAdjustment = true;
+}
+
+bool CoordinatedGraphicsLayer::hasPendingVisibleChanges()
+{
+ if (opacity() < 0.01 && !m_animations.hasActiveAnimationsOfType(AnimatedPropertyOpacity))
+ return false;
+
+ for (size_t i = 0; i < children().size(); ++i) {
+ if (toCoordinatedGraphicsLayer(children()[i])->hasPendingVisibleChanges())
+ return true;
+ }
+
+ bool shouldSyncCanvas = false;
+#if USE(GRAPHICS_SURFACE)
+ shouldSyncCanvas = m_pendingCanvasOperation & SyncCanvas;
+#endif
+
+ if (!m_shouldSyncLayerState && !m_shouldSyncChildren && !m_shouldSyncFilters && !m_shouldSyncImageBacking && !m_shouldSyncAnimations && !shouldSyncCanvas)
+ return false;
+
+ return tiledBackingStoreVisibleRect().intersects(tiledBackingStoreContentsRect());
+}
+
+static inline bool isIntegral(float value)
+{
+ return static_cast<int>(value) == value;
+}
+
+FloatPoint CoordinatedGraphicsLayer::computePositionRelativeToBase()
+{
+ FloatPoint offset;
+ for (const GraphicsLayer* currLayer = this; currLayer; currLayer = currLayer->parent())
+ offset += currLayer->position();
+
+ return offset;
+}
+
+void CoordinatedGraphicsLayer::computePixelAlignment(FloatPoint& position, FloatSize& size, FloatPoint3D& anchorPoint, FloatSize& alignmentOffset)
+{
+ if (isIntegral(effectiveContentsScale())) {
+ position = m_position;
+ size = m_size;
+ anchorPoint = m_anchorPoint;
+ alignmentOffset = FloatSize();
+ return;
+ }
+
+ FloatPoint positionRelativeToBase = computePositionRelativeToBase();
+
+ FloatRect baseRelativeBounds(positionRelativeToBase, m_size);
+ FloatRect scaledBounds = baseRelativeBounds;
+
+ // Scale by the effective scale factor to compute the screen-relative bounds.
+ scaledBounds.scale(effectiveContentsScale());
+
+ // Round to integer boundaries.
+ // NOTE: When using enclosingIntRect (as mac) it will have different sizes depending on position.
+ FloatRect alignedBounds = roundedIntRect(scaledBounds);
+
+ // Convert back to layer coordinates.
+ alignedBounds.scale(1 / effectiveContentsScale());
+
+ // Convert back to layer coordinates.
+ alignmentOffset = baseRelativeBounds.location() - alignedBounds.location();
+
+ position = m_position - alignmentOffset;
+ size = alignedBounds.size();
+
+ // Now we have to compute a new anchor point which compensates for rounding.
+ float anchorPointX = m_anchorPoint.x();
+ float anchorPointY = m_anchorPoint.y();
+
+ if (alignedBounds.width())
+ anchorPointX = (baseRelativeBounds.width() * anchorPointX + alignmentOffset.width()) / alignedBounds.width();
+
+ if (alignedBounds.height())
+ anchorPointY = (baseRelativeBounds.height() * anchorPointY + alignmentOffset.height()) / alignedBounds.height();
+
+ anchorPoint = FloatPoint3D(anchorPointX, anchorPointY, m_anchorPoint.z() * effectiveContentsScale());
+}
+
+void CoordinatedGraphicsLayer::computeTransformedVisibleRect()
+{
+ if (!m_shouldUpdateVisibleRect && !m_movingVisibleRect)
+ return;
+
+ m_shouldUpdateVisibleRect = false;
+ TransformationMatrix currentTransform = transform();
+ if (m_movingVisibleRect)
+ client()->getCurrentTransform(this, currentTransform);
+ m_layerTransform.setLocalTransform(currentTransform);
+
+ m_layerTransform.setAnchorPoint(m_adjustedAnchorPoint);
+ m_layerTransform.setPosition(m_adjustedPosition);
+ m_layerTransform.setSize(m_adjustedSize);
+
+ m_layerTransform.setFlattening(!preserves3D());
+ m_layerTransform.setChildrenTransform(childrenTransform());
+ m_layerTransform.combineTransforms(parent() ? toCoordinatedGraphicsLayer(parent())->m_layerTransform.combinedForChildren() : TransformationMatrix());
+
+ m_cachedInverseTransform = m_layerTransform.combined().inverse();
+
+ // The combined transform will be used in tiledBackingStoreVisibleRect.
+ setNeedsVisibleRectAdjustment();
+}
+
+bool CoordinatedGraphicsLayer::shouldHaveBackingStore() const
+{
+ return drawsContent() && contentsAreVisible() && !m_size.isEmpty();
+}
+
+bool CoordinatedGraphicsLayer::selfOrAncestorHasActiveTransformAnimation() const
+{
+ if (m_animations.hasActiveAnimationsOfType(AnimatedPropertyWebkitTransform))
+ return true;
+
+ if (!parent())
+ return false;
+
+ return toCoordinatedGraphicsLayer(parent())->selfOrAncestorHasActiveTransformAnimation();
+}
+
+bool CoordinatedGraphicsLayer::selfOrAncestorHaveNonAffineTransforms()
+{
+ if (m_animations.hasActiveAnimationsOfType(AnimatedPropertyWebkitTransform))
+ return true;
+
+ if (!m_layerTransform.combined().isAffine())
+ return true;
+
+ if (!parent())
+ return false;
+
+ return toCoordinatedGraphicsLayer(parent())->selfOrAncestorHaveNonAffineTransforms();
+}
+
+bool CoordinatedGraphicsLayer::addAnimation(const KeyframeValueList& valueList, const IntSize& boxSize, const Animation* anim, const String& keyframesName, double delayAsNegativeTimeOffset)
+{
+ ASSERT(!keyframesName.isEmpty());
+
+ if (!anim || anim->isEmptyOrZeroDuration() || valueList.size() < 2 || (valueList.property() != AnimatedPropertyWebkitTransform && valueList.property() != AnimatedPropertyOpacity && valueList.property() != AnimatedPropertyWebkitFilter))
+ return false;
+
+ bool listsMatch = false;
+ bool ignoredHasBigRotation;
+
+ if (valueList.property() == AnimatedPropertyWebkitTransform)
+ listsMatch = validateTransformOperations(valueList, ignoredHasBigRotation) >= 0;
+
+ m_lastAnimationStartTime = WTF::currentTime() - delayAsNegativeTimeOffset;
+ m_animations.add(GraphicsLayerAnimation(keyframesName, valueList, boxSize, anim, m_lastAnimationStartTime, listsMatch));
+ m_animationStartedTimer.startOneShot(0);
+ didChangeAnimations();
+ return true;
+}
+
+void CoordinatedGraphicsLayer::pauseAnimation(const String& animationName, double time)
+{
+ m_animations.pause(animationName, time);
+ didChangeAnimations();
+}
+
+void CoordinatedGraphicsLayer::removeAnimation(const String& animationName)
+{
+ m_animations.remove(animationName);
+ didChangeAnimations();
+}
+
+void CoordinatedGraphicsLayer::suspendAnimations(double time)
+{
+ m_animations.suspend(time);
+ didChangeAnimations();
+}
+
+void CoordinatedGraphicsLayer::resumeAnimations()
+{
+ m_animations.resume();
+ didChangeAnimations();
+}
+
+void CoordinatedGraphicsLayer::animationStartedTimerFired(Timer<CoordinatedGraphicsLayer>*)
+{
+ client()->notifyAnimationStarted(this, m_lastAnimationStartTime);
+}
+} // namespace WebCore
+#endif // USE(COORDINATED_GRAPHICS)
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h
new file mode 100644
index 000000000..cfbc2135d
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h
@@ -0,0 +1,264 @@
+/*
+ Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+
+#ifndef CoordinatedGraphicsLayer_h
+#define CoordinatedGraphicsLayer_h
+
+#include "CoordinatedGraphicsState.h"
+#include "CoordinatedImageBacking.h"
+#include "CoordinatedTile.h"
+#include "FloatPoint3D.h"
+#include "GraphicsLayer.h"
+#include "GraphicsLayerAnimation.h"
+#include "GraphicsLayerTransform.h"
+#include "Image.h"
+#include "IntSize.h"
+#include "RunLoop.h"
+#include "TiledBackingStore.h"
+#include "TiledBackingStoreClient.h"
+#include "TransformationMatrix.h"
+#if USE(GRAPHICS_SURFACE)
+#include "GraphicsSurfaceToken.h"
+#endif
+#include <wtf/text/StringHash.h>
+
+#if USE(COORDINATED_GRAPHICS)
+
+namespace WebCore {
+class CoordinatedGraphicsLayer;
+class GraphicsLayerAnimations;
+class ScrollableArea;
+
+class CoordinatedGraphicsLayerClient {
+public:
+ virtual bool isFlushingLayerChanges() const = 0;
+ virtual FloatRect visibleContentsRect() const = 0;
+ virtual PassRefPtr<CoordinatedImageBacking> createImageBackingIfNeeded(Image*) = 0;
+ virtual void detachLayer(CoordinatedGraphicsLayer*) = 0;
+ virtual bool paintToSurface(const IntSize&, CoordinatedSurface::Flags, uint32_t& atlasID, IntPoint&, CoordinatedSurface::Client*) = 0;
+
+ virtual void syncLayerState(CoordinatedLayerID, CoordinatedGraphicsLayerState&) = 0;
+};
+
+class CoordinatedGraphicsLayer : public GraphicsLayer
+ , public TiledBackingStoreClient
+ , public CoordinatedImageBacking::Host
+ , public CoordinatedTileClient {
+public:
+ explicit CoordinatedGraphicsLayer(GraphicsLayerClient*);
+ virtual ~CoordinatedGraphicsLayer();
+
+ // Reimplementations from GraphicsLayer.h.
+ virtual bool setChildren(const Vector<GraphicsLayer*>&) OVERRIDE;
+ virtual void addChild(GraphicsLayer*) OVERRIDE;
+ virtual void addChildAtIndex(GraphicsLayer*, int) OVERRIDE;
+ virtual void addChildAbove(GraphicsLayer*, GraphicsLayer*) OVERRIDE;
+ virtual void addChildBelow(GraphicsLayer*, GraphicsLayer*) OVERRIDE;
+ virtual bool replaceChild(GraphicsLayer*, GraphicsLayer*) OVERRIDE;
+ virtual void removeFromParent() OVERRIDE;
+ virtual void setPosition(const FloatPoint&) OVERRIDE;
+ virtual void setAnchorPoint(const FloatPoint3D&) OVERRIDE;
+ virtual void setSize(const FloatSize&) OVERRIDE;
+ virtual void setTransform(const TransformationMatrix&) OVERRIDE;
+ virtual void setChildrenTransform(const TransformationMatrix&) OVERRIDE;
+ virtual void setPreserves3D(bool) OVERRIDE;
+ virtual void setMasksToBounds(bool) OVERRIDE;
+ virtual void setDrawsContent(bool) OVERRIDE;
+ virtual void setContentsVisible(bool) OVERRIDE;
+ virtual void setContentsOpaque(bool) OVERRIDE;
+ virtual void setBackfaceVisibility(bool) OVERRIDE;
+ virtual void setOpacity(float) OVERRIDE;
+ virtual void setContentsRect(const IntRect&) OVERRIDE;
+ virtual void setContentsTilePhase(const IntPoint&) OVERRIDE;
+ virtual void setContentsTileSize(const IntSize&) OVERRIDE;
+ virtual void setContentsToImage(Image*) OVERRIDE;
+ virtual void setContentsToSolidColor(const Color&) OVERRIDE;
+ virtual void setShowDebugBorder(bool) OVERRIDE;
+ virtual void setShowRepaintCounter(bool) OVERRIDE;
+ virtual bool shouldDirectlyCompositeImage(Image*) const OVERRIDE;
+ virtual void setContentsToCanvas(PlatformLayer*) OVERRIDE;
+ virtual void setMaskLayer(GraphicsLayer*) OVERRIDE;
+ virtual void setReplicatedByLayer(GraphicsLayer*) OVERRIDE;
+ virtual void setNeedsDisplay() OVERRIDE;
+ virtual void setNeedsDisplayInRect(const FloatRect&) OVERRIDE;
+ virtual void setContentsNeedsDisplay() OVERRIDE;
+ virtual void deviceOrPageScaleFactorChanged() OVERRIDE;
+ virtual void flushCompositingState(const FloatRect&) OVERRIDE;
+ virtual void flushCompositingStateForThisLayerOnly() OVERRIDE;
+#if ENABLE(CSS_FILTERS)
+ virtual bool setFilters(const FilterOperations&) OVERRIDE;
+#endif
+ virtual bool addAnimation(const KeyframeValueList&, const IntSize&, const Animation*, const String&, double) OVERRIDE;
+ virtual void pauseAnimation(const String&, double) OVERRIDE;
+ virtual void removeAnimation(const String&) OVERRIDE;
+ virtual void suspendAnimations(double time) OVERRIDE;
+ virtual void resumeAnimations() OVERRIDE;
+ virtual bool hasContentsLayer() const OVERRIDE { return m_canvasPlatformLayer || m_compositedImage; }
+
+ void syncPendingStateChangesIncludingSubLayers();
+ void updateContentBuffersIncludingSubLayers();
+
+ FloatPoint computePositionRelativeToBase();
+ void computePixelAlignment(FloatPoint& position, FloatSize&, FloatPoint3D& anchorPoint, FloatSize& alignmentOffset);
+
+ void setVisibleContentRectTrajectoryVector(const FloatPoint&);
+
+ void setScrollableArea(ScrollableArea*);
+ bool isScrollable() const { return !!m_scrollableArea; }
+ void commitScrollOffset(const IntSize&);
+
+ CoordinatedLayerID id() const;
+
+ void setFixedToViewport(bool isFixed);
+
+ IntRect coverRect() const { return m_mainBackingStore ? m_mainBackingStore->mapToContents(m_mainBackingStore->coverRect()) : IntRect(); }
+
+ // TiledBackingStoreClient
+ virtual void tiledBackingStorePaintBegin() OVERRIDE;
+ virtual void tiledBackingStorePaint(GraphicsContext*, const IntRect&) OVERRIDE;
+ virtual void tiledBackingStorePaintEnd(const Vector<IntRect>& paintedArea) OVERRIDE;
+ virtual void tiledBackingStoreHasPendingTileCreation() OVERRIDE;
+ virtual IntRect tiledBackingStoreContentsRect() OVERRIDE;
+ virtual IntRect tiledBackingStoreVisibleRect() OVERRIDE;
+ virtual Color tiledBackingStoreBackgroundColor() const OVERRIDE;
+
+ // CoordinatedTileClient
+ virtual void createTile(uint32_t tileID, const SurfaceUpdateInfo&, const IntRect&) OVERRIDE;
+ virtual void updateTile(uint32_t tileID, const SurfaceUpdateInfo&, const IntRect&) OVERRIDE;
+ virtual void removeTile(uint32_t tileID) OVERRIDE;
+ virtual bool paintToSurface(const IntSize&, uint32_t& /* atlasID */, IntPoint&, CoordinatedSurface::Client*) OVERRIDE;
+
+ void setCoordinator(CoordinatedGraphicsLayerClient*);
+
+ void setNeedsVisibleRectAdjustment();
+ void purgeBackingStores();
+ bool hasPendingVisibleChanges();
+
+ static void setShouldSupportContentsTiling(bool);
+ CoordinatedGraphicsLayer* findFirstDescendantWithContentsRecursively();
+
+private:
+#if USE(GRAPHICS_SURFACE)
+ enum PendingCanvasOperation {
+ None = 0x00,
+ CreateCanvas = 0x01,
+ DestroyCanvas = 0x02,
+ SyncCanvas = 0x04,
+ CreateAndSyncCanvas = CreateCanvas | SyncCanvas,
+ RecreateCanvas = CreateAndSyncCanvas | DestroyCanvas
+ };
+
+ void syncCanvas();
+ void destroyCanvasIfNeeded();
+ void createCanvasIfNeeded();
+#endif
+
+ virtual void setDebugBorder(const Color&, float width) OVERRIDE;
+
+ bool fixedToViewport() const { return m_fixedToViewport; }
+
+ void didChangeLayerState();
+ void didChangeAnimations();
+ void didChangeGeometry();
+ void didChangeChildren();
+#if ENABLE(CSS_FILTERS)
+ void didChangeFilters();
+#endif
+ void didChangeImageBacking();
+
+ void resetLayerState();
+ void syncLayerState();
+ void syncAnimations();
+ void syncChildren();
+#if ENABLE(CSS_FILTERS)
+ void syncFilters();
+#endif
+ void syncImageBacking();
+ void computeTransformedVisibleRect();
+ void updateContentBuffers();
+
+ void createBackingStore();
+ void releaseImageBackingIfNeeded();
+
+ // CoordinatedImageBacking::Host
+ virtual bool imageBackingVisible() OVERRIDE;
+ bool shouldHaveBackingStore() const;
+ bool selfOrAncestorHasActiveTransformAnimation() const;
+ bool selfOrAncestorHaveNonAffineTransforms();
+ void adjustContentsScale();
+
+ void setShouldUpdateVisibleRect();
+ float effectiveContentsScale();
+
+ void animationStartedTimerFired(Timer<CoordinatedGraphicsLayer>*);
+
+ CoordinatedLayerID m_id;
+ CoordinatedGraphicsLayerState m_layerState;
+ GraphicsLayerTransform m_layerTransform;
+ TransformationMatrix m_cachedInverseTransform;
+ FloatSize m_pixelAlignmentOffset;
+ FloatSize m_adjustedSize;
+ FloatPoint m_adjustedPosition;
+ FloatPoint3D m_adjustedAnchorPoint;
+
+#ifndef NDEBUG
+ bool m_isPurging;
+#endif
+ bool m_shouldUpdateVisibleRect: 1;
+ bool m_shouldSyncLayerState: 1;
+ bool m_shouldSyncChildren: 1;
+ bool m_shouldSyncFilters: 1;
+ bool m_shouldSyncImageBacking: 1;
+ bool m_shouldSyncAnimations: 1;
+ bool m_fixedToViewport : 1;
+ bool m_movingVisibleRect : 1;
+ bool m_pendingContentsScaleAdjustment : 1;
+ bool m_pendingVisibleRectAdjustment : 1;
+#if USE(GRAPHICS_SURFACE)
+ bool m_isValidCanvas : 1;
+ unsigned m_pendingCanvasOperation : 3;
+#endif
+
+ CoordinatedGraphicsLayerClient* m_coordinator;
+ OwnPtr<TiledBackingStore> m_mainBackingStore;
+ OwnPtr<TiledBackingStore> m_previousBackingStore;
+
+ RefPtr<Image> m_compositedImage;
+ NativeImagePtr m_compositedNativeImagePtr;
+ RefPtr<CoordinatedImageBacking> m_coordinatedImageBacking;
+
+ PlatformLayer* m_canvasPlatformLayer;
+#if USE(GRAPHICS_SURFACE)
+ IntSize m_canvasSize;
+ GraphicsSurfaceToken m_canvasToken;
+#endif
+ Timer<CoordinatedGraphicsLayer> m_animationStartedTimer;
+ GraphicsLayerAnimations m_animations;
+ double m_lastAnimationStartTime;
+
+ ScrollableArea* m_scrollableArea;
+};
+
+CoordinatedGraphicsLayer* toCoordinatedGraphicsLayer(GraphicsLayer*);
+
+} // namespace WebCore
+#endif // USE(COORDINATED_GRAPHICS)
+
+#endif // CoordinatedGraphicsLayer_h
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp
new file mode 100644
index 000000000..32c7dace4
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp
@@ -0,0 +1,781 @@
+/*
+ Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2012 Company 100, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#if USE(COORDINATED_GRAPHICS)
+
+#include "CoordinatedGraphicsScene.h"
+
+#include "CoordinatedBackingStore.h"
+#include "TextureMapper.h"
+#include "TextureMapperBackingStore.h"
+#include "TextureMapperGL.h"
+#include "TextureMapperLayer.h"
+#include <OpenGLShims.h>
+#include <wtf/Atomics.h>
+#include <wtf/MainThread.h>
+
+#if ENABLE(CSS_SHADERS)
+#include "CoordinatedCustomFilterOperation.h"
+#include "CoordinatedCustomFilterProgram.h"
+#include "CustomFilterProgram.h"
+#include "CustomFilterProgramInfo.h"
+#endif
+
+namespace WebCore {
+
+void CoordinatedGraphicsScene::dispatchOnMainThread(const Function<void()>& function)
+{
+ if (isMainThread())
+ function();
+ else
+ callOnMainThread(function);
+}
+
+static bool layerShouldHaveBackingStore(TextureMapperLayer* layer)
+{
+ return layer->drawsContent() && layer->contentsAreVisible() && !layer->size().isEmpty();
+}
+
+CoordinatedGraphicsScene::CoordinatedGraphicsScene(CoordinatedGraphicsSceneClient* client)
+ : m_client(client)
+ , m_isActive(false)
+ , m_rootLayerID(InvalidCoordinatedLayerID)
+ , m_backgroundColor(Color::white)
+ , m_setDrawsBackground(false)
+{
+ ASSERT(isMainThread());
+}
+
+CoordinatedGraphicsScene::~CoordinatedGraphicsScene()
+{
+}
+
+void CoordinatedGraphicsScene::paintToCurrentGLContext(const TransformationMatrix& matrix, float opacity, const FloatRect& clipRect, TextureMapper::PaintFlags PaintFlags)
+{
+ if (!m_textureMapper) {
+ m_textureMapper = TextureMapper::create(TextureMapper::OpenGLMode);
+ static_cast<TextureMapperGL*>(m_textureMapper.get())->setEnableEdgeDistanceAntialiasing(true);
+ }
+
+ ASSERT(m_textureMapper->accelerationMode() == TextureMapper::OpenGLMode);
+ syncRemoteContent();
+
+ adjustPositionForFixedLayers();
+ TextureMapperLayer* currentRootLayer = rootLayer();
+ if (!currentRootLayer)
+ return;
+
+ TextureMapperLayer* layer = currentRootLayer;
+
+ if (!layer)
+ return;
+
+ layer->setTextureMapper(m_textureMapper.get());
+ layer->applyAnimationsRecursively();
+ m_textureMapper->beginPainting(PaintFlags);
+ m_textureMapper->beginClip(TransformationMatrix(), clipRect);
+
+ if (m_setDrawsBackground) {
+ RGBA32 rgba = makeRGBA32FromFloats(m_backgroundColor.red(),
+ m_backgroundColor.green(), m_backgroundColor.blue(),
+ m_backgroundColor.alpha() * opacity);
+ m_textureMapper->drawSolidColor(clipRect, TransformationMatrix(), Color(rgba));
+ }
+
+ if (currentRootLayer->opacity() != opacity || currentRootLayer->transform() != matrix) {
+ currentRootLayer->setOpacity(opacity);
+ currentRootLayer->setTransform(matrix);
+ }
+
+ layer->paint();
+ m_fpsCounter.updateFPSAndDisplay(m_textureMapper.get(), clipRect.location(), matrix);
+ m_textureMapper->endClip();
+ m_textureMapper->endPainting();
+
+ if (layer->descendantsOrSelfHaveRunningAnimations())
+ dispatchOnMainThread(bind(&CoordinatedGraphicsScene::updateViewport, this));
+}
+
+void CoordinatedGraphicsScene::paintToGraphicsContext(PlatformGraphicsContext* platformContext)
+{
+ if (!m_textureMapper)
+ m_textureMapper = TextureMapper::create();
+ ASSERT(m_textureMapper->accelerationMode() == TextureMapper::SoftwareMode);
+ syncRemoteContent();
+ TextureMapperLayer* layer = rootLayer();
+
+ if (!layer)
+ return;
+
+ GraphicsContext graphicsContext(platformContext);
+ m_textureMapper->setGraphicsContext(&graphicsContext);
+ m_textureMapper->beginPainting();
+
+ IntRect clipRect = graphicsContext.clipBounds();
+ if (m_setDrawsBackground)
+ m_textureMapper->drawSolidColor(clipRect, TransformationMatrix(), m_backgroundColor);
+
+ layer->paint();
+ m_fpsCounter.updateFPSAndDisplay(m_textureMapper.get(), clipRect.location());
+ m_textureMapper->endPainting();
+ m_textureMapper->setGraphicsContext(0);
+}
+
+void CoordinatedGraphicsScene::setScrollPosition(const FloatPoint& scrollPosition)
+{
+ m_scrollPosition = scrollPosition;
+}
+
+void CoordinatedGraphicsScene::updateViewport()
+{
+ ASSERT(isMainThread());
+ if (m_client)
+ m_client->updateViewport();
+}
+
+void CoordinatedGraphicsScene::adjustPositionForFixedLayers()
+{
+ if (m_fixedLayers.isEmpty())
+ return;
+
+ // Fixed layer positions are updated by the web process when we update the visible contents rect / scroll position.
+ // If we want those layers to follow accurately the viewport when we move between the web process updates, we have to offset
+ // them by the delta between the current position and the position of the viewport used for the last layout.
+ FloatSize delta = m_scrollPosition - m_renderedContentsScrollPosition;
+
+ LayerRawPtrMap::iterator end = m_fixedLayers.end();
+ for (LayerRawPtrMap::iterator it = m_fixedLayers.begin(); it != end; ++it)
+ it->value->setScrollPositionDeltaIfNeeded(delta);
+}
+
+#if USE(GRAPHICS_SURFACE)
+void CoordinatedGraphicsScene::createCanvasIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state)
+{
+ if (!state.canvasToken.isValid())
+ return;
+
+ RefPtr<TextureMapperSurfaceBackingStore> canvasBackingStore(TextureMapperSurfaceBackingStore::create());
+ m_surfaceBackingStores.set(layer, canvasBackingStore);
+ canvasBackingStore->setGraphicsSurface(GraphicsSurface::create(state.canvasSize, state.canvasSurfaceFlags, state.canvasToken));
+ layer->setContentsLayer(canvasBackingStore.get());
+}
+
+void CoordinatedGraphicsScene::syncCanvasIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state)
+{
+ ASSERT(m_textureMapper);
+
+ if (state.canvasChanged) {
+ destroyCanvasIfNeeded(layer, state);
+ createCanvasIfNeeded(layer, state);
+ }
+
+ if (state.canvasShouldSwapBuffers) {
+ ASSERT(m_surfaceBackingStores.contains(layer));
+ SurfaceBackingStoreMap::iterator it = m_surfaceBackingStores.find(layer);
+ RefPtr<TextureMapperSurfaceBackingStore> canvasBackingStore = it->value;
+ canvasBackingStore->swapBuffersIfNeeded(state.canvasFrontBuffer);
+ }
+}
+
+void CoordinatedGraphicsScene::destroyCanvasIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state)
+{
+ if (state.canvasToken.isValid())
+ return;
+
+ m_surfaceBackingStores.remove(layer);
+ layer->setContentsLayer(0);
+}
+#endif
+
+void CoordinatedGraphicsScene::setLayerRepaintCountIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state)
+{
+ if (!layer->isShowingRepaintCounter() || !state.repaintCountChanged)
+ return;
+
+ layer->setRepaintCount(state.repaintCount);
+}
+
+void CoordinatedGraphicsScene::setLayerChildrenIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state)
+{
+ if (!state.childrenChanged)
+ return;
+
+ Vector<TextureMapperLayer*> children;
+
+ for (size_t i = 0; i < state.children.size(); ++i) {
+ CoordinatedLayerID childID = state.children[i];
+ TextureMapperLayer* child = layerByID(childID);
+ children.append(child);
+ }
+ layer->setChildren(children);
+}
+
+#if ENABLE(CSS_FILTERS)
+void CoordinatedGraphicsScene::setLayerFiltersIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state)
+{
+ if (!state.filtersChanged)
+ return;
+
+#if ENABLE(CSS_SHADERS)
+ injectCachedCustomFilterPrograms(state.filters);
+#endif
+ layer->setFilters(state.filters);
+}
+#endif
+
+#if ENABLE(CSS_SHADERS)
+void CoordinatedGraphicsScene::syncCustomFilterPrograms(const CoordinatedGraphicsState& state)
+{
+ for (size_t i = 0; i < state.customFiltersToCreate.size(); ++i)
+ createCustomFilterProgram(state.customFiltersToCreate[i].first, state.customFiltersToCreate[i].second);
+
+ for (size_t i = 0; i < state.customFiltersToRemove.size(); ++i)
+ removeCustomFilterProgram(state.customFiltersToRemove[i]);
+}
+
+void CoordinatedGraphicsScene::injectCachedCustomFilterPrograms(const FilterOperations& filters) const
+{
+ for (size_t i = 0; i < filters.size(); ++i) {
+ FilterOperation* operation = filters.operations().at(i).get();
+ if (operation->getOperationType() != FilterOperation::CUSTOM)
+ continue;
+
+ CoordinatedCustomFilterOperation* customOperation = static_cast<CoordinatedCustomFilterOperation*>(operation);
+ ASSERT(!customOperation->program());
+ CustomFilterProgramMap::const_iterator iter = m_customFilterPrograms.find(customOperation->programID());
+ ASSERT(iter != m_customFilterPrograms.end());
+ customOperation->setProgram(iter->value.get());
+ }
+}
+
+void CoordinatedGraphicsScene::createCustomFilterProgram(int id, const CustomFilterProgramInfo& programInfo)
+{
+ ASSERT(!m_customFilterPrograms.contains(id));
+ m_customFilterPrograms.set(id, CoordinatedCustomFilterProgram::create(programInfo.vertexShaderString(), programInfo.fragmentShaderString(), programInfo.programType(), programInfo.mixSettings(), programInfo.meshType()));
+}
+
+void CoordinatedGraphicsScene::removeCustomFilterProgram(int id)
+{
+ CustomFilterProgramMap::iterator iter = m_customFilterPrograms.find(id);
+ ASSERT(iter != m_customFilterPrograms.end());
+ if (m_textureMapper)
+ m_textureMapper->removeCachedCustomFilterProgram(iter->value.get());
+ m_customFilterPrograms.remove(iter);
+}
+#endif // ENABLE(CSS_SHADERS)
+
+void CoordinatedGraphicsScene::setLayerState(CoordinatedLayerID id, const CoordinatedGraphicsLayerState& layerState)
+{
+ ASSERT(m_rootLayerID != InvalidCoordinatedLayerID);
+ TextureMapperLayer* layer = layerByID(id);
+
+ if (layerState.positionChanged)
+ layer->setPosition(layerState.pos);
+
+ if (layerState.anchorPointChanged)
+ layer->setAnchorPoint(layerState.anchorPoint);
+
+ if (layerState.sizeChanged)
+ layer->setSize(layerState.size);
+
+ if (layerState.transformChanged)
+ layer->setTransform(layerState.transform);
+
+ if (layerState.childrenTransformChanged)
+ layer->setChildrenTransform(layerState.childrenTransform);
+
+ if (layerState.contentsRectChanged)
+ layer->setContentsRect(layerState.contentsRect);
+
+ if (layerState.contentsTilingChanged) {
+ layer->setContentsTilePhase(layerState.contentsTilePhase);
+ layer->setContentsTileSize(layerState.contentsTileSize);
+ }
+
+ if (layerState.opacityChanged)
+ layer->setOpacity(layerState.opacity);
+
+ if (layerState.solidColorChanged)
+ layer->setSolidColor(layerState.solidColor);
+
+ if (layerState.debugBorderColorChanged || layerState.debugBorderWidthChanged)
+ layer->setDebugVisuals(layerState.showDebugBorders, layerState.debugBorderColor, layerState.debugBorderWidth, layerState.showRepaintCounter);
+
+ if (layerState.replicaChanged)
+ layer->setReplicaLayer(getLayerByIDIfExists(layerState.replica));
+
+ if (layerState.maskChanged)
+ layer->setMaskLayer(getLayerByIDIfExists(layerState.mask));
+
+ if (layerState.imageChanged)
+ assignImageBackingToLayer(layer, layerState.imageID);
+
+ if (layerState.flagsChanged) {
+ layer->setContentsOpaque(layerState.contentsOpaque);
+ layer->setDrawsContent(layerState.drawsContent);
+ layer->setContentsVisible(layerState.contentsVisible);
+ layer->setBackfaceVisibility(layerState.backfaceVisible);
+
+ // Never clip the root layer.
+ layer->setMasksToBounds(id == m_rootLayerID ? false : layerState.masksToBounds);
+ layer->setPreserves3D(layerState.preserves3D);
+
+ bool fixedToViewportChanged = layer->fixedToViewport() != layerState.fixedToViewport;
+ layer->setFixedToViewport(layerState.fixedToViewport);
+ if (fixedToViewportChanged) {
+ if (layerState.fixedToViewport)
+ m_fixedLayers.add(id, layer);
+ else
+ m_fixedLayers.remove(id);
+ }
+
+ layer->setIsScrollable(layerState.isScrollable);
+ }
+
+ if (layerState.committedScrollOffsetChanged)
+ layer->didCommitScrollOffset(layerState.committedScrollOffset);
+
+ prepareContentBackingStore(layer);
+
+ // Apply Operations.
+ setLayerChildrenIfNeeded(layer, layerState);
+ createTilesIfNeeded(layer, layerState);
+ removeTilesIfNeeded(layer, layerState);
+ updateTilesIfNeeded(layer, layerState);
+#if ENABLE(CSS_FILTERS)
+ setLayerFiltersIfNeeded(layer, layerState);
+#endif
+ setLayerAnimationsIfNeeded(layer, layerState);
+#if USE(GRAPHICS_SURFACE)
+ syncCanvasIfNeeded(layer, layerState);
+#endif
+ setLayerRepaintCountIfNeeded(layer, layerState);
+}
+
+TextureMapperLayer* CoordinatedGraphicsScene::getLayerByIDIfExists(CoordinatedLayerID id)
+{
+ return (id != InvalidCoordinatedLayerID) ? layerByID(id) : 0;
+}
+
+void CoordinatedGraphicsScene::createLayers(const Vector<CoordinatedLayerID>& ids)
+{
+ for (size_t index = 0; index < ids.size(); ++index)
+ createLayer(ids[index]);
+}
+
+void CoordinatedGraphicsScene::createLayer(CoordinatedLayerID id)
+{
+ OwnPtr<TextureMapperLayer> newLayer = adoptPtr(new TextureMapperLayer);
+ newLayer->setID(id);
+ newLayer->setScrollClient(this);
+ m_layers.add(id, newLayer.release());
+}
+
+void CoordinatedGraphicsScene::deleteLayers(const Vector<CoordinatedLayerID>& layerIDs)
+{
+ for (size_t index = 0; index < layerIDs.size(); ++index)
+ deleteLayer(layerIDs[index]);
+}
+
+void CoordinatedGraphicsScene::deleteLayer(CoordinatedLayerID layerID)
+{
+ OwnPtr<TextureMapperLayer> layer = m_layers.take(layerID);
+ ASSERT(layer);
+
+ m_backingStores.remove(layer.get());
+ m_fixedLayers.remove(layerID);
+#if USE(GRAPHICS_SURFACE)
+ m_surfaceBackingStores.remove(layer.get());
+#endif
+}
+
+void CoordinatedGraphicsScene::setRootLayerID(CoordinatedLayerID layerID)
+{
+ ASSERT(layerID != InvalidCoordinatedLayerID);
+ ASSERT(m_rootLayerID == InvalidCoordinatedLayerID);
+
+ m_rootLayerID = layerID;
+
+ TextureMapperLayer* layer = layerByID(layerID);
+ ASSERT(m_rootLayer->children().isEmpty());
+ m_rootLayer->addChild(layer);
+}
+
+void CoordinatedGraphicsScene::prepareContentBackingStore(TextureMapperLayer* layer)
+{
+ if (!layerShouldHaveBackingStore(layer)) {
+ removeBackingStoreIfNeeded(layer);
+ return;
+ }
+
+ createBackingStoreIfNeeded(layer);
+ resetBackingStoreSizeToLayerSize(layer);
+}
+
+void CoordinatedGraphicsScene::createBackingStoreIfNeeded(TextureMapperLayer* layer)
+{
+ if (m_backingStores.contains(layer))
+ return;
+
+ RefPtr<CoordinatedBackingStore> backingStore(CoordinatedBackingStore::create());
+ m_backingStores.add(layer, backingStore);
+ layer->setBackingStore(backingStore);
+}
+
+void CoordinatedGraphicsScene::removeBackingStoreIfNeeded(TextureMapperLayer* layer)
+{
+ RefPtr<CoordinatedBackingStore> backingStore = m_backingStores.take(layer);
+ if (!backingStore)
+ return;
+
+ layer->setBackingStore(0);
+}
+
+void CoordinatedGraphicsScene::resetBackingStoreSizeToLayerSize(TextureMapperLayer* layer)
+{
+ RefPtr<CoordinatedBackingStore> backingStore = m_backingStores.get(layer);
+ ASSERT(backingStore);
+ backingStore->setSize(layer->size());
+ m_backingStoresWithPendingBuffers.add(backingStore);
+}
+
+void CoordinatedGraphicsScene::createTilesIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state)
+{
+ if (state.tilesToCreate.isEmpty())
+ return;
+
+ RefPtr<CoordinatedBackingStore> backingStore = m_backingStores.get(layer);
+ ASSERT(backingStore);
+
+ for (size_t i = 0; i < state.tilesToCreate.size(); ++i)
+ backingStore->createTile(state.tilesToCreate[i].tileID, state.tilesToCreate[i].scale);
+}
+
+void CoordinatedGraphicsScene::removeTilesIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state)
+{
+ if (state.tilesToRemove.isEmpty())
+ return;
+
+ RefPtr<CoordinatedBackingStore> backingStore = m_backingStores.get(layer);
+ if (!backingStore)
+ return;
+
+ for (size_t i = 0; i < state.tilesToRemove.size(); ++i)
+ backingStore->removeTile(state.tilesToRemove[i]);
+
+ m_backingStoresWithPendingBuffers.add(backingStore);
+}
+
+void CoordinatedGraphicsScene::updateTilesIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state)
+{
+ if (state.tilesToUpdate.isEmpty())
+ return;
+
+ RefPtr<CoordinatedBackingStore> backingStore = m_backingStores.get(layer);
+ ASSERT(backingStore);
+
+ for (size_t i = 0; i < state.tilesToUpdate.size(); ++i) {
+ const TileUpdateInfo& tileInfo = state.tilesToUpdate[i];
+ const SurfaceUpdateInfo& surfaceUpdateInfo = tileInfo.updateInfo;
+
+ SurfaceMap::iterator surfaceIt = m_surfaces.find(surfaceUpdateInfo.atlasID);
+ ASSERT(surfaceIt != m_surfaces.end());
+
+ backingStore->updateTile(tileInfo.tileID, surfaceUpdateInfo.updateRect, tileInfo.tileRect, surfaceIt->value, surfaceUpdateInfo.surfaceOffset);
+ m_backingStoresWithPendingBuffers.add(backingStore);
+ }
+}
+
+void CoordinatedGraphicsScene::syncUpdateAtlases(const CoordinatedGraphicsState& state)
+{
+ for (size_t i = 0; i < state.updateAtlasesToCreate.size(); ++i)
+ createUpdateAtlas(state.updateAtlasesToCreate[i].first, state.updateAtlasesToCreate[i].second);
+
+ for (size_t i = 0; i < state.updateAtlasesToRemove.size(); ++i)
+ removeUpdateAtlas(state.updateAtlasesToRemove[i]);
+}
+
+void CoordinatedGraphicsScene::createUpdateAtlas(uint32_t atlasID, PassRefPtr<CoordinatedSurface> surface)
+{
+ ASSERT(!m_surfaces.contains(atlasID));
+ m_surfaces.add(atlasID, surface);
+}
+
+void CoordinatedGraphicsScene::removeUpdateAtlas(uint32_t atlasID)
+{
+ ASSERT(m_surfaces.contains(atlasID));
+ m_surfaces.remove(atlasID);
+}
+
+void CoordinatedGraphicsScene::syncImageBackings(const CoordinatedGraphicsState& state)
+{
+ for (size_t i = 0; i < state.imagesToRemove.size(); ++i)
+ removeImageBacking(state.imagesToRemove[i]);
+
+ for (size_t i = 0; i < state.imagesToCreate.size(); ++i)
+ createImageBacking(state.imagesToCreate[i]);
+
+ for (size_t i = 0; i < state.imagesToUpdate.size(); ++i)
+ updateImageBacking(state.imagesToUpdate[i].first, state.imagesToUpdate[i].second);
+
+ for (size_t i = 0; i < state.imagesToClear.size(); ++i)
+ clearImageBackingContents(state.imagesToClear[i]);
+}
+
+void CoordinatedGraphicsScene::createImageBacking(CoordinatedImageBackingID imageID)
+{
+ ASSERT(!m_imageBackings.contains(imageID));
+ RefPtr<CoordinatedBackingStore> backingStore(CoordinatedBackingStore::create());
+ m_imageBackings.add(imageID, backingStore.release());
+}
+
+void CoordinatedGraphicsScene::updateImageBacking(CoordinatedImageBackingID imageID, PassRefPtr<CoordinatedSurface> surface)
+{
+ ASSERT(m_imageBackings.contains(imageID));
+ ImageBackingMap::iterator it = m_imageBackings.find(imageID);
+ RefPtr<CoordinatedBackingStore> backingStore = it->value;
+
+ // CoordinatedImageBacking is realized to CoordinatedBackingStore with only one tile in UI Process.
+ backingStore->createTile(1 /* id */, 1 /* scale */);
+ IntRect rect(IntPoint::zero(), surface->size());
+ // See CoordinatedGraphicsLayer::shouldDirectlyCompositeImage()
+ ASSERT(2000 >= std::max(rect.width(), rect.height()));
+ backingStore->setSize(rect.size());
+ backingStore->updateTile(1 /* id */, rect, rect, surface, rect.location());
+
+ m_backingStoresWithPendingBuffers.add(backingStore);
+}
+
+void CoordinatedGraphicsScene::clearImageBackingContents(CoordinatedImageBackingID imageID)
+{
+ ASSERT(m_imageBackings.contains(imageID));
+ ImageBackingMap::iterator it = m_imageBackings.find(imageID);
+ RefPtr<CoordinatedBackingStore> backingStore = it->value;
+ backingStore->removeAllTiles();
+ m_backingStoresWithPendingBuffers.add(backingStore);
+}
+
+void CoordinatedGraphicsScene::removeImageBacking(CoordinatedImageBackingID imageID)
+{
+ ASSERT(m_imageBackings.contains(imageID));
+
+ // We don't want TextureMapperLayer refers a dangling pointer.
+ m_releasedImageBackings.append(m_imageBackings.take(imageID));
+}
+
+void CoordinatedGraphicsScene::assignImageBackingToLayer(TextureMapperLayer* layer, CoordinatedImageBackingID imageID)
+{
+#if USE(GRAPHICS_SURFACE)
+ if (m_surfaceBackingStores.contains(layer))
+ return;
+#endif
+
+ if (imageID == InvalidCoordinatedImageBackingID) {
+ layer->setContentsLayer(0);
+ return;
+ }
+
+ ImageBackingMap::iterator it = m_imageBackings.find(imageID);
+ ASSERT(it != m_imageBackings.end());
+ layer->setContentsLayer(it->value.get());
+}
+
+void CoordinatedGraphicsScene::removeReleasedImageBackingsIfNeeded()
+{
+ m_releasedImageBackings.clear();
+}
+
+void CoordinatedGraphicsScene::commitPendingBackingStoreOperations()
+{
+ HashSet<RefPtr<CoordinatedBackingStore> >::iterator end = m_backingStoresWithPendingBuffers.end();
+ for (HashSet<RefPtr<CoordinatedBackingStore> >::iterator it = m_backingStoresWithPendingBuffers.begin(); it != end; ++it)
+ (*it)->commitTileOperations(m_textureMapper.get());
+
+ m_backingStoresWithPendingBuffers.clear();
+}
+
+void CoordinatedGraphicsScene::commitSceneState(const CoordinatedGraphicsState& state)
+{
+ m_renderedContentsScrollPosition = state.scrollPosition;
+
+ createLayers(state.layersToCreate);
+ deleteLayers(state.layersToRemove);
+
+ if (state.rootCompositingLayer != m_rootLayerID)
+ setRootLayerID(state.rootCompositingLayer);
+
+ syncImageBackings(state);
+ syncUpdateAtlases(state);
+#if ENABLE(CSS_SHADERS)
+ syncCustomFilterPrograms(state);
+#endif
+
+ for (size_t i = 0; i < state.layersToUpdate.size(); ++i)
+ setLayerState(state.layersToUpdate[i].first, state.layersToUpdate[i].second);
+
+ commitPendingBackingStoreOperations();
+ removeReleasedImageBackingsIfNeeded();
+
+ // The pending tiles state is on its way for the screen, tell the web process to render the next one.
+ dispatchOnMainThread(bind(&CoordinatedGraphicsScene::renderNextFrame, this));
+}
+
+void CoordinatedGraphicsScene::renderNextFrame()
+{
+ if (m_client)
+ m_client->renderNextFrame();
+}
+
+void CoordinatedGraphicsScene::ensureRootLayer()
+{
+ if (m_rootLayer)
+ return;
+
+ m_rootLayer = adoptPtr(new TextureMapperLayer);
+ m_rootLayer->setMasksToBounds(false);
+ m_rootLayer->setDrawsContent(false);
+ m_rootLayer->setAnchorPoint(FloatPoint3D(0, 0, 0));
+
+ // The root layer should not have zero size, or it would be optimized out.
+ m_rootLayer->setSize(FloatSize(1.0, 1.0));
+
+ ASSERT(m_textureMapper);
+ m_rootLayer->setTextureMapper(m_textureMapper.get());
+}
+
+void CoordinatedGraphicsScene::syncRemoteContent()
+{
+ // We enqueue messages and execute them during paint, as they require an active GL context.
+ ensureRootLayer();
+
+ Vector<Function<void()> > renderQueue;
+ bool calledOnMainThread = WTF::isMainThread();
+ if (!calledOnMainThread)
+ m_renderQueueMutex.lock();
+ renderQueue.swap(m_renderQueue);
+ if (!calledOnMainThread)
+ m_renderQueueMutex.unlock();
+
+ for (size_t i = 0; i < renderQueue.size(); ++i)
+ renderQueue[i]();
+}
+
+void CoordinatedGraphicsScene::purgeGLResources()
+{
+ m_imageBackings.clear();
+ m_releasedImageBackings.clear();
+#if USE(GRAPHICS_SURFACE)
+ m_surfaceBackingStores.clear();
+#endif
+ m_surfaces.clear();
+
+ m_rootLayer.clear();
+ m_rootLayerID = InvalidCoordinatedLayerID;
+ m_layers.clear();
+ m_fixedLayers.clear();
+ m_textureMapper.clear();
+ m_backingStores.clear();
+ m_backingStoresWithPendingBuffers.clear();
+
+ setActive(false);
+ dispatchOnMainThread(bind(&CoordinatedGraphicsScene::purgeBackingStores, this));
+}
+
+void CoordinatedGraphicsScene::dispatchCommitScrollOffset(uint32_t layerID, const IntSize& offset)
+{
+ m_client->commitScrollOffset(layerID, offset);
+}
+
+void CoordinatedGraphicsScene::commitScrollOffset(uint32_t layerID, const IntSize& offset)
+{
+ dispatchOnMainThread(bind(&CoordinatedGraphicsScene::dispatchCommitScrollOffset, this, layerID, offset));
+}
+
+void CoordinatedGraphicsScene::purgeBackingStores()
+{
+ if (m_client)
+ m_client->purgeBackingStores();
+}
+
+void CoordinatedGraphicsScene::setLayerAnimationsIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state)
+{
+ if (!state.animationsChanged)
+ return;
+
+#if ENABLE(CSS_SHADERS)
+ for (size_t i = 0; i < state.animations.animations().size(); ++i) {
+ const KeyframeValueList& keyframes = state.animations.animations().at(i).keyframes();
+ if (keyframes.property() != AnimatedPropertyWebkitFilter)
+ continue;
+ for (size_t j = 0; j < keyframes.size(); ++j) {
+ const FilterAnimationValue& filterValue = static_cast<const FilterAnimationValue&>(keyframes.at(j));
+ injectCachedCustomFilterPrograms(filterValue.value());
+ }
+ }
+#endif
+ layer->setAnimations(state.animations);
+}
+
+void CoordinatedGraphicsScene::detach()
+{
+ ASSERT(isMainThread());
+ m_renderQueue.clear();
+ m_client = 0;
+}
+
+void CoordinatedGraphicsScene::appendUpdate(const Function<void()>& function)
+{
+ if (!m_isActive)
+ return;
+
+ ASSERT(isMainThread());
+ MutexLocker locker(m_renderQueueMutex);
+ m_renderQueue.append(function);
+}
+
+void CoordinatedGraphicsScene::setActive(bool active)
+{
+ if (m_isActive == active)
+ return;
+
+ // Have to clear render queue in both cases.
+ // If there are some updates in queue during activation then those updates are from previous instance of paint node
+ // and cannot be applied to the newly created instance.
+ m_renderQueue.clear();
+ m_isActive = active;
+ if (m_isActive)
+ dispatchOnMainThread(bind(&CoordinatedGraphicsScene::renderNextFrame, this));
+}
+
+void CoordinatedGraphicsScene::setBackgroundColor(const Color& color)
+{
+ m_backgroundColor = color;
+}
+
+TextureMapperLayer* CoordinatedGraphicsScene::findScrollableContentsLayerAt(const FloatPoint& point)
+{
+ return rootLayer() ? rootLayer()->findScrollableContentsLayerAt(point) : 0;
+}
+
+} // namespace WebCore
+
+#endif // USE(COORDINATED_GRAPHICS)
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h
new file mode 100644
index 000000000..7fa92ad87
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h
@@ -0,0 +1,209 @@
+/*
+ Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2013 Company 100, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef CoordinatedGraphicsScene_h
+#define CoordinatedGraphicsScene_h
+
+#if USE(COORDINATED_GRAPHICS)
+#include "CoordinatedGraphicsState.h"
+#include "CoordinatedSurface.h"
+#include "GraphicsContext.h"
+#include "GraphicsLayer.h"
+#include "GraphicsLayerAnimation.h"
+#include "GraphicsSurface.h"
+#include "IntRect.h"
+#include "IntSize.h"
+#include "RunLoop.h"
+#include "TextureMapper.h"
+#include "TextureMapperBackingStore.h"
+#include "TextureMapperFPSCounter.h"
+#include "TextureMapperLayer.h"
+#include "Timer.h"
+#include <wtf/Functional.h>
+#include <wtf/HashSet.h>
+#include <wtf/ThreadingPrimitives.h>
+#include <wtf/Vector.h>
+
+#if USE(GRAPHICS_SURFACE)
+#include "TextureMapperSurfaceBackingStore.h"
+#endif
+
+namespace WebCore {
+
+class CoordinatedBackingStore;
+class CustomFilterProgram;
+class CustomFilterProgramInfo;
+
+class CoordinatedGraphicsSceneClient {
+public:
+ virtual ~CoordinatedGraphicsSceneClient() { }
+ virtual void purgeBackingStores() = 0;
+ virtual void renderNextFrame() = 0;
+ virtual void updateViewport() = 0;
+ virtual void commitScrollOffset(uint32_t layerID, const IntSize& offset) = 0;
+};
+
+class CoordinatedGraphicsScene : public ThreadSafeRefCounted<CoordinatedGraphicsScene>, public TextureMapperLayer::ScrollingClient {
+public:
+ explicit CoordinatedGraphicsScene(CoordinatedGraphicsSceneClient*);
+ virtual ~CoordinatedGraphicsScene();
+ void paintToCurrentGLContext(const TransformationMatrix&, float, const FloatRect&, TextureMapper::PaintFlags = 0);
+ void paintToGraphicsContext(PlatformGraphicsContext*);
+ void setScrollPosition(const FloatPoint&);
+ void detach();
+ void appendUpdate(const Function<void()>&);
+
+ WebCore::TextureMapperLayer* findScrollableContentsLayerAt(const WebCore::FloatPoint&);
+
+ virtual void commitScrollOffset(uint32_t layerID, const IntSize& offset);
+
+ // The painting thread must lock the main thread to use below two methods, because two methods access members that the main thread manages. See m_client.
+ // Currently, QQuickWebPage::updatePaintNode() locks the main thread before calling both methods.
+ void purgeGLResources();
+ void setActive(bool);
+
+ void commitSceneState(const CoordinatedGraphicsState&);
+
+ void setBackgroundColor(const Color&);
+ void setDrawsBackground(bool enable) { m_setDrawsBackground = enable; }
+
+private:
+ void setRootLayerID(CoordinatedLayerID);
+ void createLayers(const Vector<CoordinatedLayerID>&);
+ void deleteLayers(const Vector<CoordinatedLayerID>&);
+ void setLayerState(CoordinatedLayerID, const CoordinatedGraphicsLayerState&);
+ void setLayerChildrenIfNeeded(TextureMapperLayer*, const CoordinatedGraphicsLayerState&);
+ void updateTilesIfNeeded(TextureMapperLayer*, const CoordinatedGraphicsLayerState&);
+ void createTilesIfNeeded(TextureMapperLayer*, const CoordinatedGraphicsLayerState&);
+ void removeTilesIfNeeded(TextureMapperLayer*, const CoordinatedGraphicsLayerState&);
+#if ENABLE(CSS_FILTERS)
+ void setLayerFiltersIfNeeded(TextureMapperLayer*, const CoordinatedGraphicsLayerState&);
+#endif
+ void setLayerAnimationsIfNeeded(TextureMapperLayer*, const CoordinatedGraphicsLayerState&);
+#if USE(GRAPHICS_SURFACE)
+ void createCanvasIfNeeded(TextureMapperLayer*, const CoordinatedGraphicsLayerState&);
+ void syncCanvasIfNeeded(TextureMapperLayer*, const CoordinatedGraphicsLayerState&);
+ void destroyCanvasIfNeeded(TextureMapperLayer*, const CoordinatedGraphicsLayerState&);
+#endif
+ void setLayerRepaintCountIfNeeded(TextureMapperLayer*, const CoordinatedGraphicsLayerState&);
+
+ void syncUpdateAtlases(const CoordinatedGraphicsState&);
+ void createUpdateAtlas(uint32_t atlasID, PassRefPtr<CoordinatedSurface>);
+ void removeUpdateAtlas(uint32_t atlasID);
+
+ void syncImageBackings(const CoordinatedGraphicsState&);
+ void createImageBacking(CoordinatedImageBackingID);
+ void updateImageBacking(CoordinatedImageBackingID, PassRefPtr<CoordinatedSurface>);
+ void clearImageBackingContents(CoordinatedImageBackingID);
+ void removeImageBacking(CoordinatedImageBackingID);
+
+#if ENABLE(CSS_SHADERS)
+ void syncCustomFilterPrograms(const CoordinatedGraphicsState&);
+ void injectCachedCustomFilterPrograms(const FilterOperations& filters) const;
+ void createCustomFilterProgram(int id, const CustomFilterProgramInfo&);
+ void removeCustomFilterProgram(int id);
+#endif
+
+ TextureMapperLayer* layerByID(CoordinatedLayerID id)
+ {
+ ASSERT(m_layers.contains(id));
+ ASSERT(id != InvalidCoordinatedLayerID);
+ return m_layers.get(id);
+ }
+ TextureMapperLayer* getLayerByIDIfExists(CoordinatedLayerID);
+ TextureMapperLayer* rootLayer() { return m_rootLayer.get(); }
+
+ void syncRemoteContent();
+ void adjustPositionForFixedLayers();
+
+ void dispatchOnMainThread(const Function<void()>&);
+ void updateViewport();
+ void renderNextFrame();
+ void purgeBackingStores();
+
+ void createLayer(CoordinatedLayerID);
+ void deleteLayer(CoordinatedLayerID);
+
+ void assignImageBackingToLayer(TextureMapperLayer*, CoordinatedImageBackingID);
+ void removeReleasedImageBackingsIfNeeded();
+ void ensureRootLayer();
+ void commitPendingBackingStoreOperations();
+
+ void prepareContentBackingStore(TextureMapperLayer*);
+ void createBackingStoreIfNeeded(TextureMapperLayer*);
+ void removeBackingStoreIfNeeded(TextureMapperLayer*);
+ void resetBackingStoreSizeToLayerSize(TextureMapperLayer*);
+
+ void dispatchCommitScrollOffset(uint32_t layerID, const IntSize& offset);
+
+ // Render queue can be accessed ony from main thread or updatePaintNode call stack!
+ Vector<Function<void()> > m_renderQueue;
+ Mutex m_renderQueueMutex;
+
+ OwnPtr<TextureMapper> m_textureMapper;
+
+ typedef HashMap<CoordinatedImageBackingID, RefPtr<CoordinatedBackingStore> > ImageBackingMap;
+ ImageBackingMap m_imageBackings;
+ Vector<RefPtr<CoordinatedBackingStore> > m_releasedImageBackings;
+
+ typedef HashMap<TextureMapperLayer*, RefPtr<CoordinatedBackingStore> > BackingStoreMap;
+ BackingStoreMap m_backingStores;
+
+ HashSet<RefPtr<CoordinatedBackingStore> > m_backingStoresWithPendingBuffers;
+
+#if USE(GRAPHICS_SURFACE)
+ typedef HashMap<TextureMapperLayer*, RefPtr<TextureMapperSurfaceBackingStore> > SurfaceBackingStoreMap;
+ SurfaceBackingStoreMap m_surfaceBackingStores;
+#endif
+
+ typedef HashMap<uint32_t /* atlasID */, RefPtr<CoordinatedSurface> > SurfaceMap;
+ SurfaceMap m_surfaces;
+
+ // Below two members are accessed by only the main thread. The painting thread must lock the main thread to access both members.
+ CoordinatedGraphicsSceneClient* m_client;
+ bool m_isActive;
+
+ OwnPtr<TextureMapperLayer> m_rootLayer;
+
+ typedef HashMap<CoordinatedLayerID, OwnPtr<TextureMapperLayer> > LayerMap;
+ LayerMap m_layers;
+ typedef HashMap<CoordinatedLayerID, TextureMapperLayer*> LayerRawPtrMap;
+ LayerRawPtrMap m_fixedLayers;
+ CoordinatedLayerID m_rootLayerID;
+ FloatPoint m_scrollPosition;
+ FloatPoint m_renderedContentsScrollPosition;
+ Color m_backgroundColor;
+ bool m_setDrawsBackground;
+
+#if ENABLE(CSS_SHADERS)
+ typedef HashMap<int, RefPtr<CustomFilterProgram> > CustomFilterProgramMap;
+ CustomFilterProgramMap m_customFilterPrograms;
+#endif
+
+ TextureMapperFPSCounter m_fpsCounter;
+};
+
+} // namespace WebCore
+
+#endif // USE(COORDINATED_GRAPHICS)
+
+#endif // CoordinatedGraphicsScene_h
+
+
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h
new file mode 100644
index 000000000..5445e62ff
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h
@@ -0,0 +1,212 @@
+/*
+ * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2013 Company 100, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CoordinatedGraphicsState_h
+#define CoordinatedGraphicsState_h
+
+#if USE(COORDINATED_GRAPHICS)
+
+#include "Color.h"
+#include "FloatRect.h"
+#include "FloatSize.h"
+#include "GraphicsLayerAnimation.h"
+#include "IntRect.h"
+#include "IntSize.h"
+#include "SurfaceUpdateInfo.h"
+#include "TransformationMatrix.h"
+
+#if ENABLE(CSS_FILTERS)
+#include "FilterOperations.h"
+#endif
+
+#if ENABLE(CSS_FILTERS)
+#include "CustomFilterProgramInfo.h"
+#endif
+
+#if USE(GRAPHICS_SURFACE)
+#include "GraphicsSurface.h"
+#include "GraphicsSurfaceToken.h"
+#endif
+
+namespace WebCore {
+
+class CoordinatedSurface;
+
+typedef uint32_t CoordinatedLayerID;
+enum { InvalidCoordinatedLayerID = 0 };
+
+typedef uint64_t CoordinatedImageBackingID;
+enum { InvalidCoordinatedImageBackingID = 0 };
+
+struct TileUpdateInfo {
+ uint32_t tileID;
+ IntRect tileRect;
+ WebCore::SurfaceUpdateInfo updateInfo;
+};
+
+struct TileCreationInfo {
+ uint32_t tileID;
+ float scale;
+};
+
+struct CoordinatedGraphicsLayerState {
+ union {
+ struct {
+ bool positionChanged: 1;
+ bool anchorPointChanged: 1;
+ bool sizeChanged: 1;
+ bool transformChanged: 1;
+ bool childrenTransformChanged: 1;
+ bool contentsRectChanged: 1;
+ bool opacityChanged: 1;
+ bool solidColorChanged: 1;
+ bool debugBorderColorChanged: 1;
+ bool debugBorderWidthChanged: 1;
+ bool replicaChanged: 1;
+ bool maskChanged: 1;
+ bool imageChanged: 1;
+ bool flagsChanged: 1;
+ bool animationsChanged: 1;
+ bool filtersChanged: 1;
+ bool childrenChanged: 1;
+ bool repaintCountChanged : 1;
+ bool canvasChanged: 1;
+ bool canvasShouldSwapBuffers: 1;
+ bool isScrollableChanged: 1;
+ bool committedScrollOffsetChanged: 1;
+ bool contentsTilingChanged: 1;
+ };
+ unsigned changeMask;
+ };
+ union {
+ struct {
+ bool contentsOpaque : 1;
+ bool drawsContent : 1;
+ bool contentsVisible : 1;
+ bool backfaceVisible : 1;
+ bool masksToBounds : 1;
+ bool preserves3D : 1;
+ bool fixedToViewport : 1;
+ bool showDebugBorders : 1;
+ bool showRepaintCounter : 1;
+ bool isScrollable: 1;
+ };
+ unsigned flags;
+ };
+
+ CoordinatedGraphicsLayerState()
+ : changeMask(0)
+ , contentsOpaque(false)
+ , drawsContent(false)
+ , contentsVisible(true)
+ , backfaceVisible(true)
+ , masksToBounds(false)
+ , preserves3D(false)
+ , fixedToViewport(false)
+ , showDebugBorders(false)
+ , showRepaintCounter(false)
+ , isScrollable(false)
+ , opacity(0)
+ , debugBorderWidth(0)
+ , replica(InvalidCoordinatedLayerID)
+ , mask(InvalidCoordinatedLayerID)
+ , imageID(InvalidCoordinatedImageBackingID)
+#if USE(GRAPHICS_SURFACE)
+ , canvasFrontBuffer(0)
+#endif
+ {
+ }
+
+ FloatPoint pos;
+ FloatPoint3D anchorPoint;
+ FloatSize size;
+ TransformationMatrix transform;
+ TransformationMatrix childrenTransform;
+ IntRect contentsRect;
+ IntPoint contentsTilePhase;
+ IntSize contentsTileSize;
+ float opacity;
+ Color solidColor;
+ Color debugBorderColor;
+ float debugBorderWidth;
+#if ENABLE(CSS_FILTERS)
+ FilterOperations filters;
+#endif
+ GraphicsLayerAnimations animations;
+ Vector<uint32_t> children;
+ Vector<TileCreationInfo> tilesToCreate;
+ Vector<uint32_t> tilesToRemove;
+ CoordinatedLayerID replica;
+ CoordinatedLayerID mask;
+ CoordinatedImageBackingID imageID;
+
+ unsigned repaintCount;
+ Vector<TileUpdateInfo> tilesToUpdate;
+
+#if USE(GRAPHICS_SURFACE)
+ IntSize canvasSize;
+ GraphicsSurfaceToken canvasToken;
+ uint32_t canvasFrontBuffer;
+ GraphicsSurface::Flags canvasSurfaceFlags;
+#endif
+
+ IntSize committedScrollOffset;
+
+ bool hasPendingChanges() const
+ {
+ return changeMask || tilesToUpdate.size() || tilesToRemove.size() || tilesToCreate.size();
+ }
+};
+
+struct CoordinatedGraphicsState {
+ uint32_t rootCompositingLayer;
+ FloatPoint scrollPosition;
+ IntSize contentsSize;
+ IntRect coveredRect;
+
+ Vector<CoordinatedLayerID> layersToCreate;
+ Vector<std::pair<CoordinatedLayerID, CoordinatedGraphicsLayerState> > layersToUpdate;
+ Vector<CoordinatedLayerID> layersToRemove;
+
+ Vector<CoordinatedImageBackingID> imagesToCreate;
+ Vector<CoordinatedImageBackingID> imagesToRemove;
+ Vector<std::pair<CoordinatedImageBackingID, RefPtr<CoordinatedSurface> > > imagesToUpdate;
+ Vector<CoordinatedImageBackingID> imagesToClear;
+
+ Vector<std::pair<uint32_t /* atlasID */, RefPtr<CoordinatedSurface> > > updateAtlasesToCreate;
+ Vector<uint32_t /* atlasID */> updateAtlasesToRemove;
+
+#if ENABLE(CSS_SHADERS)
+ Vector<std::pair<uint32_t /* FilterID */, CustomFilterProgramInfo> > customFiltersToCreate;
+ Vector<uint32_t> customFiltersToRemove;
+#endif
+};
+
+} // namespace WebCore
+
+#endif // USE(COORDINATED_GRAPHICS)
+
+#endif // CoordinatedGraphicsState_h
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedImageBacking.cpp b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedImageBacking.cpp
new file mode 100644
index 000000000..5ca430b47
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedImageBacking.cpp
@@ -0,0 +1,182 @@
+/*
+ * Copyright (C) 2012 Company 100, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if USE(COORDINATED_GRAPHICS)
+#include "CoordinatedImageBacking.h"
+
+#include "CoordinatedGraphicsState.h"
+#include "GraphicsContext.h"
+
+namespace WebCore {
+
+class ImageBackingSurfaceClient : public CoordinatedSurface::Client {
+public:
+ ImageBackingSurfaceClient(Image* image, const IntRect& rect)
+ : m_image(image)
+ , m_rect(rect)
+ {
+ }
+
+ virtual void paintToSurfaceContext(GraphicsContext* context) OVERRIDE
+ {
+ context->drawImage(m_image, ColorSpaceDeviceRGB, m_rect, m_rect);
+ }
+
+private:
+ Image* m_image;
+ IntRect m_rect;
+};
+
+CoordinatedImageBackingID CoordinatedImageBacking::getCoordinatedImageBackingID(Image* image)
+{
+ // CoordinatedImageBacking keeps a RefPtr<Image> member, so the same Image pointer can not refer two different instances until CoordinatedImageBacking releases the member.
+ return reinterpret_cast<CoordinatedImageBackingID>(image);
+}
+
+PassRefPtr<CoordinatedImageBacking> CoordinatedImageBacking::create(Client* client, PassRefPtr<Image> image)
+{
+ return adoptRef(new CoordinatedImageBacking(client, image));
+}
+
+CoordinatedImageBacking::CoordinatedImageBacking(Client* client, PassRefPtr<Image> image)
+ : m_client(client)
+ , m_image(image)
+ , m_id(getCoordinatedImageBackingID(m_image.get()))
+ , m_clearContentsTimer(this, &CoordinatedImageBacking::clearContentsTimerFired)
+ , m_isDirty(false)
+ , m_isVisible(false)
+{
+ // FIXME: We would need to decode a small image directly into a GraphicsSurface.
+ // http://webkit.org/b/101426
+
+ m_client->createImageBacking(id());
+}
+
+CoordinatedImageBacking::~CoordinatedImageBacking()
+{
+}
+
+void CoordinatedImageBacking::addHost(Host* host)
+{
+ ASSERT(!m_hosts.contains(host));
+ m_hosts.append(host);
+}
+
+void CoordinatedImageBacking::removeHost(Host* host)
+{
+ size_t position = m_hosts.find(host);
+ ASSERT(position != notFound);
+ m_hosts.remove(position);
+
+ if (m_hosts.isEmpty())
+ m_client->removeImageBacking(id());
+}
+
+void CoordinatedImageBacking::markDirty()
+{
+ m_isDirty = true;
+}
+
+void CoordinatedImageBacking::update()
+{
+ releaseSurfaceIfNeeded();
+
+ bool changedToVisible;
+ updateVisibilityIfNeeded(changedToVisible);
+ if (!m_isVisible)
+ return;
+
+ if (!changedToVisible) {
+ if (!m_isDirty)
+ return;
+
+ if (m_nativeImagePtr == m_image->nativeImageForCurrentFrame()) {
+ m_isDirty = false;
+ return;
+ }
+ }
+
+ m_surface = CoordinatedSurface::create(m_image->size(), !m_image->currentFrameKnownToBeOpaque() ? CoordinatedSurface::SupportsAlpha : CoordinatedSurface::NoFlags);
+ if (!m_surface) {
+ m_isDirty = false;
+ return;
+ }
+
+ IntRect rect(IntPoint::zero(), m_image->size());
+
+ ImageBackingSurfaceClient surfaceClient(m_image.get(), rect);
+ m_surface->paintToSurface(rect, &surfaceClient);
+
+ m_nativeImagePtr = m_image->nativeImageForCurrentFrame();
+
+ m_client->updateImageBacking(id(), m_surface);
+ m_isDirty = false;
+}
+
+void CoordinatedImageBacking::releaseSurfaceIfNeeded()
+{
+ // We must keep m_surface until UI Process reads m_surface.
+ // If m_surface exists, it was created in the previous update.
+ m_surface.clear();
+}
+
+static const double clearContentsTimerInterval = 3;
+
+void CoordinatedImageBacking::updateVisibilityIfNeeded(bool& changedToVisible)
+{
+ bool previousIsVisible = m_isVisible;
+
+ m_isVisible = false;
+ for (size_t i = 0; i < m_hosts.size(); ++i) {
+ if (m_hosts[i]->imageBackingVisible()) {
+ m_isVisible = true;
+ break;
+ }
+ }
+
+ bool changedToInvisible = previousIsVisible && !m_isVisible;
+ if (changedToInvisible) {
+ ASSERT(!m_clearContentsTimer.isActive());
+ m_clearContentsTimer.startOneShot(clearContentsTimerInterval);
+ }
+
+ changedToVisible = !previousIsVisible && m_isVisible;
+
+ if (m_isVisible && m_clearContentsTimer.isActive()) {
+ m_clearContentsTimer.stop();
+ // We don't want to update the texture if we didn't remove the texture.
+ changedToVisible = false;
+ }
+}
+
+void CoordinatedImageBacking::clearContentsTimerFired(Timer<CoordinatedImageBacking>*)
+{
+ m_client->clearImageBackingContents(id());
+}
+
+} // namespace WebCore
+#endif
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedImageBacking.h b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedImageBacking.h
new file mode 100644
index 000000000..711e491fe
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedImageBacking.h
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2012 Company 100, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#ifndef CoordinatedImageBacking_h
+#define CoordinatedImageBacking_h
+
+#if USE(COORDINATED_GRAPHICS)
+#include "CoordinatedGraphicsState.h"
+#include "CoordinatedSurface.h"
+#include "Image.h"
+#include "Timer.h"
+#include <wtf/RefCounted.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class CoordinatedImageBacking : public RefCounted<CoordinatedImageBacking> {
+public:
+ class Client {
+ public:
+ virtual void createImageBacking(CoordinatedImageBackingID) = 0;
+ virtual void updateImageBacking(CoordinatedImageBackingID, PassRefPtr<CoordinatedSurface>) = 0;
+ virtual void clearImageBackingContents(CoordinatedImageBackingID) = 0;
+ virtual void removeImageBacking(CoordinatedImageBackingID) = 0;
+ };
+
+ class Host {
+ public:
+ virtual bool imageBackingVisible() = 0;
+ };
+
+ static PassRefPtr<CoordinatedImageBacking> create(Client*, PassRefPtr<Image>);
+ virtual ~CoordinatedImageBacking();
+
+ static CoordinatedImageBackingID getCoordinatedImageBackingID(Image*);
+ CoordinatedImageBackingID id() const { return m_id; }
+
+ void addHost(Host*);
+ void removeHost(Host*);
+
+ // When a new image is updated or an animated gif is progressed, CoordinatedGraphicsLayer calls markDirty().
+ void markDirty();
+
+ // Create, remove or update its backing.
+ void update();
+
+private:
+ CoordinatedImageBacking(Client*, PassRefPtr<Image>);
+
+ void releaseSurfaceIfNeeded();
+ void updateVisibilityIfNeeded(bool& changedToVisible);
+ void clearContentsTimerFired(Timer<CoordinatedImageBacking>*);
+
+ Client* m_client;
+ RefPtr<Image> m_image;
+ NativeImagePtr m_nativeImagePtr;
+ CoordinatedImageBackingID m_id;
+ Vector<Host*> m_hosts;
+
+ RefPtr<CoordinatedSurface> m_surface;
+
+ Timer<CoordinatedImageBacking> m_clearContentsTimer;
+
+ bool m_isDirty;
+ bool m_isVisible;
+
+};
+
+} // namespace WebCore
+#endif // USE(COORDINATED_GRAPHICS)
+
+#endif // CoordinatedImageBacking_h
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedSurface.cpp b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedSurface.cpp
new file mode 100644
index 000000000..9aa67a5e0
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedSurface.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2013 Company 100, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "CoordinatedSurface.h"
+
+#if USE(COORDINATED_GRAPHICS)
+
+namespace WebCore {
+
+CoordinatedSurface::Factory* CoordinatedSurface::s_factory = 0;
+
+void CoordinatedSurface::setFactory(CoordinatedSurface::Factory factory)
+{
+ s_factory = factory;
+}
+
+PassRefPtr<CoordinatedSurface> CoordinatedSurface::create(const IntSize& size, Flags flags)
+{
+ ASSERT(s_factory);
+ return s_factory(size, flags);
+}
+
+CoordinatedSurface::CoordinatedSurface(const IntSize& size, Flags flags)
+ : m_size(size)
+ , m_flags(flags)
+{
+}
+
+} // namespace WebCore
+
+#endif // USE(COORDINATED_GRAPHICS)
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedSurface.h b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedSurface.h
new file mode 100644
index 000000000..9142528c6
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedSurface.h
@@ -0,0 +1,76 @@
+/*
+ Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2012 Company 100, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#ifndef CoordinatedSurface_h
+#define CoordinatedSurface_h
+
+#if USE(COORDINATED_GRAPHICS)
+#include "IntRect.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/ThreadSafeRefCounted.h>
+
+namespace WebCore {
+class BitmapTexture;
+class GraphicsContext;
+
+class CoordinatedSurface : public ThreadSafeRefCounted<CoordinatedSurface> {
+public:
+ enum Flag {
+ NoFlags = 0,
+ SupportsAlpha = 1 << 0,
+ };
+ typedef unsigned Flags;
+
+ class Client {
+ public:
+ virtual ~Client() { }
+ virtual void paintToSurfaceContext(GraphicsContext*) = 0;
+ };
+
+ typedef PassRefPtr<CoordinatedSurface> Factory(const IntSize&, Flags);
+ static void setFactory(Factory);
+ static PassRefPtr<CoordinatedSurface> create(const IntSize&, Flags);
+
+ virtual ~CoordinatedSurface() { }
+
+ bool supportsAlpha() const { return flags() & SupportsAlpha; }
+ IntSize size() const { return m_size; }
+
+ virtual void paintToSurface(const IntRect&, Client*) = 0;
+
+#if USE(TEXTURE_MAPPER)
+ virtual void copyToTexture(PassRefPtr<BitmapTexture>, const IntRect& target, const IntPoint& sourceOffset) = 0;
+#endif
+
+protected:
+ CoordinatedSurface(const IntSize&, Flags);
+ Flags flags() const { return m_flags; }
+
+ IntSize m_size;
+ Flags m_flags;
+
+private:
+ static CoordinatedSurface::Factory* s_factory;
+};
+
+} // namespace WebCore
+
+#endif // USE(COORDINATED_GRAPHICS)
+#endif // CoordinatedSurface_h
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedTile.cpp b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedTile.cpp
new file mode 100644
index 000000000..b24f48d23
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedTile.cpp
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "CoordinatedTile.h"
+
+#if USE(TILED_BACKING_STORE)
+
+#include "GraphicsContext.h"
+#include "ImageBuffer.h"
+#include "SurfaceUpdateInfo.h"
+#include "TiledBackingStoreClient.h"
+
+namespace WebCore {
+
+static const uint32_t InvalidCoordinatedTileID = 0;
+
+CoordinatedTile::CoordinatedTile(CoordinatedTileClient* client, TiledBackingStore* tiledBackingStore, const Coordinate& tileCoordinate)
+ : m_client(client)
+ , m_tiledBackingStore(tiledBackingStore)
+ , m_coordinate(tileCoordinate)
+ , m_rect(tiledBackingStore->tileRectForCoordinate(tileCoordinate))
+ , m_ID(InvalidCoordinatedTileID)
+ , m_dirtyRect(m_rect)
+{
+}
+
+CoordinatedTile::~CoordinatedTile()
+{
+ if (m_ID != InvalidCoordinatedTileID)
+ m_client->removeTile(m_ID);
+}
+
+bool CoordinatedTile::isDirty() const
+{
+ return !m_dirtyRect.isEmpty();
+}
+
+void CoordinatedTile::invalidate(const IntRect& dirtyRect)
+{
+ IntRect tileDirtyRect = intersection(dirtyRect, m_rect);
+ if (tileDirtyRect.isEmpty())
+ return;
+
+ m_dirtyRect.unite(tileDirtyRect);
+}
+
+Vector<IntRect> CoordinatedTile::updateBackBuffer()
+{
+ if (!isDirty())
+ return Vector<IntRect>();
+
+ SurfaceUpdateInfo updateInfo;
+
+ if (!m_client->paintToSurface(m_dirtyRect.size(), updateInfo.atlasID, updateInfo.surfaceOffset, this))
+ return Vector<IntRect>();
+
+ updateInfo.updateRect = m_dirtyRect;
+ updateInfo.updateRect.move(-m_rect.x(), -m_rect.y());
+ updateInfo.scaleFactor = m_tiledBackingStore->contentsScale();
+
+ static uint32_t id = 1;
+ if (m_ID == InvalidCoordinatedTileID) {
+ m_ID = id++;
+ // We may get an invalid ID due to wrap-around on overflow.
+ if (m_ID == InvalidCoordinatedTileID)
+ m_ID = id++;
+ m_client->createTile(m_ID, updateInfo, m_rect);
+ } else
+ m_client->updateTile(m_ID, updateInfo, m_rect);
+
+ Vector<IntRect> updatedRects;
+ updatedRects.append(m_dirtyRect);
+ m_dirtyRect = IntRect();
+ return updatedRects;
+}
+
+void CoordinatedTile::paintToSurfaceContext(GraphicsContext* context)
+{
+ context->translate(-m_dirtyRect.x(), -m_dirtyRect.y());
+ context->scale(FloatSize(m_tiledBackingStore->contentsScale(), m_tiledBackingStore->contentsScale()));
+ m_tiledBackingStore->client()->tiledBackingStorePaint(context, m_tiledBackingStore->mapToContents(m_dirtyRect));
+}
+
+void CoordinatedTile::swapBackBufferToFront()
+{
+ // Handled by tiledBackingStorePaintEnd.
+}
+
+bool CoordinatedTile::isReadyToPaint() const
+{
+ return m_ID != InvalidCoordinatedTileID;
+}
+
+void CoordinatedTile::paint(GraphicsContext*, const IntRect&)
+{
+ ASSERT_NOT_REACHED();
+}
+
+void CoordinatedTile::resize(const IntSize& newSize)
+{
+ m_rect = IntRect(m_rect.location(), newSize);
+ m_dirtyRect = m_rect;
+}
+
+CoordinatedTileBackend::CoordinatedTileBackend(CoordinatedTileClient* client)
+ : m_client(client)
+{
+}
+
+PassRefPtr<Tile> CoordinatedTileBackend::createTile(TiledBackingStore* tiledBackingStore, const Tile::Coordinate& tileCoordinate)
+{
+ return CoordinatedTile::create(m_client, tiledBackingStore, tileCoordinate);
+}
+
+void CoordinatedTileBackend::paintCheckerPattern(GraphicsContext*, const FloatRect&)
+{
+}
+
+} // namespace WebCore
+
+#endif // USE(TILED_BACKING_STORE)
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedTile.h b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedTile.h
new file mode 100644
index 000000000..cab526e2b
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedTile.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CoordinatedTile_h
+#define CoordinatedTile_h
+
+#if USE(TILED_BACKING_STORE)
+
+#include "CoordinatedSurface.h"
+#include "IntRect.h"
+#include "Tile.h"
+#include "TiledBackingStore.h"
+
+namespace WebCore {
+
+class CoordinatedTileClient;
+class ImageBuffer;
+class SurfaceUpdateInfo;
+class TiledBackingStore;
+
+class CoordinatedTile : public Tile, public CoordinatedSurface::Client {
+public:
+ static PassRefPtr<Tile> create(CoordinatedTileClient* client, TiledBackingStore* tiledBackingStore, const Coordinate& tileCoordinate) { return adoptRef(new CoordinatedTile(client, tiledBackingStore, tileCoordinate)); }
+ ~CoordinatedTile();
+
+ bool isDirty() const;
+ void invalidate(const IntRect&);
+ Vector<IntRect> updateBackBuffer();
+ void swapBackBufferToFront();
+ bool isReadyToPaint() const;
+ void paint(GraphicsContext*, const IntRect&);
+
+ const Coordinate& coordinate() const { return m_coordinate; }
+ const IntRect& rect() const { return m_rect; }
+ void resize(const IntSize&);
+
+ virtual void paintToSurfaceContext(GraphicsContext*) OVERRIDE;
+
+private:
+ CoordinatedTile(CoordinatedTileClient*, TiledBackingStore*, const Coordinate&);
+
+ CoordinatedTileClient* m_client;
+ TiledBackingStore* m_tiledBackingStore;
+ Coordinate m_coordinate;
+ IntRect m_rect;
+
+ uint32_t m_ID;
+ IntRect m_dirtyRect;
+
+ OwnPtr<ImageBuffer> m_localBuffer;
+};
+
+class CoordinatedTileClient {
+public:
+ virtual ~CoordinatedTileClient() { }
+ virtual void createTile(uint32_t tileID, const SurfaceUpdateInfo&, const IntRect&) = 0;
+ virtual void updateTile(uint32_t tileID, const SurfaceUpdateInfo&, const IntRect&) = 0;
+ virtual void removeTile(uint32_t tileID) = 0;
+ virtual bool paintToSurface(const IntSize&, uint32_t& atlasID, IntPoint&, CoordinatedSurface::Client*) = 0;
+};
+
+class CoordinatedTileBackend : public TiledBackingStoreBackend {
+public:
+ static PassOwnPtr<TiledBackingStoreBackend> create(CoordinatedTileClient* client) { return adoptPtr(new CoordinatedTileBackend(client)); }
+ PassRefPtr<Tile> createTile(TiledBackingStore*, const Tile::Coordinate&);
+ void paintCheckerPattern(GraphicsContext*, const FloatRect&);
+
+private:
+ explicit CoordinatedTileBackend(CoordinatedTileClient*);
+ CoordinatedTileClient* m_client;
+};
+
+} // namespace WebCore
+
+#endif // USE(TILED_BACKING_STORE)
+
+#endif // CoordinatedTile_h
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/SurfaceUpdateInfo.h b/Source/WebCore/platform/graphics/texmap/coordinated/SurfaceUpdateInfo.h
new file mode 100644
index 000000000..5af069a2b
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/coordinated/SurfaceUpdateInfo.h
@@ -0,0 +1,51 @@
+/*
+ Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#ifndef SurfaceUpdateInfo_h
+#define SurfaceUpdateInfo_h
+
+#if USE(COORDINATED_GRAPHICS)
+
+#include "IntRect.h"
+
+namespace WebCore {
+
+class SurfaceUpdateInfo {
+
+public:
+ SurfaceUpdateInfo() { }
+
+ // The rect to be updated.
+ IntRect updateRect;
+
+ // The page scale factor used to render this update.
+ float scaleFactor;
+
+ // The id of the update atlas including the shareable bitmap containing the updates.
+ uint32_t atlasID;
+
+ // The offset in the bitmap where the rendered contents are.
+ IntPoint surfaceOffset;
+};
+
+} // namespace WebCore
+
+#endif // USE(COORDINATED_GRAPHICS)
+
+#endif // SurfaceUpdateInfo_h
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/ThreadSafeCoordinatedSurface.cpp b/Source/WebCore/platform/graphics/texmap/coordinated/ThreadSafeCoordinatedSurface.cpp
new file mode 100644
index 000000000..94497dd84
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/coordinated/ThreadSafeCoordinatedSurface.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2013 Company 100, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ThreadSafeCoordinatedSurface.h"
+
+#if USE(COORDINATED_GRAPHICS)
+
+#include "TextureMapper.h"
+
+namespace WebCore {
+
+PassRefPtr<ThreadSafeCoordinatedSurface> ThreadSafeCoordinatedSurface::create(const IntSize& size, CoordinatedSurface::Flags flags)
+{
+ return adoptRef(new ThreadSafeCoordinatedSurface(size, flags, ImageBuffer::create(size)));
+}
+
+ThreadSafeCoordinatedSurface::ThreadSafeCoordinatedSurface(const IntSize& size, CoordinatedSurface::Flags flags, PassOwnPtr<ImageBuffer> buffer)
+ : CoordinatedSurface(size, flags)
+ , m_imageBuffer(buffer)
+{
+}
+
+ThreadSafeCoordinatedSurface::~ThreadSafeCoordinatedSurface()
+{
+}
+
+void ThreadSafeCoordinatedSurface::paintToSurface(const IntRect& rect, CoordinatedSurface::Client* client)
+{
+ ASSERT(client);
+ ASSERT(m_imageBuffer);
+
+ GraphicsContext* context = m_imageBuffer->context();
+ context->save();
+ context->clip(rect);
+ context->translate(rect.x(), rect.y());
+
+ client->paintToSurfaceContext(context);
+
+ context->restore();
+}
+
+void ThreadSafeCoordinatedSurface::copyToTexture(PassRefPtr<BitmapTexture> passTexture, const IntRect& target, const IntPoint& sourceOffset)
+{
+ RefPtr<BitmapTexture> texture(passTexture);
+
+ ASSERT(m_imageBuffer);
+ RefPtr<Image> image = m_imageBuffer->copyImage(DontCopyBackingStore);
+ texture->updateContents(image.get(), target, sourceOffset, BitmapTexture::UpdateCanModifyOriginalImageData);
+}
+
+} // namespace WebCore
+
+#endif // USE(COORDINATED_GRAPHICS)
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/ThreadSafeCoordinatedSurface.h b/Source/WebCore/platform/graphics/texmap/coordinated/ThreadSafeCoordinatedSurface.h
new file mode 100644
index 000000000..e003818af
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/coordinated/ThreadSafeCoordinatedSurface.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2013 Company 100, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ThreadSafeCoordinatedSurface_h
+#define ThreadSafeCoordinatedSurface_h
+
+#if USE(COORDINATED_GRAPHICS)
+#include "CoordinatedSurface.h"
+#include "ImageBuffer.h"
+
+namespace WebCore {
+
+class ThreadSafeCoordinatedSurface : public CoordinatedSurface {
+public:
+ virtual ~ThreadSafeCoordinatedSurface();
+
+ static PassRefPtr<ThreadSafeCoordinatedSurface> create(const IntSize&, Flags);
+
+ virtual void paintToSurface(const IntRect&, CoordinatedSurface::Client*) OVERRIDE;
+ virtual void copyToTexture(PassRefPtr<BitmapTexture>, const IntRect& target, const IntPoint& sourceOffset) OVERRIDE;
+
+private:
+ ThreadSafeCoordinatedSurface(const IntSize&, Flags, PassOwnPtr<ImageBuffer>);
+
+ OwnPtr<ImageBuffer> m_imageBuffer;
+};
+
+} // namespace WebCore
+
+#endif // USE(COORDINATED_GRAPHICS)
+
+#endif // ThreadSafeCoordinatedSurface_h
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/UpdateAtlas.cpp b/Source/WebCore/platform/graphics/texmap/coordinated/UpdateAtlas.cpp
new file mode 100644
index 000000000..319e9b8e4
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/coordinated/UpdateAtlas.cpp
@@ -0,0 +1,116 @@
+/*
+ Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2012 Company 100, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "UpdateAtlas.h"
+
+#if USE(COORDINATED_GRAPHICS)
+
+#include "CoordinatedGraphicsState.h"
+#include "GraphicsContext.h"
+#include "IntRect.h"
+#include <wtf/MathExtras.h>
+
+namespace WebCore {
+
+class UpdateAtlasSurfaceClient : public CoordinatedSurface::Client {
+public:
+ UpdateAtlasSurfaceClient(CoordinatedSurface::Client* client, const IntSize& size, bool supportsAlpha)
+ : m_client(client)
+ , m_size(size)
+ , m_supportsAlpha(supportsAlpha)
+ {
+ }
+
+ virtual void paintToSurfaceContext(GraphicsContext* context) OVERRIDE
+ {
+ if (m_supportsAlpha) {
+ context->setCompositeOperation(CompositeCopy);
+ context->fillRect(IntRect(IntPoint::zero(), m_size), Color::transparent, ColorSpaceDeviceRGB);
+ context->setCompositeOperation(CompositeSourceOver);
+ }
+
+ m_client->paintToSurfaceContext(context);
+ }
+
+private:
+ CoordinatedSurface::Client* m_client;
+ IntSize m_size;
+ bool m_supportsAlpha;
+};
+
+UpdateAtlas::UpdateAtlas(Client* client, int dimension, CoordinatedSurface::Flags flags)
+ : m_client(client)
+ , m_inactivityInSeconds(0)
+{
+ static uint32_t nextID = 0;
+ m_ID = ++nextID;
+ IntSize size = nextPowerOfTwo(IntSize(dimension, dimension));
+ m_surface = CoordinatedSurface::create(size, flags);
+
+ m_client->createUpdateAtlas(m_ID, m_surface);
+}
+
+UpdateAtlas::~UpdateAtlas()
+{
+ if (m_surface)
+ m_client->removeUpdateAtlas(m_ID);
+}
+
+void UpdateAtlas::buildLayoutIfNeeded()
+{
+ if (!m_areaAllocator) {
+ m_areaAllocator = adoptPtr(new GeneralAreaAllocator(size()));
+ m_areaAllocator->setMinimumAllocation(IntSize(32, 32));
+ }
+}
+
+void UpdateAtlas::didSwapBuffers()
+{
+ m_areaAllocator.clear();
+}
+
+
+bool UpdateAtlas::paintOnAvailableBuffer(const IntSize& size, uint32_t& atlasID, IntPoint& offset, CoordinatedSurface::Client* client)
+{
+ m_inactivityInSeconds = 0;
+ buildLayoutIfNeeded();
+ IntRect rect = m_areaAllocator->allocate(size);
+
+ // No available buffer was found.
+ if (rect.isEmpty())
+ return false;
+
+ if (!m_surface)
+ return false;
+
+ atlasID = m_ID;
+
+ // FIXME: Use tri-state buffers, to allow faster updates.
+ offset = rect.location();
+
+ UpdateAtlasSurfaceClient surfaceClient(client, size, supportsAlpha());
+ m_surface->paintToSurface(rect, &surfaceClient);
+
+ return true;
+}
+
+} // namespace WebCore
+#endif // USE(COORDINATED_GRAPHICS)
diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/UpdateAtlas.h b/Source/WebCore/platform/graphics/texmap/coordinated/UpdateAtlas.h
new file mode 100644
index 000000000..2eb45f7c7
--- /dev/null
+++ b/Source/WebCore/platform/graphics/texmap/coordinated/UpdateAtlas.h
@@ -0,0 +1,78 @@
+/*
+ Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2012 Company 100, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#ifndef UpdateAtlas_h
+#define UpdateAtlas_h
+
+#include "AreaAllocator.h"
+#include "CoordinatedSurface.h"
+#include "IntSize.h"
+
+#if USE(COORDINATED_GRAPHICS)
+
+namespace WebCore {
+class GraphicsContext;
+class IntPoint;
+
+class UpdateAtlas {
+ WTF_MAKE_NONCOPYABLE(UpdateAtlas);
+public:
+ class Client {
+ public:
+ virtual void createUpdateAtlas(uint32_t /* id */, PassRefPtr<CoordinatedSurface>) = 0;
+ virtual void removeUpdateAtlas(uint32_t /* id */) = 0;
+ };
+
+ UpdateAtlas(Client*, int dimension, CoordinatedSurface::Flags);
+ ~UpdateAtlas();
+
+ inline IntSize size() const { return m_surface->size(); }
+
+ // Returns false if there is no available buffer.
+ bool paintOnAvailableBuffer(const IntSize&, uint32_t& atlasID, IntPoint& offset, CoordinatedSurface::Client*);
+ void didSwapBuffers();
+ bool supportsAlpha() const { return m_surface->supportsAlpha(); }
+
+ void addTimeInactive(double seconds)
+ {
+ ASSERT(!isInUse());
+ m_inactivityInSeconds += seconds;
+ }
+ bool isInactive() const
+ {
+ const double inactiveSecondsTolerance = 3;
+ return m_inactivityInSeconds > inactiveSecondsTolerance;
+ }
+ bool isInUse() const { return m_areaAllocator; }
+
+private:
+ void buildLayoutIfNeeded();
+
+private:
+ Client* m_client;
+ OwnPtr<GeneralAreaAllocator> m_areaAllocator;
+ RefPtr<CoordinatedSurface> m_surface;
+ double m_inactivityInSeconds;
+ uint32_t m_ID;
+};
+
+} // namespace WebCore
+#endif // USE(COORDINATED_GRAPHICS)
+#endif // UpdateAtlas_h
diff --git a/Source/WebCore/platform/graphics/transforms/AffineTransform.cpp b/Source/WebCore/platform/graphics/transforms/AffineTransform.cpp
index 4131ca4c4..62a7639ba 100644
--- a/Source/WebCore/platform/graphics/transforms/AffineTransform.cpp
+++ b/Source/WebCore/platform/graphics/transforms/AffineTransform.cpp
@@ -31,6 +31,7 @@
#include "FloatQuad.h"
#include "FloatRect.h"
#include "IntRect.h"
+#include "TransformationMatrix.h"
#include <wtf/MathExtras.h>
diff --git a/Source/WebCore/platform/graphics/transforms/AffineTransform.h b/Source/WebCore/platform/graphics/transforms/AffineTransform.h
index 7d83f592f..d8f323b4f 100644
--- a/Source/WebCore/platform/graphics/transforms/AffineTransform.h
+++ b/Source/WebCore/platform/graphics/transforms/AffineTransform.h
@@ -27,23 +27,15 @@
#ifndef AffineTransform_h
#define AffineTransform_h
-#include "TransformationMatrix.h"
-
#include <string.h> // for memcpy
#include <wtf/FastAllocBase.h>
#if USE(CG)
-#include <CoreGraphics/CGAffineTransform.h>
+typedef struct CGAffineTransform CGAffineTransform;
#elif USE(CAIRO)
#include <cairo.h>
-#elif PLATFORM(OPENVG)
-#include "VGUtils.h"
#elif PLATFORM(QT)
#include <QTransform>
-#elif USE(SKIA)
-#include <SkMatrix.h>
-#elif PLATFORM(WX) && USE(WXGC)
-#include <wx/graphics.h>
#endif
namespace WebCore {
@@ -51,7 +43,9 @@ namespace WebCore {
class FloatPoint;
class FloatQuad;
class FloatRect;
+class FloatSize;
class IntPoint;
+class IntSize;
class IntRect;
class TransformationMatrix;
@@ -174,14 +168,8 @@ public:
operator CGAffineTransform() const;
#elif USE(CAIRO)
operator cairo_matrix_t() const;
-#elif PLATFORM(OPENVG)
- operator VGMatrix() const;
#elif PLATFORM(QT)
operator QTransform() const;
-#elif USE(SKIA)
- operator SkMatrix() const;
-#elif PLATFORM(WX) && USE(WXGC)
- operator wxGraphicsMatrix() const;
#endif
static AffineTransform translation(double x, double y)
diff --git a/Source/WebCore/platform/graphics/transforms/RotateTransformOperation.cpp b/Source/WebCore/platform/graphics/transforms/RotateTransformOperation.cpp
index 8c4fad6d9..90634b7eb 100644
--- a/Source/WebCore/platform/graphics/transforms/RotateTransformOperation.cpp
+++ b/Source/WebCore/platform/graphics/transforms/RotateTransformOperation.cpp
@@ -56,15 +56,15 @@ PassRefPtr<TransformOperation> RotateTransformOperation::blend(const TransformOp
// Create the 2 rotation matrices
TransformationMatrix fromT;
TransformationMatrix toT;
- fromT.rotate3d((float)(fromOp ? fromOp->m_x : 0),
- (float)(fromOp ? fromOp->m_y : 0),
- (float)(fromOp ? fromOp->m_z : 1),
- (float)(fromOp ? fromOp->m_angle : 0));
+ fromT.rotate3d((fromOp ? fromOp->m_x : 0),
+ (fromOp ? fromOp->m_y : 0),
+ (fromOp ? fromOp->m_z : 1),
+ (fromOp ? fromOp->m_angle : 0));
- toT.rotate3d((float)(toOp ? toOp->m_x : 0),
- (float)(toOp ? toOp->m_y : 0),
- (float)(toOp ? toOp->m_z : 1),
- (float)(toOp ? toOp->m_angle : 0));
+ toT.rotate3d((toOp ? toOp->m_x : 0),
+ (toOp ? toOp->m_y : 0),
+ (toOp ? toOp->m_z : 1),
+ (toOp ? toOp->m_angle : 0));
// Blend them
toT.blend(fromT, progress);
diff --git a/Source/WebCore/platform/graphics/transforms/TransformState.cpp b/Source/WebCore/platform/graphics/transforms/TransformState.cpp
index e0a9cec82..541b1c648 100644
--- a/Source/WebCore/platform/graphics/transforms/TransformState.cpp
+++ b/Source/WebCore/platform/graphics/transforms/TransformState.cpp
@@ -32,6 +32,7 @@ namespace WebCore {
TransformState& TransformState::operator=(const TransformState& other)
{
+ m_accumulatedOffset = other.m_accumulatedOffset;
m_mapPoint = other.m_mapPoint;
m_mapQuad = other.m_mapQuad;
if (m_mapPoint)
@@ -49,32 +50,56 @@ TransformState& TransformState::operator=(const TransformState& other)
return *this;
}
-void TransformState::move(LayoutUnit x, LayoutUnit y, TransformAccumulation accumulate)
+void TransformState::translateTransform(const LayoutSize& offset)
{
- if (m_accumulatingTransform && m_accumulatedTransform) {
- // If we're accumulating into an existing transform, apply the translation.
- if (m_direction == ApplyTransformDirection)
- m_accumulatedTransform->translateRight(x, y);
- else
- m_accumulatedTransform->translate(x, y);
-
- // Then flatten if necessary.
- if (accumulate == FlattenTransform)
- flatten();
- } else {
- // Just move the point and, optionally, the quad.
- if (m_direction == UnapplyInverseTransformDirection) {
- x = -x;
- y = -y;
- }
- if (m_mapPoint)
- m_lastPlanarPoint.move(x, y);
- if (m_mapQuad)
- m_lastPlanarQuad.move(x, y);
+ if (m_direction == ApplyTransformDirection)
+ m_accumulatedTransform->translateRight(offset.width(), offset.height());
+ else
+ m_accumulatedTransform->translate(offset.width(), offset.height());
+}
+
+void TransformState::translateMappedCoordinates(const LayoutSize& offset)
+{
+ LayoutSize adjustedOffset = (m_direction == ApplyTransformDirection) ? offset : -offset;
+ if (m_mapPoint)
+ m_lastPlanarPoint.move(adjustedOffset);
+ if (m_mapQuad)
+ m_lastPlanarQuad.move(adjustedOffset);
+}
+
+void TransformState::move(const LayoutSize& offset, TransformAccumulation accumulate)
+{
+ if (accumulate == FlattenTransform && !m_accumulatedTransform)
+ m_accumulatedOffset += offset;
+ else {
+ applyAccumulatedOffset();
+ if (m_accumulatingTransform && m_accumulatedTransform) {
+ // If we're accumulating into an existing transform, apply the translation.
+ translateTransform(offset);
+
+ // Then flatten if necessary.
+ if (accumulate == FlattenTransform)
+ flatten();
+ } else
+ // Just move the point and/or quad.
+ translateMappedCoordinates(offset);
}
m_accumulatingTransform = accumulate == AccumulateTransform;
}
+void TransformState::applyAccumulatedOffset()
+{
+ LayoutSize offset = m_accumulatedOffset;
+ m_accumulatedOffset = LayoutSize();
+ if (!offset.isZero()) {
+ if (m_accumulatedTransform) {
+ translateTransform(offset);
+ flatten();
+ } else
+ translateMappedCoordinates(offset);
+ }
+}
+
// FIXME: We transform AffineTransform to TransformationMatrix. This is rather inefficient.
void TransformState::applyTransform(const AffineTransform& transformFromContainer, TransformAccumulation accumulate, bool* wasClamped)
{
@@ -86,6 +111,13 @@ void TransformState::applyTransform(const TransformationMatrix& transformFromCon
if (wasClamped)
*wasClamped = false;
+ if (transformFromContainer.isIntegerTranslation()) {
+ move(LayoutSize(transformFromContainer.e(), transformFromContainer.f()), accumulate);
+ return;
+ }
+
+ applyAccumulatedOffset();
+
// If we have an accumulated transform from last time, multiply in this transform
if (m_accumulatedTransform) {
if (m_direction == ApplyTransformDirection)
@@ -109,6 +141,8 @@ void TransformState::flatten(bool* wasClamped)
if (wasClamped)
*wasClamped = false;
+ applyAccumulatedOffset();
+
if (!m_accumulatedTransform) {
m_accumulatingTransform = false;
return;
@@ -122,13 +156,15 @@ FloatPoint TransformState::mappedPoint(bool* wasClamped) const
if (wasClamped)
*wasClamped = false;
+ FloatPoint point = m_lastPlanarPoint;
+ point.move((m_direction == ApplyTransformDirection) ? m_accumulatedOffset : -m_accumulatedOffset);
if (!m_accumulatedTransform)
- return m_lastPlanarPoint;
+ return point;
if (m_direction == ApplyTransformDirection)
- return m_accumulatedTransform->mapPoint(m_lastPlanarPoint);
+ return m_accumulatedTransform->mapPoint(point);
- return m_accumulatedTransform->inverse().projectPoint(m_lastPlanarPoint, wasClamped);
+ return m_accumulatedTransform->inverse().projectPoint(point, wasClamped);
}
FloatQuad TransformState::mappedQuad(bool* wasClamped) const
@@ -136,13 +172,15 @@ FloatQuad TransformState::mappedQuad(bool* wasClamped) const
if (wasClamped)
*wasClamped = false;
+ FloatQuad quad = m_lastPlanarQuad;
+ quad.move((m_direction == ApplyTransformDirection) ? m_accumulatedOffset : -m_accumulatedOffset);
if (!m_accumulatedTransform)
- return m_lastPlanarQuad;
+ return quad;
if (m_direction == ApplyTransformDirection)
- return m_accumulatedTransform->mapQuad(m_lastPlanarQuad);
+ return m_accumulatedTransform->mapQuad(quad);
- return m_accumulatedTransform->inverse().projectQuad(m_lastPlanarQuad, wasClamped);
+ return m_accumulatedTransform->inverse().projectQuad(quad, wasClamped);
}
void TransformState::flattenWithTransform(const TransformationMatrix& t, bool* wasClamped)
diff --git a/Source/WebCore/platform/graphics/transforms/TransformState.h b/Source/WebCore/platform/graphics/transforms/TransformState.h
index 1d1d355eb..874177b5d 100644
--- a/Source/WebCore/platform/graphics/transforms/TransformState.h
+++ b/Source/WebCore/platform/graphics/transforms/TransformState.h
@@ -73,14 +73,21 @@ public:
TransformState& operator=(const TransformState&);
- void setQuad(const FloatQuad& quad) { m_lastPlanarQuad = quad; }
-
- void move(const LayoutSize& s, TransformAccumulation accumulate = FlattenTransform)
+ void setQuad(const FloatQuad& quad)
{
- move(s.width(), s.height(), accumulate);
+ // FIXME: this assumes that the quad being added is in the coordinate system of the current state.
+ // This breaks if we're simultaneously mapping a point. https://bugs.webkit.org/show_bug.cgi?id=106680
+ ASSERT(!m_mapPoint);
+ m_accumulatedOffset = LayoutSize();
+ m_lastPlanarQuad = quad;
}
-
- void move(LayoutUnit x, LayoutUnit y, TransformAccumulation = FlattenTransform);
+
+ void move(LayoutUnit x, LayoutUnit y, TransformAccumulation accumulate = FlattenTransform)
+ {
+ move(LayoutSize(x, y), accumulate);
+ }
+
+ void move(const LayoutSize&, TransformAccumulation = FlattenTransform);
void applyTransform(const AffineTransform& transformFromContainer, TransformAccumulation = FlattenTransform, bool* wasClamped = 0);
void applyTransform(const TransformationMatrix& transformFromContainer, TransformAccumulation = FlattenTransform, bool* wasClamped = 0);
void flatten(bool* wasClamped = 0);
@@ -94,13 +101,17 @@ public:
FloatQuad mappedQuad(bool* wasClamped = 0) const;
private:
+ void translateTransform(const LayoutSize&);
+ void translateMappedCoordinates(const LayoutSize&);
void flattenWithTransform(const TransformationMatrix&, bool* wasClamped);
+ void applyAccumulatedOffset();
FloatPoint m_lastPlanarPoint;
FloatQuad m_lastPlanarQuad;
// We only allocate the transform if we need to
OwnPtr<TransformationMatrix> m_accumulatedTransform;
+ LayoutSize m_accumulatedOffset;
bool m_accumulatingTransform;
bool m_mapPoint, m_mapQuad;
TransformDirection m_direction;
diff --git a/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp b/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp
index 22ac0075e..bce67773a 100644
--- a/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp
+++ b/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp
@@ -36,6 +36,10 @@
#include <wtf/Assertions.h>
#include <wtf/MathExtras.h>
+#if CPU(X86_64)
+#include <emmintrin.h>
+#endif
+
using namespace std;
namespace WebCore {
@@ -531,12 +535,12 @@ TransformationMatrix& TransformationMatrix::rotateFromVector(double x, double y)
TransformationMatrix& TransformationMatrix::flipX()
{
- return scaleNonUniform(-1.0f, 1.0f);
+ return scaleNonUniform(-1.0, 1.0);
}
TransformationMatrix& TransformationMatrix::flipY()
{
- return scaleNonUniform(1.0f, -1.0f);
+ return scaleNonUniform(1.0, -1.0);
}
FloatPoint TransformationMatrix::projectPoint(const FloatPoint& p, bool* clamped) const
@@ -615,7 +619,7 @@ FloatQuad TransformationMatrix::projectQuad(const FloatQuad& q, bool* clamped) c
static float clampEdgeValue(float f)
{
- ASSERT(!isnan(f));
+ ASSERT(!std::isnan(f));
return min<float>(max<float>(f, -LayoutUnit::max() / 2), LayoutUnit::max() / 2);
}
@@ -627,13 +631,13 @@ LayoutRect TransformationMatrix::clampedBoundsOfProjectedQuad(const FloatQuad& q
float top = clampEdgeValue(floorf(mappedQuadBounds.y()));
float right;
- if (isinf(mappedQuadBounds.x()) && isinf(mappedQuadBounds.width()))
+ if (std::isinf(mappedQuadBounds.x()) && std::isinf(mappedQuadBounds.width()))
right = LayoutUnit::max() / 2;
else
right = clampEdgeValue(ceilf(mappedQuadBounds.maxX()));
float bottom;
- if (isinf(mappedQuadBounds.y()) && isinf(mappedQuadBounds.height()))
+ if (std::isinf(mappedQuadBounds.y()) && std::isinf(mappedQuadBounds.height()))
bottom = LayoutUnit::max() / 2;
else
bottom = clampEdgeValue(ceilf(mappedQuadBounds.maxY()));
@@ -752,45 +756,45 @@ TransformationMatrix& TransformationMatrix::rotate3d(double x, double y, double
TransformationMatrix mat;
// Optimize cases where the axis is along a major axis
- if (x == 1.0f && y == 0.0f && z == 0.0f) {
- mat.m_matrix[0][0] = 1.0f;
- mat.m_matrix[0][1] = 0.0f;
- mat.m_matrix[0][2] = 0.0f;
- mat.m_matrix[1][0] = 0.0f;
+ if (x == 1.0 && y == 0.0 && z == 0.0) {
+ mat.m_matrix[0][0] = 1.0;
+ mat.m_matrix[0][1] = 0.0;
+ mat.m_matrix[0][2] = 0.0;
+ mat.m_matrix[1][0] = 0.0;
mat.m_matrix[1][1] = cosTheta;
mat.m_matrix[1][2] = sinTheta;
- mat.m_matrix[2][0] = 0.0f;
+ mat.m_matrix[2][0] = 0.0;
mat.m_matrix[2][1] = -sinTheta;
mat.m_matrix[2][2] = cosTheta;
- mat.m_matrix[0][3] = mat.m_matrix[1][3] = mat.m_matrix[2][3] = 0.0f;
- mat.m_matrix[3][0] = mat.m_matrix[3][1] = mat.m_matrix[3][2] = 0.0f;
- mat.m_matrix[3][3] = 1.0f;
- } else if (x == 0.0f && y == 1.0f && z == 0.0f) {
+ mat.m_matrix[0][3] = mat.m_matrix[1][3] = mat.m_matrix[2][3] = 0.0;
+ mat.m_matrix[3][0] = mat.m_matrix[3][1] = mat.m_matrix[3][2] = 0.0;
+ mat.m_matrix[3][3] = 1.0;
+ } else if (x == 0.0 && y == 1.0 && z == 0.0) {
mat.m_matrix[0][0] = cosTheta;
- mat.m_matrix[0][1] = 0.0f;
+ mat.m_matrix[0][1] = 0.0;
mat.m_matrix[0][2] = -sinTheta;
- mat.m_matrix[1][0] = 0.0f;
- mat.m_matrix[1][1] = 1.0f;
- mat.m_matrix[1][2] = 0.0f;
+ mat.m_matrix[1][0] = 0.0;
+ mat.m_matrix[1][1] = 1.0;
+ mat.m_matrix[1][2] = 0.0;
mat.m_matrix[2][0] = sinTheta;
- mat.m_matrix[2][1] = 0.0f;
+ mat.m_matrix[2][1] = 0.0;
mat.m_matrix[2][2] = cosTheta;
- mat.m_matrix[0][3] = mat.m_matrix[1][3] = mat.m_matrix[2][3] = 0.0f;
- mat.m_matrix[3][0] = mat.m_matrix[3][1] = mat.m_matrix[3][2] = 0.0f;
- mat.m_matrix[3][3] = 1.0f;
- } else if (x == 0.0f && y == 0.0f && z == 1.0f) {
+ mat.m_matrix[0][3] = mat.m_matrix[1][3] = mat.m_matrix[2][3] = 0.0;
+ mat.m_matrix[3][0] = mat.m_matrix[3][1] = mat.m_matrix[3][2] = 0.0;
+ mat.m_matrix[3][3] = 1.0;
+ } else if (x == 0.0 && y == 0.0 && z == 1.0) {
mat.m_matrix[0][0] = cosTheta;
mat.m_matrix[0][1] = sinTheta;
- mat.m_matrix[0][2] = 0.0f;
+ mat.m_matrix[0][2] = 0.0;
mat.m_matrix[1][0] = -sinTheta;
mat.m_matrix[1][1] = cosTheta;
- mat.m_matrix[1][2] = 0.0f;
- mat.m_matrix[2][0] = 0.0f;
- mat.m_matrix[2][1] = 0.0f;
- mat.m_matrix[2][2] = 1.0f;
- mat.m_matrix[0][3] = mat.m_matrix[1][3] = mat.m_matrix[2][3] = 0.0f;
- mat.m_matrix[3][0] = mat.m_matrix[3][1] = mat.m_matrix[3][2] = 0.0f;
- mat.m_matrix[3][3] = 1.0f;
+ mat.m_matrix[1][2] = 0.0;
+ mat.m_matrix[2][0] = 0.0;
+ mat.m_matrix[2][1] = 0.0;
+ mat.m_matrix[2][2] = 1.0;
+ mat.m_matrix[0][3] = mat.m_matrix[1][3] = mat.m_matrix[2][3] = 0.0;
+ mat.m_matrix[3][0] = mat.m_matrix[3][1] = mat.m_matrix[3][2] = 0.0;
+ mat.m_matrix[3][3] = 1.0;
} else {
// This case is the rotation about an arbitrary unit vector.
//
@@ -809,9 +813,9 @@ TransformationMatrix& TransformationMatrix::rotate3d(double x, double y, double
mat.m_matrix[2][0] = x * z * oneMinusCosTheta + y * sinTheta;
mat.m_matrix[2][1] = y * z * oneMinusCosTheta - x * sinTheta;
mat.m_matrix[2][2] = cosTheta + z * z * oneMinusCosTheta;
- mat.m_matrix[0][3] = mat.m_matrix[1][3] = mat.m_matrix[2][3] = 0.0f;
- mat.m_matrix[3][0] = mat.m_matrix[3][1] = mat.m_matrix[3][2] = 0.0f;
- mat.m_matrix[3][3] = 1.0f;
+ mat.m_matrix[0][3] = mat.m_matrix[1][3] = mat.m_matrix[2][3] = 0.0;
+ mat.m_matrix[3][0] = mat.m_matrix[3][1] = mat.m_matrix[3][2] = 0.0;
+ mat.m_matrix[3][3] = 1.0;
}
multiply(mat);
return *this;
@@ -831,16 +835,16 @@ TransformationMatrix& TransformationMatrix::rotate3d(double rx, double ry, doubl
mat.m_matrix[0][0] = cosTheta;
mat.m_matrix[0][1] = sinTheta;
- mat.m_matrix[0][2] = 0.0f;
+ mat.m_matrix[0][2] = 0.0;
mat.m_matrix[1][0] = -sinTheta;
mat.m_matrix[1][1] = cosTheta;
- mat.m_matrix[1][2] = 0.0f;
- mat.m_matrix[2][0] = 0.0f;
- mat.m_matrix[2][1] = 0.0f;
- mat.m_matrix[2][2] = 1.0f;
- mat.m_matrix[0][3] = mat.m_matrix[1][3] = mat.m_matrix[2][3] = 0.0f;
- mat.m_matrix[3][0] = mat.m_matrix[3][1] = mat.m_matrix[3][2] = 0.0f;
- mat.m_matrix[3][3] = 1.0f;
+ mat.m_matrix[1][2] = 0.0;
+ mat.m_matrix[2][0] = 0.0;
+ mat.m_matrix[2][1] = 0.0;
+ mat.m_matrix[2][2] = 1.0;
+ mat.m_matrix[0][3] = mat.m_matrix[1][3] = mat.m_matrix[2][3] = 0.0;
+ mat.m_matrix[3][0] = mat.m_matrix[3][1] = mat.m_matrix[3][2] = 0.0;
+ mat.m_matrix[3][3] = 1.0;
TransformationMatrix rmat(mat);
@@ -848,35 +852,35 @@ TransformationMatrix& TransformationMatrix::rotate3d(double rx, double ry, doubl
cosTheta = cos(ry);
mat.m_matrix[0][0] = cosTheta;
- mat.m_matrix[0][1] = 0.0f;
+ mat.m_matrix[0][1] = 0.0;
mat.m_matrix[0][2] = -sinTheta;
- mat.m_matrix[1][0] = 0.0f;
- mat.m_matrix[1][1] = 1.0f;
- mat.m_matrix[1][2] = 0.0f;
+ mat.m_matrix[1][0] = 0.0;
+ mat.m_matrix[1][1] = 1.0;
+ mat.m_matrix[1][2] = 0.0;
mat.m_matrix[2][0] = sinTheta;
- mat.m_matrix[2][1] = 0.0f;
+ mat.m_matrix[2][1] = 0.0;
mat.m_matrix[2][2] = cosTheta;
- mat.m_matrix[0][3] = mat.m_matrix[1][3] = mat.m_matrix[2][3] = 0.0f;
- mat.m_matrix[3][0] = mat.m_matrix[3][1] = mat.m_matrix[3][2] = 0.0f;
- mat.m_matrix[3][3] = 1.0f;
+ mat.m_matrix[0][3] = mat.m_matrix[1][3] = mat.m_matrix[2][3] = 0.0;
+ mat.m_matrix[3][0] = mat.m_matrix[3][1] = mat.m_matrix[3][2] = 0.0;
+ mat.m_matrix[3][3] = 1.0;
rmat.multiply(mat);
sinTheta = sin(rx);
cosTheta = cos(rx);
- mat.m_matrix[0][0] = 1.0f;
- mat.m_matrix[0][1] = 0.0f;
- mat.m_matrix[0][2] = 0.0f;
- mat.m_matrix[1][0] = 0.0f;
+ mat.m_matrix[0][0] = 1.0;
+ mat.m_matrix[0][1] = 0.0;
+ mat.m_matrix[0][2] = 0.0;
+ mat.m_matrix[1][0] = 0.0;
mat.m_matrix[1][1] = cosTheta;
mat.m_matrix[1][2] = sinTheta;
- mat.m_matrix[2][0] = 0.0f;
+ mat.m_matrix[2][0] = 0.0;
mat.m_matrix[2][1] = -sinTheta;
mat.m_matrix[2][2] = cosTheta;
- mat.m_matrix[0][3] = mat.m_matrix[1][3] = mat.m_matrix[2][3] = 0.0f;
- mat.m_matrix[3][0] = mat.m_matrix[3][1] = mat.m_matrix[3][2] = 0.0f;
- mat.m_matrix[3][3] = 1.0f;
+ mat.m_matrix[0][3] = mat.m_matrix[1][3] = mat.m_matrix[2][3] = 0.0;
+ mat.m_matrix[3][0] = mat.m_matrix[3][1] = mat.m_matrix[3][2] = 0.0;
+ mat.m_matrix[3][3] = 1.0;
rmat.multiply(mat);
@@ -968,9 +972,7 @@ TransformationMatrix TransformationMatrix::rectToRect(const FloatRect& from, con
to.y() - from.y());
}
-//
-// *this = mat * *this
-//
+// this = mat * this.
TransformationMatrix& TransformationMatrix::multiply(const TransformationMatrix& mat)
{
#if CPU(APPLE_ARMV7S)
@@ -1115,6 +1117,129 @@ TransformationMatrix& TransformationMatrix::multiply(const TransformationMatrix&
}
#undef MATRIX_MULTIPLY_ONE_LINE
+#elif defined(TRANSFORMATION_MATRIX_USE_X86_64_SSE2)
+ // x86_64 has 16 XMM registers which is enough to do the multiplication fully in registers.
+ __m128d matrixBlockA = _mm_load_pd(&(m_matrix[0][0]));
+ __m128d matrixBlockC = _mm_load_pd(&(m_matrix[1][0]));
+ __m128d matrixBlockE = _mm_load_pd(&(m_matrix[2][0]));
+ __m128d matrixBlockG = _mm_load_pd(&(m_matrix[3][0]));
+
+ // First row.
+ __m128d otherMatrixFirstParam = _mm_set1_pd(mat.m_matrix[0][0]);
+ __m128d otherMatrixSecondParam = _mm_set1_pd(mat.m_matrix[0][1]);
+ __m128d otherMatrixThirdParam = _mm_set1_pd(mat.m_matrix[0][2]);
+ __m128d otherMatrixFourthParam = _mm_set1_pd(mat.m_matrix[0][3]);
+
+ // output00 and output01.
+ __m128d accumulator = _mm_mul_pd(matrixBlockA, otherMatrixFirstParam);
+ __m128d temp1 = _mm_mul_pd(matrixBlockC, otherMatrixSecondParam);
+ __m128d temp2 = _mm_mul_pd(matrixBlockE, otherMatrixThirdParam);
+ __m128d temp3 = _mm_mul_pd(matrixBlockG, otherMatrixFourthParam);
+
+ __m128d matrixBlockB = _mm_load_pd(&(m_matrix[0][2]));
+ __m128d matrixBlockD = _mm_load_pd(&(m_matrix[1][2]));
+ __m128d matrixBlockF = _mm_load_pd(&(m_matrix[2][2]));
+ __m128d matrixBlockH = _mm_load_pd(&(m_matrix[3][2]));
+
+ accumulator = _mm_add_pd(accumulator, temp1);
+ accumulator = _mm_add_pd(accumulator, temp2);
+ accumulator = _mm_add_pd(accumulator, temp3);
+ _mm_store_pd(&m_matrix[0][0], accumulator);
+
+ // output02 and output03.
+ accumulator = _mm_mul_pd(matrixBlockB, otherMatrixFirstParam);
+ temp1 = _mm_mul_pd(matrixBlockD, otherMatrixSecondParam);
+ temp2 = _mm_mul_pd(matrixBlockF, otherMatrixThirdParam);
+ temp3 = _mm_mul_pd(matrixBlockH, otherMatrixFourthParam);
+
+ accumulator = _mm_add_pd(accumulator, temp1);
+ accumulator = _mm_add_pd(accumulator, temp2);
+ accumulator = _mm_add_pd(accumulator, temp3);
+ _mm_store_pd(&m_matrix[0][2], accumulator);
+
+ // Second row.
+ otherMatrixFirstParam = _mm_set1_pd(mat.m_matrix[1][0]);
+ otherMatrixSecondParam = _mm_set1_pd(mat.m_matrix[1][1]);
+ otherMatrixThirdParam = _mm_set1_pd(mat.m_matrix[1][2]);
+ otherMatrixFourthParam = _mm_set1_pd(mat.m_matrix[1][3]);
+
+ // output10 and output11.
+ accumulator = _mm_mul_pd(matrixBlockA, otherMatrixFirstParam);
+ temp1 = _mm_mul_pd(matrixBlockC, otherMatrixSecondParam);
+ temp2 = _mm_mul_pd(matrixBlockE, otherMatrixThirdParam);
+ temp3 = _mm_mul_pd(matrixBlockG, otherMatrixFourthParam);
+
+ accumulator = _mm_add_pd(accumulator, temp1);
+ accumulator = _mm_add_pd(accumulator, temp2);
+ accumulator = _mm_add_pd(accumulator, temp3);
+ _mm_store_pd(&m_matrix[1][0], accumulator);
+
+ // output12 and output13.
+ accumulator = _mm_mul_pd(matrixBlockB, otherMatrixFirstParam);
+ temp1 = _mm_mul_pd(matrixBlockD, otherMatrixSecondParam);
+ temp2 = _mm_mul_pd(matrixBlockF, otherMatrixThirdParam);
+ temp3 = _mm_mul_pd(matrixBlockH, otherMatrixFourthParam);
+
+ accumulator = _mm_add_pd(accumulator, temp1);
+ accumulator = _mm_add_pd(accumulator, temp2);
+ accumulator = _mm_add_pd(accumulator, temp3);
+ _mm_store_pd(&m_matrix[1][2], accumulator);
+
+ // Third row.
+ otherMatrixFirstParam = _mm_set1_pd(mat.m_matrix[2][0]);
+ otherMatrixSecondParam = _mm_set1_pd(mat.m_matrix[2][1]);
+ otherMatrixThirdParam = _mm_set1_pd(mat.m_matrix[2][2]);
+ otherMatrixFourthParam = _mm_set1_pd(mat.m_matrix[2][3]);
+
+ // output20 and output21.
+ accumulator = _mm_mul_pd(matrixBlockA, otherMatrixFirstParam);
+ temp1 = _mm_mul_pd(matrixBlockC, otherMatrixSecondParam);
+ temp2 = _mm_mul_pd(matrixBlockE, otherMatrixThirdParam);
+ temp3 = _mm_mul_pd(matrixBlockG, otherMatrixFourthParam);
+
+ accumulator = _mm_add_pd(accumulator, temp1);
+ accumulator = _mm_add_pd(accumulator, temp2);
+ accumulator = _mm_add_pd(accumulator, temp3);
+ _mm_store_pd(&m_matrix[2][0], accumulator);
+
+ // output22 and output23.
+ accumulator = _mm_mul_pd(matrixBlockB, otherMatrixFirstParam);
+ temp1 = _mm_mul_pd(matrixBlockD, otherMatrixSecondParam);
+ temp2 = _mm_mul_pd(matrixBlockF, otherMatrixThirdParam);
+ temp3 = _mm_mul_pd(matrixBlockH, otherMatrixFourthParam);
+
+ accumulator = _mm_add_pd(accumulator, temp1);
+ accumulator = _mm_add_pd(accumulator, temp2);
+ accumulator = _mm_add_pd(accumulator, temp3);
+ _mm_store_pd(&m_matrix[2][2], accumulator);
+
+ // Fourth row.
+ otherMatrixFirstParam = _mm_set1_pd(mat.m_matrix[3][0]);
+ otherMatrixSecondParam = _mm_set1_pd(mat.m_matrix[3][1]);
+ otherMatrixThirdParam = _mm_set1_pd(mat.m_matrix[3][2]);
+ otherMatrixFourthParam = _mm_set1_pd(mat.m_matrix[3][3]);
+
+ // output30 and output31.
+ accumulator = _mm_mul_pd(matrixBlockA, otherMatrixFirstParam);
+ temp1 = _mm_mul_pd(matrixBlockC, otherMatrixSecondParam);
+ temp2 = _mm_mul_pd(matrixBlockE, otherMatrixThirdParam);
+ temp3 = _mm_mul_pd(matrixBlockG, otherMatrixFourthParam);
+
+ accumulator = _mm_add_pd(accumulator, temp1);
+ accumulator = _mm_add_pd(accumulator, temp2);
+ accumulator = _mm_add_pd(accumulator, temp3);
+ _mm_store_pd(&m_matrix[3][0], accumulator);
+
+ // output32 and output33.
+ accumulator = _mm_mul_pd(matrixBlockB, otherMatrixFirstParam);
+ temp1 = _mm_mul_pd(matrixBlockD, otherMatrixSecondParam);
+ temp2 = _mm_mul_pd(matrixBlockF, otherMatrixThirdParam);
+ temp3 = _mm_mul_pd(matrixBlockH, otherMatrixFourthParam);
+
+ accumulator = _mm_add_pd(accumulator, temp1);
+ accumulator = _mm_add_pd(accumulator, temp2);
+ accumulator = _mm_add_pd(accumulator, temp3);
+ _mm_store_pd(&m_matrix[3][2], accumulator);
#else
Matrix4 tmp;
@@ -1299,13 +1424,13 @@ void TransformationMatrix::recompose(const DecomposedType& decomp)
makeIdentity();
// first apply perspective
- m_matrix[0][3] = (float) decomp.perspectiveX;
- m_matrix[1][3] = (float) decomp.perspectiveY;
- m_matrix[2][3] = (float) decomp.perspectiveZ;
- m_matrix[3][3] = (float) decomp.perspectiveW;
+ m_matrix[0][3] = decomp.perspectiveX;
+ m_matrix[1][3] = decomp.perspectiveY;
+ m_matrix[2][3] = decomp.perspectiveZ;
+ m_matrix[3][3] = decomp.perspectiveW;
// now translate
- translate3d((float) decomp.translateX, (float) decomp.translateY, (float) decomp.translateZ);
+ translate3d(decomp.translateX, decomp.translateY, decomp.translateZ);
// apply rotation
double xx = decomp.quaternionX * decomp.quaternionX;
@@ -1329,24 +1454,24 @@ void TransformationMatrix::recompose(const DecomposedType& decomp)
// now apply skew
if (decomp.skewYZ) {
TransformationMatrix tmp;
- tmp.setM32((float) decomp.skewYZ);
+ tmp.setM32(decomp.skewYZ);
multiply(tmp);
}
if (decomp.skewXZ) {
TransformationMatrix tmp;
- tmp.setM31((float) decomp.skewXZ);
+ tmp.setM31(decomp.skewXZ);
multiply(tmp);
}
if (decomp.skewXY) {
TransformationMatrix tmp;
- tmp.setM21((float) decomp.skewXY);
+ tmp.setM21(decomp.skewXY);
multiply(tmp);
}
// finally, apply scale
- scale3d((float) decomp.scaleX, (float) decomp.scaleY, (float) decomp.scaleZ);
+ scale3d(decomp.scaleX, decomp.scaleY, decomp.scaleZ);
}
bool TransformationMatrix::isIntegerTranslation() const
diff --git a/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h b/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h
index 181e0330d..0f04b676e 100644
--- a/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h
+++ b/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h
@@ -35,25 +35,16 @@
#if USE(CA)
typedef struct CATransform3D CATransform3D;
#endif
-#if USE(CLUTTER)
-typedef struct _CoglMatrix CoglMatrix;
-#endif
#if USE(CG)
typedef struct CGAffineTransform CGAffineTransform;
#elif USE(CAIRO)
#include <cairo.h>
-#elif PLATFORM(OPENVG)
-#include "VGUtils.h"
#elif PLATFORM(QT)
#include <QMatrix4x4>
#include <QTransform>
-#elif USE(SKIA)
-#include <SkMatrix.h>
-#elif PLATFORM(WX) && USE(WXGC)
-#include <wx/graphics.h>
#endif
-#if PLATFORM(WIN) || (PLATFORM(GTK) && OS(WINDOWS)) || (PLATFORM(QT) && OS(WINDOWS)) || (PLATFORM(WX) && OS(WINDOWS))
+#if PLATFORM(WIN) || (PLATFORM(GTK) && OS(WINDOWS)) || (PLATFORM(QT) && OS(WINDOWS))
#if COMPILER(MINGW) && !COMPILER(MINGW64)
typedef struct _XFORM XFORM;
#else
@@ -69,11 +60,20 @@ class LayoutRect;
class FloatRect;
class FloatQuad;
+#if CPU(X86_64)
+#define TRANSFORMATION_MATRIX_USE_X86_64_SSE2
+#endif
+
class TransformationMatrix {
WTF_MAKE_FAST_ALLOCATED;
public:
-#if CPU(APPLE_ARMV7S)
+
+#if CPU(APPLE_ARMV7S) || defined(TRANSFORMATION_MATRIX_USE_X86_64_SSE2)
+#if COMPILER(MSVC)
+ __declspec(align(16)) typedef double Matrix4[4][4];
+#else
typedef double Matrix4[4][4] __attribute__((aligned (16)));
+#endif
#else
typedef double Matrix4[4][4];
#endif
@@ -226,7 +226,7 @@ public:
double f() const { return m_matrix[3][1]; }
void setF(double f) { m_matrix[3][1] = f; }
- // this = this * mat
+ // this = mat * this.
TransformationMatrix& multiply(const TransformationMatrix&);
TransformationMatrix& scale(double);
@@ -331,26 +331,17 @@ public:
TransformationMatrix(const CATransform3D&);
operator CATransform3D() const;
#endif
-#if USE(CLUTTER)
- operator CoglMatrix() const;
-#endif
#if USE(CG)
TransformationMatrix(const CGAffineTransform&);
operator CGAffineTransform() const;
#elif USE(CAIRO)
operator cairo_matrix_t() const;
-#elif PLATFORM(OPENVG)
- operator VGMatrix() const;
#elif PLATFORM(QT)
operator QTransform() const;
operator QMatrix4x4() const;
-#elif USE(SKIA)
- operator SkMatrix() const;
-#elif PLATFORM(WX) && USE(WXGC)
- operator wxGraphicsMatrix() const;
#endif
-#if PLATFORM(WIN) || (PLATFORM(GTK) && OS(WINDOWS)) || (PLATFORM(QT) && OS(WINDOWS)) || (PLATFORM(WX) && OS(WINDOWS))
+#if PLATFORM(WIN) || (PLATFORM(GTK) && OS(WINDOWS)) || (PLATFORM(QT) && OS(WINDOWS))
operator XFORM() const;
#endif
diff --git a/Source/WebCore/platform/graphics/transforms/TranslateTransformOperation.cpp b/Source/WebCore/platform/graphics/transforms/TranslateTransformOperation.cpp
index 81c30ae85..f140c5081 100644
--- a/Source/WebCore/platform/graphics/transforms/TranslateTransformOperation.cpp
+++ b/Source/WebCore/platform/graphics/transforms/TranslateTransformOperation.cpp
@@ -29,16 +29,15 @@ PassRefPtr<TransformOperation> TranslateTransformOperation::blend(const Transfor
{
if (from && !from->isSameType(*this))
return this;
-
+
+ Length zeroLength(0, Fixed);
if (blendToIdentity)
- return TranslateTransformOperation::create(Length(m_x.type()).blend(m_x, progress),
- Length(m_y.type()).blend(m_y, progress),
- Length(m_z.type()).blend(m_z, progress), m_type);
+ return TranslateTransformOperation::create(zeroLength.blend(m_x, progress), zeroLength.blend(m_y, progress), zeroLength.blend(m_z, progress), m_type);
const TranslateTransformOperation* fromOp = static_cast<const TranslateTransformOperation*>(from);
- Length fromX = fromOp ? fromOp->m_x : Length(m_x.type());
- Length fromY = fromOp ? fromOp->m_y : Length(m_y.type());
- Length fromZ = fromOp ? fromOp->m_z : Length(m_z.type());
+ Length fromX = fromOp ? fromOp->m_x : zeroLength;
+ Length fromY = fromOp ? fromOp->m_y : zeroLength;
+ Length fromZ = fromOp ? fromOp->m_z : zeroLength;
return TranslateTransformOperation::create(m_x.blend(fromX, progress), m_y.blend(fromY, progress), m_z.blend(fromZ, progress), m_type);
}
diff --git a/Source/WebCore/platform/graphics/win/DIBPixelData.cpp b/Source/WebCore/platform/graphics/win/DIBPixelData.cpp
index 5d1928004..e9a0f9b15 100644
--- a/Source/WebCore/platform/graphics/win/DIBPixelData.cpp
+++ b/Source/WebCore/platform/graphics/win/DIBPixelData.cpp
@@ -90,11 +90,13 @@ void DIBPixelData::setRGBABitmapAlpha(HDC hdc, const IntRect& dstRect, unsigned
DIBPixelData pixelData(bitmap);
ASSERT(pixelData.bitsPerPixel() == 32);
+ IntRect drawRect(dstRect);
+#if !OS(WINCE)
XFORM trans;
GetWorldTransform(hdc, &trans);
IntSize transformedPosition(trans.eDx, trans.eDy);
- IntRect drawRect(dstRect);
drawRect.move(transformedPosition);
+#endif
int pixelDataWidth = pixelData.size().width();
int pixelDataHeight = pixelData.size().height();
diff --git a/Source/WebCore/platform/graphics/win/FontCacheWin.cpp b/Source/WebCore/platform/graphics/win/FontCacheWin.cpp
index ee55e1d23..8f9306dc4 100644
--- a/Source/WebCore/platform/graphics/win/FontCacheWin.cpp
+++ b/Source/WebCore/platform/graphics/win/FontCacheWin.cpp
@@ -100,9 +100,9 @@ static const Vector<String>* getLinkedFonts(String& family)
return result;
DWORD linkedFontsBufferSize = 0;
- RegQueryValueEx(fontLinkKey, family.charactersWithNullTermination(), 0, NULL, NULL, &linkedFontsBufferSize);
+ RegQueryValueEx(fontLinkKey, family.charactersWithNullTermination().data(), 0, NULL, NULL, &linkedFontsBufferSize);
WCHAR* linkedFonts = reinterpret_cast<WCHAR*>(malloc(linkedFontsBufferSize));
- if (SUCCEEDED(RegQueryValueEx(fontLinkKey, family.charactersWithNullTermination(), 0, NULL, reinterpret_cast<BYTE*>(linkedFonts), &linkedFontsBufferSize))) {
+ if (SUCCEEDED(RegQueryValueEx(fontLinkKey, family.charactersWithNullTermination().data(), 0, NULL, reinterpret_cast<BYTE*>(linkedFonts), &linkedFontsBufferSize))) {
unsigned i = 0;
unsigned length = linkedFontsBufferSize / sizeof(*linkedFonts);
while (i < length) {
@@ -186,12 +186,12 @@ static HFONT createMLangFont(IMLangFontLinkType* langFontLink, HDC hdc, DWORD co
return hfont;
}
-PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
+PassRefPtr<SimpleFontData> FontCache::systemFallbackForCharacters(const FontDescription& description, const SimpleFontData* originalFontData, bool, const UChar* characters, int length)
{
UChar character = characters[0];
RefPtr<SimpleFontData> fontData;
HWndDC hdc(0);
- HFONT primaryFont = font.primaryFont()->fontDataForCharacter(character)->platformData().hfont();
+ HFONT primaryFont = originalFontData->platformData().hfont();
HGDIOBJ oldFont = SelectObject(hdc, primaryFont);
HFONT hfont = 0;
@@ -284,7 +284,7 @@ PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font,
if (hfont) {
if (!familyName.isEmpty()) {
- FontPlatformData* result = getCachedFontPlatformData(font.fontDescription(), familyName);
+ FontPlatformData* result = getCachedFontPlatformData(description, familyName);
if (result)
fontData = getCachedFontData(result, DoNotRetain);
}
@@ -296,11 +296,6 @@ PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font,
return fontData.release();
}
-PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font& font)
-{
- return 0;
-}
-
PassRefPtr<SimpleFontData> FontCache::fontDataFromDescriptionAndLogFont(const FontDescription& fontDescription, ShouldRetain shouldRetain, const LOGFONT& font, AtomicString& outFontFamilyName)
{
AtomicString familyName = String(font.lfFaceName, wcsnlen(font.lfFaceName, LF_FACESIZE));
@@ -545,7 +540,7 @@ void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigne
copyToVector(procData.m_traitsMasks, traitsMasks);
}
-FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
+PassOwnPtr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
{
bool isLucidaGrande = false;
static AtomicString lucidaStr("Lucida Grande");
@@ -563,7 +558,7 @@ FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD
fontDescription.computedPixelSize() * (useGDI ? 1 : 32), useGDI);
if (!hfont)
- return 0;
+ return nullptr;
if (isLucidaGrande)
useGDI = false; // Never use GDI for Lucida Grande.
@@ -588,10 +583,10 @@ FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD
// font.
delete result;
DeleteObject(hfont);
- return 0;
+ return nullptr;
}
- return result;
+ return adoptPtr(result);
}
}
diff --git a/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp b/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp
index b9d90fef9..78309bcaa 100644
--- a/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp
+++ b/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp
@@ -24,51 +24,28 @@
#include "FontPlatformData.h"
#include "OpenTypeUtilities.h"
#include "SharedBuffer.h"
-#include "SoftLinking.h"
#include "WOFFFileFormat.h"
#include <ApplicationServices/ApplicationServices.h>
#include <WebKitSystemInterface/WebKitSystemInterface.h>
#include <wtf/RetainPtr.h>
#include <wtf/text/Base64.h>
-// From t2embapi.h, which is missing from the Microsoft Platform SDK.
-typedef unsigned long(WINAPIV *READEMBEDPROC) (void*, void*, unsigned long);
-struct TTLOADINFO;
-#define TTLOAD_PRIVATE 0x00000001
-#define LICENSE_PREVIEWPRINT 0x0004
-#define E_NONE 0x0000L
-
namespace WebCore {
using namespace std;
-SOFT_LINK_LIBRARY(T2embed);
-SOFT_LINK(T2embed, TTLoadEmbeddedFont, LONG, __stdcall, (HANDLE* phFontReference, ULONG ulFlags, ULONG* pulPrivStatus, ULONG ulPrivs, ULONG* pulStatus, READEMBEDPROC lpfnReadFromStream, LPVOID lpvReadStream, LPWSTR szWinFamilyName, LPSTR szMacFamilyName, TTLOADINFO* pTTLoadInfo), (phFontReference, ulFlags,pulPrivStatus, ulPrivs, pulStatus, lpfnReadFromStream, lpvReadStream, szWinFamilyName, szMacFamilyName, pTTLoadInfo));
-SOFT_LINK(T2embed, TTGetNewFontName, LONG, __stdcall, (HANDLE* phFontReference, LPWSTR szWinFamilyName, long cchMaxWinName, LPSTR szMacFamilyName, long cchMaxMacName), (phFontReference, szWinFamilyName, cchMaxWinName, szMacFamilyName, cchMaxMacName));
-SOFT_LINK(T2embed, TTDeleteEmbeddedFont, LONG, __stdcall, (HANDLE hFontReference, ULONG ulFlags, ULONG* pulStatus), (hFontReference, ulFlags, pulStatus));
-
FontCustomPlatformData::~FontCustomPlatformData()
{
- if (m_fontReference) {
- if (m_name.isNull()) {
- ASSERT(T2embedLibrary());
- ULONG status;
- TTDeleteEmbeddedFont(m_fontReference, 0, &status);
- } else
+ if (m_fontReference)
RemoveFontMemResourceEx(m_fontReference);
- }
}
-FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation, TextOrientation, FontWidthVariant, FontRenderingMode renderingMode)
+FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation, FontWidthVariant, FontRenderingMode renderingMode)
{
ASSERT(m_fontReference);
- ASSERT(T2embedLibrary());
LOGFONT& logFont = *static_cast<LOGFONT*>(malloc(sizeof(LOGFONT)));
- if (m_name.isNull())
- TTGetNewFontName(&m_fontReference, logFont.lfFaceName, LF_FACESIZE, 0, 0);
- else
- memcpy(logFont.lfFaceName, m_name.charactersWithNullTermination(), sizeof(logFont.lfFaceName[0]) * min(static_cast<size_t>(LF_FACESIZE), 1 + m_name.length()));
+ memcpy(logFont.lfFaceName, m_name.charactersWithNullTermination().data(), sizeof(logFont.lfFaceName[0]) * min(static_cast<size_t>(LF_FACESIZE), 1 + m_name.length()));
logFont.lfHeight = -size;
if (renderingMode == NormalRenderingMode)
@@ -87,69 +64,10 @@ FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, b
HFONT hfont = CreateFontIndirect(&logFont);
- RetainPtr<CGFontRef> cgFont(AdoptCF, CGFontCreateWithPlatformFont(&logFont));
+ RetainPtr<CGFontRef> cgFont = adoptCF(CGFontCreateWithPlatformFont(&logFont));
return FontPlatformData(hfont, cgFont.get(), size, bold, italic, renderingMode == AlternateRenderingMode);
}
-// Streams the concatenation of a header and font data.
-class EOTStream {
-public:
- EOTStream(const EOTHeader& eotHeader, const SharedBuffer* fontData, size_t overlayDst, size_t overlaySrc, size_t overlayLength)
- : m_eotHeader(eotHeader)
- , m_fontData(fontData)
- , m_overlayDst(overlayDst)
- , m_overlaySrc(overlaySrc)
- , m_overlayLength(overlayLength)
- , m_offset(0)
- , m_inHeader(true)
- {
- }
-
- size_t read(void* buffer, size_t count);
-
-private:
- const EOTHeader& m_eotHeader;
- const SharedBuffer* m_fontData;
- size_t m_overlayDst;
- size_t m_overlaySrc;
- size_t m_overlayLength;
- size_t m_offset;
- bool m_inHeader;
-};
-
-size_t EOTStream::read(void* buffer, size_t count)
-{
- size_t bytesToRead = count;
- if (m_inHeader) {
- size_t bytesFromHeader = min(m_eotHeader.size() - m_offset, count);
- memcpy(buffer, m_eotHeader.data() + m_offset, bytesFromHeader);
- m_offset += bytesFromHeader;
- bytesToRead -= bytesFromHeader;
- if (m_offset == m_eotHeader.size()) {
- m_inHeader = false;
- m_offset = 0;
- }
- }
- if (bytesToRead && !m_inHeader) {
- size_t bytesFromData = min(m_fontData->size() - m_offset, bytesToRead);
- memcpy(buffer, m_fontData->data() + m_offset, bytesFromData);
- if (m_offset < m_overlayDst + m_overlayLength && m_offset + bytesFromData >= m_overlayDst) {
- size_t dstOffset = max<int>(m_overlayDst - m_offset, 0);
- size_t srcOffset = max<int>(0, m_offset - m_overlayDst);
- size_t bytesToCopy = min(bytesFromData - dstOffset, m_overlayLength - srcOffset);
- memcpy(reinterpret_cast<char*>(buffer) + dstOffset, m_fontData->data() + m_overlaySrc + srcOffset, bytesToCopy);
- }
- m_offset += bytesFromData;
- bytesToRead -= bytesFromData;
- }
- return count - bytesToRead;
-}
-
-static unsigned long WINAPIV readEmbedProc(void* stream, void* buffer, unsigned long length)
-{
- return static_cast<EOTStream*>(stream)->read(buffer, length);
-}
-
// Creates a unique and unpredictable font name, in order to avoid collisions and to
// not allow access from CSS.
static String createUniqueFontName()
@@ -165,7 +83,6 @@ static String createUniqueFontName()
FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
{
ASSERT_ARG(buffer, buffer);
- ASSERT(T2embedLibrary());
RefPtr<SharedBuffer> sfntBuffer;
if (isWOFF(buffer)) {
@@ -177,36 +94,11 @@ FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
buffer = sfntBuffer.get();
}
- // Introduce the font to GDI. AddFontMemResourceEx cannot be used, because it will pollute the process's
- // font namespace (Windows has no API for creating an HFONT from data without exposing the font to the
- // entire process first). TTLoadEmbeddedFont lets us override the font family name, so using a unique name
- // we avoid namespace collisions.
-
String fontName = createUniqueFontName();
-
- // TTLoadEmbeddedFont works only with Embedded OpenType (.eot) data, so we need to create an EOT header
- // and prepend it to the font data.
- EOTHeader eotHeader;
- size_t overlayDst;
- size_t overlaySrc;
- size_t overlayLength;
- if (!getEOTHeader(buffer, eotHeader, overlayDst, overlaySrc, overlayLength))
- return 0;
-
HANDLE fontReference;
- ULONG privStatus;
- ULONG status;
- EOTStream eotStream(eotHeader, buffer, overlayDst, overlaySrc, overlayLength);
-
- LONG loadEmbeddedFontResult = TTLoadEmbeddedFont(&fontReference, TTLOAD_PRIVATE, &privStatus, LICENSE_PREVIEWPRINT, &status, readEmbedProc, &eotStream, const_cast<LPWSTR>(fontName.charactersWithNullTermination()), 0, 0);
- if (loadEmbeddedFontResult == E_NONE)
- fontName = String();
- else {
- fontReference = renameAndActivateFont(buffer, fontName);
- if (!fontReference)
- return 0;
- }
-
+ fontReference = renameAndActivateFont(buffer, fontName);
+ if (!fontReference)
+ return 0;
return new FontCustomPlatformData(fontReference, fontName);
}
diff --git a/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h
index d3e5c0761..188951bc8 100644
--- a/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h
+++ b/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h
@@ -24,7 +24,6 @@
#include "FontOrientation.h"
#include "FontRenderingMode.h"
#include "FontWidthVariant.h"
-#include "TextOrientation.h"
#include <windows.h>
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
@@ -48,7 +47,7 @@ public:
~FontCustomPlatformData();
- FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation = Horizontal, TextOrientation = TextOrientationVerticalRight,
+ FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation = Horizontal,
FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode);
static bool supportsFormat(const String&);
diff --git a/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp b/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp
index 6f9bbf0ff..cb09b33c6 100644
--- a/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp
+++ b/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp
@@ -19,46 +19,77 @@
*/
#include "config.h"
-#include "FontCustomPlatformDataCairo.h"
+#include "FontCustomPlatformData.h"
+#include "OpenTypeUtilities.h"
#include "SharedBuffer.h"
#include "FontPlatformData.h"
#include <cairo-win32.h>
#include <wtf/RetainPtr.h>
-
+#include <wtf/text/Base64.h>
namespace WebCore {
FontCustomPlatformData::~FontCustomPlatformData()
{
- cairo_font_face_destroy(m_fontFace);
+ if (m_fontReference)
+ RemoveFontMemResourceEx(m_fontReference);
}
-FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation, TextOrientation, FontWidthVariant)
+FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation, FontWidthVariant, FontRenderingMode renderingMode)
{
- return FontPlatformData(m_fontFace, size, bold, italic);
+ LOGFONT logFont;
+ memset(&logFont, 0, sizeof(LOGFONT));
+ wcsncpy(logFont.lfFaceName, m_name.charactersWithNullTermination().data(), LF_FACESIZE - 1);
+
+ logFont.lfHeight = -size;
+ if (renderingMode == NormalRenderingMode)
+ logFont.lfHeight *= 32;
+ logFont.lfWidth = 0;
+ logFont.lfEscapement = 0;
+ logFont.lfOrientation = 0;
+ logFont.lfUnderline = false;
+ logFont.lfStrikeOut = false;
+ logFont.lfCharSet = DEFAULT_CHARSET;
+ logFont.lfOutPrecision = OUT_TT_ONLY_PRECIS;
+ logFont.lfQuality = CLEARTYPE_QUALITY;
+ logFont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
+ logFont.lfItalic = italic;
+ logFont.lfWeight = bold ? 700 : 400;
+
+ HFONT hfont = CreateFontIndirect(&logFont);
+
+ cairo_font_face_t* fontFace = cairo_win32_font_face_create_for_hfont(hfont);
+
+ FontPlatformData fontPlatformData(hfont, fontFace, size, bold, italic);
+
+ cairo_font_face_destroy(fontFace);
+
+ return fontPlatformData;
}
-static void releaseData(void* data)
+static String createUniqueFontName()
{
- static_cast<SharedBuffer*>(data)->deref();
+ GUID fontUuid;
+ CoCreateGuid(&fontUuid);
+
+ String fontName = base64Encode(reinterpret_cast<char*>(&fontUuid), sizeof(fontUuid));
+ ASSERT(fontName.length() < LF_FACESIZE);
+ return fontName;
}
FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
{
ASSERT_ARG(buffer, buffer);
- buffer->ref();
- HFONT font = reinterpret_cast<HFONT>(buffer);
- cairo_font_face_t* fontFace = cairo_win32_font_face_create_for_hfont(font);
- if (!fontFace)
- return 0;
+ String fontName = createUniqueFontName();
+ HANDLE fontReference = renameAndActivateFont(buffer, fontName);
- static cairo_user_data_key_t bufferKey;
- cairo_font_face_set_user_data(fontFace, &bufferKey, buffer, releaseData);
+ if (!fontReference)
+ return 0;
- return new FontCustomPlatformData(fontFace);
+ return new FontCustomPlatformData(fontReference, fontName);
}
bool FontCustomPlatformData::supportsFormat(const String& format)
diff --git a/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h b/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h
deleted file mode 100644
index bd90f189f..000000000
--- a/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Computer, Inc.
- * Copyright (C) 2010 Brent Fulgham <bfulgham@webkit.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef FontCustomPlatformDataCairo_h
-#define FontCustomPlatformDataCairo_h
-
-#include "FontDescription.h"
-#include <wtf/Forward.h>
-#include <wtf/Noncopyable.h>
-
-#include <cairo.h>
-
-namespace WebCore {
-
-class FontPlatformData;
-class SharedBuffer;
-
-struct FontCustomPlatformData {
- WTF_MAKE_NONCOPYABLE(FontCustomPlatformData);
-public:
- FontCustomPlatformData(cairo_font_face_t* fontFace)
- : m_fontFace(fontFace)
- {
- }
- ~FontCustomPlatformData();
-
- FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation = Horizontal, TextOrientation = TextOrientationVerticalRight, FontWidthVariant = RegularWidth);
-
- static bool supportsFormat(const String&);
-
- cairo_font_face_t* m_fontFace;
-};
-
-FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer*);
-
-}
-
-#endif
diff --git a/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp b/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp
index a424a86b6..4d71f3721 100644
--- a/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp
+++ b/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp
@@ -88,14 +88,14 @@ static CFStringRef getPostScriptName(CFStringRef faceName, HDC dc)
// Pass Big Endian as the encoding.
if (bufferSize < stringsOffset + nameOffset + length)
return NULL;
- result.adoptCF(CFStringCreateWithBytes(NULL, strings + nameOffset, length, kCFStringEncodingUTF16BE, false));
+ result = adoptCF(CFStringCreateWithBytes(NULL, strings + nameOffset, length, kCFStringEncodingUTF16BE, false));
break;
} else if (platformID == 1 && encodingID == 0 && languageID == 0 && nameID == 6) {
// This is a Mac PostScript name and is therefore ASCII.
// See http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6name.html
if (bufferSize < stringsOffset + nameOffset + length)
return NULL;
- result.adoptCF(CFStringCreateWithBytes(NULL, strings + nameOffset, length, kCFStringEncodingASCII, false));
+ result = adoptCF(CFStringCreateWithBytes(NULL, strings + nameOffset, length, kCFStringEncodingASCII, false));
break;
}
@@ -111,14 +111,13 @@ void FontPlatformData::platformDataInit(HFONT font, float size, HDC hdc, WCHAR*
{
LOGFONT logfont;
GetObject(font, sizeof(logfont), &logfont);
- m_cgFont.adoptCF(CGFontCreateWithPlatformFont(&logfont));
+ m_cgFont = adoptCF(CGFontCreateWithPlatformFont(&logfont));
}
FontPlatformData::FontPlatformData(HFONT hfont, CGFontRef font, float size, bool bold, bool oblique, bool useGDI)
: m_syntheticBold(bold)
, m_syntheticOblique(oblique)
, m_orientation(Horizontal)
- , m_textOrientation(TextOrientationVerticalRight)
, m_size(size)
, m_widthVariant(RegularWidth)
, m_font(RefCountedGDIHandle<HFONT>::create(hfont))
diff --git a/Source/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp b/Source/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp
index cc49b986f..9cddb3886 100644
--- a/Source/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp
+++ b/Source/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp
@@ -56,11 +56,10 @@ void FontPlatformData::platformDataInit(HFONT font, float size, HDC hdc, WCHAR*
cairo_font_face_destroy(fontFace);
}
-FontPlatformData::FontPlatformData(cairo_font_face_t* fontFace, float size, bool bold, bool oblique)
- : m_font(0)
+FontPlatformData::FontPlatformData(HFONT font, cairo_font_face_t* fontFace, float size, bool bold, bool oblique)
+ : m_font(RefCountedGDIHandle<HFONT>::create(font))
, m_size(size)
, m_orientation(Horizontal)
- , m_textOrientation(TextOrientationVerticalRight)
, m_widthVariant(RegularWidth)
, m_scaledFont(0)
, m_isColorBitmapFont(false)
diff --git a/Source/WebCore/platform/graphics/win/FontPlatformDataWin.cpp b/Source/WebCore/platform/graphics/win/FontPlatformDataWin.cpp
index 44a4ec4be..56c1688bc 100644
--- a/Source/WebCore/platform/graphics/win/FontPlatformDataWin.cpp
+++ b/Source/WebCore/platform/graphics/win/FontPlatformDataWin.cpp
@@ -41,7 +41,6 @@ FontPlatformData::FontPlatformData(HFONT font, float size, bool bold, bool obliq
: m_font(RefCountedGDIHandle<HFONT>::create(font))
, m_size(size)
, m_orientation(Horizontal)
- , m_textOrientation(TextOrientationVerticalRight)
, m_widthVariant(RegularWidth)
#if USE(CG)
, m_cgFont(0)
diff --git a/Source/WebCore/platform/graphics/win/FontWin.cpp b/Source/WebCore/platform/graphics/win/FontWin.cpp
index b01862f40..92093d091 100644
--- a/Source/WebCore/platform/graphics/win/FontWin.cpp
+++ b/Source/WebCore/platform/graphics/win/FontWin.cpp
@@ -26,7 +26,7 @@
#include "config.h"
#include "Font.h"
-#include "FontFallbackList.h"
+#include "FontGlyphs.h"
#include "GlyphBuffer.h"
#include "GraphicsContext.h"
#include "IntRect.h"
diff --git a/Source/WebCore/platform/graphics/win/FullScreenController.cpp b/Source/WebCore/platform/graphics/win/FullScreenController.cpp
index def538eb9..a3adeae95 100644
--- a/Source/WebCore/platform/graphics/win/FullScreenController.cpp
+++ b/Source/WebCore/platform/graphics/win/FullScreenController.cpp
@@ -124,6 +124,8 @@ void FullScreenController::enterFullScreen()
m_private->m_isFullScreen = true;
m_private->m_isEnteringFullScreen = true;
+ m_private->m_client->fullScreenClientSaveScrollPosition();
+
m_private->m_originalHost = m_private->m_client->fullScreenClientParentWindow();
RECT originalFrame = {0, 0, 0, 0};
::GetClientRect(m_private->m_client->fullScreenClientWindow(), &originalFrame);
@@ -178,6 +180,7 @@ void FullScreenController::exitFullScreen()
::SetWindowPos(m_private->m_client->fullScreenClientWindow(), 0, m_private->m_originalFrame.x(), m_private->m_originalFrame.y(), m_private->m_originalFrame.width(), m_private->m_originalFrame.height(), SWP_NOACTIVATE | SWP_NOZORDER);
+ m_private->m_client->fullScreenClientRestoreScrollPosition();
m_private->m_client->fullScreenClientDidExitFullScreen();
m_private->m_client->fullScreenClientForceRepaint();
}
diff --git a/Source/WebCore/platform/graphics/win/FullScreenControllerClient.h b/Source/WebCore/platform/graphics/win/FullScreenControllerClient.h
index 3acf9cf49..f591dbd6a 100644
--- a/Source/WebCore/platform/graphics/win/FullScreenControllerClient.h
+++ b/Source/WebCore/platform/graphics/win/FullScreenControllerClient.h
@@ -40,6 +40,8 @@ public:
virtual void fullScreenClientWillExitFullScreen() = 0;
virtual void fullScreenClientDidExitFullScreen() = 0;
virtual void fullScreenClientForceRepaint() = 0;
+ virtual void fullScreenClientSaveScrollPosition() = 0;
+ virtual void fullScreenClientRestoreScrollPosition() = 0;
protected:
virtual ~FullScreenControllerClient() { }
};
diff --git a/Source/WebCore/platform/graphics/win/GL/glext.h b/Source/WebCore/platform/graphics/win/GL/glext.h
new file mode 100644
index 000000000..36919370e
--- /dev/null
+++ b/Source/WebCore/platform/graphics/win/GL/glext.h
@@ -0,0 +1,13146 @@
+#ifndef __glext_h_
+#define __glext_h_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+** THIS FILE IS OBSOLETE. Please migrate away from using the
+** ".spec" files and the headers generated from them to the
+** XML Registry and headers generated from that. See
+** http://www.opengl.org/registry/api/README.txt
+** for more information.
+**
+**
+** Copyright (c) 2007-2013 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+/* Header file version number, required by OpenGL ABI for Linux */
+/* glext.h last updated $Date: 2013-06-13 02:52:31 -0700 (Thu, 13 Jun 2013) $ */
+/* Current version at http://www.opengl.org/registry/ */
+#define GL_GLEXT_VERSION 87
+/* Function declaration macros - to move into glplatform.h */
+
+#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
+#define WIN32_LEAN_AND_MEAN 1
+#include <windows.h>
+#endif
+
+#ifndef APIENTRY
+#define APIENTRY
+#endif
+#ifndef APIENTRYP
+#define APIENTRYP APIENTRY *
+#endif
+#ifndef GLAPI
+#define GLAPI extern
+#endif
+
+/*************************************************************/
+
+#ifndef GL_VERSION_1_2
+#define GL_UNSIGNED_BYTE_3_3_2 0x8032
+#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
+#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
+#define GL_UNSIGNED_INT_8_8_8_8 0x8035
+#define GL_UNSIGNED_INT_10_10_10_2 0x8036
+#define GL_TEXTURE_BINDING_3D 0x806A
+#define GL_PACK_SKIP_IMAGES 0x806B
+#define GL_PACK_IMAGE_HEIGHT 0x806C
+#define GL_UNPACK_SKIP_IMAGES 0x806D
+#define GL_UNPACK_IMAGE_HEIGHT 0x806E
+#define GL_TEXTURE_3D 0x806F
+#define GL_PROXY_TEXTURE_3D 0x8070
+#define GL_TEXTURE_DEPTH 0x8071
+#define GL_TEXTURE_WRAP_R 0x8072
+#define GL_MAX_3D_TEXTURE_SIZE 0x8073
+#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362
+#define GL_UNSIGNED_SHORT_5_6_5 0x8363
+#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364
+#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365
+#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366
+#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
+#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
+#define GL_BGR 0x80E0
+#define GL_BGRA 0x80E1
+#define GL_MAX_ELEMENTS_VERTICES 0x80E8
+#define GL_MAX_ELEMENTS_INDICES 0x80E9
+#define GL_CLAMP_TO_EDGE 0x812F
+#define GL_TEXTURE_MIN_LOD 0x813A
+#define GL_TEXTURE_MAX_LOD 0x813B
+#define GL_TEXTURE_BASE_LEVEL 0x813C
+#define GL_TEXTURE_MAX_LEVEL 0x813D
+#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12
+#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13
+#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22
+#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23
+#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
+#define GL_RESCALE_NORMAL 0x803A
+#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8
+#define GL_SINGLE_COLOR 0x81F9
+#define GL_SEPARATE_SPECULAR_COLOR 0x81FA
+#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
+#endif
+
+#ifndef GL_ARB_imaging
+#define GL_CONSTANT_COLOR 0x8001
+#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
+#define GL_CONSTANT_ALPHA 0x8003
+#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
+#define GL_BLEND_COLOR 0x8005
+#define GL_FUNC_ADD 0x8006
+#define GL_MIN 0x8007
+#define GL_MAX 0x8008
+#define GL_BLEND_EQUATION 0x8009
+#define GL_FUNC_SUBTRACT 0x800A
+#define GL_FUNC_REVERSE_SUBTRACT 0x800B
+#define GL_CONVOLUTION_1D 0x8010
+#define GL_CONVOLUTION_2D 0x8011
+#define GL_SEPARABLE_2D 0x8012
+#define GL_CONVOLUTION_BORDER_MODE 0x8013
+#define GL_CONVOLUTION_FILTER_SCALE 0x8014
+#define GL_CONVOLUTION_FILTER_BIAS 0x8015
+#define GL_REDUCE 0x8016
+#define GL_CONVOLUTION_FORMAT 0x8017
+#define GL_CONVOLUTION_WIDTH 0x8018
+#define GL_CONVOLUTION_HEIGHT 0x8019
+#define GL_MAX_CONVOLUTION_WIDTH 0x801A
+#define GL_MAX_CONVOLUTION_HEIGHT 0x801B
+#define GL_POST_CONVOLUTION_RED_SCALE 0x801C
+#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D
+#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E
+#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F
+#define GL_POST_CONVOLUTION_RED_BIAS 0x8020
+#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021
+#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022
+#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023
+#define GL_HISTOGRAM 0x8024
+#define GL_PROXY_HISTOGRAM 0x8025
+#define GL_HISTOGRAM_WIDTH 0x8026
+#define GL_HISTOGRAM_FORMAT 0x8027
+#define GL_HISTOGRAM_RED_SIZE 0x8028
+#define GL_HISTOGRAM_GREEN_SIZE 0x8029
+#define GL_HISTOGRAM_BLUE_SIZE 0x802A
+#define GL_HISTOGRAM_ALPHA_SIZE 0x802B
+#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C
+#define GL_HISTOGRAM_SINK 0x802D
+#define GL_MINMAX 0x802E
+#define GL_MINMAX_FORMAT 0x802F
+#define GL_MINMAX_SINK 0x8030
+#define GL_TABLE_TOO_LARGE 0x8031
+#define GL_COLOR_MATRIX 0x80B1
+#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2
+#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3
+#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4
+#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5
+#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6
+#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7
+#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8
+#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9
+#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA
+#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB
+#define GL_COLOR_TABLE 0x80D0
+#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1
+#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2
+#define GL_PROXY_COLOR_TABLE 0x80D3
+#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4
+#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5
+#define GL_COLOR_TABLE_SCALE 0x80D6
+#define GL_COLOR_TABLE_BIAS 0x80D7
+#define GL_COLOR_TABLE_FORMAT 0x80D8
+#define GL_COLOR_TABLE_WIDTH 0x80D9
+#define GL_COLOR_TABLE_RED_SIZE 0x80DA
+#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB
+#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC
+#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD
+#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE
+#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF
+#define GL_CONSTANT_BORDER 0x8151
+#define GL_REPLICATE_BORDER 0x8153
+#define GL_CONVOLUTION_BORDER_COLOR 0x8154
+#endif
+
+#ifndef GL_VERSION_1_3
+#define GL_TEXTURE0 0x84C0
+#define GL_TEXTURE1 0x84C1
+#define GL_TEXTURE2 0x84C2
+#define GL_TEXTURE3 0x84C3
+#define GL_TEXTURE4 0x84C4
+#define GL_TEXTURE5 0x84C5
+#define GL_TEXTURE6 0x84C6
+#define GL_TEXTURE7 0x84C7
+#define GL_TEXTURE8 0x84C8
+#define GL_TEXTURE9 0x84C9
+#define GL_TEXTURE10 0x84CA
+#define GL_TEXTURE11 0x84CB
+#define GL_TEXTURE12 0x84CC
+#define GL_TEXTURE13 0x84CD
+#define GL_TEXTURE14 0x84CE
+#define GL_TEXTURE15 0x84CF
+#define GL_TEXTURE16 0x84D0
+#define GL_TEXTURE17 0x84D1
+#define GL_TEXTURE18 0x84D2
+#define GL_TEXTURE19 0x84D3
+#define GL_TEXTURE20 0x84D4
+#define GL_TEXTURE21 0x84D5
+#define GL_TEXTURE22 0x84D6
+#define GL_TEXTURE23 0x84D7
+#define GL_TEXTURE24 0x84D8
+#define GL_TEXTURE25 0x84D9
+#define GL_TEXTURE26 0x84DA
+#define GL_TEXTURE27 0x84DB
+#define GL_TEXTURE28 0x84DC
+#define GL_TEXTURE29 0x84DD
+#define GL_TEXTURE30 0x84DE
+#define GL_TEXTURE31 0x84DF
+#define GL_ACTIVE_TEXTURE 0x84E0
+#define GL_MULTISAMPLE 0x809D
+#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
+#define GL_SAMPLE_ALPHA_TO_ONE 0x809F
+#define GL_SAMPLE_COVERAGE 0x80A0
+#define GL_SAMPLE_BUFFERS 0x80A8
+#define GL_SAMPLES 0x80A9
+#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
+#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
+#define GL_TEXTURE_CUBE_MAP 0x8513
+#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
+#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B
+#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
+#define GL_COMPRESSED_RGB 0x84ED
+#define GL_COMPRESSED_RGBA 0x84EE
+#define GL_TEXTURE_COMPRESSION_HINT 0x84EF
+#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0
+#define GL_TEXTURE_COMPRESSED 0x86A1
+#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
+#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
+#define GL_CLAMP_TO_BORDER 0x812D
+#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1
+#define GL_MAX_TEXTURE_UNITS 0x84E2
+#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3
+#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4
+#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5
+#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6
+#define GL_MULTISAMPLE_BIT 0x20000000
+#define GL_NORMAL_MAP 0x8511
+#define GL_REFLECTION_MAP 0x8512
+#define GL_COMPRESSED_ALPHA 0x84E9
+#define GL_COMPRESSED_LUMINANCE 0x84EA
+#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB
+#define GL_COMPRESSED_INTENSITY 0x84EC
+#define GL_COMBINE 0x8570
+#define GL_COMBINE_RGB 0x8571
+#define GL_COMBINE_ALPHA 0x8572
+#define GL_SOURCE0_RGB 0x8580
+#define GL_SOURCE1_RGB 0x8581
+#define GL_SOURCE2_RGB 0x8582
+#define GL_SOURCE0_ALPHA 0x8588
+#define GL_SOURCE1_ALPHA 0x8589
+#define GL_SOURCE2_ALPHA 0x858A
+#define GL_OPERAND0_RGB 0x8590
+#define GL_OPERAND1_RGB 0x8591
+#define GL_OPERAND2_RGB 0x8592
+#define GL_OPERAND0_ALPHA 0x8598
+#define GL_OPERAND1_ALPHA 0x8599
+#define GL_OPERAND2_ALPHA 0x859A
+#define GL_RGB_SCALE 0x8573
+#define GL_ADD_SIGNED 0x8574
+#define GL_INTERPOLATE 0x8575
+#define GL_SUBTRACT 0x84E7
+#define GL_CONSTANT 0x8576
+#define GL_PRIMARY_COLOR 0x8577
+#define GL_PREVIOUS 0x8578
+#define GL_DOT3_RGB 0x86AE
+#define GL_DOT3_RGBA 0x86AF
+#endif
+
+#ifndef GL_VERSION_1_4
+#define GL_BLEND_DST_RGB 0x80C8
+#define GL_BLEND_SRC_RGB 0x80C9
+#define GL_BLEND_DST_ALPHA 0x80CA
+#define GL_BLEND_SRC_ALPHA 0x80CB
+#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128
+#define GL_DEPTH_COMPONENT16 0x81A5
+#define GL_DEPTH_COMPONENT24 0x81A6
+#define GL_DEPTH_COMPONENT32 0x81A7
+#define GL_MIRRORED_REPEAT 0x8370
+#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD
+#define GL_TEXTURE_LOD_BIAS 0x8501
+#define GL_INCR_WRAP 0x8507
+#define GL_DECR_WRAP 0x8508
+#define GL_TEXTURE_DEPTH_SIZE 0x884A
+#define GL_TEXTURE_COMPARE_MODE 0x884C
+#define GL_TEXTURE_COMPARE_FUNC 0x884D
+#define GL_POINT_SIZE_MIN 0x8126
+#define GL_POINT_SIZE_MAX 0x8127
+#define GL_POINT_DISTANCE_ATTENUATION 0x8129
+#define GL_GENERATE_MIPMAP 0x8191
+#define GL_GENERATE_MIPMAP_HINT 0x8192
+#define GL_FOG_COORDINATE_SOURCE 0x8450
+#define GL_FOG_COORDINATE 0x8451
+#define GL_FRAGMENT_DEPTH 0x8452
+#define GL_CURRENT_FOG_COORDINATE 0x8453
+#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454
+#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455
+#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456
+#define GL_FOG_COORDINATE_ARRAY 0x8457
+#define GL_COLOR_SUM 0x8458
+#define GL_CURRENT_SECONDARY_COLOR 0x8459
+#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A
+#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B
+#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C
+#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D
+#define GL_SECONDARY_COLOR_ARRAY 0x845E
+#define GL_TEXTURE_FILTER_CONTROL 0x8500
+#define GL_DEPTH_TEXTURE_MODE 0x884B
+#define GL_COMPARE_R_TO_TEXTURE 0x884E
+#endif
+
+#ifndef GL_VERSION_1_5
+#define GL_BUFFER_SIZE 0x8764
+#define GL_BUFFER_USAGE 0x8765
+#define GL_QUERY_COUNTER_BITS 0x8864
+#define GL_CURRENT_QUERY 0x8865
+#define GL_QUERY_RESULT 0x8866
+#define GL_QUERY_RESULT_AVAILABLE 0x8867
+#define GL_ARRAY_BUFFER 0x8892
+#define GL_ELEMENT_ARRAY_BUFFER 0x8893
+#define GL_ARRAY_BUFFER_BINDING 0x8894
+#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
+#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
+#define GL_READ_ONLY 0x88B8
+#define GL_WRITE_ONLY 0x88B9
+#define GL_READ_WRITE 0x88BA
+#define GL_BUFFER_ACCESS 0x88BB
+#define GL_BUFFER_MAPPED 0x88BC
+#define GL_BUFFER_MAP_POINTER 0x88BD
+#define GL_STREAM_DRAW 0x88E0
+#define GL_STREAM_READ 0x88E1
+#define GL_STREAM_COPY 0x88E2
+#define GL_STATIC_DRAW 0x88E4
+#define GL_STATIC_READ 0x88E5
+#define GL_STATIC_COPY 0x88E6
+#define GL_DYNAMIC_DRAW 0x88E8
+#define GL_DYNAMIC_READ 0x88E9
+#define GL_DYNAMIC_COPY 0x88EA
+#define GL_SAMPLES_PASSED 0x8914
+#define GL_SRC1_ALPHA 0x8589
+#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896
+#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897
+#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898
+#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899
+#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A
+#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B
+#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C
+#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D
+#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E
+#define GL_FOG_COORD_SRC 0x8450
+#define GL_FOG_COORD 0x8451
+#define GL_CURRENT_FOG_COORD 0x8453
+#define GL_FOG_COORD_ARRAY_TYPE 0x8454
+#define GL_FOG_COORD_ARRAY_STRIDE 0x8455
+#define GL_FOG_COORD_ARRAY_POINTER 0x8456
+#define GL_FOG_COORD_ARRAY 0x8457
+#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D
+#define GL_SRC0_RGB 0x8580
+#define GL_SRC1_RGB 0x8581
+#define GL_SRC2_RGB 0x8582
+#define GL_SRC0_ALPHA 0x8588
+#define GL_SRC2_ALPHA 0x858A
+#endif
+
+#ifndef GL_VERSION_2_0
+#define GL_BLEND_EQUATION_RGB 0x8009
+#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
+#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
+#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
+#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
+#define GL_CURRENT_VERTEX_ATTRIB 0x8626
+#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
+#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
+#define GL_STENCIL_BACK_FUNC 0x8800
+#define GL_STENCIL_BACK_FAIL 0x8801
+#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
+#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
+#define GL_MAX_DRAW_BUFFERS 0x8824
+#define GL_DRAW_BUFFER0 0x8825
+#define GL_DRAW_BUFFER1 0x8826
+#define GL_DRAW_BUFFER2 0x8827
+#define GL_DRAW_BUFFER3 0x8828
+#define GL_DRAW_BUFFER4 0x8829
+#define GL_DRAW_BUFFER5 0x882A
+#define GL_DRAW_BUFFER6 0x882B
+#define GL_DRAW_BUFFER7 0x882C
+#define GL_DRAW_BUFFER8 0x882D
+#define GL_DRAW_BUFFER9 0x882E
+#define GL_DRAW_BUFFER10 0x882F
+#define GL_DRAW_BUFFER11 0x8830
+#define GL_DRAW_BUFFER12 0x8831
+#define GL_DRAW_BUFFER13 0x8832
+#define GL_DRAW_BUFFER14 0x8833
+#define GL_DRAW_BUFFER15 0x8834
+#define GL_BLEND_EQUATION_ALPHA 0x883D
+#define GL_MAX_VERTEX_ATTRIBS 0x8869
+#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
+#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
+#define GL_FRAGMENT_SHADER 0x8B30
+#define GL_VERTEX_SHADER 0x8B31
+#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49
+#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A
+#define GL_MAX_VARYING_FLOATS 0x8B4B
+#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
+#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
+#define GL_SHADER_TYPE 0x8B4F
+#define GL_FLOAT_VEC2 0x8B50
+#define GL_FLOAT_VEC3 0x8B51
+#define GL_FLOAT_VEC4 0x8B52
+#define GL_INT_VEC2 0x8B53
+#define GL_INT_VEC3 0x8B54
+#define GL_INT_VEC4 0x8B55
+#define GL_BOOL 0x8B56
+#define GL_BOOL_VEC2 0x8B57
+#define GL_BOOL_VEC3 0x8B58
+#define GL_BOOL_VEC4 0x8B59
+#define GL_FLOAT_MAT2 0x8B5A
+#define GL_FLOAT_MAT3 0x8B5B
+#define GL_FLOAT_MAT4 0x8B5C
+#define GL_SAMPLER_1D 0x8B5D
+#define GL_SAMPLER_2D 0x8B5E
+#define GL_SAMPLER_3D 0x8B5F
+#define GL_SAMPLER_CUBE 0x8B60
+#define GL_SAMPLER_1D_SHADOW 0x8B61
+#define GL_SAMPLER_2D_SHADOW 0x8B62
+#define GL_DELETE_STATUS 0x8B80
+#define GL_COMPILE_STATUS 0x8B81
+#define GL_LINK_STATUS 0x8B82
+#define GL_VALIDATE_STATUS 0x8B83
+#define GL_INFO_LOG_LENGTH 0x8B84
+#define GL_ATTACHED_SHADERS 0x8B85
+#define GL_ACTIVE_UNIFORMS 0x8B86
+#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
+#define GL_SHADER_SOURCE_LENGTH 0x8B88
+#define GL_ACTIVE_ATTRIBUTES 0x8B89
+#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
+#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B
+#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
+#define GL_CURRENT_PROGRAM 0x8B8D
+#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0
+#define GL_LOWER_LEFT 0x8CA1
+#define GL_UPPER_LEFT 0x8CA2
+#define GL_STENCIL_BACK_REF 0x8CA3
+#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
+#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
+#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643
+#define GL_POINT_SPRITE 0x8861
+#define GL_COORD_REPLACE 0x8862
+#define GL_MAX_TEXTURE_COORDS 0x8871
+#endif
+
+#ifndef GL_VERSION_2_1
+#define GL_PIXEL_PACK_BUFFER 0x88EB
+#define GL_PIXEL_UNPACK_BUFFER 0x88EC
+#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED
+#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF
+#define GL_FLOAT_MAT2x3 0x8B65
+#define GL_FLOAT_MAT2x4 0x8B66
+#define GL_FLOAT_MAT3x2 0x8B67
+#define GL_FLOAT_MAT3x4 0x8B68
+#define GL_FLOAT_MAT4x2 0x8B69
+#define GL_FLOAT_MAT4x3 0x8B6A
+#define GL_SRGB 0x8C40
+#define GL_SRGB8 0x8C41
+#define GL_SRGB_ALPHA 0x8C42
+#define GL_SRGB8_ALPHA8 0x8C43
+#define GL_COMPRESSED_SRGB 0x8C48
+#define GL_COMPRESSED_SRGB_ALPHA 0x8C49
+#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F
+#define GL_SLUMINANCE_ALPHA 0x8C44
+#define GL_SLUMINANCE8_ALPHA8 0x8C45
+#define GL_SLUMINANCE 0x8C46
+#define GL_SLUMINANCE8 0x8C47
+#define GL_COMPRESSED_SLUMINANCE 0x8C4A
+#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B
+#endif
+
+#ifndef GL_VERSION_3_0
+#define GL_COMPARE_REF_TO_TEXTURE 0x884E
+#define GL_CLIP_DISTANCE0 0x3000
+#define GL_CLIP_DISTANCE1 0x3001
+#define GL_CLIP_DISTANCE2 0x3002
+#define GL_CLIP_DISTANCE3 0x3003
+#define GL_CLIP_DISTANCE4 0x3004
+#define GL_CLIP_DISTANCE5 0x3005
+#define GL_CLIP_DISTANCE6 0x3006
+#define GL_CLIP_DISTANCE7 0x3007
+#define GL_MAX_CLIP_DISTANCES 0x0D32
+#define GL_MAJOR_VERSION 0x821B
+#define GL_MINOR_VERSION 0x821C
+#define GL_NUM_EXTENSIONS 0x821D
+#define GL_CONTEXT_FLAGS 0x821E
+#define GL_COMPRESSED_RED 0x8225
+#define GL_COMPRESSED_RG 0x8226
+#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001
+#define GL_RGBA32F 0x8814
+#define GL_RGB32F 0x8815
+#define GL_RGBA16F 0x881A
+#define GL_RGB16F 0x881B
+#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD
+#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF
+#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904
+#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905
+#define GL_CLAMP_READ_COLOR 0x891C
+#define GL_FIXED_ONLY 0x891D
+#define GL_MAX_VARYING_COMPONENTS 0x8B4B
+#define GL_TEXTURE_1D_ARRAY 0x8C18
+#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19
+#define GL_TEXTURE_2D_ARRAY 0x8C1A
+#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B
+#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C
+#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D
+#define GL_R11F_G11F_B10F 0x8C3A
+#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B
+#define GL_RGB9_E5 0x8C3D
+#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E
+#define GL_TEXTURE_SHARED_SIZE 0x8C3F
+#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76
+#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F
+#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80
+#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83
+#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84
+#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85
+#define GL_PRIMITIVES_GENERATED 0x8C87
+#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88
+#define GL_RASTERIZER_DISCARD 0x8C89
+#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A
+#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B
+#define GL_INTERLEAVED_ATTRIBS 0x8C8C
+#define GL_SEPARATE_ATTRIBS 0x8C8D
+#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E
+#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F
+#define GL_RGBA32UI 0x8D70
+#define GL_RGB32UI 0x8D71
+#define GL_RGBA16UI 0x8D76
+#define GL_RGB16UI 0x8D77
+#define GL_RGBA8UI 0x8D7C
+#define GL_RGB8UI 0x8D7D
+#define GL_RGBA32I 0x8D82
+#define GL_RGB32I 0x8D83
+#define GL_RGBA16I 0x8D88
+#define GL_RGB16I 0x8D89
+#define GL_RGBA8I 0x8D8E
+#define GL_RGB8I 0x8D8F
+#define GL_RED_INTEGER 0x8D94
+#define GL_GREEN_INTEGER 0x8D95
+#define GL_BLUE_INTEGER 0x8D96
+#define GL_RGB_INTEGER 0x8D98
+#define GL_RGBA_INTEGER 0x8D99
+#define GL_BGR_INTEGER 0x8D9A
+#define GL_BGRA_INTEGER 0x8D9B
+#define GL_SAMPLER_1D_ARRAY 0x8DC0
+#define GL_SAMPLER_2D_ARRAY 0x8DC1
+#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3
+#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4
+#define GL_SAMPLER_CUBE_SHADOW 0x8DC5
+#define GL_UNSIGNED_INT_VEC2 0x8DC6
+#define GL_UNSIGNED_INT_VEC3 0x8DC7
+#define GL_UNSIGNED_INT_VEC4 0x8DC8
+#define GL_INT_SAMPLER_1D 0x8DC9
+#define GL_INT_SAMPLER_2D 0x8DCA
+#define GL_INT_SAMPLER_3D 0x8DCB
+#define GL_INT_SAMPLER_CUBE 0x8DCC
+#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE
+#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF
+#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1
+#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2
+#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3
+#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4
+#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6
+#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7
+#define GL_QUERY_WAIT 0x8E13
+#define GL_QUERY_NO_WAIT 0x8E14
+#define GL_QUERY_BY_REGION_WAIT 0x8E15
+#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16
+#define GL_BUFFER_ACCESS_FLAGS 0x911F
+#define GL_BUFFER_MAP_LENGTH 0x9120
+#define GL_BUFFER_MAP_OFFSET 0x9121
+/* Reuse tokens from ARB_depth_buffer_float */
+/* reuse GL_DEPTH_COMPONENT32F */
+/* reuse GL_DEPTH32F_STENCIL8 */
+/* reuse GL_FLOAT_32_UNSIGNED_INT_24_8_REV */
+/* Reuse tokens from ARB_framebuffer_object */
+/* reuse GL_INVALID_FRAMEBUFFER_OPERATION */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */
+/* reuse GL_FRAMEBUFFER_DEFAULT */
+/* reuse GL_FRAMEBUFFER_UNDEFINED */
+/* reuse GL_DEPTH_STENCIL_ATTACHMENT */
+/* reuse GL_INDEX */
+/* reuse GL_MAX_RENDERBUFFER_SIZE */
+/* reuse GL_DEPTH_STENCIL */
+/* reuse GL_UNSIGNED_INT_24_8 */
+/* reuse GL_DEPTH24_STENCIL8 */
+/* reuse GL_TEXTURE_STENCIL_SIZE */
+/* reuse GL_TEXTURE_RED_TYPE */
+/* reuse GL_TEXTURE_GREEN_TYPE */
+/* reuse GL_TEXTURE_BLUE_TYPE */
+/* reuse GL_TEXTURE_ALPHA_TYPE */
+/* reuse GL_TEXTURE_DEPTH_TYPE */
+/* reuse GL_UNSIGNED_NORMALIZED */
+/* reuse GL_FRAMEBUFFER_BINDING */
+/* reuse GL_DRAW_FRAMEBUFFER_BINDING */
+/* reuse GL_RENDERBUFFER_BINDING */
+/* reuse GL_READ_FRAMEBUFFER */
+/* reuse GL_DRAW_FRAMEBUFFER */
+/* reuse GL_READ_FRAMEBUFFER_BINDING */
+/* reuse GL_RENDERBUFFER_SAMPLES */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */
+/* reuse GL_FRAMEBUFFER_COMPLETE */
+/* reuse GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */
+/* reuse GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */
+/* reuse GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER */
+/* reuse GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */
+/* reuse GL_FRAMEBUFFER_UNSUPPORTED */
+/* reuse GL_MAX_COLOR_ATTACHMENTS */
+/* reuse GL_COLOR_ATTACHMENT0 */
+/* reuse GL_COLOR_ATTACHMENT1 */
+/* reuse GL_COLOR_ATTACHMENT2 */
+/* reuse GL_COLOR_ATTACHMENT3 */
+/* reuse GL_COLOR_ATTACHMENT4 */
+/* reuse GL_COLOR_ATTACHMENT5 */
+/* reuse GL_COLOR_ATTACHMENT6 */
+/* reuse GL_COLOR_ATTACHMENT7 */
+/* reuse GL_COLOR_ATTACHMENT8 */
+/* reuse GL_COLOR_ATTACHMENT9 */
+/* reuse GL_COLOR_ATTACHMENT10 */
+/* reuse GL_COLOR_ATTACHMENT11 */
+/* reuse GL_COLOR_ATTACHMENT12 */
+/* reuse GL_COLOR_ATTACHMENT13 */
+/* reuse GL_COLOR_ATTACHMENT14 */
+/* reuse GL_COLOR_ATTACHMENT15 */
+/* reuse GL_DEPTH_ATTACHMENT */
+/* reuse GL_STENCIL_ATTACHMENT */
+/* reuse GL_FRAMEBUFFER */
+/* reuse GL_RENDERBUFFER */
+/* reuse GL_RENDERBUFFER_WIDTH */
+/* reuse GL_RENDERBUFFER_HEIGHT */
+/* reuse GL_RENDERBUFFER_INTERNAL_FORMAT */
+/* reuse GL_STENCIL_INDEX1 */
+/* reuse GL_STENCIL_INDEX4 */
+/* reuse GL_STENCIL_INDEX8 */
+/* reuse GL_STENCIL_INDEX16 */
+/* reuse GL_RENDERBUFFER_RED_SIZE */
+/* reuse GL_RENDERBUFFER_GREEN_SIZE */
+/* reuse GL_RENDERBUFFER_BLUE_SIZE */
+/* reuse GL_RENDERBUFFER_ALPHA_SIZE */
+/* reuse GL_RENDERBUFFER_DEPTH_SIZE */
+/* reuse GL_RENDERBUFFER_STENCIL_SIZE */
+/* reuse GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */
+/* reuse GL_MAX_SAMPLES */
+/* Reuse tokens from ARB_framebuffer_sRGB */
+/* reuse GL_FRAMEBUFFER_SRGB */
+/* Reuse tokens from ARB_half_float_vertex */
+/* reuse GL_HALF_FLOAT */
+/* Reuse tokens from ARB_map_buffer_range */
+/* reuse GL_MAP_READ_BIT */
+/* reuse GL_MAP_WRITE_BIT */
+/* reuse GL_MAP_INVALIDATE_RANGE_BIT */
+/* reuse GL_MAP_INVALIDATE_BUFFER_BIT */
+/* reuse GL_MAP_FLUSH_EXPLICIT_BIT */
+/* reuse GL_MAP_UNSYNCHRONIZED_BIT */
+/* Reuse tokens from ARB_texture_compression_rgtc */
+/* reuse GL_COMPRESSED_RED_RGTC1 */
+/* reuse GL_COMPRESSED_SIGNED_RED_RGTC1 */
+/* reuse GL_COMPRESSED_RG_RGTC2 */
+/* reuse GL_COMPRESSED_SIGNED_RG_RGTC2 */
+/* Reuse tokens from ARB_texture_rg */
+/* reuse GL_RG */
+/* reuse GL_RG_INTEGER */
+/* reuse GL_R8 */
+/* reuse GL_R16 */
+/* reuse GL_RG8 */
+/* reuse GL_RG16 */
+/* reuse GL_R16F */
+/* reuse GL_R32F */
+/* reuse GL_RG16F */
+/* reuse GL_RG32F */
+/* reuse GL_R8I */
+/* reuse GL_R8UI */
+/* reuse GL_R16I */
+/* reuse GL_R16UI */
+/* reuse GL_R32I */
+/* reuse GL_R32UI */
+/* reuse GL_RG8I */
+/* reuse GL_RG8UI */
+/* reuse GL_RG16I */
+/* reuse GL_RG16UI */
+/* reuse GL_RG32I */
+/* reuse GL_RG32UI */
+/* Reuse tokens from ARB_vertex_array_object */
+/* reuse GL_VERTEX_ARRAY_BINDING */
+#define GL_CLAMP_VERTEX_COLOR 0x891A
+#define GL_CLAMP_FRAGMENT_COLOR 0x891B
+#define GL_ALPHA_INTEGER 0x8D97
+/* Reuse tokens from ARB_framebuffer_object */
+/* reuse GL_TEXTURE_LUMINANCE_TYPE */
+/* reuse GL_TEXTURE_INTENSITY_TYPE */
+#endif
+
+#ifndef GL_VERSION_3_1
+#define GL_SAMPLER_2D_RECT 0x8B63
+#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64
+#define GL_SAMPLER_BUFFER 0x8DC2
+#define GL_INT_SAMPLER_2D_RECT 0x8DCD
+#define GL_INT_SAMPLER_BUFFER 0x8DD0
+#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5
+#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8
+#define GL_TEXTURE_BUFFER 0x8C2A
+#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B
+#define GL_TEXTURE_BINDING_BUFFER 0x8C2C
+#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D
+#define GL_TEXTURE_RECTANGLE 0x84F5
+#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6
+#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7
+#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8
+#define GL_RED_SNORM 0x8F90
+#define GL_RG_SNORM 0x8F91
+#define GL_RGB_SNORM 0x8F92
+#define GL_RGBA_SNORM 0x8F93
+#define GL_R8_SNORM 0x8F94
+#define GL_RG8_SNORM 0x8F95
+#define GL_RGB8_SNORM 0x8F96
+#define GL_RGBA8_SNORM 0x8F97
+#define GL_R16_SNORM 0x8F98
+#define GL_RG16_SNORM 0x8F99
+#define GL_RGB16_SNORM 0x8F9A
+#define GL_RGBA16_SNORM 0x8F9B
+#define GL_SIGNED_NORMALIZED 0x8F9C
+#define GL_PRIMITIVE_RESTART 0x8F9D
+#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E
+/* Reuse tokens from ARB_copy_buffer */
+/* reuse GL_COPY_READ_BUFFER */
+/* reuse GL_COPY_WRITE_BUFFER */
+/* Reuse tokens from ARB_draw_instanced (none) */
+/* Reuse tokens from ARB_uniform_buffer_object */
+/* reuse GL_UNIFORM_BUFFER */
+/* reuse GL_UNIFORM_BUFFER_BINDING */
+/* reuse GL_UNIFORM_BUFFER_START */
+/* reuse GL_UNIFORM_BUFFER_SIZE */
+/* reuse GL_MAX_VERTEX_UNIFORM_BLOCKS */
+/* reuse GL_MAX_FRAGMENT_UNIFORM_BLOCKS */
+/* reuse GL_MAX_COMBINED_UNIFORM_BLOCKS */
+/* reuse GL_MAX_UNIFORM_BUFFER_BINDINGS */
+/* reuse GL_MAX_UNIFORM_BLOCK_SIZE */
+/* reuse GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS */
+/* reuse GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS */
+/* reuse GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT */
+/* reuse GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH */
+/* reuse GL_ACTIVE_UNIFORM_BLOCKS */
+/* reuse GL_UNIFORM_TYPE */
+/* reuse GL_UNIFORM_SIZE */
+/* reuse GL_UNIFORM_NAME_LENGTH */
+/* reuse GL_UNIFORM_BLOCK_INDEX */
+/* reuse GL_UNIFORM_OFFSET */
+/* reuse GL_UNIFORM_ARRAY_STRIDE */
+/* reuse GL_UNIFORM_MATRIX_STRIDE */
+/* reuse GL_UNIFORM_IS_ROW_MAJOR */
+/* reuse GL_UNIFORM_BLOCK_BINDING */
+/* reuse GL_UNIFORM_BLOCK_DATA_SIZE */
+/* reuse GL_UNIFORM_BLOCK_NAME_LENGTH */
+/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS */
+/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES */
+/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER */
+/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER */
+/* reuse GL_INVALID_INDEX */
+#endif
+
+#ifndef GL_VERSION_3_2
+#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001
+#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002
+#define GL_LINES_ADJACENCY 0x000A
+#define GL_LINE_STRIP_ADJACENCY 0x000B
+#define GL_TRIANGLES_ADJACENCY 0x000C
+#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D
+#define GL_PROGRAM_POINT_SIZE 0x8642
+#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29
+#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7
+#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8
+#define GL_GEOMETRY_SHADER 0x8DD9
+#define GL_GEOMETRY_VERTICES_OUT 0x8916
+#define GL_GEOMETRY_INPUT_TYPE 0x8917
+#define GL_GEOMETRY_OUTPUT_TYPE 0x8918
+#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF
+#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0
+#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1
+#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122
+#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123
+#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124
+#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125
+#define GL_CONTEXT_PROFILE_MASK 0x9126
+/* reuse GL_MAX_VARYING_COMPONENTS */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */
+/* Reuse tokens from ARB_depth_clamp */
+/* reuse GL_DEPTH_CLAMP */
+/* Reuse tokens from ARB_draw_elements_base_vertex (none) */
+/* Reuse tokens from ARB_fragment_coord_conventions (none) */
+/* Reuse tokens from ARB_provoking_vertex */
+/* reuse GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */
+/* reuse GL_FIRST_VERTEX_CONVENTION */
+/* reuse GL_LAST_VERTEX_CONVENTION */
+/* reuse GL_PROVOKING_VERTEX */
+/* Reuse tokens from ARB_seamless_cube_map */
+/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS */
+/* Reuse tokens from ARB_sync */
+/* reuse GL_MAX_SERVER_WAIT_TIMEOUT */
+/* reuse GL_OBJECT_TYPE */
+/* reuse GL_SYNC_CONDITION */
+/* reuse GL_SYNC_STATUS */
+/* reuse GL_SYNC_FLAGS */
+/* reuse GL_SYNC_FENCE */
+/* reuse GL_SYNC_GPU_COMMANDS_COMPLETE */
+/* reuse GL_UNSIGNALED */
+/* reuse GL_SIGNALED */
+/* reuse GL_ALREADY_SIGNALED */
+/* reuse GL_TIMEOUT_EXPIRED */
+/* reuse GL_CONDITION_SATISFIED */
+/* reuse GL_WAIT_FAILED */
+/* reuse GL_TIMEOUT_IGNORED */
+/* reuse GL_SYNC_FLUSH_COMMANDS_BIT */
+/* reuse GL_TIMEOUT_IGNORED */
+/* Reuse tokens from ARB_texture_multisample */
+/* reuse GL_SAMPLE_POSITION */
+/* reuse GL_SAMPLE_MASK */
+/* reuse GL_SAMPLE_MASK_VALUE */
+/* reuse GL_MAX_SAMPLE_MASK_WORDS */
+/* reuse GL_TEXTURE_2D_MULTISAMPLE */
+/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE */
+/* reuse GL_TEXTURE_2D_MULTISAMPLE_ARRAY */
+/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY */
+/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE */
+/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY */
+/* reuse GL_TEXTURE_SAMPLES */
+/* reuse GL_TEXTURE_FIXED_SAMPLE_LOCATIONS */
+/* reuse GL_SAMPLER_2D_MULTISAMPLE */
+/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE */
+/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE */
+/* reuse GL_SAMPLER_2D_MULTISAMPLE_ARRAY */
+/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */
+/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */
+/* reuse GL_MAX_COLOR_TEXTURE_SAMPLES */
+/* reuse GL_MAX_DEPTH_TEXTURE_SAMPLES */
+/* reuse GL_MAX_INTEGER_SAMPLES */
+/* Don't need to reuse tokens from ARB_vertex_array_bgra since they're already in 1.2 core */
+#endif
+
+#ifndef GL_VERSION_3_3
+#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE
+/* Reuse tokens from ARB_blend_func_extended */
+/* reuse GL_SRC1_COLOR */
+/* reuse GL_ONE_MINUS_SRC1_COLOR */
+/* reuse GL_ONE_MINUS_SRC1_ALPHA */
+/* reuse GL_MAX_DUAL_SOURCE_DRAW_BUFFERS */
+/* Reuse tokens from ARB_explicit_attrib_location (none) */
+/* Reuse tokens from ARB_occlusion_query2 */
+/* reuse GL_ANY_SAMPLES_PASSED */
+/* Reuse tokens from ARB_sampler_objects */
+/* reuse GL_SAMPLER_BINDING */
+/* Reuse tokens from ARB_shader_bit_encoding (none) */
+/* Reuse tokens from ARB_texture_rgb10_a2ui */
+/* reuse GL_RGB10_A2UI */
+/* Reuse tokens from ARB_texture_swizzle */
+/* reuse GL_TEXTURE_SWIZZLE_R */
+/* reuse GL_TEXTURE_SWIZZLE_G */
+/* reuse GL_TEXTURE_SWIZZLE_B */
+/* reuse GL_TEXTURE_SWIZZLE_A */
+/* reuse GL_TEXTURE_SWIZZLE_RGBA */
+/* Reuse tokens from ARB_timer_query */
+/* reuse GL_TIME_ELAPSED */
+/* reuse GL_TIMESTAMP */
+/* Reuse tokens from ARB_vertex_type_2_10_10_10_rev */
+/* reuse GL_INT_2_10_10_10_REV */
+#endif
+
+#ifndef GL_VERSION_4_0
+#define GL_SAMPLE_SHADING 0x8C36
+#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37
+#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E
+#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F
+#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009
+#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A
+#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B
+#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C
+#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D
+#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E
+#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F
+/* Reuse tokens from ARB_texture_query_lod (none) */
+/* Reuse tokens from ARB_draw_buffers_blend (none) */
+/* Reuse tokens from ARB_draw_indirect */
+/* reuse GL_DRAW_INDIRECT_BUFFER */
+/* reuse GL_DRAW_INDIRECT_BUFFER_BINDING */
+/* Reuse tokens from ARB_gpu_shader5 */
+/* reuse GL_GEOMETRY_SHADER_INVOCATIONS */
+/* reuse GL_MAX_GEOMETRY_SHADER_INVOCATIONS */
+/* reuse GL_MIN_FRAGMENT_INTERPOLATION_OFFSET */
+/* reuse GL_MAX_FRAGMENT_INTERPOLATION_OFFSET */
+/* reuse GL_FRAGMENT_INTERPOLATION_OFFSET_BITS */
+/* Reuse tokens from ARB_gpu_shader_fp64 */
+/* reuse GL_DOUBLE_VEC2 */
+/* reuse GL_DOUBLE_VEC3 */
+/* reuse GL_DOUBLE_VEC4 */
+/* reuse GL_DOUBLE_MAT2 */
+/* reuse GL_DOUBLE_MAT3 */
+/* reuse GL_DOUBLE_MAT4 */
+/* reuse GL_DOUBLE_MAT2x3 */
+/* reuse GL_DOUBLE_MAT2x4 */
+/* reuse GL_DOUBLE_MAT3x2 */
+/* reuse GL_DOUBLE_MAT3x4 */
+/* reuse GL_DOUBLE_MAT4x2 */
+/* reuse GL_DOUBLE_MAT4x3 */
+/* Reuse tokens from ARB_shader_subroutine */
+/* reuse GL_ACTIVE_SUBROUTINES */
+/* reuse GL_ACTIVE_SUBROUTINE_UNIFORMS */
+/* reuse GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS */
+/* reuse GL_ACTIVE_SUBROUTINE_MAX_LENGTH */
+/* reuse GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH */
+/* reuse GL_MAX_SUBROUTINES */
+/* reuse GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS */
+/* reuse GL_NUM_COMPATIBLE_SUBROUTINES */
+/* reuse GL_COMPATIBLE_SUBROUTINES */
+/* Reuse tokens from ARB_tessellation_shader */
+/* reuse GL_PATCHES */
+/* reuse GL_PATCH_VERTICES */
+/* reuse GL_PATCH_DEFAULT_INNER_LEVEL */
+/* reuse GL_PATCH_DEFAULT_OUTER_LEVEL */
+/* reuse GL_TESS_CONTROL_OUTPUT_VERTICES */
+/* reuse GL_TESS_GEN_MODE */
+/* reuse GL_TESS_GEN_SPACING */
+/* reuse GL_TESS_GEN_VERTEX_ORDER */
+/* reuse GL_TESS_GEN_POINT_MODE */
+/* reuse GL_ISOLINES */
+/* reuse GL_FRACTIONAL_ODD */
+/* reuse GL_FRACTIONAL_EVEN */
+/* reuse GL_MAX_PATCH_VERTICES */
+/* reuse GL_MAX_TESS_GEN_LEVEL */
+/* reuse GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS */
+/* reuse GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS */
+/* reuse GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS */
+/* reuse GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS */
+/* reuse GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS */
+/* reuse GL_MAX_TESS_PATCH_COMPONENTS */
+/* reuse GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS */
+/* reuse GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS */
+/* reuse GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS */
+/* reuse GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS */
+/* reuse GL_MAX_TESS_CONTROL_INPUT_COMPONENTS */
+/* reuse GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS */
+/* reuse GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS */
+/* reuse GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS */
+/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER */
+/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER */
+/* reuse GL_TESS_EVALUATION_SHADER */
+/* reuse GL_TESS_CONTROL_SHADER */
+/* Reuse tokens from ARB_texture_buffer_object_rgb32 (none) */
+/* Reuse tokens from ARB_transform_feedback2 */
+/* reuse GL_TRANSFORM_FEEDBACK */
+/* reuse GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED */
+/* reuse GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE */
+/* reuse GL_TRANSFORM_FEEDBACK_BINDING */
+/* Reuse tokens from ARB_transform_feedback3 */
+/* reuse GL_MAX_TRANSFORM_FEEDBACK_BUFFERS */
+/* reuse GL_MAX_VERTEX_STREAMS */
+#endif
+
+#ifndef GL_VERSION_4_1
+/* Reuse tokens from ARB_ES2_compatibility */
+/* reuse GL_FIXED */
+/* reuse GL_IMPLEMENTATION_COLOR_READ_TYPE */
+/* reuse GL_IMPLEMENTATION_COLOR_READ_FORMAT */
+/* reuse GL_LOW_FLOAT */
+/* reuse GL_MEDIUM_FLOAT */
+/* reuse GL_HIGH_FLOAT */
+/* reuse GL_LOW_INT */
+/* reuse GL_MEDIUM_INT */
+/* reuse GL_HIGH_INT */
+/* reuse GL_SHADER_COMPILER */
+/* reuse GL_SHADER_BINARY_FORMATS */
+/* reuse GL_NUM_SHADER_BINARY_FORMATS */
+/* reuse GL_MAX_VERTEX_UNIFORM_VECTORS */
+/* reuse GL_MAX_VARYING_VECTORS */
+/* reuse GL_MAX_FRAGMENT_UNIFORM_VECTORS */
+/* reuse GL_RGB565 */
+/* Reuse tokens from ARB_get_program_binary */
+/* reuse GL_PROGRAM_BINARY_RETRIEVABLE_HINT */
+/* reuse GL_PROGRAM_BINARY_LENGTH */
+/* reuse GL_NUM_PROGRAM_BINARY_FORMATS */
+/* reuse GL_PROGRAM_BINARY_FORMATS */
+/* Reuse tokens from ARB_separate_shader_objects */
+/* reuse GL_VERTEX_SHADER_BIT */
+/* reuse GL_FRAGMENT_SHADER_BIT */
+/* reuse GL_GEOMETRY_SHADER_BIT */
+/* reuse GL_TESS_CONTROL_SHADER_BIT */
+/* reuse GL_TESS_EVALUATION_SHADER_BIT */
+/* reuse GL_ALL_SHADER_BITS */
+/* reuse GL_PROGRAM_SEPARABLE */
+/* reuse GL_ACTIVE_PROGRAM */
+/* reuse GL_PROGRAM_PIPELINE_BINDING */
+/* Reuse tokens from ARB_shader_precision (none) */
+/* Reuse tokens from ARB_vertex_attrib_64bit - all are in GL 3.0 and 4.0 already */
+/* Reuse tokens from ARB_viewport_array - some are in GL 1.1 and ARB_provoking_vertex already */
+/* reuse GL_MAX_VIEWPORTS */
+/* reuse GL_VIEWPORT_SUBPIXEL_BITS */
+/* reuse GL_VIEWPORT_BOUNDS_RANGE */
+/* reuse GL_LAYER_PROVOKING_VERTEX */
+/* reuse GL_VIEWPORT_INDEX_PROVOKING_VERTEX */
+/* reuse GL_UNDEFINED_VERTEX */
+#endif
+
+#ifndef GL_VERSION_4_2
+/* Reuse tokens from ARB_base_instance (none) */
+/* Reuse tokens from ARB_shading_language_420pack (none) */
+/* Reuse tokens from ARB_transform_feedback_instanced (none) */
+/* Reuse tokens from ARB_compressed_texture_pixel_storage */
+/* reuse GL_UNPACK_COMPRESSED_BLOCK_WIDTH */
+/* reuse GL_UNPACK_COMPRESSED_BLOCK_HEIGHT */
+/* reuse GL_UNPACK_COMPRESSED_BLOCK_DEPTH */
+/* reuse GL_UNPACK_COMPRESSED_BLOCK_SIZE */
+/* reuse GL_PACK_COMPRESSED_BLOCK_WIDTH */
+/* reuse GL_PACK_COMPRESSED_BLOCK_HEIGHT */
+/* reuse GL_PACK_COMPRESSED_BLOCK_DEPTH */
+/* reuse GL_PACK_COMPRESSED_BLOCK_SIZE */
+/* Reuse tokens from ARB_conservative_depth (none) */
+/* Reuse tokens from ARB_internalformat_query */
+/* reuse GL_NUM_SAMPLE_COUNTS */
+/* Reuse tokens from ARB_map_buffer_alignment */
+/* reuse GL_MIN_MAP_BUFFER_ALIGNMENT */
+/* Reuse tokens from ARB_shader_atomic_counters */
+/* reuse GL_ATOMIC_COUNTER_BUFFER */
+/* reuse GL_ATOMIC_COUNTER_BUFFER_BINDING */
+/* reuse GL_ATOMIC_COUNTER_BUFFER_START */
+/* reuse GL_ATOMIC_COUNTER_BUFFER_SIZE */
+/* reuse GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE */
+/* reuse GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS */
+/* reuse GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES */
+/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER */
+/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER */
+/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER */
+/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER */
+/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER */
+/* reuse GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS */
+/* reuse GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS */
+/* reuse GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS */
+/* reuse GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS */
+/* reuse GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS */
+/* reuse GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS */
+/* reuse GL_MAX_VERTEX_ATOMIC_COUNTERS */
+/* reuse GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS */
+/* reuse GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS */
+/* reuse GL_MAX_GEOMETRY_ATOMIC_COUNTERS */
+/* reuse GL_MAX_FRAGMENT_ATOMIC_COUNTERS */
+/* reuse GL_MAX_COMBINED_ATOMIC_COUNTERS */
+/* reuse GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE */
+/* reuse GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS */
+/* reuse GL_ACTIVE_ATOMIC_COUNTER_BUFFERS */
+/* reuse GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX */
+/* reuse GL_UNSIGNED_INT_ATOMIC_COUNTER */
+/* Reuse tokens from ARB_shader_image_load_store */
+/* reuse GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT */
+/* reuse GL_ELEMENT_ARRAY_BARRIER_BIT */
+/* reuse GL_UNIFORM_BARRIER_BIT */
+/* reuse GL_TEXTURE_FETCH_BARRIER_BIT */
+/* reuse GL_SHADER_IMAGE_ACCESS_BARRIER_BIT */
+/* reuse GL_COMMAND_BARRIER_BIT */
+/* reuse GL_PIXEL_BUFFER_BARRIER_BIT */
+/* reuse GL_TEXTURE_UPDATE_BARRIER_BIT */
+/* reuse GL_BUFFER_UPDATE_BARRIER_BIT */
+/* reuse GL_FRAMEBUFFER_BARRIER_BIT */
+/* reuse GL_TRANSFORM_FEEDBACK_BARRIER_BIT */
+/* reuse GL_ATOMIC_COUNTER_BARRIER_BIT */
+/* reuse GL_ALL_BARRIER_BITS */
+/* reuse GL_MAX_IMAGE_UNITS */
+/* reuse GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS */
+/* reuse GL_IMAGE_BINDING_NAME */
+/* reuse GL_IMAGE_BINDING_LEVEL */
+/* reuse GL_IMAGE_BINDING_LAYERED */
+/* reuse GL_IMAGE_BINDING_LAYER */
+/* reuse GL_IMAGE_BINDING_ACCESS */
+/* reuse GL_IMAGE_1D */
+/* reuse GL_IMAGE_2D */
+/* reuse GL_IMAGE_3D */
+/* reuse GL_IMAGE_2D_RECT */
+/* reuse GL_IMAGE_CUBE */
+/* reuse GL_IMAGE_BUFFER */
+/* reuse GL_IMAGE_1D_ARRAY */
+/* reuse GL_IMAGE_2D_ARRAY */
+/* reuse GL_IMAGE_CUBE_MAP_ARRAY */
+/* reuse GL_IMAGE_2D_MULTISAMPLE */
+/* reuse GL_IMAGE_2D_MULTISAMPLE_ARRAY */
+/* reuse GL_INT_IMAGE_1D */
+/* reuse GL_INT_IMAGE_2D */
+/* reuse GL_INT_IMAGE_3D */
+/* reuse GL_INT_IMAGE_2D_RECT */
+/* reuse GL_INT_IMAGE_CUBE */
+/* reuse GL_INT_IMAGE_BUFFER */
+/* reuse GL_INT_IMAGE_1D_ARRAY */
+/* reuse GL_INT_IMAGE_2D_ARRAY */
+/* reuse GL_INT_IMAGE_CUBE_MAP_ARRAY */
+/* reuse GL_INT_IMAGE_2D_MULTISAMPLE */
+/* reuse GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY */
+/* reuse GL_UNSIGNED_INT_IMAGE_1D */
+/* reuse GL_UNSIGNED_INT_IMAGE_2D */
+/* reuse GL_UNSIGNED_INT_IMAGE_3D */
+/* reuse GL_UNSIGNED_INT_IMAGE_2D_RECT */
+/* reuse GL_UNSIGNED_INT_IMAGE_CUBE */
+/* reuse GL_UNSIGNED_INT_IMAGE_BUFFER */
+/* reuse GL_UNSIGNED_INT_IMAGE_1D_ARRAY */
+/* reuse GL_UNSIGNED_INT_IMAGE_2D_ARRAY */
+/* reuse GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY */
+/* reuse GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE */
+/* reuse GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY */
+/* reuse GL_MAX_IMAGE_SAMPLES */
+/* reuse GL_IMAGE_BINDING_FORMAT */
+/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_TYPE */
+/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE */
+/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS */
+/* reuse GL_MAX_VERTEX_IMAGE_UNIFORMS */
+/* reuse GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS */
+/* reuse GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS */
+/* reuse GL_MAX_GEOMETRY_IMAGE_UNIFORMS */
+/* reuse GL_MAX_FRAGMENT_IMAGE_UNIFORMS */
+/* reuse GL_MAX_COMBINED_IMAGE_UNIFORMS */
+/* Reuse tokens from ARB_shading_language_packing (none) */
+/* Reuse tokens from ARB_texture_storage */
+/* reuse GL_TEXTURE_IMMUTABLE_FORMAT */
+#endif
+
+#ifndef GL_VERSION_4_3
+#define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9
+#define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E
+/* Reuse tokens from ARB_arrays_of_arrays (none, GLSL only) */
+/* Reuse tokens from ARB_fragment_layer_viewport (none, GLSL only) */
+/* Reuse tokens from ARB_shader_image_size (none, GLSL only) */
+/* Reuse tokens from ARB_ES3_compatibility */
+/* reuse GL_COMPRESSED_RGB8_ETC2 */
+/* reuse GL_COMPRESSED_SRGB8_ETC2 */
+/* reuse GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 */
+/* reuse GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 */
+/* reuse GL_COMPRESSED_RGBA8_ETC2_EAC */
+/* reuse GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC */
+/* reuse GL_COMPRESSED_R11_EAC */
+/* reuse GL_COMPRESSED_SIGNED_R11_EAC */
+/* reuse GL_COMPRESSED_RG11_EAC */
+/* reuse GL_COMPRESSED_SIGNED_RG11_EAC */
+/* reuse GL_PRIMITIVE_RESTART_FIXED_INDEX */
+/* reuse GL_ANY_SAMPLES_PASSED_CONSERVATIVE */
+/* reuse GL_MAX_ELEMENT_INDEX */
+/* Reuse tokens from ARB_clear_buffer_object (none) */
+/* Reuse tokens from ARB_compute_shader */
+/* reuse GL_COMPUTE_SHADER */
+/* reuse GL_MAX_COMPUTE_UNIFORM_BLOCKS */
+/* reuse GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS */
+/* reuse GL_MAX_COMPUTE_IMAGE_UNIFORMS */
+/* reuse GL_MAX_COMPUTE_SHARED_MEMORY_SIZE */
+/* reuse GL_MAX_COMPUTE_UNIFORM_COMPONENTS */
+/* reuse GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS */
+/* reuse GL_MAX_COMPUTE_ATOMIC_COUNTERS */
+/* reuse GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS */
+/* reuse GL_MAX_COMPUTE_LOCAL_INVOCATIONS */
+/* reuse GL_MAX_COMPUTE_WORK_GROUP_COUNT */
+/* reuse GL_MAX_COMPUTE_WORK_GROUP_SIZE */
+/* reuse GL_COMPUTE_LOCAL_WORK_SIZE */
+/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER */
+/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER */
+/* reuse GL_DISPATCH_INDIRECT_BUFFER */
+/* reuse GL_DISPATCH_INDIRECT_BUFFER_BINDING */
+/* Reuse tokens from ARB_copy_image (none) */
+/* Reuse tokens from KHR_debug */
+/* reuse GL_DEBUG_OUTPUT_SYNCHRONOUS */
+/* reuse GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH */
+/* reuse GL_DEBUG_CALLBACK_FUNCTION */
+/* reuse GL_DEBUG_CALLBACK_USER_PARAM */
+/* reuse GL_DEBUG_SOURCE_API */
+/* reuse GL_DEBUG_SOURCE_WINDOW_SYSTEM */
+/* reuse GL_DEBUG_SOURCE_SHADER_COMPILER */
+/* reuse GL_DEBUG_SOURCE_THIRD_PARTY */
+/* reuse GL_DEBUG_SOURCE_APPLICATION */
+/* reuse GL_DEBUG_SOURCE_OTHER */
+/* reuse GL_DEBUG_TYPE_ERROR */
+/* reuse GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR */
+/* reuse GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR */
+/* reuse GL_DEBUG_TYPE_PORTABILITY */
+/* reuse GL_DEBUG_TYPE_PERFORMANCE */
+/* reuse GL_DEBUG_TYPE_OTHER */
+/* reuse GL_MAX_DEBUG_MESSAGE_LENGTH */
+/* reuse GL_MAX_DEBUG_LOGGED_MESSAGES */
+/* reuse GL_DEBUG_LOGGED_MESSAGES */
+/* reuse GL_DEBUG_SEVERITY_HIGH */
+/* reuse GL_DEBUG_SEVERITY_MEDIUM */
+/* reuse GL_DEBUG_SEVERITY_LOW */
+/* reuse GL_DEBUG_TYPE_MARKER */
+/* reuse GL_DEBUG_TYPE_PUSH_GROUP */
+/* reuse GL_DEBUG_TYPE_POP_GROUP */
+/* reuse GL_DEBUG_SEVERITY_NOTIFICATION */
+/* reuse GL_MAX_DEBUG_GROUP_STACK_DEPTH */
+/* reuse GL_DEBUG_GROUP_STACK_DEPTH */
+/* reuse GL_BUFFER */
+/* reuse GL_SHADER */
+/* reuse GL_PROGRAM */
+/* reuse GL_QUERY */
+/* reuse GL_PROGRAM_PIPELINE */
+/* reuse GL_SAMPLER */
+/* reuse GL_DISPLAY_LIST */
+/* reuse GL_MAX_LABEL_LENGTH */
+/* reuse GL_DEBUG_OUTPUT */
+/* reuse GL_CONTEXT_FLAG_DEBUG_BIT */
+/* reuse GL_STACK_UNDERFLOW */
+/* reuse GL_STACK_OVERFLOW */
+/* Reuse tokens from ARB_explicit_uniform_location */
+/* reuse GL_MAX_UNIFORM_LOCATIONS */
+/* Reuse tokens from ARB_framebuffer_no_attachments */
+/* reuse GL_FRAMEBUFFER_DEFAULT_WIDTH */
+/* reuse GL_FRAMEBUFFER_DEFAULT_HEIGHT */
+/* reuse GL_FRAMEBUFFER_DEFAULT_LAYERS */
+/* reuse GL_FRAMEBUFFER_DEFAULT_SAMPLES */
+/* reuse GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS */
+/* reuse GL_MAX_FRAMEBUFFER_WIDTH */
+/* reuse GL_MAX_FRAMEBUFFER_HEIGHT */
+/* reuse GL_MAX_FRAMEBUFFER_LAYERS */
+/* reuse GL_MAX_FRAMEBUFFER_SAMPLES */
+/* Reuse tokens from ARB_internalformat_query2 */
+/* reuse GL_INTERNALFORMAT_SUPPORTED */
+/* reuse GL_INTERNALFORMAT_PREFERRED */
+/* reuse GL_INTERNALFORMAT_RED_SIZE */
+/* reuse GL_INTERNALFORMAT_GREEN_SIZE */
+/* reuse GL_INTERNALFORMAT_BLUE_SIZE */
+/* reuse GL_INTERNALFORMAT_ALPHA_SIZE */
+/* reuse GL_INTERNALFORMAT_DEPTH_SIZE */
+/* reuse GL_INTERNALFORMAT_STENCIL_SIZE */
+/* reuse GL_INTERNALFORMAT_SHARED_SIZE */
+/* reuse GL_INTERNALFORMAT_RED_TYPE */
+/* reuse GL_INTERNALFORMAT_GREEN_TYPE */
+/* reuse GL_INTERNALFORMAT_BLUE_TYPE */
+/* reuse GL_INTERNALFORMAT_ALPHA_TYPE */
+/* reuse GL_INTERNALFORMAT_DEPTH_TYPE */
+/* reuse GL_INTERNALFORMAT_STENCIL_TYPE */
+/* reuse GL_MAX_WIDTH */
+/* reuse GL_MAX_HEIGHT */
+/* reuse GL_MAX_DEPTH */
+/* reuse GL_MAX_LAYERS */
+/* reuse GL_MAX_COMBINED_DIMENSIONS */
+/* reuse GL_COLOR_COMPONENTS */
+/* reuse GL_DEPTH_COMPONENTS */
+/* reuse GL_STENCIL_COMPONENTS */
+/* reuse GL_COLOR_RENDERABLE */
+/* reuse GL_DEPTH_RENDERABLE */
+/* reuse GL_STENCIL_RENDERABLE */
+/* reuse GL_FRAMEBUFFER_RENDERABLE */
+/* reuse GL_FRAMEBUFFER_RENDERABLE_LAYERED */
+/* reuse GL_FRAMEBUFFER_BLEND */
+/* reuse GL_READ_PIXELS */
+/* reuse GL_READ_PIXELS_FORMAT */
+/* reuse GL_READ_PIXELS_TYPE */
+/* reuse GL_TEXTURE_IMAGE_FORMAT */
+/* reuse GL_TEXTURE_IMAGE_TYPE */
+/* reuse GL_GET_TEXTURE_IMAGE_FORMAT */
+/* reuse GL_GET_TEXTURE_IMAGE_TYPE */
+/* reuse GL_MIPMAP */
+/* reuse GL_MANUAL_GENERATE_MIPMAP */
+/* reuse GL_AUTO_GENERATE_MIPMAP */
+/* reuse GL_COLOR_ENCODING */
+/* reuse GL_SRGB_READ */
+/* reuse GL_SRGB_WRITE */
+/* reuse GL_FILTER */
+/* reuse GL_VERTEX_TEXTURE */
+/* reuse GL_TESS_CONTROL_TEXTURE */
+/* reuse GL_TESS_EVALUATION_TEXTURE */
+/* reuse GL_GEOMETRY_TEXTURE */
+/* reuse GL_FRAGMENT_TEXTURE */
+/* reuse GL_COMPUTE_TEXTURE */
+/* reuse GL_TEXTURE_SHADOW */
+/* reuse GL_TEXTURE_GATHER */
+/* reuse GL_TEXTURE_GATHER_SHADOW */
+/* reuse GL_SHADER_IMAGE_LOAD */
+/* reuse GL_SHADER_IMAGE_STORE */
+/* reuse GL_SHADER_IMAGE_ATOMIC */
+/* reuse GL_IMAGE_TEXEL_SIZE */
+/* reuse GL_IMAGE_COMPATIBILITY_CLASS */
+/* reuse GL_IMAGE_PIXEL_FORMAT */
+/* reuse GL_IMAGE_PIXEL_TYPE */
+/* reuse GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST */
+/* reuse GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST */
+/* reuse GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE */
+/* reuse GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE */
+/* reuse GL_TEXTURE_COMPRESSED_BLOCK_WIDTH */
+/* reuse GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT */
+/* reuse GL_TEXTURE_COMPRESSED_BLOCK_SIZE */
+/* reuse GL_CLEAR_BUFFER */
+/* reuse GL_TEXTURE_VIEW */
+/* reuse GL_VIEW_COMPATIBILITY_CLASS */
+/* reuse GL_FULL_SUPPORT */
+/* reuse GL_CAVEAT_SUPPORT */
+/* reuse GL_IMAGE_CLASS_4_X_32 */
+/* reuse GL_IMAGE_CLASS_2_X_32 */
+/* reuse GL_IMAGE_CLASS_1_X_32 */
+/* reuse GL_IMAGE_CLASS_4_X_16 */
+/* reuse GL_IMAGE_CLASS_2_X_16 */
+/* reuse GL_IMAGE_CLASS_1_X_16 */
+/* reuse GL_IMAGE_CLASS_4_X_8 */
+/* reuse GL_IMAGE_CLASS_2_X_8 */
+/* reuse GL_IMAGE_CLASS_1_X_8 */
+/* reuse GL_IMAGE_CLASS_11_11_10 */
+/* reuse GL_IMAGE_CLASS_10_10_10_2 */
+/* reuse GL_VIEW_CLASS_128_BITS */
+/* reuse GL_VIEW_CLASS_96_BITS */
+/* reuse GL_VIEW_CLASS_64_BITS */
+/* reuse GL_VIEW_CLASS_48_BITS */
+/* reuse GL_VIEW_CLASS_32_BITS */
+/* reuse GL_VIEW_CLASS_24_BITS */
+/* reuse GL_VIEW_CLASS_16_BITS */
+/* reuse GL_VIEW_CLASS_8_BITS */
+/* reuse GL_VIEW_CLASS_S3TC_DXT1_RGB */
+/* reuse GL_VIEW_CLASS_S3TC_DXT1_RGBA */
+/* reuse GL_VIEW_CLASS_S3TC_DXT3_RGBA */
+/* reuse GL_VIEW_CLASS_S3TC_DXT5_RGBA */
+/* reuse GL_VIEW_CLASS_RGTC1_RED */
+/* reuse GL_VIEW_CLASS_RGTC2_RG */
+/* reuse GL_VIEW_CLASS_BPTC_UNORM */
+/* reuse GL_VIEW_CLASS_BPTC_FLOAT */
+/* Reuse tokens from ARB_invalidate_subdata (none) */
+/* Reuse tokens from ARB_multi_draw_indirect (none) */
+/* Reuse tokens from ARB_program_interface_query */
+/* reuse GL_UNIFORM */
+/* reuse GL_UNIFORM_BLOCK */
+/* reuse GL_PROGRAM_INPUT */
+/* reuse GL_PROGRAM_OUTPUT */
+/* reuse GL_BUFFER_VARIABLE */
+/* reuse GL_SHADER_STORAGE_BLOCK */
+/* reuse GL_VERTEX_SUBROUTINE */
+/* reuse GL_TESS_CONTROL_SUBROUTINE */
+/* reuse GL_TESS_EVALUATION_SUBROUTINE */
+/* reuse GL_GEOMETRY_SUBROUTINE */
+/* reuse GL_FRAGMENT_SUBROUTINE */
+/* reuse GL_COMPUTE_SUBROUTINE */
+/* reuse GL_VERTEX_SUBROUTINE_UNIFORM */
+/* reuse GL_TESS_CONTROL_SUBROUTINE_UNIFORM */
+/* reuse GL_TESS_EVALUATION_SUBROUTINE_UNIFORM */
+/* reuse GL_GEOMETRY_SUBROUTINE_UNIFORM */
+/* reuse GL_FRAGMENT_SUBROUTINE_UNIFORM */
+/* reuse GL_COMPUTE_SUBROUTINE_UNIFORM */
+/* reuse GL_TRANSFORM_FEEDBACK_VARYING */
+/* reuse GL_ACTIVE_RESOURCES */
+/* reuse GL_MAX_NAME_LENGTH */
+/* reuse GL_MAX_NUM_ACTIVE_VARIABLES */
+/* reuse GL_MAX_NUM_COMPATIBLE_SUBROUTINES */
+/* reuse GL_NAME_LENGTH */
+/* reuse GL_TYPE */
+/* reuse GL_ARRAY_SIZE */
+/* reuse GL_OFFSET */
+/* reuse GL_BLOCK_INDEX */
+/* reuse GL_ARRAY_STRIDE */
+/* reuse GL_MATRIX_STRIDE */
+/* reuse GL_IS_ROW_MAJOR */
+/* reuse GL_ATOMIC_COUNTER_BUFFER_INDEX */
+/* reuse GL_BUFFER_BINDING */
+/* reuse GL_BUFFER_DATA_SIZE */
+/* reuse GL_NUM_ACTIVE_VARIABLES */
+/* reuse GL_ACTIVE_VARIABLES */
+/* reuse GL_REFERENCED_BY_VERTEX_SHADER */
+/* reuse GL_REFERENCED_BY_TESS_CONTROL_SHADER */
+/* reuse GL_REFERENCED_BY_TESS_EVALUATION_SHADER */
+/* reuse GL_REFERENCED_BY_GEOMETRY_SHADER */
+/* reuse GL_REFERENCED_BY_FRAGMENT_SHADER */
+/* reuse GL_REFERENCED_BY_COMPUTE_SHADER */
+/* reuse GL_TOP_LEVEL_ARRAY_SIZE */
+/* reuse GL_TOP_LEVEL_ARRAY_STRIDE */
+/* reuse GL_LOCATION */
+/* reuse GL_LOCATION_INDEX */
+/* reuse GL_IS_PER_PATCH */
+/* Reuse tokens from ARB_robust_buffer_access_behavior (none) */
+/* Reuse tokens from ARB_shader_storage_buffer_object */
+/* reuse GL_SHADER_STORAGE_BUFFER */
+/* reuse GL_SHADER_STORAGE_BUFFER_BINDING */
+/* reuse GL_SHADER_STORAGE_BUFFER_START */
+/* reuse GL_SHADER_STORAGE_BUFFER_SIZE */
+/* reuse GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS */
+/* reuse GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS */
+/* reuse GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS */
+/* reuse GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS */
+/* reuse GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS */
+/* reuse GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS */
+/* reuse GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS */
+/* reuse GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS */
+/* reuse GL_MAX_SHADER_STORAGE_BLOCK_SIZE */
+/* reuse GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT */
+/* reuse GL_SHADER_STORAGE_BARRIER_BIT */
+/* reuse GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES */
+/* Reuse tokens from ARB_stencil_texturing */
+/* reuse GL_DEPTH_STENCIL_TEXTURE_MODE */
+/* Reuse tokens from ARB_texture_buffer_range */
+/* reuse GL_TEXTURE_BUFFER_OFFSET */
+/* reuse GL_TEXTURE_BUFFER_SIZE */
+/* reuse GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT */
+/* Reuse tokens from ARB_texture_query_levels (none) */
+/* Reuse tokens from ARB_texture_storage_multisample (none) */
+/* Reuse tokens from ARB_texture_view */
+/* reuse GL_TEXTURE_VIEW_MIN_LEVEL */
+/* reuse GL_TEXTURE_VIEW_NUM_LEVELS */
+/* reuse GL_TEXTURE_VIEW_MIN_LAYER */
+/* reuse GL_TEXTURE_VIEW_NUM_LAYERS */
+/* reuse GL_TEXTURE_IMMUTABLE_LEVELS */
+/* Reuse tokens from ARB_vertex_attrib_binding */
+/* reuse GL_VERTEX_ATTRIB_BINDING */
+/* reuse GL_VERTEX_ATTRIB_RELATIVE_OFFSET */
+/* reuse GL_VERTEX_BINDING_DIVISOR */
+/* reuse GL_VERTEX_BINDING_OFFSET */
+/* reuse GL_VERTEX_BINDING_STRIDE */
+/* reuse GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET */
+/* reuse GL_MAX_VERTEX_ATTRIB_BINDINGS */
+#endif
+
+#ifndef GL_ARB_multitexture
+#define GL_TEXTURE0_ARB 0x84C0
+#define GL_TEXTURE1_ARB 0x84C1
+#define GL_TEXTURE2_ARB 0x84C2
+#define GL_TEXTURE3_ARB 0x84C3
+#define GL_TEXTURE4_ARB 0x84C4
+#define GL_TEXTURE5_ARB 0x84C5
+#define GL_TEXTURE6_ARB 0x84C6
+#define GL_TEXTURE7_ARB 0x84C7
+#define GL_TEXTURE8_ARB 0x84C8
+#define GL_TEXTURE9_ARB 0x84C9
+#define GL_TEXTURE10_ARB 0x84CA
+#define GL_TEXTURE11_ARB 0x84CB
+#define GL_TEXTURE12_ARB 0x84CC
+#define GL_TEXTURE13_ARB 0x84CD
+#define GL_TEXTURE14_ARB 0x84CE
+#define GL_TEXTURE15_ARB 0x84CF
+#define GL_TEXTURE16_ARB 0x84D0
+#define GL_TEXTURE17_ARB 0x84D1
+#define GL_TEXTURE18_ARB 0x84D2
+#define GL_TEXTURE19_ARB 0x84D3
+#define GL_TEXTURE20_ARB 0x84D4
+#define GL_TEXTURE21_ARB 0x84D5
+#define GL_TEXTURE22_ARB 0x84D6
+#define GL_TEXTURE23_ARB 0x84D7
+#define GL_TEXTURE24_ARB 0x84D8
+#define GL_TEXTURE25_ARB 0x84D9
+#define GL_TEXTURE26_ARB 0x84DA
+#define GL_TEXTURE27_ARB 0x84DB
+#define GL_TEXTURE28_ARB 0x84DC
+#define GL_TEXTURE29_ARB 0x84DD
+#define GL_TEXTURE30_ARB 0x84DE
+#define GL_TEXTURE31_ARB 0x84DF
+#define GL_ACTIVE_TEXTURE_ARB 0x84E0
+#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1
+#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2
+#endif
+
+#ifndef GL_ARB_transpose_matrix
+#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3
+#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4
+#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5
+#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6
+#endif
+
+#ifndef GL_ARB_multisample
+#define GL_MULTISAMPLE_ARB 0x809D
+#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E
+#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F
+#define GL_SAMPLE_COVERAGE_ARB 0x80A0
+#define GL_SAMPLE_BUFFERS_ARB 0x80A8
+#define GL_SAMPLES_ARB 0x80A9
+#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA
+#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB
+#define GL_MULTISAMPLE_BIT_ARB 0x20000000
+#endif
+
+#ifndef GL_ARB_texture_env_add
+#endif
+
+#ifndef GL_ARB_texture_cube_map
+#define GL_NORMAL_MAP_ARB 0x8511
+#define GL_REFLECTION_MAP_ARB 0x8512
+#define GL_TEXTURE_CUBE_MAP_ARB 0x8513
+#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A
+#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B
+#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C
+#endif
+
+#ifndef GL_ARB_texture_compression
+#define GL_COMPRESSED_ALPHA_ARB 0x84E9
+#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA
+#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB
+#define GL_COMPRESSED_INTENSITY_ARB 0x84EC
+#define GL_COMPRESSED_RGB_ARB 0x84ED
+#define GL_COMPRESSED_RGBA_ARB 0x84EE
+#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF
+#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0
+#define GL_TEXTURE_COMPRESSED_ARB 0x86A1
+#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2
+#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3
+#endif
+
+#ifndef GL_ARB_texture_border_clamp
+#define GL_CLAMP_TO_BORDER_ARB 0x812D
+#endif
+
+#ifndef GL_ARB_point_parameters
+#define GL_POINT_SIZE_MIN_ARB 0x8126
+#define GL_POINT_SIZE_MAX_ARB 0x8127
+#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128
+#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129
+#endif
+
+#ifndef GL_ARB_vertex_blend
+#define GL_MAX_VERTEX_UNITS_ARB 0x86A4
+#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5
+#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6
+#define GL_VERTEX_BLEND_ARB 0x86A7
+#define GL_CURRENT_WEIGHT_ARB 0x86A8
+#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9
+#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA
+#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB
+#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC
+#define GL_WEIGHT_ARRAY_ARB 0x86AD
+#define GL_MODELVIEW0_ARB 0x1700
+#define GL_MODELVIEW1_ARB 0x850A
+#define GL_MODELVIEW2_ARB 0x8722
+#define GL_MODELVIEW3_ARB 0x8723
+#define GL_MODELVIEW4_ARB 0x8724
+#define GL_MODELVIEW5_ARB 0x8725
+#define GL_MODELVIEW6_ARB 0x8726
+#define GL_MODELVIEW7_ARB 0x8727
+#define GL_MODELVIEW8_ARB 0x8728
+#define GL_MODELVIEW9_ARB 0x8729
+#define GL_MODELVIEW10_ARB 0x872A
+#define GL_MODELVIEW11_ARB 0x872B
+#define GL_MODELVIEW12_ARB 0x872C
+#define GL_MODELVIEW13_ARB 0x872D
+#define GL_MODELVIEW14_ARB 0x872E
+#define GL_MODELVIEW15_ARB 0x872F
+#define GL_MODELVIEW16_ARB 0x8730
+#define GL_MODELVIEW17_ARB 0x8731
+#define GL_MODELVIEW18_ARB 0x8732
+#define GL_MODELVIEW19_ARB 0x8733
+#define GL_MODELVIEW20_ARB 0x8734
+#define GL_MODELVIEW21_ARB 0x8735
+#define GL_MODELVIEW22_ARB 0x8736
+#define GL_MODELVIEW23_ARB 0x8737
+#define GL_MODELVIEW24_ARB 0x8738
+#define GL_MODELVIEW25_ARB 0x8739
+#define GL_MODELVIEW26_ARB 0x873A
+#define GL_MODELVIEW27_ARB 0x873B
+#define GL_MODELVIEW28_ARB 0x873C
+#define GL_MODELVIEW29_ARB 0x873D
+#define GL_MODELVIEW30_ARB 0x873E
+#define GL_MODELVIEW31_ARB 0x873F
+#endif
+
+#ifndef GL_ARB_matrix_palette
+#define GL_MATRIX_PALETTE_ARB 0x8840
+#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841
+#define GL_MAX_PALETTE_MATRICES_ARB 0x8842
+#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843
+#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844
+#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845
+#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846
+#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847
+#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848
+#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849
+#endif
+
+#ifndef GL_ARB_texture_env_combine
+#define GL_COMBINE_ARB 0x8570
+#define GL_COMBINE_RGB_ARB 0x8571
+#define GL_COMBINE_ALPHA_ARB 0x8572
+#define GL_SOURCE0_RGB_ARB 0x8580
+#define GL_SOURCE1_RGB_ARB 0x8581
+#define GL_SOURCE2_RGB_ARB 0x8582
+#define GL_SOURCE0_ALPHA_ARB 0x8588
+#define GL_SOURCE1_ALPHA_ARB 0x8589
+#define GL_SOURCE2_ALPHA_ARB 0x858A
+#define GL_OPERAND0_RGB_ARB 0x8590
+#define GL_OPERAND1_RGB_ARB 0x8591
+#define GL_OPERAND2_RGB_ARB 0x8592
+#define GL_OPERAND0_ALPHA_ARB 0x8598
+#define GL_OPERAND1_ALPHA_ARB 0x8599
+#define GL_OPERAND2_ALPHA_ARB 0x859A
+#define GL_RGB_SCALE_ARB 0x8573
+#define GL_ADD_SIGNED_ARB 0x8574
+#define GL_INTERPOLATE_ARB 0x8575
+#define GL_SUBTRACT_ARB 0x84E7
+#define GL_CONSTANT_ARB 0x8576
+#define GL_PRIMARY_COLOR_ARB 0x8577
+#define GL_PREVIOUS_ARB 0x8578
+#endif
+
+#ifndef GL_ARB_texture_env_crossbar
+#endif
+
+#ifndef GL_ARB_texture_env_dot3
+#define GL_DOT3_RGB_ARB 0x86AE
+#define GL_DOT3_RGBA_ARB 0x86AF
+#endif
+
+#ifndef GL_ARB_texture_mirrored_repeat
+#define GL_MIRRORED_REPEAT_ARB 0x8370
+#endif
+
+#ifndef GL_ARB_depth_texture
+#define GL_DEPTH_COMPONENT16_ARB 0x81A5
+#define GL_DEPTH_COMPONENT24_ARB 0x81A6
+#define GL_DEPTH_COMPONENT32_ARB 0x81A7
+#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A
+#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B
+#endif
+
+#ifndef GL_ARB_shadow
+#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C
+#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D
+#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E
+#endif
+
+#ifndef GL_ARB_shadow_ambient
+#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF
+#endif
+
+#ifndef GL_ARB_window_pos
+#endif
+
+#ifndef GL_ARB_vertex_program
+#define GL_COLOR_SUM_ARB 0x8458
+#define GL_VERTEX_PROGRAM_ARB 0x8620
+#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622
+#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623
+#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624
+#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625
+#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626
+#define GL_PROGRAM_LENGTH_ARB 0x8627
+#define GL_PROGRAM_STRING_ARB 0x8628
+#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E
+#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F
+#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640
+#define GL_CURRENT_MATRIX_ARB 0x8641
+#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642
+#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643
+#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645
+#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B
+#define GL_PROGRAM_BINDING_ARB 0x8677
+#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869
+#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A
+#define GL_PROGRAM_ERROR_STRING_ARB 0x8874
+#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875
+#define GL_PROGRAM_FORMAT_ARB 0x8876
+#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0
+#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1
+#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2
+#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3
+#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4
+#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5
+#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6
+#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7
+#define GL_PROGRAM_PARAMETERS_ARB 0x88A8
+#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9
+#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA
+#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB
+#define GL_PROGRAM_ATTRIBS_ARB 0x88AC
+#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD
+#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE
+#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF
+#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0
+#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1
+#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2
+#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3
+#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4
+#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5
+#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6
+#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7
+#define GL_MATRIX0_ARB 0x88C0
+#define GL_MATRIX1_ARB 0x88C1
+#define GL_MATRIX2_ARB 0x88C2
+#define GL_MATRIX3_ARB 0x88C3
+#define GL_MATRIX4_ARB 0x88C4
+#define GL_MATRIX5_ARB 0x88C5
+#define GL_MATRIX6_ARB 0x88C6
+#define GL_MATRIX7_ARB 0x88C7
+#define GL_MATRIX8_ARB 0x88C8
+#define GL_MATRIX9_ARB 0x88C9
+#define GL_MATRIX10_ARB 0x88CA
+#define GL_MATRIX11_ARB 0x88CB
+#define GL_MATRIX12_ARB 0x88CC
+#define GL_MATRIX13_ARB 0x88CD
+#define GL_MATRIX14_ARB 0x88CE
+#define GL_MATRIX15_ARB 0x88CF
+#define GL_MATRIX16_ARB 0x88D0
+#define GL_MATRIX17_ARB 0x88D1
+#define GL_MATRIX18_ARB 0x88D2
+#define GL_MATRIX19_ARB 0x88D3
+#define GL_MATRIX20_ARB 0x88D4
+#define GL_MATRIX21_ARB 0x88D5
+#define GL_MATRIX22_ARB 0x88D6
+#define GL_MATRIX23_ARB 0x88D7
+#define GL_MATRIX24_ARB 0x88D8
+#define GL_MATRIX25_ARB 0x88D9
+#define GL_MATRIX26_ARB 0x88DA
+#define GL_MATRIX27_ARB 0x88DB
+#define GL_MATRIX28_ARB 0x88DC
+#define GL_MATRIX29_ARB 0x88DD
+#define GL_MATRIX30_ARB 0x88DE
+#define GL_MATRIX31_ARB 0x88DF
+#endif
+
+#ifndef GL_ARB_fragment_program
+#define GL_FRAGMENT_PROGRAM_ARB 0x8804
+#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805
+#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806
+#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807
+#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808
+#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809
+#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A
+#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B
+#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C
+#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D
+#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E
+#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F
+#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810
+#define GL_MAX_TEXTURE_COORDS_ARB 0x8871
+#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872
+#endif
+
+#ifndef GL_ARB_vertex_buffer_object
+#define GL_BUFFER_SIZE_ARB 0x8764
+#define GL_BUFFER_USAGE_ARB 0x8765
+#define GL_ARRAY_BUFFER_ARB 0x8892
+#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893
+#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894
+#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895
+#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896
+#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897
+#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898
+#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899
+#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A
+#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B
+#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C
+#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D
+#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E
+#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F
+#define GL_READ_ONLY_ARB 0x88B8
+#define GL_WRITE_ONLY_ARB 0x88B9
+#define GL_READ_WRITE_ARB 0x88BA
+#define GL_BUFFER_ACCESS_ARB 0x88BB
+#define GL_BUFFER_MAPPED_ARB 0x88BC
+#define GL_BUFFER_MAP_POINTER_ARB 0x88BD
+#define GL_STREAM_DRAW_ARB 0x88E0
+#define GL_STREAM_READ_ARB 0x88E1
+#define GL_STREAM_COPY_ARB 0x88E2
+#define GL_STATIC_DRAW_ARB 0x88E4
+#define GL_STATIC_READ_ARB 0x88E5
+#define GL_STATIC_COPY_ARB 0x88E6
+#define GL_DYNAMIC_DRAW_ARB 0x88E8
+#define GL_DYNAMIC_READ_ARB 0x88E9
+#define GL_DYNAMIC_COPY_ARB 0x88EA
+#endif
+
+#ifndef GL_ARB_occlusion_query
+#define GL_QUERY_COUNTER_BITS_ARB 0x8864
+#define GL_CURRENT_QUERY_ARB 0x8865
+#define GL_QUERY_RESULT_ARB 0x8866
+#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867
+#define GL_SAMPLES_PASSED_ARB 0x8914
+#endif
+
+#ifndef GL_ARB_shader_objects
+#define GL_PROGRAM_OBJECT_ARB 0x8B40
+#define GL_SHADER_OBJECT_ARB 0x8B48
+#define GL_OBJECT_TYPE_ARB 0x8B4E
+#define GL_OBJECT_SUBTYPE_ARB 0x8B4F
+#define GL_FLOAT_VEC2_ARB 0x8B50
+#define GL_FLOAT_VEC3_ARB 0x8B51
+#define GL_FLOAT_VEC4_ARB 0x8B52
+#define GL_INT_VEC2_ARB 0x8B53
+#define GL_INT_VEC3_ARB 0x8B54
+#define GL_INT_VEC4_ARB 0x8B55
+#define GL_BOOL_ARB 0x8B56
+#define GL_BOOL_VEC2_ARB 0x8B57
+#define GL_BOOL_VEC3_ARB 0x8B58
+#define GL_BOOL_VEC4_ARB 0x8B59
+#define GL_FLOAT_MAT2_ARB 0x8B5A
+#define GL_FLOAT_MAT3_ARB 0x8B5B
+#define GL_FLOAT_MAT4_ARB 0x8B5C
+#define GL_SAMPLER_1D_ARB 0x8B5D
+#define GL_SAMPLER_2D_ARB 0x8B5E
+#define GL_SAMPLER_3D_ARB 0x8B5F
+#define GL_SAMPLER_CUBE_ARB 0x8B60
+#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61
+#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62
+#define GL_SAMPLER_2D_RECT_ARB 0x8B63
+#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64
+#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80
+#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81
+#define GL_OBJECT_LINK_STATUS_ARB 0x8B82
+#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83
+#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84
+#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85
+#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86
+#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87
+#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88
+#endif
+
+#ifndef GL_ARB_vertex_shader
+#define GL_VERTEX_SHADER_ARB 0x8B31
+#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A
+#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B
+#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C
+#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D
+#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89
+#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A
+#endif
+
+#ifndef GL_ARB_fragment_shader
+#define GL_FRAGMENT_SHADER_ARB 0x8B30
+#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49
+#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B
+#endif
+
+#ifndef GL_ARB_shading_language_100
+#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C
+#endif
+
+#ifndef GL_ARB_texture_non_power_of_two
+#endif
+
+#ifndef GL_ARB_point_sprite
+#define GL_POINT_SPRITE_ARB 0x8861
+#define GL_COORD_REPLACE_ARB 0x8862
+#endif
+
+#ifndef GL_ARB_fragment_program_shadow
+#endif
+
+#ifndef GL_ARB_draw_buffers
+#define GL_MAX_DRAW_BUFFERS_ARB 0x8824
+#define GL_DRAW_BUFFER0_ARB 0x8825
+#define GL_DRAW_BUFFER1_ARB 0x8826
+#define GL_DRAW_BUFFER2_ARB 0x8827
+#define GL_DRAW_BUFFER3_ARB 0x8828
+#define GL_DRAW_BUFFER4_ARB 0x8829
+#define GL_DRAW_BUFFER5_ARB 0x882A
+#define GL_DRAW_BUFFER6_ARB 0x882B
+#define GL_DRAW_BUFFER7_ARB 0x882C
+#define GL_DRAW_BUFFER8_ARB 0x882D
+#define GL_DRAW_BUFFER9_ARB 0x882E
+#define GL_DRAW_BUFFER10_ARB 0x882F
+#define GL_DRAW_BUFFER11_ARB 0x8830
+#define GL_DRAW_BUFFER12_ARB 0x8831
+#define GL_DRAW_BUFFER13_ARB 0x8832
+#define GL_DRAW_BUFFER14_ARB 0x8833
+#define GL_DRAW_BUFFER15_ARB 0x8834
+#endif
+
+#ifndef GL_ARB_texture_rectangle
+#define GL_TEXTURE_RECTANGLE_ARB 0x84F5
+#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6
+#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7
+#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8
+#endif
+
+#ifndef GL_ARB_color_buffer_float
+#define GL_RGBA_FLOAT_MODE_ARB 0x8820
+#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A
+#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B
+#define GL_CLAMP_READ_COLOR_ARB 0x891C
+#define GL_FIXED_ONLY_ARB 0x891D
+#endif
+
+#ifndef GL_ARB_half_float_pixel
+#define GL_HALF_FLOAT_ARB 0x140B
+#endif
+
+#ifndef GL_ARB_texture_float
+#define GL_TEXTURE_RED_TYPE_ARB 0x8C10
+#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11
+#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12
+#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13
+#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14
+#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15
+#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16
+#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17
+#define GL_RGBA32F_ARB 0x8814
+#define GL_RGB32F_ARB 0x8815
+#define GL_ALPHA32F_ARB 0x8816
+#define GL_INTENSITY32F_ARB 0x8817
+#define GL_LUMINANCE32F_ARB 0x8818
+#define GL_LUMINANCE_ALPHA32F_ARB 0x8819
+#define GL_RGBA16F_ARB 0x881A
+#define GL_RGB16F_ARB 0x881B
+#define GL_ALPHA16F_ARB 0x881C
+#define GL_INTENSITY16F_ARB 0x881D
+#define GL_LUMINANCE16F_ARB 0x881E
+#define GL_LUMINANCE_ALPHA16F_ARB 0x881F
+#endif
+
+#ifndef GL_ARB_pixel_buffer_object
+#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB
+#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC
+#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED
+#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF
+#endif
+
+#ifndef GL_ARB_depth_buffer_float
+#define GL_DEPTH_COMPONENT32F 0x8CAC
+#define GL_DEPTH32F_STENCIL8 0x8CAD
+#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD
+#endif
+
+#ifndef GL_ARB_draw_instanced
+#endif
+
+#ifndef GL_ARB_framebuffer_object
+#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
+#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210
+#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211
+#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212
+#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213
+#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214
+#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215
+#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216
+#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217
+#define GL_FRAMEBUFFER_DEFAULT 0x8218
+#define GL_FRAMEBUFFER_UNDEFINED 0x8219
+#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A
+#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
+#define GL_DEPTH_STENCIL 0x84F9
+#define GL_UNSIGNED_INT_24_8 0x84FA
+#define GL_DEPTH24_STENCIL8 0x88F0
+#define GL_TEXTURE_STENCIL_SIZE 0x88F1
+#define GL_TEXTURE_RED_TYPE 0x8C10
+#define GL_TEXTURE_GREEN_TYPE 0x8C11
+#define GL_TEXTURE_BLUE_TYPE 0x8C12
+#define GL_TEXTURE_ALPHA_TYPE 0x8C13
+#define GL_TEXTURE_DEPTH_TYPE 0x8C16
+#define GL_UNSIGNED_NORMALIZED 0x8C17
+#define GL_FRAMEBUFFER_BINDING 0x8CA6
+#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6
+#define GL_RENDERBUFFER_BINDING 0x8CA7
+#define GL_READ_FRAMEBUFFER 0x8CA8
+#define GL_DRAW_FRAMEBUFFER 0x8CA9
+#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA
+#define GL_RENDERBUFFER_SAMPLES 0x8CAB
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4
+#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
+#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
+#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
+#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB
+#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC
+#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
+#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF
+#define GL_COLOR_ATTACHMENT0 0x8CE0
+#define GL_COLOR_ATTACHMENT1 0x8CE1
+#define GL_COLOR_ATTACHMENT2 0x8CE2
+#define GL_COLOR_ATTACHMENT3 0x8CE3
+#define GL_COLOR_ATTACHMENT4 0x8CE4
+#define GL_COLOR_ATTACHMENT5 0x8CE5
+#define GL_COLOR_ATTACHMENT6 0x8CE6
+#define GL_COLOR_ATTACHMENT7 0x8CE7
+#define GL_COLOR_ATTACHMENT8 0x8CE8
+#define GL_COLOR_ATTACHMENT9 0x8CE9
+#define GL_COLOR_ATTACHMENT10 0x8CEA
+#define GL_COLOR_ATTACHMENT11 0x8CEB
+#define GL_COLOR_ATTACHMENT12 0x8CEC
+#define GL_COLOR_ATTACHMENT13 0x8CED
+#define GL_COLOR_ATTACHMENT14 0x8CEE
+#define GL_COLOR_ATTACHMENT15 0x8CEF
+#define GL_DEPTH_ATTACHMENT 0x8D00
+#define GL_STENCIL_ATTACHMENT 0x8D20
+#define GL_FRAMEBUFFER 0x8D40
+#define GL_RENDERBUFFER 0x8D41
+#define GL_RENDERBUFFER_WIDTH 0x8D42
+#define GL_RENDERBUFFER_HEIGHT 0x8D43
+#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
+#define GL_STENCIL_INDEX1 0x8D46
+#define GL_STENCIL_INDEX4 0x8D47
+#define GL_STENCIL_INDEX8 0x8D48
+#define GL_STENCIL_INDEX16 0x8D49
+#define GL_RENDERBUFFER_RED_SIZE 0x8D50
+#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51
+#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52
+#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
+#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
+#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56
+#define GL_MAX_SAMPLES 0x8D57
+#define GL_INDEX 0x8222
+#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14
+#define GL_TEXTURE_INTENSITY_TYPE 0x8C15
+#endif
+
+#ifndef GL_ARB_framebuffer_sRGB
+#define GL_FRAMEBUFFER_SRGB 0x8DB9
+#endif
+
+#ifndef GL_ARB_geometry_shader4
+#define GL_LINES_ADJACENCY_ARB 0x000A
+#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B
+#define GL_TRIANGLES_ADJACENCY_ARB 0x000C
+#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D
+#define GL_PROGRAM_POINT_SIZE_ARB 0x8642
+#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29
+#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7
+#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8
+#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9
+#define GL_GEOMETRY_SHADER_ARB 0x8DD9
+#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA
+#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB
+#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC
+#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD
+#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE
+#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF
+#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0
+#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1
+/* reuse GL_MAX_VARYING_COMPONENTS */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */
+#endif
+
+#ifndef GL_ARB_half_float_vertex
+#define GL_HALF_FLOAT 0x140B
+#endif
+
+#ifndef GL_ARB_instanced_arrays
+#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE
+#endif
+
+#ifndef GL_ARB_map_buffer_range
+#define GL_MAP_READ_BIT 0x0001
+#define GL_MAP_WRITE_BIT 0x0002
+#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004
+#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008
+#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010
+#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020
+#endif
+
+#ifndef GL_ARB_texture_buffer_object
+#define GL_TEXTURE_BUFFER_ARB 0x8C2A
+#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B
+#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C
+#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D
+#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E
+#endif
+
+#ifndef GL_ARB_texture_compression_rgtc
+#define GL_COMPRESSED_RED_RGTC1 0x8DBB
+#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC
+#define GL_COMPRESSED_RG_RGTC2 0x8DBD
+#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE
+#endif
+
+#ifndef GL_ARB_texture_rg
+#define GL_RG 0x8227
+#define GL_RG_INTEGER 0x8228
+#define GL_R8 0x8229
+#define GL_R16 0x822A
+#define GL_RG8 0x822B
+#define GL_RG16 0x822C
+#define GL_R16F 0x822D
+#define GL_R32F 0x822E
+#define GL_RG16F 0x822F
+#define GL_RG32F 0x8230
+#define GL_R8I 0x8231
+#define GL_R8UI 0x8232
+#define GL_R16I 0x8233
+#define GL_R16UI 0x8234
+#define GL_R32I 0x8235
+#define GL_R32UI 0x8236
+#define GL_RG8I 0x8237
+#define GL_RG8UI 0x8238
+#define GL_RG16I 0x8239
+#define GL_RG16UI 0x823A
+#define GL_RG32I 0x823B
+#define GL_RG32UI 0x823C
+#endif
+
+#ifndef GL_ARB_vertex_array_object
+#define GL_VERTEX_ARRAY_BINDING 0x85B5
+#endif
+
+#ifndef GL_ARB_uniform_buffer_object
+#define GL_UNIFORM_BUFFER 0x8A11
+#define GL_UNIFORM_BUFFER_BINDING 0x8A28
+#define GL_UNIFORM_BUFFER_START 0x8A29
+#define GL_UNIFORM_BUFFER_SIZE 0x8A2A
+#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B
+#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C
+#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D
+#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E
+#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F
+#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30
+#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31
+#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32
+#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33
+#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34
+#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35
+#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36
+#define GL_UNIFORM_TYPE 0x8A37
+#define GL_UNIFORM_SIZE 0x8A38
+#define GL_UNIFORM_NAME_LENGTH 0x8A39
+#define GL_UNIFORM_BLOCK_INDEX 0x8A3A
+#define GL_UNIFORM_OFFSET 0x8A3B
+#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C
+#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D
+#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E
+#define GL_UNIFORM_BLOCK_BINDING 0x8A3F
+#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40
+#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41
+#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42
+#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43
+#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44
+#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45
+#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46
+#define GL_INVALID_INDEX 0xFFFFFFFFu
+#endif
+
+#ifndef GL_ARB_compatibility
+/* ARB_compatibility just defines tokens from core 3.0 */
+#endif
+
+#ifndef GL_ARB_copy_buffer
+#define GL_COPY_READ_BUFFER_BINDING 0x8F36
+#define GL_COPY_READ_BUFFER 0x8F36
+#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37
+#define GL_COPY_WRITE_BUFFER 0x8F37
+#endif
+
+#ifndef GL_ARB_shader_texture_lod
+#endif
+
+#ifndef GL_ARB_depth_clamp
+#define GL_DEPTH_CLAMP 0x864F
+#endif
+
+#ifndef GL_ARB_draw_elements_base_vertex
+#endif
+
+#ifndef GL_ARB_fragment_coord_conventions
+#endif
+
+#ifndef GL_ARB_provoking_vertex
+#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C
+#define GL_FIRST_VERTEX_CONVENTION 0x8E4D
+#define GL_LAST_VERTEX_CONVENTION 0x8E4E
+#define GL_PROVOKING_VERTEX 0x8E4F
+#endif
+
+#ifndef GL_ARB_seamless_cube_map
+#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F
+#endif
+
+#ifndef GL_ARB_sync
+#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111
+#define GL_OBJECT_TYPE 0x9112
+#define GL_SYNC_CONDITION 0x9113
+#define GL_SYNC_STATUS 0x9114
+#define GL_SYNC_FLAGS 0x9115
+#define GL_SYNC_FENCE 0x9116
+#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117
+#define GL_UNSIGNALED 0x9118
+#define GL_SIGNALED 0x9119
+#define GL_ALREADY_SIGNALED 0x911A
+#define GL_TIMEOUT_EXPIRED 0x911B
+#define GL_CONDITION_SATISFIED 0x911C
+#define GL_WAIT_FAILED 0x911D
+#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001
+#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull
+#endif
+
+#ifndef GL_ARB_texture_multisample
+#define GL_SAMPLE_POSITION 0x8E50
+#define GL_SAMPLE_MASK 0x8E51
+#define GL_SAMPLE_MASK_VALUE 0x8E52
+#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59
+#define GL_TEXTURE_2D_MULTISAMPLE 0x9100
+#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101
+#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102
+#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103
+#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104
+#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105
+#define GL_TEXTURE_SAMPLES 0x9106
+#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107
+#define GL_SAMPLER_2D_MULTISAMPLE 0x9108
+#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109
+#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A
+#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B
+#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C
+#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D
+#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E
+#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F
+#define GL_MAX_INTEGER_SAMPLES 0x9110
+#endif
+
+#ifndef GL_ARB_vertex_array_bgra
+/* reuse GL_BGRA */
+#endif
+
+#ifndef GL_ARB_draw_buffers_blend
+#endif
+
+#ifndef GL_ARB_sample_shading
+#define GL_SAMPLE_SHADING_ARB 0x8C36
+#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37
+#endif
+
+#ifndef GL_ARB_texture_cube_map_array
+#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009
+#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A
+#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B
+#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C
+#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D
+#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E
+#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F
+#endif
+
+#ifndef GL_ARB_texture_gather
+#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E
+#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F
+#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB 0x8F9F
+#endif
+
+#ifndef GL_ARB_texture_query_lod
+#endif
+
+#ifndef GL_ARB_shading_language_include
+#define GL_SHADER_INCLUDE_ARB 0x8DAE
+#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9
+#define GL_NAMED_STRING_TYPE_ARB 0x8DEA
+#endif
+
+#ifndef GL_ARB_texture_compression_bptc
+#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C
+#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D
+#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E
+#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F
+#endif
+
+#ifndef GL_ARB_blend_func_extended
+#define GL_SRC1_COLOR 0x88F9
+/* reuse GL_SRC1_ALPHA */
+#define GL_ONE_MINUS_SRC1_COLOR 0x88FA
+#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB
+#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC
+#endif
+
+#ifndef GL_ARB_explicit_attrib_location
+#endif
+
+#ifndef GL_ARB_occlusion_query2
+#define GL_ANY_SAMPLES_PASSED 0x8C2F
+#endif
+
+#ifndef GL_ARB_sampler_objects
+#define GL_SAMPLER_BINDING 0x8919
+#endif
+
+#ifndef GL_ARB_shader_bit_encoding
+#endif
+
+#ifndef GL_ARB_texture_rgb10_a2ui
+#define GL_RGB10_A2UI 0x906F
+#endif
+
+#ifndef GL_ARB_texture_swizzle
+#define GL_TEXTURE_SWIZZLE_R 0x8E42
+#define GL_TEXTURE_SWIZZLE_G 0x8E43
+#define GL_TEXTURE_SWIZZLE_B 0x8E44
+#define GL_TEXTURE_SWIZZLE_A 0x8E45
+#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46
+#endif
+
+#ifndef GL_ARB_timer_query
+#define GL_TIME_ELAPSED 0x88BF
+#define GL_TIMESTAMP 0x8E28
+#endif
+
+#ifndef GL_ARB_vertex_type_2_10_10_10_rev
+/* reuse GL_UNSIGNED_INT_2_10_10_10_REV */
+#define GL_INT_2_10_10_10_REV 0x8D9F
+#endif
+
+#ifndef GL_ARB_draw_indirect
+#define GL_DRAW_INDIRECT_BUFFER 0x8F3F
+#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43
+#endif
+
+#ifndef GL_ARB_gpu_shader5
+#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F
+#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A
+#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B
+#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C
+#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D
+/* reuse GL_MAX_VERTEX_STREAMS */
+#endif
+
+#ifndef GL_ARB_gpu_shader_fp64
+/* reuse GL_DOUBLE */
+#define GL_DOUBLE_VEC2 0x8FFC
+#define GL_DOUBLE_VEC3 0x8FFD
+#define GL_DOUBLE_VEC4 0x8FFE
+#define GL_DOUBLE_MAT2 0x8F46
+#define GL_DOUBLE_MAT3 0x8F47
+#define GL_DOUBLE_MAT4 0x8F48
+#define GL_DOUBLE_MAT2x3 0x8F49
+#define GL_DOUBLE_MAT2x4 0x8F4A
+#define GL_DOUBLE_MAT3x2 0x8F4B
+#define GL_DOUBLE_MAT3x4 0x8F4C
+#define GL_DOUBLE_MAT4x2 0x8F4D
+#define GL_DOUBLE_MAT4x3 0x8F4E
+#endif
+
+#ifndef GL_ARB_shader_subroutine
+#define GL_ACTIVE_SUBROUTINES 0x8DE5
+#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6
+#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47
+#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48
+#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49
+#define GL_MAX_SUBROUTINES 0x8DE7
+#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8
+#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A
+#define GL_COMPATIBLE_SUBROUTINES 0x8E4B
+/* reuse GL_UNIFORM_SIZE */
+/* reuse GL_UNIFORM_NAME_LENGTH */
+#endif
+
+#ifndef GL_ARB_tessellation_shader
+#define GL_PATCHES 0x000E
+#define GL_PATCH_VERTICES 0x8E72
+#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73
+#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74
+#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75
+#define GL_TESS_GEN_MODE 0x8E76
+#define GL_TESS_GEN_SPACING 0x8E77
+#define GL_TESS_GEN_VERTEX_ORDER 0x8E78
+#define GL_TESS_GEN_POINT_MODE 0x8E79
+/* reuse GL_TRIANGLES */
+/* reuse GL_QUADS */
+#define GL_ISOLINES 0x8E7A
+/* reuse GL_EQUAL */
+#define GL_FRACTIONAL_ODD 0x8E7B
+#define GL_FRACTIONAL_EVEN 0x8E7C
+/* reuse GL_CCW */
+/* reuse GL_CW */
+#define GL_MAX_PATCH_VERTICES 0x8E7D
+#define GL_MAX_TESS_GEN_LEVEL 0x8E7E
+#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F
+#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80
+#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81
+#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82
+#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83
+#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84
+#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85
+#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86
+#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89
+#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A
+#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C
+#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D
+#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E
+#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F
+#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0
+#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1
+#define GL_TESS_EVALUATION_SHADER 0x8E87
+#define GL_TESS_CONTROL_SHADER 0x8E88
+#endif
+
+#ifndef GL_ARB_texture_buffer_object_rgb32
+/* reuse GL_RGB32F */
+/* reuse GL_RGB32UI */
+/* reuse GL_RGB32I */
+#endif
+
+#ifndef GL_ARB_transform_feedback2
+#define GL_TRANSFORM_FEEDBACK 0x8E22
+#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23
+#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23
+#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24
+#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24
+#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25
+#endif
+
+#ifndef GL_ARB_transform_feedback3
+#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70
+#define GL_MAX_VERTEX_STREAMS 0x8E71
+#endif
+
+#ifndef GL_ARB_ES2_compatibility
+#define GL_FIXED 0x140C
+#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
+#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
+#define GL_LOW_FLOAT 0x8DF0
+#define GL_MEDIUM_FLOAT 0x8DF1
+#define GL_HIGH_FLOAT 0x8DF2
+#define GL_LOW_INT 0x8DF3
+#define GL_MEDIUM_INT 0x8DF4
+#define GL_HIGH_INT 0x8DF5
+#define GL_SHADER_COMPILER 0x8DFA
+#define GL_SHADER_BINARY_FORMATS 0x8DF8
+#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
+#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
+#define GL_MAX_VARYING_VECTORS 0x8DFC
+#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
+#define GL_RGB565 0x8D62
+#endif
+
+#ifndef GL_ARB_get_program_binary
+#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257
+#define GL_PROGRAM_BINARY_LENGTH 0x8741
+#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE
+#define GL_PROGRAM_BINARY_FORMATS 0x87FF
+#endif
+
+#ifndef GL_ARB_separate_shader_objects
+#define GL_VERTEX_SHADER_BIT 0x00000001
+#define GL_FRAGMENT_SHADER_BIT 0x00000002
+#define GL_GEOMETRY_SHADER_BIT 0x00000004
+#define GL_TESS_CONTROL_SHADER_BIT 0x00000008
+#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010
+#define GL_ALL_SHADER_BITS 0xFFFFFFFF
+#define GL_PROGRAM_SEPARABLE 0x8258
+#define GL_ACTIVE_PROGRAM 0x8259
+#define GL_PROGRAM_PIPELINE_BINDING 0x825A
+#endif
+
+#ifndef GL_ARB_shader_precision
+#endif
+
+#ifndef GL_ARB_vertex_attrib_64bit
+/* reuse GL_RGB32I */
+/* reuse GL_DOUBLE_VEC2 */
+/* reuse GL_DOUBLE_VEC3 */
+/* reuse GL_DOUBLE_VEC4 */
+/* reuse GL_DOUBLE_MAT2 */
+/* reuse GL_DOUBLE_MAT3 */
+/* reuse GL_DOUBLE_MAT4 */
+/* reuse GL_DOUBLE_MAT2x3 */
+/* reuse GL_DOUBLE_MAT2x4 */
+/* reuse GL_DOUBLE_MAT3x2 */
+/* reuse GL_DOUBLE_MAT3x4 */
+/* reuse GL_DOUBLE_MAT4x2 */
+/* reuse GL_DOUBLE_MAT4x3 */
+#endif
+
+#ifndef GL_ARB_viewport_array
+/* reuse GL_SCISSOR_BOX */
+/* reuse GL_VIEWPORT */
+/* reuse GL_DEPTH_RANGE */
+/* reuse GL_SCISSOR_TEST */
+#define GL_MAX_VIEWPORTS 0x825B
+#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C
+#define GL_VIEWPORT_BOUNDS_RANGE 0x825D
+#define GL_LAYER_PROVOKING_VERTEX 0x825E
+#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F
+#define GL_UNDEFINED_VERTEX 0x8260
+/* reuse GL_FIRST_VERTEX_CONVENTION */
+/* reuse GL_LAST_VERTEX_CONVENTION */
+/* reuse GL_PROVOKING_VERTEX */
+#endif
+
+#ifndef GL_ARB_cl_event
+#define GL_SYNC_CL_EVENT_ARB 0x8240
+#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241
+#endif
+
+#ifndef GL_ARB_debug_output
+#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242
+#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243
+#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244
+#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245
+#define GL_DEBUG_SOURCE_API_ARB 0x8246
+#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247
+#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248
+#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249
+#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A
+#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B
+#define GL_DEBUG_TYPE_ERROR_ARB 0x824C
+#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D
+#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E
+#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F
+#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250
+#define GL_DEBUG_TYPE_OTHER_ARB 0x8251
+#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143
+#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144
+#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145
+#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146
+#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147
+#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148
+#endif
+
+#ifndef GL_ARB_robustness
+/* reuse GL_NO_ERROR */
+#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004
+#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252
+#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253
+#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254
+#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255
+#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
+#define GL_NO_RESET_NOTIFICATION_ARB 0x8261
+#endif
+
+#ifndef GL_ARB_shader_stencil_export
+#endif
+
+#ifndef GL_ARB_base_instance
+#endif
+
+#ifndef GL_ARB_shading_language_420pack
+#endif
+
+#ifndef GL_ARB_transform_feedback_instanced
+#endif
+
+#ifndef GL_ARB_compressed_texture_pixel_storage
+#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127
+#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128
+#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129
+#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A
+#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B
+#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C
+#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D
+#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E
+#endif
+
+#ifndef GL_ARB_conservative_depth
+#endif
+
+#ifndef GL_ARB_internalformat_query
+#define GL_NUM_SAMPLE_COUNTS 0x9380
+#endif
+
+#ifndef GL_ARB_map_buffer_alignment
+#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC
+#endif
+
+#ifndef GL_ARB_shader_atomic_counters
+#define GL_ATOMIC_COUNTER_BUFFER 0x92C0
+#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1
+#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2
+#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3
+#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4
+#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5
+#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6
+#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7
+#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8
+#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9
+#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA
+#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB
+#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC
+#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD
+#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE
+#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF
+#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0
+#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1
+#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2
+#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3
+#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4
+#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5
+#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6
+#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7
+#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8
+#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC
+#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9
+#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA
+#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB
+#endif
+
+#ifndef GL_ARB_shader_image_load_store
+#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001
+#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002
+#define GL_UNIFORM_BARRIER_BIT 0x00000004
+#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008
+#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020
+#define GL_COMMAND_BARRIER_BIT 0x00000040
+#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080
+#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100
+#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200
+#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400
+#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800
+#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000
+#define GL_ALL_BARRIER_BITS 0xFFFFFFFF
+#define GL_MAX_IMAGE_UNITS 0x8F38
+#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39
+#define GL_IMAGE_BINDING_NAME 0x8F3A
+#define GL_IMAGE_BINDING_LEVEL 0x8F3B
+#define GL_IMAGE_BINDING_LAYERED 0x8F3C
+#define GL_IMAGE_BINDING_LAYER 0x8F3D
+#define GL_IMAGE_BINDING_ACCESS 0x8F3E
+#define GL_IMAGE_1D 0x904C
+#define GL_IMAGE_2D 0x904D
+#define GL_IMAGE_3D 0x904E
+#define GL_IMAGE_2D_RECT 0x904F
+#define GL_IMAGE_CUBE 0x9050
+#define GL_IMAGE_BUFFER 0x9051
+#define GL_IMAGE_1D_ARRAY 0x9052
+#define GL_IMAGE_2D_ARRAY 0x9053
+#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054
+#define GL_IMAGE_2D_MULTISAMPLE 0x9055
+#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056
+#define GL_INT_IMAGE_1D 0x9057
+#define GL_INT_IMAGE_2D 0x9058
+#define GL_INT_IMAGE_3D 0x9059
+#define GL_INT_IMAGE_2D_RECT 0x905A
+#define GL_INT_IMAGE_CUBE 0x905B
+#define GL_INT_IMAGE_BUFFER 0x905C
+#define GL_INT_IMAGE_1D_ARRAY 0x905D
+#define GL_INT_IMAGE_2D_ARRAY 0x905E
+#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F
+#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060
+#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061
+#define GL_UNSIGNED_INT_IMAGE_1D 0x9062
+#define GL_UNSIGNED_INT_IMAGE_2D 0x9063
+#define GL_UNSIGNED_INT_IMAGE_3D 0x9064
+#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065
+#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066
+#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067
+#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068
+#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069
+#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A
+#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B
+#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C
+#define GL_MAX_IMAGE_SAMPLES 0x906D
+#define GL_IMAGE_BINDING_FORMAT 0x906E
+#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7
+#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8
+#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9
+#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA
+#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB
+#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC
+#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD
+#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE
+#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF
+#endif
+
+#ifndef GL_ARB_shading_language_packing
+#endif
+
+#ifndef GL_ARB_texture_storage
+#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F
+#endif
+
+#ifndef GL_KHR_texture_compression_astc_ldr
+#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0
+#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1
+#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2
+#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3
+#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4
+#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5
+#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6
+#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7
+#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8
+#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9
+#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA
+#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB
+#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC
+#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD
+#endif
+
+#ifndef GL_KHR_debug
+#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242
+#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243
+#define GL_DEBUG_CALLBACK_FUNCTION 0x8244
+#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245
+#define GL_DEBUG_SOURCE_API 0x8246
+#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247
+#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248
+#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249
+#define GL_DEBUG_SOURCE_APPLICATION 0x824A
+#define GL_DEBUG_SOURCE_OTHER 0x824B
+#define GL_DEBUG_TYPE_ERROR 0x824C
+#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D
+#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E
+#define GL_DEBUG_TYPE_PORTABILITY 0x824F
+#define GL_DEBUG_TYPE_PERFORMANCE 0x8250
+#define GL_DEBUG_TYPE_OTHER 0x8251
+#define GL_DEBUG_TYPE_MARKER 0x8268
+#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269
+#define GL_DEBUG_TYPE_POP_GROUP 0x826A
+#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B
+#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C
+#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D
+#define GL_BUFFER 0x82E0
+#define GL_SHADER 0x82E1
+#define GL_PROGRAM 0x82E2
+#define GL_QUERY 0x82E3
+#define GL_PROGRAM_PIPELINE 0x82E4
+#define GL_SAMPLER 0x82E6
+#define GL_DISPLAY_LIST 0x82E7
+/* DISPLAY_LIST used in compatibility profile only */
+#define GL_MAX_LABEL_LENGTH 0x82E8
+#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143
+#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144
+#define GL_DEBUG_LOGGED_MESSAGES 0x9145
+#define GL_DEBUG_SEVERITY_HIGH 0x9146
+#define GL_DEBUG_SEVERITY_MEDIUM 0x9147
+#define GL_DEBUG_SEVERITY_LOW 0x9148
+#define GL_DEBUG_OUTPUT 0x92E0
+#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002
+/* reuse GL_STACK_UNDERFLOW */
+/* reuse GL_STACK_OVERFLOW */
+#endif
+
+#ifndef GL_ARB_arrays_of_arrays
+#endif
+
+#ifndef GL_ARB_clear_buffer_object
+#endif
+
+#ifndef GL_ARB_compute_shader
+#define GL_COMPUTE_SHADER 0x91B9
+#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB
+#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC
+#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD
+#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262
+#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263
+#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264
+#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265
+#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266
+#define GL_MAX_COMPUTE_LOCAL_INVOCATIONS 0x90EB
+#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE
+#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF
+#define GL_COMPUTE_LOCAL_WORK_SIZE 0x8267
+#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC
+#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED
+#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE
+#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF
+#define GL_COMPUTE_SHADER_BIT 0x00000020
+#endif
+
+#ifndef GL_ARB_copy_image
+#endif
+
+#ifndef GL_ARB_texture_view
+#define GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB
+#define GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC
+#define GL_TEXTURE_VIEW_MIN_LAYER 0x82DD
+#define GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE
+#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF
+#endif
+
+#ifndef GL_ARB_vertex_attrib_binding
+#define GL_VERTEX_ATTRIB_BINDING 0x82D4
+#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5
+#define GL_VERTEX_BINDING_DIVISOR 0x82D6
+#define GL_VERTEX_BINDING_OFFSET 0x82D7
+#define GL_VERTEX_BINDING_STRIDE 0x82D8
+#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9
+#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA
+#endif
+
+#ifndef GL_ARB_robustness_isolation
+#endif
+
+#ifndef GL_ARB_ES3_compatibility
+#define GL_COMPRESSED_RGB8_ETC2 0x9274
+#define GL_COMPRESSED_SRGB8_ETC2 0x9275
+#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276
+#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277
+#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278
+#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279
+#define GL_COMPRESSED_R11_EAC 0x9270
+#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271
+#define GL_COMPRESSED_RG11_EAC 0x9272
+#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273
+#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69
+#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A
+#define GL_MAX_ELEMENT_INDEX 0x8D6B
+#endif
+
+#ifndef GL_ARB_explicit_uniform_location
+#define GL_MAX_UNIFORM_LOCATIONS 0x826E
+#endif
+
+#ifndef GL_ARB_fragment_layer_viewport
+#endif
+
+#ifndef GL_ARB_framebuffer_no_attachments
+#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310
+#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311
+#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312
+#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313
+#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314
+#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315
+#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316
+#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317
+#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318
+#endif
+
+#ifndef GL_ARB_internalformat_query2
+/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_TYPE */
+/* reuse GL_NUM_SAMPLE_COUNTS */
+/* reuse GL_RENDERBUFFER */
+/* reuse GL_SAMPLES */
+/* reuse GL_TEXTURE_1D */
+/* reuse GL_TEXTURE_1D_ARRAY */
+/* reuse GL_TEXTURE_2D */
+/* reuse GL_TEXTURE_2D_ARRAY */
+/* reuse GL_TEXTURE_3D */
+/* reuse GL_TEXTURE_CUBE_MAP */
+/* reuse GL_TEXTURE_CUBE_MAP_ARRAY */
+/* reuse GL_TEXTURE_RECTANGLE */
+/* reuse GL_TEXTURE_BUFFER */
+/* reuse GL_TEXTURE_2D_MULTISAMPLE */
+/* reuse GL_TEXTURE_2D_MULTISAMPLE_ARRAY */
+/* reuse GL_TEXTURE_COMPRESSED */
+#define GL_INTERNALFORMAT_SUPPORTED 0x826F
+#define GL_INTERNALFORMAT_PREFERRED 0x8270
+#define GL_INTERNALFORMAT_RED_SIZE 0x8271
+#define GL_INTERNALFORMAT_GREEN_SIZE 0x8272
+#define GL_INTERNALFORMAT_BLUE_SIZE 0x8273
+#define GL_INTERNALFORMAT_ALPHA_SIZE 0x8274
+#define GL_INTERNALFORMAT_DEPTH_SIZE 0x8275
+#define GL_INTERNALFORMAT_STENCIL_SIZE 0x8276
+#define GL_INTERNALFORMAT_SHARED_SIZE 0x8277
+#define GL_INTERNALFORMAT_RED_TYPE 0x8278
+#define GL_INTERNALFORMAT_GREEN_TYPE 0x8279
+#define GL_INTERNALFORMAT_BLUE_TYPE 0x827A
+#define GL_INTERNALFORMAT_ALPHA_TYPE 0x827B
+#define GL_INTERNALFORMAT_DEPTH_TYPE 0x827C
+#define GL_INTERNALFORMAT_STENCIL_TYPE 0x827D
+#define GL_MAX_WIDTH 0x827E
+#define GL_MAX_HEIGHT 0x827F
+#define GL_MAX_DEPTH 0x8280
+#define GL_MAX_LAYERS 0x8281
+#define GL_MAX_COMBINED_DIMENSIONS 0x8282
+#define GL_COLOR_COMPONENTS 0x8283
+#define GL_DEPTH_COMPONENTS 0x8284
+#define GL_STENCIL_COMPONENTS 0x8285
+#define GL_COLOR_RENDERABLE 0x8286
+#define GL_DEPTH_RENDERABLE 0x8287
+#define GL_STENCIL_RENDERABLE 0x8288
+#define GL_FRAMEBUFFER_RENDERABLE 0x8289
+#define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A
+#define GL_FRAMEBUFFER_BLEND 0x828B
+#define GL_READ_PIXELS 0x828C
+#define GL_READ_PIXELS_FORMAT 0x828D
+#define GL_READ_PIXELS_TYPE 0x828E
+#define GL_TEXTURE_IMAGE_FORMAT 0x828F
+#define GL_TEXTURE_IMAGE_TYPE 0x8290
+#define GL_GET_TEXTURE_IMAGE_FORMAT 0x8291
+#define GL_GET_TEXTURE_IMAGE_TYPE 0x8292
+#define GL_MIPMAP 0x8293
+#define GL_MANUAL_GENERATE_MIPMAP 0x8294
+#define GL_AUTO_GENERATE_MIPMAP 0x8295
+#define GL_COLOR_ENCODING 0x8296
+#define GL_SRGB_READ 0x8297
+#define GL_SRGB_WRITE 0x8298
+#define GL_SRGB_DECODE_ARB 0x8299
+#define GL_FILTER 0x829A
+#define GL_VERTEX_TEXTURE 0x829B
+#define GL_TESS_CONTROL_TEXTURE 0x829C
+#define GL_TESS_EVALUATION_TEXTURE 0x829D
+#define GL_GEOMETRY_TEXTURE 0x829E
+#define GL_FRAGMENT_TEXTURE 0x829F
+#define GL_COMPUTE_TEXTURE 0x82A0
+#define GL_TEXTURE_SHADOW 0x82A1
+#define GL_TEXTURE_GATHER 0x82A2
+#define GL_TEXTURE_GATHER_SHADOW 0x82A3
+#define GL_SHADER_IMAGE_LOAD 0x82A4
+#define GL_SHADER_IMAGE_STORE 0x82A5
+#define GL_SHADER_IMAGE_ATOMIC 0x82A6
+#define GL_IMAGE_TEXEL_SIZE 0x82A7
+#define GL_IMAGE_COMPATIBILITY_CLASS 0x82A8
+#define GL_IMAGE_PIXEL_FORMAT 0x82A9
+#define GL_IMAGE_PIXEL_TYPE 0x82AA
+#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC
+#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD
+#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE
+#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF
+#define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1
+#define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2
+#define GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3
+#define GL_CLEAR_BUFFER 0x82B4
+#define GL_TEXTURE_VIEW 0x82B5
+#define GL_VIEW_COMPATIBILITY_CLASS 0x82B6
+#define GL_FULL_SUPPORT 0x82B7
+#define GL_CAVEAT_SUPPORT 0x82B8
+#define GL_IMAGE_CLASS_4_X_32 0x82B9
+#define GL_IMAGE_CLASS_2_X_32 0x82BA
+#define GL_IMAGE_CLASS_1_X_32 0x82BB
+#define GL_IMAGE_CLASS_4_X_16 0x82BC
+#define GL_IMAGE_CLASS_2_X_16 0x82BD
+#define GL_IMAGE_CLASS_1_X_16 0x82BE
+#define GL_IMAGE_CLASS_4_X_8 0x82BF
+#define GL_IMAGE_CLASS_2_X_8 0x82C0
+#define GL_IMAGE_CLASS_1_X_8 0x82C1
+#define GL_IMAGE_CLASS_11_11_10 0x82C2
+#define GL_IMAGE_CLASS_10_10_10_2 0x82C3
+#define GL_VIEW_CLASS_128_BITS 0x82C4
+#define GL_VIEW_CLASS_96_BITS 0x82C5
+#define GL_VIEW_CLASS_64_BITS 0x82C6
+#define GL_VIEW_CLASS_48_BITS 0x82C7
+#define GL_VIEW_CLASS_32_BITS 0x82C8
+#define GL_VIEW_CLASS_24_BITS 0x82C9
+#define GL_VIEW_CLASS_16_BITS 0x82CA
+#define GL_VIEW_CLASS_8_BITS 0x82CB
+#define GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC
+#define GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD
+#define GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE
+#define GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF
+#define GL_VIEW_CLASS_RGTC1_RED 0x82D0
+#define GL_VIEW_CLASS_RGTC2_RG 0x82D1
+#define GL_VIEW_CLASS_BPTC_UNORM 0x82D2
+#define GL_VIEW_CLASS_BPTC_FLOAT 0x82D3
+#endif
+
+#ifndef GL_ARB_invalidate_subdata
+#endif
+
+#ifndef GL_ARB_multi_draw_indirect
+#endif
+
+#ifndef GL_ARB_program_interface_query
+#define GL_UNIFORM 0x92E1
+#define GL_UNIFORM_BLOCK 0x92E2
+#define GL_PROGRAM_INPUT 0x92E3
+#define GL_PROGRAM_OUTPUT 0x92E4
+#define GL_BUFFER_VARIABLE 0x92E5
+#define GL_SHADER_STORAGE_BLOCK 0x92E6
+/* reuse GL_ATOMIC_COUNTER_BUFFER */
+#define GL_VERTEX_SUBROUTINE 0x92E8
+#define GL_TESS_CONTROL_SUBROUTINE 0x92E9
+#define GL_TESS_EVALUATION_SUBROUTINE 0x92EA
+#define GL_GEOMETRY_SUBROUTINE 0x92EB
+#define GL_FRAGMENT_SUBROUTINE 0x92EC
+#define GL_COMPUTE_SUBROUTINE 0x92ED
+#define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE
+#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF
+#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0
+#define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1
+#define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2
+#define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3
+#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4
+#define GL_ACTIVE_RESOURCES 0x92F5
+#define GL_MAX_NAME_LENGTH 0x92F6
+#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7
+#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8
+#define GL_NAME_LENGTH 0x92F9
+#define GL_TYPE 0x92FA
+#define GL_ARRAY_SIZE 0x92FB
+#define GL_OFFSET 0x92FC
+#define GL_BLOCK_INDEX 0x92FD
+#define GL_ARRAY_STRIDE 0x92FE
+#define GL_MATRIX_STRIDE 0x92FF
+#define GL_IS_ROW_MAJOR 0x9300
+#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301
+#define GL_BUFFER_BINDING 0x9302
+#define GL_BUFFER_DATA_SIZE 0x9303
+#define GL_NUM_ACTIVE_VARIABLES 0x9304
+#define GL_ACTIVE_VARIABLES 0x9305
+#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306
+#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307
+#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308
+#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309
+#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A
+#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B
+#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C
+#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D
+#define GL_LOCATION 0x930E
+#define GL_LOCATION_INDEX 0x930F
+#define GL_IS_PER_PATCH 0x92E7
+/* reuse GL_NUM_COMPATIBLE_SUBROUTINES */
+/* reuse GL_COMPATIBLE_SUBROUTINES */
+#endif
+
+#ifndef GL_ARB_robust_buffer_access_behavior
+#endif
+
+#ifndef GL_ARB_shader_image_size
+#endif
+
+#ifndef GL_ARB_shader_storage_buffer_object
+#define GL_SHADER_STORAGE_BUFFER 0x90D2
+#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3
+#define GL_SHADER_STORAGE_BUFFER_START 0x90D4
+#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5
+#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6
+#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7
+#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8
+#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9
+#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA
+#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB
+#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC
+#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD
+#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE
+#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF
+#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000
+#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39
+/* reuse GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS */
+#endif
+
+#ifndef GL_ARB_stencil_texturing
+#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA
+#endif
+
+#ifndef GL_ARB_texture_buffer_range
+#define GL_TEXTURE_BUFFER_OFFSET 0x919D
+#define GL_TEXTURE_BUFFER_SIZE 0x919E
+#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F
+#endif
+
+#ifndef GL_ARB_texture_query_levels
+#endif
+
+#ifndef GL_ARB_texture_storage_multisample
+#endif
+
+#ifndef GL_EXT_abgr
+#define GL_ABGR_EXT 0x8000
+#endif
+
+#ifndef GL_EXT_blend_color
+#define GL_CONSTANT_COLOR_EXT 0x8001
+#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002
+#define GL_CONSTANT_ALPHA_EXT 0x8003
+#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004
+#define GL_BLEND_COLOR_EXT 0x8005
+#endif
+
+#ifndef GL_EXT_polygon_offset
+#define GL_POLYGON_OFFSET_EXT 0x8037
+#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038
+#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039
+#endif
+
+#ifndef GL_EXT_texture
+#define GL_ALPHA4_EXT 0x803B
+#define GL_ALPHA8_EXT 0x803C
+#define GL_ALPHA12_EXT 0x803D
+#define GL_ALPHA16_EXT 0x803E
+#define GL_LUMINANCE4_EXT 0x803F
+#define GL_LUMINANCE8_EXT 0x8040
+#define GL_LUMINANCE12_EXT 0x8041
+#define GL_LUMINANCE16_EXT 0x8042
+#define GL_LUMINANCE4_ALPHA4_EXT 0x8043
+#define GL_LUMINANCE6_ALPHA2_EXT 0x8044
+#define GL_LUMINANCE8_ALPHA8_EXT 0x8045
+#define GL_LUMINANCE12_ALPHA4_EXT 0x8046
+#define GL_LUMINANCE12_ALPHA12_EXT 0x8047
+#define GL_LUMINANCE16_ALPHA16_EXT 0x8048
+#define GL_INTENSITY_EXT 0x8049
+#define GL_INTENSITY4_EXT 0x804A
+#define GL_INTENSITY8_EXT 0x804B
+#define GL_INTENSITY12_EXT 0x804C
+#define GL_INTENSITY16_EXT 0x804D
+#define GL_RGB2_EXT 0x804E
+#define GL_RGB4_EXT 0x804F
+#define GL_RGB5_EXT 0x8050
+#define GL_RGB8_EXT 0x8051
+#define GL_RGB10_EXT 0x8052
+#define GL_RGB12_EXT 0x8053
+#define GL_RGB16_EXT 0x8054
+#define GL_RGBA2_EXT 0x8055
+#define GL_RGBA4_EXT 0x8056
+#define GL_RGB5_A1_EXT 0x8057
+#define GL_RGBA8_EXT 0x8058
+#define GL_RGB10_A2_EXT 0x8059
+#define GL_RGBA12_EXT 0x805A
+#define GL_RGBA16_EXT 0x805B
+#define GL_TEXTURE_RED_SIZE_EXT 0x805C
+#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D
+#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E
+#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F
+#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060
+#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061
+#define GL_REPLACE_EXT 0x8062
+#define GL_PROXY_TEXTURE_1D_EXT 0x8063
+#define GL_PROXY_TEXTURE_2D_EXT 0x8064
+#define GL_TEXTURE_TOO_LARGE_EXT 0x8065
+#endif
+
+#ifndef GL_EXT_texture3D
+#define GL_PACK_SKIP_IMAGES_EXT 0x806B
+#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C
+#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D
+#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E
+#define GL_TEXTURE_3D_EXT 0x806F
+#define GL_PROXY_TEXTURE_3D_EXT 0x8070
+#define GL_TEXTURE_DEPTH_EXT 0x8071
+#define GL_TEXTURE_WRAP_R_EXT 0x8072
+#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073
+#endif
+
+#ifndef GL_SGIS_texture_filter4
+#define GL_FILTER4_SGIS 0x8146
+#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147
+#endif
+
+#ifndef GL_EXT_subtexture
+#endif
+
+#ifndef GL_EXT_copy_texture
+#endif
+
+#ifndef GL_EXT_histogram
+#define GL_HISTOGRAM_EXT 0x8024
+#define GL_PROXY_HISTOGRAM_EXT 0x8025
+#define GL_HISTOGRAM_WIDTH_EXT 0x8026
+#define GL_HISTOGRAM_FORMAT_EXT 0x8027
+#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028
+#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029
+#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A
+#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B
+#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C
+#define GL_HISTOGRAM_SINK_EXT 0x802D
+#define GL_MINMAX_EXT 0x802E
+#define GL_MINMAX_FORMAT_EXT 0x802F
+#define GL_MINMAX_SINK_EXT 0x8030
+#define GL_TABLE_TOO_LARGE_EXT 0x8031
+#endif
+
+#ifndef GL_EXT_convolution
+#define GL_CONVOLUTION_1D_EXT 0x8010
+#define GL_CONVOLUTION_2D_EXT 0x8011
+#define GL_SEPARABLE_2D_EXT 0x8012
+#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013
+#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014
+#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015
+#define GL_REDUCE_EXT 0x8016
+#define GL_CONVOLUTION_FORMAT_EXT 0x8017
+#define GL_CONVOLUTION_WIDTH_EXT 0x8018
+#define GL_CONVOLUTION_HEIGHT_EXT 0x8019
+#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A
+#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B
+#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C
+#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D
+#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E
+#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F
+#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020
+#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021
+#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022
+#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023
+#endif
+
+#ifndef GL_SGI_color_matrix
+#define GL_COLOR_MATRIX_SGI 0x80B1
+#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2
+#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3
+#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4
+#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5
+#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6
+#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7
+#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8
+#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9
+#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA
+#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB
+#endif
+
+#ifndef GL_SGI_color_table
+#define GL_COLOR_TABLE_SGI 0x80D0
+#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1
+#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2
+#define GL_PROXY_COLOR_TABLE_SGI 0x80D3
+#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4
+#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5
+#define GL_COLOR_TABLE_SCALE_SGI 0x80D6
+#define GL_COLOR_TABLE_BIAS_SGI 0x80D7
+#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8
+#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9
+#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA
+#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB
+#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC
+#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD
+#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE
+#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF
+#endif
+
+#ifndef GL_SGIS_pixel_texture
+#define GL_PIXEL_TEXTURE_SGIS 0x8353
+#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354
+#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355
+#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356
+#endif
+
+#ifndef GL_SGIX_pixel_texture
+#define GL_PIXEL_TEX_GEN_SGIX 0x8139
+#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B
+#endif
+
+#ifndef GL_SGIS_texture4D
+#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130
+#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131
+#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132
+#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133
+#define GL_TEXTURE_4D_SGIS 0x8134
+#define GL_PROXY_TEXTURE_4D_SGIS 0x8135
+#define GL_TEXTURE_4DSIZE_SGIS 0x8136
+#define GL_TEXTURE_WRAP_Q_SGIS 0x8137
+#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138
+#define GL_TEXTURE_4D_BINDING_SGIS 0x814F
+#endif
+
+#ifndef GL_SGI_texture_color_table
+#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC
+#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD
+#endif
+
+#ifndef GL_EXT_cmyka
+#define GL_CMYK_EXT 0x800C
+#define GL_CMYKA_EXT 0x800D
+#define GL_PACK_CMYK_HINT_EXT 0x800E
+#define GL_UNPACK_CMYK_HINT_EXT 0x800F
+#endif
+
+#ifndef GL_EXT_texture_object
+#define GL_TEXTURE_PRIORITY_EXT 0x8066
+#define GL_TEXTURE_RESIDENT_EXT 0x8067
+#define GL_TEXTURE_1D_BINDING_EXT 0x8068
+#define GL_TEXTURE_2D_BINDING_EXT 0x8069
+#define GL_TEXTURE_3D_BINDING_EXT 0x806A
+#endif
+
+#ifndef GL_SGIS_detail_texture
+#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095
+#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096
+#define GL_LINEAR_DETAIL_SGIS 0x8097
+#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098
+#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099
+#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A
+#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B
+#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C
+#endif
+
+#ifndef GL_SGIS_sharpen_texture
+#define GL_LINEAR_SHARPEN_SGIS 0x80AD
+#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE
+#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF
+#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0
+#endif
+
+#ifndef GL_EXT_packed_pixels
+#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032
+#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033
+#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034
+#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035
+#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036
+#endif
+
+#ifndef GL_SGIS_texture_lod
+#define GL_TEXTURE_MIN_LOD_SGIS 0x813A
+#define GL_TEXTURE_MAX_LOD_SGIS 0x813B
+#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C
+#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D
+#endif
+
+#ifndef GL_SGIS_multisample
+#define GL_MULTISAMPLE_SGIS 0x809D
+#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E
+#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F
+#define GL_SAMPLE_MASK_SGIS 0x80A0
+#define GL_1PASS_SGIS 0x80A1
+#define GL_2PASS_0_SGIS 0x80A2
+#define GL_2PASS_1_SGIS 0x80A3
+#define GL_4PASS_0_SGIS 0x80A4
+#define GL_4PASS_1_SGIS 0x80A5
+#define GL_4PASS_2_SGIS 0x80A6
+#define GL_4PASS_3_SGIS 0x80A7
+#define GL_SAMPLE_BUFFERS_SGIS 0x80A8
+#define GL_SAMPLES_SGIS 0x80A9
+#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA
+#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB
+#define GL_SAMPLE_PATTERN_SGIS 0x80AC
+#endif
+
+#ifndef GL_EXT_rescale_normal
+#define GL_RESCALE_NORMAL_EXT 0x803A
+#endif
+
+#ifndef GL_EXT_vertex_array
+#define GL_VERTEX_ARRAY_EXT 0x8074
+#define GL_NORMAL_ARRAY_EXT 0x8075
+#define GL_COLOR_ARRAY_EXT 0x8076
+#define GL_INDEX_ARRAY_EXT 0x8077
+#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078
+#define GL_EDGE_FLAG_ARRAY_EXT 0x8079
+#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A
+#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B
+#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C
+#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D
+#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E
+#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F
+#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080
+#define GL_COLOR_ARRAY_SIZE_EXT 0x8081
+#define GL_COLOR_ARRAY_TYPE_EXT 0x8082
+#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083
+#define GL_COLOR_ARRAY_COUNT_EXT 0x8084
+#define GL_INDEX_ARRAY_TYPE_EXT 0x8085
+#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086
+#define GL_INDEX_ARRAY_COUNT_EXT 0x8087
+#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088
+#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089
+#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A
+#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B
+#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C
+#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D
+#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E
+#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F
+#define GL_COLOR_ARRAY_POINTER_EXT 0x8090
+#define GL_INDEX_ARRAY_POINTER_EXT 0x8091
+#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092
+#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093
+#endif
+
+#ifndef GL_EXT_misc_attribute
+#endif
+
+#ifndef GL_SGIS_generate_mipmap
+#define GL_GENERATE_MIPMAP_SGIS 0x8191
+#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192
+#endif
+
+#ifndef GL_SGIX_clipmap
+#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170
+#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171
+#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172
+#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173
+#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174
+#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175
+#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176
+#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177
+#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178
+#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D
+#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E
+#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F
+#endif
+
+#ifndef GL_SGIX_shadow
+#define GL_TEXTURE_COMPARE_SGIX 0x819A
+#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B
+#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C
+#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D
+#endif
+
+#ifndef GL_SGIS_texture_edge_clamp
+#define GL_CLAMP_TO_EDGE_SGIS 0x812F
+#endif
+
+#ifndef GL_SGIS_texture_border_clamp
+#define GL_CLAMP_TO_BORDER_SGIS 0x812D
+#endif
+
+#ifndef GL_EXT_blend_minmax
+#define GL_FUNC_ADD_EXT 0x8006
+#define GL_MIN_EXT 0x8007
+#define GL_MAX_EXT 0x8008
+#define GL_BLEND_EQUATION_EXT 0x8009
+#endif
+
+#ifndef GL_EXT_blend_subtract
+#define GL_FUNC_SUBTRACT_EXT 0x800A
+#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B
+#endif
+
+#ifndef GL_EXT_blend_logic_op
+#endif
+
+#ifndef GL_SGIX_interlace
+#define GL_INTERLACE_SGIX 0x8094
+#endif
+
+#ifndef GL_SGIX_pixel_tiles
+#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E
+#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F
+#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140
+#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141
+#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142
+#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143
+#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144
+#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145
+#endif
+
+#ifndef GL_SGIS_texture_select
+#define GL_DUAL_ALPHA4_SGIS 0x8110
+#define GL_DUAL_ALPHA8_SGIS 0x8111
+#define GL_DUAL_ALPHA12_SGIS 0x8112
+#define GL_DUAL_ALPHA16_SGIS 0x8113
+#define GL_DUAL_LUMINANCE4_SGIS 0x8114
+#define GL_DUAL_LUMINANCE8_SGIS 0x8115
+#define GL_DUAL_LUMINANCE12_SGIS 0x8116
+#define GL_DUAL_LUMINANCE16_SGIS 0x8117
+#define GL_DUAL_INTENSITY4_SGIS 0x8118
+#define GL_DUAL_INTENSITY8_SGIS 0x8119
+#define GL_DUAL_INTENSITY12_SGIS 0x811A
+#define GL_DUAL_INTENSITY16_SGIS 0x811B
+#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C
+#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D
+#define GL_QUAD_ALPHA4_SGIS 0x811E
+#define GL_QUAD_ALPHA8_SGIS 0x811F
+#define GL_QUAD_LUMINANCE4_SGIS 0x8120
+#define GL_QUAD_LUMINANCE8_SGIS 0x8121
+#define GL_QUAD_INTENSITY4_SGIS 0x8122
+#define GL_QUAD_INTENSITY8_SGIS 0x8123
+#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124
+#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125
+#endif
+
+#ifndef GL_SGIX_sprite
+#define GL_SPRITE_SGIX 0x8148
+#define GL_SPRITE_MODE_SGIX 0x8149
+#define GL_SPRITE_AXIS_SGIX 0x814A
+#define GL_SPRITE_TRANSLATION_SGIX 0x814B
+#define GL_SPRITE_AXIAL_SGIX 0x814C
+#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D
+#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E
+#endif
+
+#ifndef GL_SGIX_texture_multi_buffer
+#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E
+#endif
+
+#ifndef GL_EXT_point_parameters
+#define GL_POINT_SIZE_MIN_EXT 0x8126
+#define GL_POINT_SIZE_MAX_EXT 0x8127
+#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128
+#define GL_DISTANCE_ATTENUATION_EXT 0x8129
+#endif
+
+#ifndef GL_SGIS_point_parameters
+#define GL_POINT_SIZE_MIN_SGIS 0x8126
+#define GL_POINT_SIZE_MAX_SGIS 0x8127
+#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128
+#define GL_DISTANCE_ATTENUATION_SGIS 0x8129
+#endif
+
+#ifndef GL_SGIX_instruments
+#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180
+#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181
+#endif
+
+#ifndef GL_SGIX_texture_scale_bias
+#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179
+#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A
+#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B
+#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C
+#endif
+
+#ifndef GL_SGIX_framezoom
+#define GL_FRAMEZOOM_SGIX 0x818B
+#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C
+#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D
+#endif
+
+#ifndef GL_SGIX_tag_sample_buffer
+#endif
+
+#ifndef GL_SGIX_polynomial_ffd
+#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001
+#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002
+#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194
+#define GL_TEXTURE_DEFORMATION_SGIX 0x8195
+#define GL_DEFORMATIONS_MASK_SGIX 0x8196
+#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197
+#endif
+
+#ifndef GL_SGIX_reference_plane
+#define GL_REFERENCE_PLANE_SGIX 0x817D
+#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E
+#endif
+
+#ifndef GL_SGIX_flush_raster
+#endif
+
+#ifndef GL_SGIX_depth_texture
+#define GL_DEPTH_COMPONENT16_SGIX 0x81A5
+#define GL_DEPTH_COMPONENT24_SGIX 0x81A6
+#define GL_DEPTH_COMPONENT32_SGIX 0x81A7
+#endif
+
+#ifndef GL_SGIS_fog_function
+#define GL_FOG_FUNC_SGIS 0x812A
+#define GL_FOG_FUNC_POINTS_SGIS 0x812B
+#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C
+#endif
+
+#ifndef GL_SGIX_fog_offset
+#define GL_FOG_OFFSET_SGIX 0x8198
+#define GL_FOG_OFFSET_VALUE_SGIX 0x8199
+#endif
+
+#ifndef GL_HP_image_transform
+#define GL_IMAGE_SCALE_X_HP 0x8155
+#define GL_IMAGE_SCALE_Y_HP 0x8156
+#define GL_IMAGE_TRANSLATE_X_HP 0x8157
+#define GL_IMAGE_TRANSLATE_Y_HP 0x8158
+#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159
+#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A
+#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B
+#define GL_IMAGE_MAG_FILTER_HP 0x815C
+#define GL_IMAGE_MIN_FILTER_HP 0x815D
+#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E
+#define GL_CUBIC_HP 0x815F
+#define GL_AVERAGE_HP 0x8160
+#define GL_IMAGE_TRANSFORM_2D_HP 0x8161
+#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162
+#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163
+#endif
+
+#ifndef GL_HP_convolution_border_modes
+#define GL_IGNORE_BORDER_HP 0x8150
+#define GL_CONSTANT_BORDER_HP 0x8151
+#define GL_REPLICATE_BORDER_HP 0x8153
+#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154
+#endif
+
+#ifndef GL_INGR_palette_buffer
+#endif
+
+#ifndef GL_SGIX_texture_add_env
+#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE
+#endif
+
+#ifndef GL_EXT_color_subtable
+#endif
+
+#ifndef GL_PGI_vertex_hints
+#define GL_VERTEX_DATA_HINT_PGI 0x1A22A
+#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B
+#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C
+#define GL_MAX_VERTEX_HINT_PGI 0x1A22D
+#define GL_VERTEX23_BIT_PGI 0x00000004
+#define GL_VERTEX4_BIT_PGI 0x00000008
+#define GL_COLOR3_BIT_PGI 0x00010000
+#define GL_COLOR4_BIT_PGI 0x00020000
+#define GL_EDGEFLAG_BIT_PGI 0x00040000
+#define GL_INDEX_BIT_PGI 0x00080000
+#define GL_MAT_AMBIENT_BIT_PGI 0x00100000
+#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000
+#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000
+#define GL_MAT_EMISSION_BIT_PGI 0x00800000
+#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000
+#define GL_MAT_SHININESS_BIT_PGI 0x02000000
+#define GL_MAT_SPECULAR_BIT_PGI 0x04000000
+#define GL_NORMAL_BIT_PGI 0x08000000
+#define GL_TEXCOORD1_BIT_PGI 0x10000000
+#define GL_TEXCOORD2_BIT_PGI 0x20000000
+#define GL_TEXCOORD3_BIT_PGI 0x40000000
+#define GL_TEXCOORD4_BIT_PGI 0x80000000
+#endif
+
+#ifndef GL_PGI_misc_hints
+#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8
+#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD
+#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE
+#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202
+#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203
+#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204
+#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C
+#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D
+#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E
+#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F
+#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210
+#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211
+#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216
+#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217
+#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218
+#define GL_FULL_STIPPLE_HINT_PGI 0x1A219
+#define GL_CLIP_NEAR_HINT_PGI 0x1A220
+#define GL_CLIP_FAR_HINT_PGI 0x1A221
+#define GL_WIDE_LINE_HINT_PGI 0x1A222
+#define GL_BACK_NORMALS_HINT_PGI 0x1A223
+#endif
+
+#ifndef GL_EXT_paletted_texture
+#define GL_COLOR_INDEX1_EXT 0x80E2
+#define GL_COLOR_INDEX2_EXT 0x80E3
+#define GL_COLOR_INDEX4_EXT 0x80E4
+#define GL_COLOR_INDEX8_EXT 0x80E5
+#define GL_COLOR_INDEX12_EXT 0x80E6
+#define GL_COLOR_INDEX16_EXT 0x80E7
+#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED
+#endif
+
+#ifndef GL_EXT_clip_volume_hint
+#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0
+#endif
+
+#ifndef GL_SGIX_list_priority
+#define GL_LIST_PRIORITY_SGIX 0x8182
+#endif
+
+#ifndef GL_SGIX_ir_instrument1
+#define GL_IR_INSTRUMENT1_SGIX 0x817F
+#endif
+
+#ifndef GL_SGIX_calligraphic_fragment
+#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183
+#endif
+
+#ifndef GL_SGIX_texture_lod_bias
+#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E
+#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F
+#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190
+#endif
+
+#ifndef GL_SGIX_shadow_ambient
+#define GL_SHADOW_AMBIENT_SGIX 0x80BF
+#endif
+
+#ifndef GL_EXT_index_texture
+#endif
+
+#ifndef GL_EXT_index_material
+#define GL_INDEX_MATERIAL_EXT 0x81B8
+#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9
+#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA
+#endif
+
+#ifndef GL_EXT_index_func
+#define GL_INDEX_TEST_EXT 0x81B5
+#define GL_INDEX_TEST_FUNC_EXT 0x81B6
+#define GL_INDEX_TEST_REF_EXT 0x81B7
+#endif
+
+#ifndef GL_EXT_index_array_formats
+#define GL_IUI_V2F_EXT 0x81AD
+#define GL_IUI_V3F_EXT 0x81AE
+#define GL_IUI_N3F_V2F_EXT 0x81AF
+#define GL_IUI_N3F_V3F_EXT 0x81B0
+#define GL_T2F_IUI_V2F_EXT 0x81B1
+#define GL_T2F_IUI_V3F_EXT 0x81B2
+#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3
+#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4
+#endif
+
+#ifndef GL_EXT_compiled_vertex_array
+#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8
+#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9
+#endif
+
+#ifndef GL_EXT_cull_vertex
+#define GL_CULL_VERTEX_EXT 0x81AA
+#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB
+#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC
+#endif
+
+#ifndef GL_SGIX_ycrcb
+#define GL_YCRCB_422_SGIX 0x81BB
+#define GL_YCRCB_444_SGIX 0x81BC
+#endif
+
+#ifndef GL_SGIX_fragment_lighting
+#define GL_FRAGMENT_LIGHTING_SGIX 0x8400
+#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401
+#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402
+#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403
+#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404
+#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405
+#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406
+#define GL_LIGHT_ENV_MODE_SGIX 0x8407
+#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408
+#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409
+#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A
+#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B
+#define GL_FRAGMENT_LIGHT0_SGIX 0x840C
+#define GL_FRAGMENT_LIGHT1_SGIX 0x840D
+#define GL_FRAGMENT_LIGHT2_SGIX 0x840E
+#define GL_FRAGMENT_LIGHT3_SGIX 0x840F
+#define GL_FRAGMENT_LIGHT4_SGIX 0x8410
+#define GL_FRAGMENT_LIGHT5_SGIX 0x8411
+#define GL_FRAGMENT_LIGHT6_SGIX 0x8412
+#define GL_FRAGMENT_LIGHT7_SGIX 0x8413
+#endif
+
+#ifndef GL_IBM_rasterpos_clip
+#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262
+#endif
+
+#ifndef GL_HP_texture_lighting
+#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167
+#define GL_TEXTURE_POST_SPECULAR_HP 0x8168
+#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169
+#endif
+
+#ifndef GL_EXT_draw_range_elements
+#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8
+#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9
+#endif
+
+#ifndef GL_WIN_phong_shading
+#define GL_PHONG_WIN 0x80EA
+#define GL_PHONG_HINT_WIN 0x80EB
+#endif
+
+#ifndef GL_WIN_specular_fog
+#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC
+#endif
+
+#ifndef GL_EXT_light_texture
+#define GL_FRAGMENT_MATERIAL_EXT 0x8349
+#define GL_FRAGMENT_NORMAL_EXT 0x834A
+#define GL_FRAGMENT_COLOR_EXT 0x834C
+#define GL_ATTENUATION_EXT 0x834D
+#define GL_SHADOW_ATTENUATION_EXT 0x834E
+#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F
+#define GL_TEXTURE_LIGHT_EXT 0x8350
+#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351
+#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352
+/* reuse GL_FRAGMENT_DEPTH_EXT */
+#endif
+
+#ifndef GL_SGIX_blend_alpha_minmax
+#define GL_ALPHA_MIN_SGIX 0x8320
+#define GL_ALPHA_MAX_SGIX 0x8321
+#endif
+
+#ifndef GL_EXT_bgra
+#define GL_BGR_EXT 0x80E0
+#define GL_BGRA_EXT 0x80E1
+#endif
+
+#ifndef GL_SGIX_async
+#define GL_ASYNC_MARKER_SGIX 0x8329
+#endif
+
+#ifndef GL_SGIX_async_pixel
+#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C
+#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D
+#define GL_ASYNC_READ_PIXELS_SGIX 0x835E
+#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F
+#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360
+#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361
+#endif
+
+#ifndef GL_SGIX_async_histogram
+#define GL_ASYNC_HISTOGRAM_SGIX 0x832C
+#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D
+#endif
+
+#ifndef GL_INTEL_texture_scissor
+#endif
+
+#ifndef GL_INTEL_parallel_arrays
+#define GL_PARALLEL_ARRAYS_INTEL 0x83F4
+#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5
+#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6
+#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7
+#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8
+#endif
+
+#ifndef GL_HP_occlusion_test
+#define GL_OCCLUSION_TEST_HP 0x8165
+#define GL_OCCLUSION_TEST_RESULT_HP 0x8166
+#endif
+
+#ifndef GL_EXT_pixel_transform
+#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330
+#define GL_PIXEL_MAG_FILTER_EXT 0x8331
+#define GL_PIXEL_MIN_FILTER_EXT 0x8332
+#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333
+#define GL_CUBIC_EXT 0x8334
+#define GL_AVERAGE_EXT 0x8335
+#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336
+#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337
+#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338
+#endif
+
+#ifndef GL_EXT_pixel_transform_color_table
+#endif
+
+#ifndef GL_EXT_shared_texture_palette
+#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB
+#endif
+
+#ifndef GL_EXT_separate_specular_color
+#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8
+#define GL_SINGLE_COLOR_EXT 0x81F9
+#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA
+#endif
+
+#ifndef GL_EXT_secondary_color
+#define GL_COLOR_SUM_EXT 0x8458
+#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459
+#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A
+#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B
+#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C
+#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D
+#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E
+#endif
+
+#ifndef GL_EXT_texture_perturb_normal
+#define GL_PERTURB_EXT 0x85AE
+#define GL_TEXTURE_NORMAL_EXT 0x85AF
+#endif
+
+#ifndef GL_EXT_multi_draw_arrays
+#endif
+
+#ifndef GL_EXT_fog_coord
+#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450
+#define GL_FOG_COORDINATE_EXT 0x8451
+#define GL_FRAGMENT_DEPTH_EXT 0x8452
+#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453
+#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454
+#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455
+#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456
+#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457
+#endif
+
+#ifndef GL_REND_screen_coordinates
+#define GL_SCREEN_COORDINATES_REND 0x8490
+#define GL_INVERTED_SCREEN_W_REND 0x8491
+#endif
+
+#ifndef GL_EXT_coordinate_frame
+#define GL_TANGENT_ARRAY_EXT 0x8439
+#define GL_BINORMAL_ARRAY_EXT 0x843A
+#define GL_CURRENT_TANGENT_EXT 0x843B
+#define GL_CURRENT_BINORMAL_EXT 0x843C
+#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E
+#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F
+#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440
+#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441
+#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442
+#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443
+#define GL_MAP1_TANGENT_EXT 0x8444
+#define GL_MAP2_TANGENT_EXT 0x8445
+#define GL_MAP1_BINORMAL_EXT 0x8446
+#define GL_MAP2_BINORMAL_EXT 0x8447
+#endif
+
+#ifndef GL_EXT_texture_env_combine
+#define GL_COMBINE_EXT 0x8570
+#define GL_COMBINE_RGB_EXT 0x8571
+#define GL_COMBINE_ALPHA_EXT 0x8572
+#define GL_RGB_SCALE_EXT 0x8573
+#define GL_ADD_SIGNED_EXT 0x8574
+#define GL_INTERPOLATE_EXT 0x8575
+#define GL_CONSTANT_EXT 0x8576
+#define GL_PRIMARY_COLOR_EXT 0x8577
+#define GL_PREVIOUS_EXT 0x8578
+#define GL_SOURCE0_RGB_EXT 0x8580
+#define GL_SOURCE1_RGB_EXT 0x8581
+#define GL_SOURCE2_RGB_EXT 0x8582
+#define GL_SOURCE0_ALPHA_EXT 0x8588
+#define GL_SOURCE1_ALPHA_EXT 0x8589
+#define GL_SOURCE2_ALPHA_EXT 0x858A
+#define GL_OPERAND0_RGB_EXT 0x8590
+#define GL_OPERAND1_RGB_EXT 0x8591
+#define GL_OPERAND2_RGB_EXT 0x8592
+#define GL_OPERAND0_ALPHA_EXT 0x8598
+#define GL_OPERAND1_ALPHA_EXT 0x8599
+#define GL_OPERAND2_ALPHA_EXT 0x859A
+#endif
+
+#ifndef GL_APPLE_specular_vector
+#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0
+#endif
+
+#ifndef GL_APPLE_transform_hint
+#define GL_TRANSFORM_HINT_APPLE 0x85B1
+#endif
+
+#ifndef GL_SUNX_constant_data
+#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5
+#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6
+#endif
+
+#ifndef GL_SUN_global_alpha
+#define GL_GLOBAL_ALPHA_SUN 0x81D9
+#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA
+#endif
+
+#ifndef GL_SUN_triangle_list
+#define GL_RESTART_SUN 0x0001
+#define GL_REPLACE_MIDDLE_SUN 0x0002
+#define GL_REPLACE_OLDEST_SUN 0x0003
+#define GL_TRIANGLE_LIST_SUN 0x81D7
+#define GL_REPLACEMENT_CODE_SUN 0x81D8
+#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0
+#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1
+#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2
+#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3
+#define GL_R1UI_V3F_SUN 0x85C4
+#define GL_R1UI_C4UB_V3F_SUN 0x85C5
+#define GL_R1UI_C3F_V3F_SUN 0x85C6
+#define GL_R1UI_N3F_V3F_SUN 0x85C7
+#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8
+#define GL_R1UI_T2F_V3F_SUN 0x85C9
+#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA
+#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB
+#endif
+
+#ifndef GL_SUN_vertex
+#endif
+
+#ifndef GL_EXT_blend_func_separate
+#define GL_BLEND_DST_RGB_EXT 0x80C8
+#define GL_BLEND_SRC_RGB_EXT 0x80C9
+#define GL_BLEND_DST_ALPHA_EXT 0x80CA
+#define GL_BLEND_SRC_ALPHA_EXT 0x80CB
+#endif
+
+#ifndef GL_INGR_color_clamp
+#define GL_RED_MIN_CLAMP_INGR 0x8560
+#define GL_GREEN_MIN_CLAMP_INGR 0x8561
+#define GL_BLUE_MIN_CLAMP_INGR 0x8562
+#define GL_ALPHA_MIN_CLAMP_INGR 0x8563
+#define GL_RED_MAX_CLAMP_INGR 0x8564
+#define GL_GREEN_MAX_CLAMP_INGR 0x8565
+#define GL_BLUE_MAX_CLAMP_INGR 0x8566
+#define GL_ALPHA_MAX_CLAMP_INGR 0x8567
+#endif
+
+#ifndef GL_INGR_interlace_read
+#define GL_INTERLACE_READ_INGR 0x8568
+#endif
+
+#ifndef GL_EXT_stencil_wrap
+#define GL_INCR_WRAP_EXT 0x8507
+#define GL_DECR_WRAP_EXT 0x8508
+#endif
+
+#ifndef GL_EXT_422_pixels
+#define GL_422_EXT 0x80CC
+#define GL_422_REV_EXT 0x80CD
+#define GL_422_AVERAGE_EXT 0x80CE
+#define GL_422_REV_AVERAGE_EXT 0x80CF
+#endif
+
+#ifndef GL_NV_texgen_reflection
+#define GL_NORMAL_MAP_NV 0x8511
+#define GL_REFLECTION_MAP_NV 0x8512
+#endif
+
+#ifndef GL_EXT_texture_cube_map
+#define GL_NORMAL_MAP_EXT 0x8511
+#define GL_REFLECTION_MAP_EXT 0x8512
+#define GL_TEXTURE_CUBE_MAP_EXT 0x8513
+#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A
+#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B
+#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C
+#endif
+
+#ifndef GL_SUN_convolution_border_modes
+#define GL_WRAP_BORDER_SUN 0x81D4
+#endif
+
+#ifndef GL_EXT_texture_env_add
+#endif
+
+#ifndef GL_EXT_texture_lod_bias
+#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD
+#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500
+#define GL_TEXTURE_LOD_BIAS_EXT 0x8501
+#endif
+
+#ifndef GL_EXT_texture_filter_anisotropic
+#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
+#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
+#endif
+
+#ifndef GL_EXT_vertex_weighting
+#define GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3
+#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502
+#define GL_MODELVIEW0_MATRIX_EXT 0x0BA6
+#define GL_MODELVIEW1_MATRIX_EXT 0x8506
+#define GL_VERTEX_WEIGHTING_EXT 0x8509
+#define GL_MODELVIEW0_EXT 0x1700
+#define GL_MODELVIEW1_EXT 0x850A
+#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B
+#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C
+#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D
+#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E
+#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F
+#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510
+#endif
+
+#ifndef GL_NV_light_max_exponent
+#define GL_MAX_SHININESS_NV 0x8504
+#define GL_MAX_SPOT_EXPONENT_NV 0x8505
+#endif
+
+#ifndef GL_NV_vertex_array_range
+#define GL_VERTEX_ARRAY_RANGE_NV 0x851D
+#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E
+#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F
+#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520
+#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521
+#endif
+
+#ifndef GL_NV_register_combiners
+#define GL_REGISTER_COMBINERS_NV 0x8522
+#define GL_VARIABLE_A_NV 0x8523
+#define GL_VARIABLE_B_NV 0x8524
+#define GL_VARIABLE_C_NV 0x8525
+#define GL_VARIABLE_D_NV 0x8526
+#define GL_VARIABLE_E_NV 0x8527
+#define GL_VARIABLE_F_NV 0x8528
+#define GL_VARIABLE_G_NV 0x8529
+#define GL_CONSTANT_COLOR0_NV 0x852A
+#define GL_CONSTANT_COLOR1_NV 0x852B
+#define GL_PRIMARY_COLOR_NV 0x852C
+#define GL_SECONDARY_COLOR_NV 0x852D
+#define GL_SPARE0_NV 0x852E
+#define GL_SPARE1_NV 0x852F
+#define GL_DISCARD_NV 0x8530
+#define GL_E_TIMES_F_NV 0x8531
+#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532
+#define GL_UNSIGNED_IDENTITY_NV 0x8536
+#define GL_UNSIGNED_INVERT_NV 0x8537
+#define GL_EXPAND_NORMAL_NV 0x8538
+#define GL_EXPAND_NEGATE_NV 0x8539
+#define GL_HALF_BIAS_NORMAL_NV 0x853A
+#define GL_HALF_BIAS_NEGATE_NV 0x853B
+#define GL_SIGNED_IDENTITY_NV 0x853C
+#define GL_SIGNED_NEGATE_NV 0x853D
+#define GL_SCALE_BY_TWO_NV 0x853E
+#define GL_SCALE_BY_FOUR_NV 0x853F
+#define GL_SCALE_BY_ONE_HALF_NV 0x8540
+#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541
+#define GL_COMBINER_INPUT_NV 0x8542
+#define GL_COMBINER_MAPPING_NV 0x8543
+#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544
+#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545
+#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546
+#define GL_COMBINER_MUX_SUM_NV 0x8547
+#define GL_COMBINER_SCALE_NV 0x8548
+#define GL_COMBINER_BIAS_NV 0x8549
+#define GL_COMBINER_AB_OUTPUT_NV 0x854A
+#define GL_COMBINER_CD_OUTPUT_NV 0x854B
+#define GL_COMBINER_SUM_OUTPUT_NV 0x854C
+#define GL_MAX_GENERAL_COMBINERS_NV 0x854D
+#define GL_NUM_GENERAL_COMBINERS_NV 0x854E
+#define GL_COLOR_SUM_CLAMP_NV 0x854F
+#define GL_COMBINER0_NV 0x8550
+#define GL_COMBINER1_NV 0x8551
+#define GL_COMBINER2_NV 0x8552
+#define GL_COMBINER3_NV 0x8553
+#define GL_COMBINER4_NV 0x8554
+#define GL_COMBINER5_NV 0x8555
+#define GL_COMBINER6_NV 0x8556
+#define GL_COMBINER7_NV 0x8557
+/* reuse GL_TEXTURE0_ARB */
+/* reuse GL_TEXTURE1_ARB */
+/* reuse GL_ZERO */
+/* reuse GL_NONE */
+/* reuse GL_FOG */
+#endif
+
+#ifndef GL_NV_fog_distance
+#define GL_FOG_DISTANCE_MODE_NV 0x855A
+#define GL_EYE_RADIAL_NV 0x855B
+#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C
+/* reuse GL_EYE_PLANE */
+#endif
+
+#ifndef GL_NV_texgen_emboss
+#define GL_EMBOSS_LIGHT_NV 0x855D
+#define GL_EMBOSS_CONSTANT_NV 0x855E
+#define GL_EMBOSS_MAP_NV 0x855F
+#endif
+
+#ifndef GL_NV_blend_square
+#endif
+
+#ifndef GL_NV_texture_env_combine4
+#define GL_COMBINE4_NV 0x8503
+#define GL_SOURCE3_RGB_NV 0x8583
+#define GL_SOURCE3_ALPHA_NV 0x858B
+#define GL_OPERAND3_RGB_NV 0x8593
+#define GL_OPERAND3_ALPHA_NV 0x859B
+#endif
+
+#ifndef GL_MESA_resize_buffers
+#endif
+
+#ifndef GL_MESA_window_pos
+#endif
+
+#ifndef GL_EXT_texture_compression_s3tc
+#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
+#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
+#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
+#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
+#endif
+
+#ifndef GL_IBM_cull_vertex
+#define GL_CULL_VERTEX_IBM 103050
+#endif
+
+#ifndef GL_IBM_multimode_draw_arrays
+#endif
+
+#ifndef GL_IBM_vertex_array_lists
+#define GL_VERTEX_ARRAY_LIST_IBM 103070
+#define GL_NORMAL_ARRAY_LIST_IBM 103071
+#define GL_COLOR_ARRAY_LIST_IBM 103072
+#define GL_INDEX_ARRAY_LIST_IBM 103073
+#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074
+#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075
+#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076
+#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077
+#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080
+#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081
+#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082
+#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083
+#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084
+#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085
+#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086
+#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087
+#endif
+
+#ifndef GL_SGIX_subsample
+#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0
+#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1
+#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2
+#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3
+#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4
+#endif
+
+#ifndef GL_SGIX_ycrcb_subsample
+#endif
+
+#ifndef GL_SGIX_ycrcba
+#define GL_YCRCB_SGIX 0x8318
+#define GL_YCRCBA_SGIX 0x8319
+#endif
+
+#ifndef GL_3DFX_texture_compression_FXT1
+#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0
+#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1
+#endif
+
+#ifndef GL_3DFX_multisample
+#define GL_MULTISAMPLE_3DFX 0x86B2
+#define GL_SAMPLE_BUFFERS_3DFX 0x86B3
+#define GL_SAMPLES_3DFX 0x86B4
+#define GL_MULTISAMPLE_BIT_3DFX 0x20000000
+#endif
+
+#ifndef GL_3DFX_tbuffer
+#endif
+
+#ifndef GL_EXT_multisample
+#define GL_MULTISAMPLE_EXT 0x809D
+#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E
+#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F
+#define GL_SAMPLE_MASK_EXT 0x80A0
+#define GL_1PASS_EXT 0x80A1
+#define GL_2PASS_0_EXT 0x80A2
+#define GL_2PASS_1_EXT 0x80A3
+#define GL_4PASS_0_EXT 0x80A4
+#define GL_4PASS_1_EXT 0x80A5
+#define GL_4PASS_2_EXT 0x80A6
+#define GL_4PASS_3_EXT 0x80A7
+#define GL_SAMPLE_BUFFERS_EXT 0x80A8
+#define GL_SAMPLES_EXT 0x80A9
+#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA
+#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB
+#define GL_SAMPLE_PATTERN_EXT 0x80AC
+#define GL_MULTISAMPLE_BIT_EXT 0x20000000
+#endif
+
+#ifndef GL_SGIX_vertex_preclip
+#define GL_VERTEX_PRECLIP_SGIX 0x83EE
+#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF
+#endif
+
+#ifndef GL_SGIX_convolution_accuracy
+#define GL_CONVOLUTION_HINT_SGIX 0x8316
+#endif
+
+#ifndef GL_SGIX_resample
+#define GL_PACK_RESAMPLE_SGIX 0x842C
+#define GL_UNPACK_RESAMPLE_SGIX 0x842D
+#define GL_RESAMPLE_REPLICATE_SGIX 0x842E
+#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F
+#define GL_RESAMPLE_DECIMATE_SGIX 0x8430
+#endif
+
+#ifndef GL_SGIS_point_line_texgen
+#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0
+#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1
+#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2
+#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3
+#define GL_EYE_POINT_SGIS 0x81F4
+#define GL_OBJECT_POINT_SGIS 0x81F5
+#define GL_EYE_LINE_SGIS 0x81F6
+#define GL_OBJECT_LINE_SGIS 0x81F7
+#endif
+
+#ifndef GL_SGIS_texture_color_mask
+#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF
+#endif
+
+#ifndef GL_EXT_texture_env_dot3
+#define GL_DOT3_RGB_EXT 0x8740
+#define GL_DOT3_RGBA_EXT 0x8741
+#endif
+
+#ifndef GL_ATI_texture_mirror_once
+#define GL_MIRROR_CLAMP_ATI 0x8742
+#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743
+#endif
+
+#ifndef GL_NV_fence
+#define GL_ALL_COMPLETED_NV 0x84F2
+#define GL_FENCE_STATUS_NV 0x84F3
+#define GL_FENCE_CONDITION_NV 0x84F4
+#endif
+
+#ifndef GL_IBM_static_data
+#define GL_ALL_STATIC_DATA_IBM 103060
+#define GL_STATIC_VERTEX_ARRAY_IBM 103061
+#endif
+
+#ifndef GL_IBM_texture_mirrored_repeat
+#define GL_MIRRORED_REPEAT_IBM 0x8370
+#endif
+
+#ifndef GL_NV_evaluators
+#define GL_EVAL_2D_NV 0x86C0
+#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1
+#define GL_MAP_TESSELLATION_NV 0x86C2
+#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3
+#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4
+#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5
+#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6
+#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7
+#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8
+#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9
+#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA
+#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB
+#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC
+#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD
+#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE
+#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF
+#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0
+#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1
+#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2
+#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3
+#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4
+#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5
+#define GL_MAX_MAP_TESSELLATION_NV 0x86D6
+#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7
+#endif
+
+#ifndef GL_NV_packed_depth_stencil
+#define GL_DEPTH_STENCIL_NV 0x84F9
+#define GL_UNSIGNED_INT_24_8_NV 0x84FA
+#endif
+
+#ifndef GL_NV_register_combiners2
+#define GL_PER_STAGE_CONSTANTS_NV 0x8535
+#endif
+
+#ifndef GL_NV_texture_compression_vtc
+#endif
+
+#ifndef GL_NV_texture_rectangle
+#define GL_TEXTURE_RECTANGLE_NV 0x84F5
+#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6
+#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7
+#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8
+#endif
+
+#ifndef GL_NV_texture_shader
+#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C
+#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D
+#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E
+#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9
+#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA
+#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB
+#define GL_DSDT_MAG_INTENSITY_NV 0x86DC
+#define GL_SHADER_CONSISTENT_NV 0x86DD
+#define GL_TEXTURE_SHADER_NV 0x86DE
+#define GL_SHADER_OPERATION_NV 0x86DF
+#define GL_CULL_MODES_NV 0x86E0
+#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1
+#define GL_OFFSET_TEXTURE_2D_MATRIX_NV 0x86E1
+#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2
+#define GL_OFFSET_TEXTURE_2D_SCALE_NV 0x86E2
+#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3
+#define GL_OFFSET_TEXTURE_2D_BIAS_NV 0x86E3
+#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4
+#define GL_CONST_EYE_NV 0x86E5
+#define GL_PASS_THROUGH_NV 0x86E6
+#define GL_CULL_FRAGMENT_NV 0x86E7
+#define GL_OFFSET_TEXTURE_2D_NV 0x86E8
+#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9
+#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA
+#define GL_DOT_PRODUCT_NV 0x86EC
+#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED
+#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE
+#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0
+#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1
+#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2
+#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3
+#define GL_HILO_NV 0x86F4
+#define GL_DSDT_NV 0x86F5
+#define GL_DSDT_MAG_NV 0x86F6
+#define GL_DSDT_MAG_VIB_NV 0x86F7
+#define GL_HILO16_NV 0x86F8
+#define GL_SIGNED_HILO_NV 0x86F9
+#define GL_SIGNED_HILO16_NV 0x86FA
+#define GL_SIGNED_RGBA_NV 0x86FB
+#define GL_SIGNED_RGBA8_NV 0x86FC
+#define GL_SIGNED_RGB_NV 0x86FE
+#define GL_SIGNED_RGB8_NV 0x86FF
+#define GL_SIGNED_LUMINANCE_NV 0x8701
+#define GL_SIGNED_LUMINANCE8_NV 0x8702
+#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703
+#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704
+#define GL_SIGNED_ALPHA_NV 0x8705
+#define GL_SIGNED_ALPHA8_NV 0x8706
+#define GL_SIGNED_INTENSITY_NV 0x8707
+#define GL_SIGNED_INTENSITY8_NV 0x8708
+#define GL_DSDT8_NV 0x8709
+#define GL_DSDT8_MAG8_NV 0x870A
+#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B
+#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C
+#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D
+#define GL_HI_SCALE_NV 0x870E
+#define GL_LO_SCALE_NV 0x870F
+#define GL_DS_SCALE_NV 0x8710
+#define GL_DT_SCALE_NV 0x8711
+#define GL_MAGNITUDE_SCALE_NV 0x8712
+#define GL_VIBRANCE_SCALE_NV 0x8713
+#define GL_HI_BIAS_NV 0x8714
+#define GL_LO_BIAS_NV 0x8715
+#define GL_DS_BIAS_NV 0x8716
+#define GL_DT_BIAS_NV 0x8717
+#define GL_MAGNITUDE_BIAS_NV 0x8718
+#define GL_VIBRANCE_BIAS_NV 0x8719
+#define GL_TEXTURE_BORDER_VALUES_NV 0x871A
+#define GL_TEXTURE_HI_SIZE_NV 0x871B
+#define GL_TEXTURE_LO_SIZE_NV 0x871C
+#define GL_TEXTURE_DS_SIZE_NV 0x871D
+#define GL_TEXTURE_DT_SIZE_NV 0x871E
+#define GL_TEXTURE_MAG_SIZE_NV 0x871F
+#endif
+
+#ifndef GL_NV_texture_shader2
+#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF
+#endif
+
+#ifndef GL_NV_vertex_array_range2
+#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533
+#endif
+
+#ifndef GL_NV_vertex_program
+#define GL_VERTEX_PROGRAM_NV 0x8620
+#define GL_VERTEX_STATE_PROGRAM_NV 0x8621
+#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623
+#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624
+#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625
+#define GL_CURRENT_ATTRIB_NV 0x8626
+#define GL_PROGRAM_LENGTH_NV 0x8627
+#define GL_PROGRAM_STRING_NV 0x8628
+#define GL_MODELVIEW_PROJECTION_NV 0x8629
+#define GL_IDENTITY_NV 0x862A
+#define GL_INVERSE_NV 0x862B
+#define GL_TRANSPOSE_NV 0x862C
+#define GL_INVERSE_TRANSPOSE_NV 0x862D
+#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E
+#define GL_MAX_TRACK_MATRICES_NV 0x862F
+#define GL_MATRIX0_NV 0x8630
+#define GL_MATRIX1_NV 0x8631
+#define GL_MATRIX2_NV 0x8632
+#define GL_MATRIX3_NV 0x8633
+#define GL_MATRIX4_NV 0x8634
+#define GL_MATRIX5_NV 0x8635
+#define GL_MATRIX6_NV 0x8636
+#define GL_MATRIX7_NV 0x8637
+#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640
+#define GL_CURRENT_MATRIX_NV 0x8641
+#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642
+#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643
+#define GL_PROGRAM_PARAMETER_NV 0x8644
+#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645
+#define GL_PROGRAM_TARGET_NV 0x8646
+#define GL_PROGRAM_RESIDENT_NV 0x8647
+#define GL_TRACK_MATRIX_NV 0x8648
+#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649
+#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A
+#define GL_PROGRAM_ERROR_POSITION_NV 0x864B
+#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650
+#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651
+#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652
+#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653
+#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654
+#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655
+#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656
+#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657
+#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658
+#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659
+#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A
+#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B
+#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C
+#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D
+#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E
+#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F
+#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660
+#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661
+#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662
+#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663
+#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664
+#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665
+#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666
+#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667
+#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668
+#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669
+#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A
+#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B
+#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C
+#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D
+#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E
+#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F
+#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670
+#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671
+#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672
+#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673
+#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674
+#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675
+#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676
+#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677
+#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678
+#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679
+#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A
+#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B
+#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C
+#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D
+#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E
+#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F
+#endif
+
+#ifndef GL_SGIX_texture_coordinate_clamp
+#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369
+#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A
+#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B
+#endif
+
+#ifndef GL_SGIX_scalebias_hint
+#define GL_SCALEBIAS_HINT_SGIX 0x8322
+#endif
+
+#ifndef GL_OML_interlace
+#define GL_INTERLACE_OML 0x8980
+#define GL_INTERLACE_READ_OML 0x8981
+#endif
+
+#ifndef GL_OML_subsample
+#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982
+#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983
+#endif
+
+#ifndef GL_OML_resample
+#define GL_PACK_RESAMPLE_OML 0x8984
+#define GL_UNPACK_RESAMPLE_OML 0x8985
+#define GL_RESAMPLE_REPLICATE_OML 0x8986
+#define GL_RESAMPLE_ZERO_FILL_OML 0x8987
+#define GL_RESAMPLE_AVERAGE_OML 0x8988
+#define GL_RESAMPLE_DECIMATE_OML 0x8989
+#endif
+
+#ifndef GL_NV_copy_depth_to_color
+#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E
+#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F
+#endif
+
+#ifndef GL_ATI_envmap_bumpmap
+#define GL_BUMP_ROT_MATRIX_ATI 0x8775
+#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776
+#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777
+#define GL_BUMP_TEX_UNITS_ATI 0x8778
+#define GL_DUDV_ATI 0x8779
+#define GL_DU8DV8_ATI 0x877A
+#define GL_BUMP_ENVMAP_ATI 0x877B
+#define GL_BUMP_TARGET_ATI 0x877C
+#endif
+
+#ifndef GL_ATI_fragment_shader
+#define GL_FRAGMENT_SHADER_ATI 0x8920
+#define GL_REG_0_ATI 0x8921
+#define GL_REG_1_ATI 0x8922
+#define GL_REG_2_ATI 0x8923
+#define GL_REG_3_ATI 0x8924
+#define GL_REG_4_ATI 0x8925
+#define GL_REG_5_ATI 0x8926
+#define GL_REG_6_ATI 0x8927
+#define GL_REG_7_ATI 0x8928
+#define GL_REG_8_ATI 0x8929
+#define GL_REG_9_ATI 0x892A
+#define GL_REG_10_ATI 0x892B
+#define GL_REG_11_ATI 0x892C
+#define GL_REG_12_ATI 0x892D
+#define GL_REG_13_ATI 0x892E
+#define GL_REG_14_ATI 0x892F
+#define GL_REG_15_ATI 0x8930
+#define GL_REG_16_ATI 0x8931
+#define GL_REG_17_ATI 0x8932
+#define GL_REG_18_ATI 0x8933
+#define GL_REG_19_ATI 0x8934
+#define GL_REG_20_ATI 0x8935
+#define GL_REG_21_ATI 0x8936
+#define GL_REG_22_ATI 0x8937
+#define GL_REG_23_ATI 0x8938
+#define GL_REG_24_ATI 0x8939
+#define GL_REG_25_ATI 0x893A
+#define GL_REG_26_ATI 0x893B
+#define GL_REG_27_ATI 0x893C
+#define GL_REG_28_ATI 0x893D
+#define GL_REG_29_ATI 0x893E
+#define GL_REG_30_ATI 0x893F
+#define GL_REG_31_ATI 0x8940
+#define GL_CON_0_ATI 0x8941
+#define GL_CON_1_ATI 0x8942
+#define GL_CON_2_ATI 0x8943
+#define GL_CON_3_ATI 0x8944
+#define GL_CON_4_ATI 0x8945
+#define GL_CON_5_ATI 0x8946
+#define GL_CON_6_ATI 0x8947
+#define GL_CON_7_ATI 0x8948
+#define GL_CON_8_ATI 0x8949
+#define GL_CON_9_ATI 0x894A
+#define GL_CON_10_ATI 0x894B
+#define GL_CON_11_ATI 0x894C
+#define GL_CON_12_ATI 0x894D
+#define GL_CON_13_ATI 0x894E
+#define GL_CON_14_ATI 0x894F
+#define GL_CON_15_ATI 0x8950
+#define GL_CON_16_ATI 0x8951
+#define GL_CON_17_ATI 0x8952
+#define GL_CON_18_ATI 0x8953
+#define GL_CON_19_ATI 0x8954
+#define GL_CON_20_ATI 0x8955
+#define GL_CON_21_ATI 0x8956
+#define GL_CON_22_ATI 0x8957
+#define GL_CON_23_ATI 0x8958
+#define GL_CON_24_ATI 0x8959
+#define GL_CON_25_ATI 0x895A
+#define GL_CON_26_ATI 0x895B
+#define GL_CON_27_ATI 0x895C
+#define GL_CON_28_ATI 0x895D
+#define GL_CON_29_ATI 0x895E
+#define GL_CON_30_ATI 0x895F
+#define GL_CON_31_ATI 0x8960
+#define GL_MOV_ATI 0x8961
+#define GL_ADD_ATI 0x8963
+#define GL_MUL_ATI 0x8964
+#define GL_SUB_ATI 0x8965
+#define GL_DOT3_ATI 0x8966
+#define GL_DOT4_ATI 0x8967
+#define GL_MAD_ATI 0x8968
+#define GL_LERP_ATI 0x8969
+#define GL_CND_ATI 0x896A
+#define GL_CND0_ATI 0x896B
+#define GL_DOT2_ADD_ATI 0x896C
+#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D
+#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E
+#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F
+#define GL_NUM_PASSES_ATI 0x8970
+#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971
+#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972
+#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973
+#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974
+#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975
+#define GL_SWIZZLE_STR_ATI 0x8976
+#define GL_SWIZZLE_STQ_ATI 0x8977
+#define GL_SWIZZLE_STR_DR_ATI 0x8978
+#define GL_SWIZZLE_STQ_DQ_ATI 0x8979
+#define GL_SWIZZLE_STRQ_ATI 0x897A
+#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B
+#define GL_RED_BIT_ATI 0x00000001
+#define GL_GREEN_BIT_ATI 0x00000002
+#define GL_BLUE_BIT_ATI 0x00000004
+#define GL_2X_BIT_ATI 0x00000001
+#define GL_4X_BIT_ATI 0x00000002
+#define GL_8X_BIT_ATI 0x00000004
+#define GL_HALF_BIT_ATI 0x00000008
+#define GL_QUARTER_BIT_ATI 0x00000010
+#define GL_EIGHTH_BIT_ATI 0x00000020
+#define GL_SATURATE_BIT_ATI 0x00000040
+#define GL_COMP_BIT_ATI 0x00000002
+#define GL_NEGATE_BIT_ATI 0x00000004
+#define GL_BIAS_BIT_ATI 0x00000008
+#endif
+
+#ifndef GL_ATI_pn_triangles
+#define GL_PN_TRIANGLES_ATI 0x87F0
+#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1
+#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2
+#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3
+#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4
+#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5
+#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6
+#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7
+#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8
+#endif
+
+#ifndef GL_ATI_vertex_array_object
+#define GL_STATIC_ATI 0x8760
+#define GL_DYNAMIC_ATI 0x8761
+#define GL_PRESERVE_ATI 0x8762
+#define GL_DISCARD_ATI 0x8763
+#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764
+#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765
+#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766
+#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767
+#endif
+
+#ifndef GL_EXT_vertex_shader
+#define GL_VERTEX_SHADER_EXT 0x8780
+#define GL_VERTEX_SHADER_BINDING_EXT 0x8781
+#define GL_OP_INDEX_EXT 0x8782
+#define GL_OP_NEGATE_EXT 0x8783
+#define GL_OP_DOT3_EXT 0x8784
+#define GL_OP_DOT4_EXT 0x8785
+#define GL_OP_MUL_EXT 0x8786
+#define GL_OP_ADD_EXT 0x8787
+#define GL_OP_MADD_EXT 0x8788
+#define GL_OP_FRAC_EXT 0x8789
+#define GL_OP_MAX_EXT 0x878A
+#define GL_OP_MIN_EXT 0x878B
+#define GL_OP_SET_GE_EXT 0x878C
+#define GL_OP_SET_LT_EXT 0x878D
+#define GL_OP_CLAMP_EXT 0x878E
+#define GL_OP_FLOOR_EXT 0x878F
+#define GL_OP_ROUND_EXT 0x8790
+#define GL_OP_EXP_BASE_2_EXT 0x8791
+#define GL_OP_LOG_BASE_2_EXT 0x8792
+#define GL_OP_POWER_EXT 0x8793
+#define GL_OP_RECIP_EXT 0x8794
+#define GL_OP_RECIP_SQRT_EXT 0x8795
+#define GL_OP_SUB_EXT 0x8796
+#define GL_OP_CROSS_PRODUCT_EXT 0x8797
+#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798
+#define GL_OP_MOV_EXT 0x8799
+#define GL_OUTPUT_VERTEX_EXT 0x879A
+#define GL_OUTPUT_COLOR0_EXT 0x879B
+#define GL_OUTPUT_COLOR1_EXT 0x879C
+#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D
+#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E
+#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F
+#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0
+#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1
+#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2
+#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3
+#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4
+#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5
+#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6
+#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7
+#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8
+#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9
+#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA
+#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB
+#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC
+#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD
+#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE
+#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF
+#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0
+#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1
+#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2
+#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3
+#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4
+#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5
+#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6
+#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7
+#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8
+#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9
+#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA
+#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB
+#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC
+#define GL_OUTPUT_FOG_EXT 0x87BD
+#define GL_SCALAR_EXT 0x87BE
+#define GL_VECTOR_EXT 0x87BF
+#define GL_MATRIX_EXT 0x87C0
+#define GL_VARIANT_EXT 0x87C1
+#define GL_INVARIANT_EXT 0x87C2
+#define GL_LOCAL_CONSTANT_EXT 0x87C3
+#define GL_LOCAL_EXT 0x87C4
+#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5
+#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6
+#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7
+#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8
+#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9
+#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA
+#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB
+#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC
+#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD
+#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE
+#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF
+#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0
+#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1
+#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2
+#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3
+#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4
+#define GL_X_EXT 0x87D5
+#define GL_Y_EXT 0x87D6
+#define GL_Z_EXT 0x87D7
+#define GL_W_EXT 0x87D8
+#define GL_NEGATIVE_X_EXT 0x87D9
+#define GL_NEGATIVE_Y_EXT 0x87DA
+#define GL_NEGATIVE_Z_EXT 0x87DB
+#define GL_NEGATIVE_W_EXT 0x87DC
+#define GL_ZERO_EXT 0x87DD
+#define GL_ONE_EXT 0x87DE
+#define GL_NEGATIVE_ONE_EXT 0x87DF
+#define GL_NORMALIZED_RANGE_EXT 0x87E0
+#define GL_FULL_RANGE_EXT 0x87E1
+#define GL_CURRENT_VERTEX_EXT 0x87E2
+#define GL_MVP_MATRIX_EXT 0x87E3
+#define GL_VARIANT_VALUE_EXT 0x87E4
+#define GL_VARIANT_DATATYPE_EXT 0x87E5
+#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6
+#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7
+#define GL_VARIANT_ARRAY_EXT 0x87E8
+#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9
+#define GL_INVARIANT_VALUE_EXT 0x87EA
+#define GL_INVARIANT_DATATYPE_EXT 0x87EB
+#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC
+#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED
+#endif
+
+#ifndef GL_ATI_vertex_streams
+#define GL_MAX_VERTEX_STREAMS_ATI 0x876B
+#define GL_VERTEX_STREAM0_ATI 0x876C
+#define GL_VERTEX_STREAM1_ATI 0x876D
+#define GL_VERTEX_STREAM2_ATI 0x876E
+#define GL_VERTEX_STREAM3_ATI 0x876F
+#define GL_VERTEX_STREAM4_ATI 0x8770
+#define GL_VERTEX_STREAM5_ATI 0x8771
+#define GL_VERTEX_STREAM6_ATI 0x8772
+#define GL_VERTEX_STREAM7_ATI 0x8773
+#define GL_VERTEX_SOURCE_ATI 0x8774
+#endif
+
+#ifndef GL_ATI_element_array
+#define GL_ELEMENT_ARRAY_ATI 0x8768
+#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769
+#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A
+#endif
+
+#ifndef GL_SUN_mesh_array
+#define GL_QUAD_MESH_SUN 0x8614
+#define GL_TRIANGLE_MESH_SUN 0x8615
+#endif
+
+#ifndef GL_SUN_slice_accum
+#define GL_SLICE_ACCUM_SUN 0x85CC
+#endif
+
+#ifndef GL_NV_multisample_filter_hint
+#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534
+#endif
+
+#ifndef GL_NV_depth_clamp
+#define GL_DEPTH_CLAMP_NV 0x864F
+#endif
+
+#ifndef GL_NV_occlusion_query
+#define GL_PIXEL_COUNTER_BITS_NV 0x8864
+#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865
+#define GL_PIXEL_COUNT_NV 0x8866
+#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867
+#endif
+
+#ifndef GL_NV_point_sprite
+#define GL_POINT_SPRITE_NV 0x8861
+#define GL_COORD_REPLACE_NV 0x8862
+#define GL_POINT_SPRITE_R_MODE_NV 0x8863
+#endif
+
+#ifndef GL_NV_texture_shader3
+#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850
+#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851
+#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852
+#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853
+#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854
+#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855
+#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856
+#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857
+#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858
+#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859
+#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A
+#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B
+#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C
+#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D
+#define GL_HILO8_NV 0x885E
+#define GL_SIGNED_HILO8_NV 0x885F
+#define GL_FORCE_BLUE_TO_ONE_NV 0x8860
+#endif
+
+#ifndef GL_NV_vertex_program1_1
+#endif
+
+#ifndef GL_EXT_shadow_funcs
+#endif
+
+#ifndef GL_EXT_stencil_two_side
+#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910
+#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911
+#endif
+
+#ifndef GL_ATI_text_fragment_shader
+#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200
+#endif
+
+#ifndef GL_APPLE_client_storage
+#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2
+#endif
+
+#ifndef GL_APPLE_element_array
+#define GL_ELEMENT_ARRAY_APPLE 0x8A0C
+#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D
+#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E
+#endif
+
+#ifndef GL_APPLE_fence
+#define GL_DRAW_PIXELS_APPLE 0x8A0A
+#define GL_FENCE_APPLE 0x8A0B
+#endif
+
+#ifndef GL_APPLE_vertex_array_object
+#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5
+#endif
+
+#ifndef GL_APPLE_vertex_array_range
+#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D
+#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E
+#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F
+#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521
+#define GL_STORAGE_CLIENT_APPLE 0x85B4
+#define GL_STORAGE_CACHED_APPLE 0x85BE
+#define GL_STORAGE_SHARED_APPLE 0x85BF
+#endif
+
+#ifndef GL_APPLE_ycbcr_422
+#define GL_YCBCR_422_APPLE 0x85B9
+#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA
+#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB
+#endif
+
+#ifndef GL_S3_s3tc
+#define GL_RGB_S3TC 0x83A0
+#define GL_RGB4_S3TC 0x83A1
+#define GL_RGBA_S3TC 0x83A2
+#define GL_RGBA4_S3TC 0x83A3
+#define GL_RGBA_DXT5_S3TC 0x83A4
+#define GL_RGBA4_DXT5_S3TC 0x83A5
+#endif
+
+#ifndef GL_ATI_draw_buffers
+#define GL_MAX_DRAW_BUFFERS_ATI 0x8824
+#define GL_DRAW_BUFFER0_ATI 0x8825
+#define GL_DRAW_BUFFER1_ATI 0x8826
+#define GL_DRAW_BUFFER2_ATI 0x8827
+#define GL_DRAW_BUFFER3_ATI 0x8828
+#define GL_DRAW_BUFFER4_ATI 0x8829
+#define GL_DRAW_BUFFER5_ATI 0x882A
+#define GL_DRAW_BUFFER6_ATI 0x882B
+#define GL_DRAW_BUFFER7_ATI 0x882C
+#define GL_DRAW_BUFFER8_ATI 0x882D
+#define GL_DRAW_BUFFER9_ATI 0x882E
+#define GL_DRAW_BUFFER10_ATI 0x882F
+#define GL_DRAW_BUFFER11_ATI 0x8830
+#define GL_DRAW_BUFFER12_ATI 0x8831
+#define GL_DRAW_BUFFER13_ATI 0x8832
+#define GL_DRAW_BUFFER14_ATI 0x8833
+#define GL_DRAW_BUFFER15_ATI 0x8834
+#endif
+
+#ifndef GL_ATI_pixel_format_float
+#define GL_RGBA_FLOAT_MODE_ATI 0x8820
+#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835
+#endif
+
+#ifndef GL_ATI_texture_env_combine3
+#define GL_MODULATE_ADD_ATI 0x8744
+#define GL_MODULATE_SIGNED_ADD_ATI 0x8745
+#define GL_MODULATE_SUBTRACT_ATI 0x8746
+#endif
+
+#ifndef GL_ATI_texture_float
+#define GL_RGBA_FLOAT32_ATI 0x8814
+#define GL_RGB_FLOAT32_ATI 0x8815
+#define GL_ALPHA_FLOAT32_ATI 0x8816
+#define GL_INTENSITY_FLOAT32_ATI 0x8817
+#define GL_LUMINANCE_FLOAT32_ATI 0x8818
+#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819
+#define GL_RGBA_FLOAT16_ATI 0x881A
+#define GL_RGB_FLOAT16_ATI 0x881B
+#define GL_ALPHA_FLOAT16_ATI 0x881C
+#define GL_INTENSITY_FLOAT16_ATI 0x881D
+#define GL_LUMINANCE_FLOAT16_ATI 0x881E
+#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F
+#endif
+
+#ifndef GL_NV_float_buffer
+#define GL_FLOAT_R_NV 0x8880
+#define GL_FLOAT_RG_NV 0x8881
+#define GL_FLOAT_RGB_NV 0x8882
+#define GL_FLOAT_RGBA_NV 0x8883
+#define GL_FLOAT_R16_NV 0x8884
+#define GL_FLOAT_R32_NV 0x8885
+#define GL_FLOAT_RG16_NV 0x8886
+#define GL_FLOAT_RG32_NV 0x8887
+#define GL_FLOAT_RGB16_NV 0x8888
+#define GL_FLOAT_RGB32_NV 0x8889
+#define GL_FLOAT_RGBA16_NV 0x888A
+#define GL_FLOAT_RGBA32_NV 0x888B
+#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C
+#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D
+#define GL_FLOAT_RGBA_MODE_NV 0x888E
+#endif
+
+#ifndef GL_NV_fragment_program
+#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868
+#define GL_FRAGMENT_PROGRAM_NV 0x8870
+#define GL_MAX_TEXTURE_COORDS_NV 0x8871
+#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872
+#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873
+#define GL_PROGRAM_ERROR_STRING_NV 0x8874
+#endif
+
+#ifndef GL_NV_half_float
+#define GL_HALF_FLOAT_NV 0x140B
+#endif
+
+#ifndef GL_NV_pixel_data_range
+#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878
+#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879
+#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A
+#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B
+#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C
+#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D
+#endif
+
+#ifndef GL_NV_primitive_restart
+#define GL_PRIMITIVE_RESTART_NV 0x8558
+#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559
+#endif
+
+#ifndef GL_NV_texture_expand_normal
+#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F
+#endif
+
+#ifndef GL_NV_vertex_program2
+#endif
+
+#ifndef GL_ATI_map_object_buffer
+#endif
+
+#ifndef GL_ATI_separate_stencil
+#define GL_STENCIL_BACK_FUNC_ATI 0x8800
+#define GL_STENCIL_BACK_FAIL_ATI 0x8801
+#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802
+#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803
+#endif
+
+#ifndef GL_ATI_vertex_attrib_array_object
+#endif
+
+#ifndef GL_OES_byte_coordinates
+#endif
+
+#ifndef GL_OES_fixed_point
+#define GL_FIXED_OES 0x140C
+#endif
+
+#ifndef GL_OES_single_precision
+#endif
+
+#ifndef GL_OES_compressed_paletted_texture
+#define GL_PALETTE4_RGB8_OES 0x8B90
+#define GL_PALETTE4_RGBA8_OES 0x8B91
+#define GL_PALETTE4_R5_G6_B5_OES 0x8B92
+#define GL_PALETTE4_RGBA4_OES 0x8B93
+#define GL_PALETTE4_RGB5_A1_OES 0x8B94
+#define GL_PALETTE8_RGB8_OES 0x8B95
+#define GL_PALETTE8_RGBA8_OES 0x8B96
+#define GL_PALETTE8_R5_G6_B5_OES 0x8B97
+#define GL_PALETTE8_RGBA4_OES 0x8B98
+#define GL_PALETTE8_RGB5_A1_OES 0x8B99
+#endif
+
+#ifndef GL_OES_read_format
+#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A
+#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B
+#endif
+
+#ifndef GL_OES_query_matrix
+#endif
+
+#ifndef GL_EXT_depth_bounds_test
+#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890
+#define GL_DEPTH_BOUNDS_EXT 0x8891
+#endif
+
+#ifndef GL_EXT_texture_mirror_clamp
+#define GL_MIRROR_CLAMP_EXT 0x8742
+#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743
+#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912
+#endif
+
+#ifndef GL_EXT_blend_equation_separate
+#define GL_BLEND_EQUATION_RGB_EXT 0x8009
+#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D
+#endif
+
+#ifndef GL_MESA_pack_invert
+#define GL_PACK_INVERT_MESA 0x8758
+#endif
+
+#ifndef GL_MESA_ycbcr_texture
+#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA
+#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB
+#define GL_YCBCR_MESA 0x8757
+#endif
+
+#ifndef GL_EXT_pixel_buffer_object
+#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB
+#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC
+#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED
+#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF
+#endif
+
+#ifndef GL_NV_fragment_program_option
+#endif
+
+#ifndef GL_NV_fragment_program2
+#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4
+#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5
+#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6
+#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7
+#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8
+#endif
+
+#ifndef GL_NV_vertex_program2_option
+/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */
+/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */
+#endif
+
+#ifndef GL_NV_vertex_program3
+/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */
+#endif
+
+#ifndef GL_EXT_framebuffer_object
+#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506
+#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8
+#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6
+#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4
+#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5
+#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6
+#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7
+#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9
+#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA
+#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB
+#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC
+#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD
+#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF
+#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
+#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1
+#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2
+#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3
+#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4
+#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5
+#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6
+#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7
+#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8
+#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9
+#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA
+#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB
+#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC
+#define GL_COLOR_ATTACHMENT13_EXT 0x8CED
+#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE
+#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF
+#define GL_DEPTH_ATTACHMENT_EXT 0x8D00
+#define GL_STENCIL_ATTACHMENT_EXT 0x8D20
+#define GL_FRAMEBUFFER_EXT 0x8D40
+#define GL_RENDERBUFFER_EXT 0x8D41
+#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42
+#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43
+#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44
+#define GL_STENCIL_INDEX1_EXT 0x8D46
+#define GL_STENCIL_INDEX4_EXT 0x8D47
+#define GL_STENCIL_INDEX8_EXT 0x8D48
+#define GL_STENCIL_INDEX16_EXT 0x8D49
+#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50
+#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51
+#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52
+#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53
+#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54
+#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55
+#endif
+
+#ifndef GL_GREMEDY_string_marker
+#endif
+
+#ifndef GL_EXT_packed_depth_stencil
+#define GL_DEPTH_STENCIL_EXT 0x84F9
+#define GL_UNSIGNED_INT_24_8_EXT 0x84FA
+#define GL_DEPTH24_STENCIL8_EXT 0x88F0
+#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1
+#endif
+
+#ifndef GL_EXT_stencil_clear_tag
+#define GL_STENCIL_TAG_BITS_EXT 0x88F2
+#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3
+#endif
+
+#ifndef GL_EXT_texture_sRGB
+#define GL_SRGB_EXT 0x8C40
+#define GL_SRGB8_EXT 0x8C41
+#define GL_SRGB_ALPHA_EXT 0x8C42
+#define GL_SRGB8_ALPHA8_EXT 0x8C43
+#define GL_SLUMINANCE_ALPHA_EXT 0x8C44
+#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45
+#define GL_SLUMINANCE_EXT 0x8C46
+#define GL_SLUMINANCE8_EXT 0x8C47
+#define GL_COMPRESSED_SRGB_EXT 0x8C48
+#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49
+#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A
+#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B
+#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C
+#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D
+#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E
+#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F
+#endif
+
+#ifndef GL_EXT_framebuffer_blit
+#define GL_READ_FRAMEBUFFER_EXT 0x8CA8
+#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9
+#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6
+#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA
+#endif
+
+#ifndef GL_EXT_framebuffer_multisample
+#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56
+#define GL_MAX_SAMPLES_EXT 0x8D57
+#endif
+
+#ifndef GL_MESAX_texture_stack
+#define GL_TEXTURE_1D_STACK_MESAX 0x8759
+#define GL_TEXTURE_2D_STACK_MESAX 0x875A
+#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B
+#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C
+#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D
+#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E
+#endif
+
+#ifndef GL_EXT_timer_query
+#define GL_TIME_ELAPSED_EXT 0x88BF
+#endif
+
+#ifndef GL_EXT_gpu_program_parameters
+#endif
+
+#ifndef GL_APPLE_flush_buffer_range
+#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12
+#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13
+#endif
+
+#ifndef GL_NV_gpu_program4
+#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904
+#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905
+#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906
+#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907
+#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908
+#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909
+#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5
+#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6
+#endif
+
+#ifndef GL_NV_geometry_program4
+#define GL_LINES_ADJACENCY_EXT 0x000A
+#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B
+#define GL_TRIANGLES_ADJACENCY_EXT 0x000C
+#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D
+#define GL_GEOMETRY_PROGRAM_NV 0x8C26
+#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27
+#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28
+#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA
+#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB
+#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC
+#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29
+#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7
+#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8
+#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4
+#define GL_PROGRAM_POINT_SIZE_EXT 0x8642
+#endif
+
+#ifndef GL_EXT_geometry_shader4
+#define GL_GEOMETRY_SHADER_EXT 0x8DD9
+/* reuse GL_GEOMETRY_VERTICES_OUT_EXT */
+/* reuse GL_GEOMETRY_INPUT_TYPE_EXT */
+/* reuse GL_GEOMETRY_OUTPUT_TYPE_EXT */
+/* reuse GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT */
+#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD
+#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE
+#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B
+#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF
+#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0
+#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1
+/* reuse GL_LINES_ADJACENCY_EXT */
+/* reuse GL_LINE_STRIP_ADJACENCY_EXT */
+/* reuse GL_TRIANGLES_ADJACENCY_EXT */
+/* reuse GL_TRIANGLE_STRIP_ADJACENCY_EXT */
+/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT */
+/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */
+/* reuse GL_PROGRAM_POINT_SIZE_EXT */
+#endif
+
+#ifndef GL_NV_vertex_program4
+#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD
+#endif
+
+#ifndef GL_EXT_gpu_shader4
+#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0
+#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1
+#define GL_SAMPLER_BUFFER_EXT 0x8DC2
+#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3
+#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4
+#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5
+#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6
+#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7
+#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8
+#define GL_INT_SAMPLER_1D_EXT 0x8DC9
+#define GL_INT_SAMPLER_2D_EXT 0x8DCA
+#define GL_INT_SAMPLER_3D_EXT 0x8DCB
+#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC
+#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD
+#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE
+#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF
+#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0
+#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1
+#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2
+#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3
+#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4
+#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5
+#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6
+#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7
+#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8
+#endif
+
+#ifndef GL_EXT_draw_instanced
+#endif
+
+#ifndef GL_EXT_packed_float
+#define GL_R11F_G11F_B10F_EXT 0x8C3A
+#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B
+#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C
+#endif
+
+#ifndef GL_EXT_texture_array
+#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18
+#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19
+#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A
+#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B
+#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C
+#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D
+#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF
+#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */
+#endif
+
+#ifndef GL_EXT_texture_buffer_object
+#define GL_TEXTURE_BUFFER_EXT 0x8C2A
+#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B
+#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C
+#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D
+#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E
+#endif
+
+#ifndef GL_EXT_texture_compression_latc
+#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70
+#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71
+#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72
+#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73
+#endif
+
+#ifndef GL_EXT_texture_compression_rgtc
+#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB
+#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC
+#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD
+#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE
+#endif
+
+#ifndef GL_EXT_texture_shared_exponent
+#define GL_RGB9_E5_EXT 0x8C3D
+#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E
+#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F
+#endif
+
+#ifndef GL_NV_depth_buffer_float
+#define GL_DEPTH_COMPONENT32F_NV 0x8DAB
+#define GL_DEPTH32F_STENCIL8_NV 0x8DAC
+#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD
+#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF
+#endif
+
+#ifndef GL_NV_fragment_program4
+#endif
+
+#ifndef GL_NV_framebuffer_multisample_coverage
+#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB
+#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10
+#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11
+#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12
+#endif
+
+#ifndef GL_EXT_framebuffer_sRGB
+#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9
+#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA
+#endif
+
+#ifndef GL_NV_geometry_shader4
+#endif
+
+#ifndef GL_NV_parameter_buffer_object
+#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0
+#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1
+#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2
+#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3
+#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4
+#endif
+
+#ifndef GL_EXT_draw_buffers2
+#endif
+
+#ifndef GL_NV_transform_feedback
+#define GL_BACK_PRIMARY_COLOR_NV 0x8C77
+#define GL_BACK_SECONDARY_COLOR_NV 0x8C78
+#define GL_TEXTURE_COORD_NV 0x8C79
+#define GL_CLIP_DISTANCE_NV 0x8C7A
+#define GL_VERTEX_ID_NV 0x8C7B
+#define GL_PRIMITIVE_ID_NV 0x8C7C
+#define GL_GENERIC_ATTRIB_NV 0x8C7D
+#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E
+#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F
+#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80
+#define GL_ACTIVE_VARYINGS_NV 0x8C81
+#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82
+#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83
+#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84
+#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85
+#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86
+#define GL_PRIMITIVES_GENERATED_NV 0x8C87
+#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88
+#define GL_RASTERIZER_DISCARD_NV 0x8C89
+#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV 0x8C8A
+#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B
+#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C
+#define GL_SEPARATE_ATTRIBS_NV 0x8C8D
+#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E
+#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F
+#define GL_LAYER_NV 0x8DAA
+#define GL_NEXT_BUFFER_NV -2
+#define GL_SKIP_COMPONENTS4_NV -3
+#define GL_SKIP_COMPONENTS3_NV -4
+#define GL_SKIP_COMPONENTS2_NV -5
+#define GL_SKIP_COMPONENTS1_NV -6
+#endif
+
+#ifndef GL_EXT_bindable_uniform
+#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2
+#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3
+#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4
+#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED
+#define GL_UNIFORM_BUFFER_EXT 0x8DEE
+#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF
+#endif
+
+#ifndef GL_EXT_texture_integer
+#define GL_RGBA32UI_EXT 0x8D70
+#define GL_RGB32UI_EXT 0x8D71
+#define GL_ALPHA32UI_EXT 0x8D72
+#define GL_INTENSITY32UI_EXT 0x8D73
+#define GL_LUMINANCE32UI_EXT 0x8D74
+#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75
+#define GL_RGBA16UI_EXT 0x8D76
+#define GL_RGB16UI_EXT 0x8D77
+#define GL_ALPHA16UI_EXT 0x8D78
+#define GL_INTENSITY16UI_EXT 0x8D79
+#define GL_LUMINANCE16UI_EXT 0x8D7A
+#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B
+#define GL_RGBA8UI_EXT 0x8D7C
+#define GL_RGB8UI_EXT 0x8D7D
+#define GL_ALPHA8UI_EXT 0x8D7E
+#define GL_INTENSITY8UI_EXT 0x8D7F
+#define GL_LUMINANCE8UI_EXT 0x8D80
+#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81
+#define GL_RGBA32I_EXT 0x8D82
+#define GL_RGB32I_EXT 0x8D83
+#define GL_ALPHA32I_EXT 0x8D84
+#define GL_INTENSITY32I_EXT 0x8D85
+#define GL_LUMINANCE32I_EXT 0x8D86
+#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87
+#define GL_RGBA16I_EXT 0x8D88
+#define GL_RGB16I_EXT 0x8D89
+#define GL_ALPHA16I_EXT 0x8D8A
+#define GL_INTENSITY16I_EXT 0x8D8B
+#define GL_LUMINANCE16I_EXT 0x8D8C
+#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D
+#define GL_RGBA8I_EXT 0x8D8E
+#define GL_RGB8I_EXT 0x8D8F
+#define GL_ALPHA8I_EXT 0x8D90
+#define GL_INTENSITY8I_EXT 0x8D91
+#define GL_LUMINANCE8I_EXT 0x8D92
+#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93
+#define GL_RED_INTEGER_EXT 0x8D94
+#define GL_GREEN_INTEGER_EXT 0x8D95
+#define GL_BLUE_INTEGER_EXT 0x8D96
+#define GL_ALPHA_INTEGER_EXT 0x8D97
+#define GL_RGB_INTEGER_EXT 0x8D98
+#define GL_RGBA_INTEGER_EXT 0x8D99
+#define GL_BGR_INTEGER_EXT 0x8D9A
+#define GL_BGRA_INTEGER_EXT 0x8D9B
+#define GL_LUMINANCE_INTEGER_EXT 0x8D9C
+#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D
+#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E
+#endif
+
+#ifndef GL_GREMEDY_frame_terminator
+#endif
+
+#ifndef GL_NV_conditional_render
+#define GL_QUERY_WAIT_NV 0x8E13
+#define GL_QUERY_NO_WAIT_NV 0x8E14
+#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15
+#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16
+#endif
+
+#ifndef GL_NV_present_video
+#define GL_FRAME_NV 0x8E26
+#define GL_FIELDS_NV 0x8E27
+#define GL_CURRENT_TIME_NV 0x8E28
+#define GL_NUM_FILL_STREAMS_NV 0x8E29
+#define GL_PRESENT_TIME_NV 0x8E2A
+#define GL_PRESENT_DURATION_NV 0x8E2B
+#endif
+
+#ifndef GL_EXT_transform_feedback
+#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E
+#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84
+#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85
+#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F
+#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C
+#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D
+#define GL_PRIMITIVES_GENERATED_EXT 0x8C87
+#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88
+#define GL_RASTERIZER_DISCARD_EXT 0x8C89
+#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A
+#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B
+#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80
+#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83
+#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F
+#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76
+#endif
+
+#ifndef GL_EXT_direct_state_access
+#define GL_PROGRAM_MATRIX_EXT 0x8E2D
+#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E
+#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F
+#endif
+
+#ifndef GL_EXT_vertex_array_bgra
+/* reuse GL_BGRA */
+#endif
+
+#ifndef GL_EXT_texture_swizzle
+#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42
+#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43
+#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44
+#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45
+#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46
+#endif
+
+#ifndef GL_NV_explicit_multisample
+#define GL_SAMPLE_POSITION_NV 0x8E50
+#define GL_SAMPLE_MASK_NV 0x8E51
+#define GL_SAMPLE_MASK_VALUE_NV 0x8E52
+#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53
+#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54
+#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55
+#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56
+#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57
+#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58
+#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59
+#endif
+
+#ifndef GL_NV_transform_feedback2
+#define GL_TRANSFORM_FEEDBACK_NV 0x8E22
+#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23
+#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24
+#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25
+#endif
+
+#ifndef GL_ATI_meminfo
+#define GL_VBO_FREE_MEMORY_ATI 0x87FB
+#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC
+#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD
+#endif
+
+#ifndef GL_AMD_performance_monitor
+#define GL_COUNTER_TYPE_AMD 0x8BC0
+#define GL_COUNTER_RANGE_AMD 0x8BC1
+#define GL_UNSIGNED_INT64_AMD 0x8BC2
+#define GL_PERCENTAGE_AMD 0x8BC3
+#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4
+#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5
+#define GL_PERFMON_RESULT_AMD 0x8BC6
+#endif
+
+#ifndef GL_AMD_texture_texture4
+#endif
+
+#ifndef GL_AMD_vertex_shader_tessellator
+#define GL_SAMPLER_BUFFER_AMD 0x9001
+#define GL_INT_SAMPLER_BUFFER_AMD 0x9002
+#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003
+#define GL_TESSELLATION_MODE_AMD 0x9004
+#define GL_TESSELLATION_FACTOR_AMD 0x9005
+#define GL_DISCRETE_AMD 0x9006
+#define GL_CONTINUOUS_AMD 0x9007
+#endif
+
+#ifndef GL_EXT_provoking_vertex
+#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C
+#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D
+#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E
+#define GL_PROVOKING_VERTEX_EXT 0x8E4F
+#endif
+
+#ifndef GL_EXT_texture_snorm
+#define GL_ALPHA_SNORM 0x9010
+#define GL_LUMINANCE_SNORM 0x9011
+#define GL_LUMINANCE_ALPHA_SNORM 0x9012
+#define GL_INTENSITY_SNORM 0x9013
+#define GL_ALPHA8_SNORM 0x9014
+#define GL_LUMINANCE8_SNORM 0x9015
+#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016
+#define GL_INTENSITY8_SNORM 0x9017
+#define GL_ALPHA16_SNORM 0x9018
+#define GL_LUMINANCE16_SNORM 0x9019
+#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A
+#define GL_INTENSITY16_SNORM 0x901B
+/* reuse GL_RED_SNORM */
+/* reuse GL_RG_SNORM */
+/* reuse GL_RGB_SNORM */
+/* reuse GL_RGBA_SNORM */
+/* reuse GL_R8_SNORM */
+/* reuse GL_RG8_SNORM */
+/* reuse GL_RGB8_SNORM */
+/* reuse GL_RGBA8_SNORM */
+/* reuse GL_R16_SNORM */
+/* reuse GL_RG16_SNORM */
+/* reuse GL_RGB16_SNORM */
+/* reuse GL_RGBA16_SNORM */
+/* reuse GL_SIGNED_NORMALIZED */
+#endif
+
+#ifndef GL_AMD_draw_buffers_blend
+#endif
+
+#ifndef GL_APPLE_texture_range
+#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7
+#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8
+#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC
+#define GL_STORAGE_PRIVATE_APPLE 0x85BD
+/* reuse GL_STORAGE_CACHED_APPLE */
+/* reuse GL_STORAGE_SHARED_APPLE */
+#endif
+
+#ifndef GL_APPLE_float_pixels
+#define GL_HALF_APPLE 0x140B
+#define GL_RGBA_FLOAT32_APPLE 0x8814
+#define GL_RGB_FLOAT32_APPLE 0x8815
+#define GL_ALPHA_FLOAT32_APPLE 0x8816
+#define GL_INTENSITY_FLOAT32_APPLE 0x8817
+#define GL_LUMINANCE_FLOAT32_APPLE 0x8818
+#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819
+#define GL_RGBA_FLOAT16_APPLE 0x881A
+#define GL_RGB_FLOAT16_APPLE 0x881B
+#define GL_ALPHA_FLOAT16_APPLE 0x881C
+#define GL_INTENSITY_FLOAT16_APPLE 0x881D
+#define GL_LUMINANCE_FLOAT16_APPLE 0x881E
+#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F
+#define GL_COLOR_FLOAT_APPLE 0x8A0F
+#endif
+
+#ifndef GL_APPLE_vertex_program_evaluators
+#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00
+#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01
+#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02
+#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03
+#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04
+#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05
+#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06
+#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07
+#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08
+#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09
+#endif
+
+#ifndef GL_APPLE_aux_depth_stencil
+#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14
+#endif
+
+#ifndef GL_APPLE_object_purgeable
+#define GL_BUFFER_OBJECT_APPLE 0x85B3
+#define GL_RELEASED_APPLE 0x8A19
+#define GL_VOLATILE_APPLE 0x8A1A
+#define GL_RETAINED_APPLE 0x8A1B
+#define GL_UNDEFINED_APPLE 0x8A1C
+#define GL_PURGEABLE_APPLE 0x8A1D
+#endif
+
+#ifndef GL_APPLE_row_bytes
+#define GL_PACK_ROW_BYTES_APPLE 0x8A15
+#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16
+#endif
+
+#ifndef GL_APPLE_rgb_422
+#define GL_RGB_422_APPLE 0x8A1F
+/* reuse GL_UNSIGNED_SHORT_8_8_APPLE */
+/* reuse GL_UNSIGNED_SHORT_8_8_REV_APPLE */
+#endif
+
+#ifndef GL_NV_video_capture
+#define GL_VIDEO_BUFFER_NV 0x9020
+#define GL_VIDEO_BUFFER_BINDING_NV 0x9021
+#define GL_FIELD_UPPER_NV 0x9022
+#define GL_FIELD_LOWER_NV 0x9023
+#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024
+#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025
+#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026
+#define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027
+#define GL_VIDEO_BUFFER_PITCH_NV 0x9028
+#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029
+#define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A
+#define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B
+#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C
+#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D
+#define GL_PARTIAL_SUCCESS_NV 0x902E
+#define GL_SUCCESS_NV 0x902F
+#define GL_FAILURE_NV 0x9030
+#define GL_YCBYCR8_422_NV 0x9031
+#define GL_YCBAYCR8A_4224_NV 0x9032
+#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033
+#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034
+#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035
+#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036
+#define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037
+#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038
+#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039
+#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A
+#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B
+#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C
+#endif
+
+#ifndef GL_NV_copy_image
+#endif
+
+#ifndef GL_EXT_separate_shader_objects
+#define GL_ACTIVE_PROGRAM_EXT 0x8B8D
+#endif
+
+#ifndef GL_NV_parameter_buffer_object2
+#endif
+
+#ifndef GL_NV_shader_buffer_load
+#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D
+#define GL_GPU_ADDRESS_NV 0x8F34
+#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35
+#endif
+
+#ifndef GL_NV_vertex_buffer_unified_memory
+#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E
+#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F
+#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20
+#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21
+#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22
+#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23
+#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24
+#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25
+#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26
+#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27
+#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28
+#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29
+#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A
+#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B
+#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C
+#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D
+#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E
+#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F
+#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30
+#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31
+#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32
+#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33
+#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40
+#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41
+#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42
+#endif
+
+#ifndef GL_NV_texture_barrier
+#endif
+
+#ifndef GL_AMD_shader_stencil_export
+#endif
+
+#ifndef GL_AMD_seamless_cubemap_per_texture
+/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS */
+#endif
+
+#ifndef GL_AMD_conservative_depth
+#endif
+
+#ifndef GL_EXT_shader_image_load_store
+#define GL_MAX_IMAGE_UNITS_EXT 0x8F38
+#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39
+#define GL_IMAGE_BINDING_NAME_EXT 0x8F3A
+#define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B
+#define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C
+#define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D
+#define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E
+#define GL_IMAGE_1D_EXT 0x904C
+#define GL_IMAGE_2D_EXT 0x904D
+#define GL_IMAGE_3D_EXT 0x904E
+#define GL_IMAGE_2D_RECT_EXT 0x904F
+#define GL_IMAGE_CUBE_EXT 0x9050
+#define GL_IMAGE_BUFFER_EXT 0x9051
+#define GL_IMAGE_1D_ARRAY_EXT 0x9052
+#define GL_IMAGE_2D_ARRAY_EXT 0x9053
+#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054
+#define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055
+#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056
+#define GL_INT_IMAGE_1D_EXT 0x9057
+#define GL_INT_IMAGE_2D_EXT 0x9058
+#define GL_INT_IMAGE_3D_EXT 0x9059
+#define GL_INT_IMAGE_2D_RECT_EXT 0x905A
+#define GL_INT_IMAGE_CUBE_EXT 0x905B
+#define GL_INT_IMAGE_BUFFER_EXT 0x905C
+#define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D
+#define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E
+#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F
+#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060
+#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061
+#define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062
+#define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063
+#define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064
+#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065
+#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066
+#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067
+#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068
+#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069
+#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A
+#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B
+#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C
+#define GL_MAX_IMAGE_SAMPLES_EXT 0x906D
+#define GL_IMAGE_BINDING_FORMAT_EXT 0x906E
+#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001
+#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002
+#define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004
+#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008
+#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020
+#define GL_COMMAND_BARRIER_BIT_EXT 0x00000040
+#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080
+#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100
+#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200
+#define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400
+#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800
+#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000
+#define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF
+#endif
+
+#ifndef GL_EXT_vertex_attrib_64bit
+/* reuse GL_DOUBLE */
+#define GL_DOUBLE_VEC2_EXT 0x8FFC
+#define GL_DOUBLE_VEC3_EXT 0x8FFD
+#define GL_DOUBLE_VEC4_EXT 0x8FFE
+#define GL_DOUBLE_MAT2_EXT 0x8F46
+#define GL_DOUBLE_MAT3_EXT 0x8F47
+#define GL_DOUBLE_MAT4_EXT 0x8F48
+#define GL_DOUBLE_MAT2x3_EXT 0x8F49
+#define GL_DOUBLE_MAT2x4_EXT 0x8F4A
+#define GL_DOUBLE_MAT3x2_EXT 0x8F4B
+#define GL_DOUBLE_MAT3x4_EXT 0x8F4C
+#define GL_DOUBLE_MAT4x2_EXT 0x8F4D
+#define GL_DOUBLE_MAT4x3_EXT 0x8F4E
+#endif
+
+#ifndef GL_NV_gpu_program5
+#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A
+#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B
+#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C
+#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D
+#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E
+#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F
+#define GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV 0x8F44
+#define GL_MAX_PROGRAM_SUBROUTINE_NUM_NV 0x8F45
+#endif
+
+#ifndef GL_NV_gpu_shader5
+#define GL_INT64_NV 0x140E
+#define GL_UNSIGNED_INT64_NV 0x140F
+#define GL_INT8_NV 0x8FE0
+#define GL_INT8_VEC2_NV 0x8FE1
+#define GL_INT8_VEC3_NV 0x8FE2
+#define GL_INT8_VEC4_NV 0x8FE3
+#define GL_INT16_NV 0x8FE4
+#define GL_INT16_VEC2_NV 0x8FE5
+#define GL_INT16_VEC3_NV 0x8FE6
+#define GL_INT16_VEC4_NV 0x8FE7
+#define GL_INT64_VEC2_NV 0x8FE9
+#define GL_INT64_VEC3_NV 0x8FEA
+#define GL_INT64_VEC4_NV 0x8FEB
+#define GL_UNSIGNED_INT8_NV 0x8FEC
+#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED
+#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE
+#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF
+#define GL_UNSIGNED_INT16_NV 0x8FF0
+#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1
+#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2
+#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3
+#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5
+#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6
+#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7
+#define GL_FLOAT16_NV 0x8FF8
+#define GL_FLOAT16_VEC2_NV 0x8FF9
+#define GL_FLOAT16_VEC3_NV 0x8FFA
+#define GL_FLOAT16_VEC4_NV 0x8FFB
+/* reuse GL_PATCHES */
+#endif
+
+#ifndef GL_NV_shader_buffer_store
+#define GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010
+/* reuse GL_READ_WRITE */
+/* reuse GL_WRITE_ONLY */
+#endif
+
+#ifndef GL_NV_tessellation_program5
+#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8
+#define GL_TESS_CONTROL_PROGRAM_NV 0x891E
+#define GL_TESS_EVALUATION_PROGRAM_NV 0x891F
+#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74
+#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75
+#endif
+
+#ifndef GL_NV_vertex_attrib_integer_64bit
+/* reuse GL_INT64_NV */
+/* reuse GL_UNSIGNED_INT64_NV */
+#endif
+
+#ifndef GL_NV_multisample_coverage
+#define GL_COLOR_SAMPLES_NV 0x8E20
+/* reuse GL_SAMPLES_ARB */
+#endif
+
+#ifndef GL_AMD_name_gen_delete
+#define GL_DATA_BUFFER_AMD 0x9151
+#define GL_PERFORMANCE_MONITOR_AMD 0x9152
+#define GL_QUERY_OBJECT_AMD 0x9153
+#define GL_VERTEX_ARRAY_OBJECT_AMD 0x9154
+#define GL_SAMPLER_OBJECT_AMD 0x9155
+#endif
+
+#ifndef GL_AMD_debug_output
+#define GL_MAX_DEBUG_MESSAGE_LENGTH_AMD 0x9143
+#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144
+#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145
+#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146
+#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147
+#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148
+#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149
+#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A
+#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B
+#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C
+#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D
+#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E
+#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F
+#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150
+#endif
+
+#ifndef GL_NV_vdpau_interop
+#define GL_SURFACE_STATE_NV 0x86EB
+#define GL_SURFACE_REGISTERED_NV 0x86FD
+#define GL_SURFACE_MAPPED_NV 0x8700
+#define GL_WRITE_DISCARD_NV 0x88BE
+#endif
+
+#ifndef GL_AMD_transform_feedback3_lines_triangles
+#endif
+
+#ifndef GL_AMD_depth_clamp_separate
+#define GL_DEPTH_CLAMP_NEAR_AMD 0x901E
+#define GL_DEPTH_CLAMP_FAR_AMD 0x901F
+#endif
+
+#ifndef GL_EXT_texture_sRGB_decode
+#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48
+#define GL_DECODE_EXT 0x8A49
+#define GL_SKIP_DECODE_EXT 0x8A4A
+#endif
+
+#ifndef GL_NV_texture_multisample
+#define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045
+#define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046
+#endif
+
+#ifndef GL_AMD_blend_minmax_factor
+#define GL_FACTOR_MIN_AMD 0x901C
+#define GL_FACTOR_MAX_AMD 0x901D
+#endif
+
+#ifndef GL_AMD_sample_positions
+#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F
+#endif
+
+#ifndef GL_EXT_x11_sync_object
+#define GL_SYNC_X11_FENCE_EXT 0x90E1
+#endif
+
+#ifndef GL_AMD_multi_draw_indirect
+#endif
+
+#ifndef GL_EXT_framebuffer_multisample_blit_scaled
+#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA
+#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB
+#endif
+
+#ifndef GL_NV_path_rendering
+#define GL_PATH_FORMAT_SVG_NV 0x9070
+#define GL_PATH_FORMAT_PS_NV 0x9071
+#define GL_STANDARD_FONT_NAME_NV 0x9072
+#define GL_SYSTEM_FONT_NAME_NV 0x9073
+#define GL_FILE_NAME_NV 0x9074
+#define GL_PATH_STROKE_WIDTH_NV 0x9075
+#define GL_PATH_END_CAPS_NV 0x9076
+#define GL_PATH_INITIAL_END_CAP_NV 0x9077
+#define GL_PATH_TERMINAL_END_CAP_NV 0x9078
+#define GL_PATH_JOIN_STYLE_NV 0x9079
+#define GL_PATH_MITER_LIMIT_NV 0x907A
+#define GL_PATH_DASH_CAPS_NV 0x907B
+#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C
+#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D
+#define GL_PATH_DASH_OFFSET_NV 0x907E
+#define GL_PATH_CLIENT_LENGTH_NV 0x907F
+#define GL_PATH_FILL_MODE_NV 0x9080
+#define GL_PATH_FILL_MASK_NV 0x9081
+#define GL_PATH_FILL_COVER_MODE_NV 0x9082
+#define GL_PATH_STROKE_COVER_MODE_NV 0x9083
+#define GL_PATH_STROKE_MASK_NV 0x9084
+#define GL_COUNT_UP_NV 0x9088
+#define GL_COUNT_DOWN_NV 0x9089
+#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A
+#define GL_CONVEX_HULL_NV 0x908B
+#define GL_BOUNDING_BOX_NV 0x908D
+#define GL_TRANSLATE_X_NV 0x908E
+#define GL_TRANSLATE_Y_NV 0x908F
+#define GL_TRANSLATE_2D_NV 0x9090
+#define GL_TRANSLATE_3D_NV 0x9091
+#define GL_AFFINE_2D_NV 0x9092
+#define GL_AFFINE_3D_NV 0x9094
+#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096
+#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098
+#define GL_UTF8_NV 0x909A
+#define GL_UTF16_NV 0x909B
+#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C
+#define GL_PATH_COMMAND_COUNT_NV 0x909D
+#define GL_PATH_COORD_COUNT_NV 0x909E
+#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F
+#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0
+#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1
+#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2
+#define GL_SQUARE_NV 0x90A3
+#define GL_ROUND_NV 0x90A4
+#define GL_TRIANGULAR_NV 0x90A5
+#define GL_BEVEL_NV 0x90A6
+#define GL_MITER_REVERT_NV 0x90A7
+#define GL_MITER_TRUNCATE_NV 0x90A8
+#define GL_SKIP_MISSING_GLYPH_NV 0x90A9
+#define GL_USE_MISSING_GLYPH_NV 0x90AA
+#define GL_PATH_ERROR_POSITION_NV 0x90AB
+#define GL_PATH_FOG_GEN_MODE_NV 0x90AC
+#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD
+#define GL_ADJACENT_PAIRS_NV 0x90AE
+#define GL_FIRST_TO_REST_NV 0x90AF
+#define GL_PATH_GEN_MODE_NV 0x90B0
+#define GL_PATH_GEN_COEFF_NV 0x90B1
+#define GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2
+#define GL_PATH_GEN_COMPONENTS_NV 0x90B3
+#define GL_PATH_STENCIL_FUNC_NV 0x90B7
+#define GL_PATH_STENCIL_REF_NV 0x90B8
+#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9
+#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD
+#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE
+#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF
+#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4
+#define GL_MOVE_TO_RESETS_NV 0x90B5
+#define GL_MOVE_TO_CONTINUES_NV 0x90B6
+#define GL_CLOSE_PATH_NV 0x00
+#define GL_MOVE_TO_NV 0x02
+#define GL_RELATIVE_MOVE_TO_NV 0x03
+#define GL_LINE_TO_NV 0x04
+#define GL_RELATIVE_LINE_TO_NV 0x05
+#define GL_HORIZONTAL_LINE_TO_NV 0x06
+#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07
+#define GL_VERTICAL_LINE_TO_NV 0x08
+#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09
+#define GL_QUADRATIC_CURVE_TO_NV 0x0A
+#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B
+#define GL_CUBIC_CURVE_TO_NV 0x0C
+#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D
+#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E
+#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F
+#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10
+#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11
+#define GL_SMALL_CCW_ARC_TO_NV 0x12
+#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13
+#define GL_SMALL_CW_ARC_TO_NV 0x14
+#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15
+#define GL_LARGE_CCW_ARC_TO_NV 0x16
+#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17
+#define GL_LARGE_CW_ARC_TO_NV 0x18
+#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19
+#define GL_RESTART_PATH_NV 0xF0
+#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2
+#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4
+#define GL_RECT_NV 0xF6
+#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8
+#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA
+#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC
+#define GL_ARC_TO_NV 0xFE
+#define GL_RELATIVE_ARC_TO_NV 0xFF
+#define GL_BOLD_BIT_NV 0x01
+#define GL_ITALIC_BIT_NV 0x02
+#define GL_GLYPH_WIDTH_BIT_NV 0x01
+#define GL_GLYPH_HEIGHT_BIT_NV 0x02
+#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04
+#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08
+#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10
+#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20
+#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40
+#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80
+#define GL_GLYPH_HAS_KERNING_BIT_NV 0x100
+#define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000
+#define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000
+#define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000
+#define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000
+#define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000
+#define GL_FONT_ASCENDER_BIT_NV 0x00200000
+#define GL_FONT_DESCENDER_BIT_NV 0x00400000
+#define GL_FONT_HEIGHT_BIT_NV 0x00800000
+#define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000
+#define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000
+#define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000
+#define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000
+#define GL_FONT_HAS_KERNING_BIT_NV 0x10000000
+/* reuse GL_PRIMARY_COLOR */
+/* reuse GL_PRIMARY_COLOR_NV */
+/* reuse GL_SECONDARY_COLOR_NV */
+#endif
+
+#ifndef GL_AMD_pinned_memory
+#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160
+#endif
+
+#ifndef GL_AMD_stencil_operation_extended
+#define GL_SET_AMD 0x874A
+#define GL_REPLACE_VALUE_AMD 0x874B
+#define GL_STENCIL_OP_VALUE_AMD 0x874C
+#define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D
+#endif
+
+#ifndef GL_AMD_vertex_shader_viewport_index
+#endif
+
+#ifndef GL_AMD_vertex_shader_layer
+#endif
+
+#ifndef GL_NV_bindless_texture
+#endif
+
+#ifndef GL_NV_shader_atomic_float
+#endif
+
+#ifndef GL_AMD_query_buffer_object
+#define GL_QUERY_BUFFER_AMD 0x9192
+#define GL_QUERY_BUFFER_BINDING_AMD 0x9193
+#define GL_QUERY_RESULT_NO_WAIT_AMD 0x9194
+#endif
+
+#ifndef GL_NV_compute_program5
+#define GL_COMPUTE_PROGRAM_NV 0x90FB
+#define GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV 0x90FC
+#endif
+
+#ifndef GL_NV_shader_storage_buffer_object
+#endif
+
+#ifndef GL_NV_shader_atomic_counters
+#endif
+
+#ifndef GL_NV_deep_texture3D
+#define GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV 0x90D0
+#define GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV 0x90D1
+#endif
+
+#ifndef GL_NVX_conditional_render
+#endif
+
+#ifndef GL_AMD_sparse_texture
+#define GL_VIRTUAL_PAGE_SIZE_X_AMD 0x9195
+#define GL_VIRTUAL_PAGE_SIZE_Y_AMD 0x9196
+#define GL_VIRTUAL_PAGE_SIZE_Z_AMD 0x9197
+#define GL_MAX_SPARSE_TEXTURE_SIZE_AMD 0x9198
+#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_AMD 0x9199
+#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS 0x919A
+#define GL_MIN_SPARSE_LEVEL_AMD 0x919B
+#define GL_MIN_LOD_WARNING_AMD 0x919C
+#define GL_TEXTURE_STORAGE_SPARSE_BIT_AMD 0x00000001
+#endif
+
+#ifndef GL_AMD_shader_trinary_minmax
+#endif
+
+#ifndef GL_INTEL_map_texture
+#define GL_TEXTURE_MEMORY_LAYOUT_INTEL 0x83FF
+#define GL_LAYOUT_DEFAULT_INTEL 0
+#define GL_LAYOUT_LINEAR_INTEL 1
+#define GL_LAYOUT_LINEAR_CPU_CACHED_INTEL 2
+#endif
+
+#ifndef GL_NV_draw_texture
+#endif
+
+
+/*************************************************************/
+
+#include <stddef.h>
+#ifndef GL_VERSION_2_0
+/* GL type for program/shader text */
+typedef char GLchar;
+#endif
+
+#ifndef GL_VERSION_1_5
+/* GL types for handling large vertex buffer objects */
+typedef ptrdiff_t GLintptr;
+typedef ptrdiff_t GLsizeiptr;
+#endif
+
+#ifndef GL_ARB_vertex_buffer_object
+/* GL types for handling large vertex buffer objects */
+typedef ptrdiff_t GLintptrARB;
+typedef ptrdiff_t GLsizeiptrARB;
+#endif
+
+#ifndef GL_ARB_shader_objects
+/* GL types for program/shader text and shader object handles */
+typedef char GLcharARB;
+typedef unsigned int GLhandleARB;
+#endif
+
+/* GL type for "half" precision (s10e5) float data in host memory */
+#ifndef GL_ARB_half_float_pixel
+typedef unsigned short GLhalfARB;
+#endif
+
+#ifndef GL_NV_half_float
+typedef unsigned short GLhalfNV;
+#endif
+
+#ifndef GLEXT_64_TYPES_DEFINED
+/* This code block is duplicated in glxext.h, so must be protected */
+#define GLEXT_64_TYPES_DEFINED
+/* Define int32_t, int64_t, and uint64_t types for UST/MSC */
+/* (as used in the GL_EXT_timer_query extension). */
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+#include <inttypes.h>
+#elif defined(__sun__) || defined(__digital__)
+#include <inttypes.h>
+#if defined(__STDC__)
+#if defined(__arch64__) || defined(_LP64)
+typedef long int int64_t;
+typedef unsigned long int uint64_t;
+#else
+typedef long long int int64_t;
+typedef unsigned long long int uint64_t;
+#endif /* __arch64__ */
+#endif /* __STDC__ */
+#elif defined( __VMS ) || defined(__sgi)
+#include <inttypes.h>
+#elif defined(__SCO__) || defined(__USLC__)
+#include <stdint.h>
+#elif defined(__UNIXOS2__) || defined(__SOL64__)
+typedef long int int32_t;
+typedef long long int int64_t;
+typedef unsigned long long int uint64_t;
+#elif defined(_WIN32) && defined(__GNUC__)
+#include <stdint.h>
+#elif defined(_WIN32)
+typedef __int32 int32_t;
+typedef __int64 int64_t;
+typedef unsigned __int64 uint64_t;
+#else
+/* Fallback if nothing above works */
+#include <inttypes.h>
+#endif
+#endif
+
+#ifndef GL_EXT_timer_query
+typedef int64_t GLint64EXT;
+typedef uint64_t GLuint64EXT;
+#endif
+
+#ifndef GL_ARB_sync
+typedef int64_t GLint64;
+typedef uint64_t GLuint64;
+typedef struct __GLsync *GLsync;
+#endif
+
+#ifndef GL_ARB_cl_event
+/* These incomplete types let us declare types compatible with OpenCL's cl_context and cl_event */
+struct _cl_context;
+struct _cl_event;
+#endif
+
+#ifndef GL_ARB_debug_output
+typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam);
+#endif
+
+#ifndef GL_AMD_debug_output
+typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam);
+#endif
+
+#ifndef GL_KHR_debug
+typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam);
+#endif
+
+#ifndef GL_NV_vdpau_interop
+typedef GLintptr GLvdpauSurfaceNV;
+#endif
+
+#ifndef GL_OES_fixed_point
+/* GLint must be 32 bits, a relatively safe assumption on modern CPUs */
+typedef GLint GLfixed;
+#endif
+
+#ifndef GL_VERSION_1_2
+#define GL_VERSION_1_2 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+GLAPI void APIENTRY glBlendEquation (GLenum mode);
+GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
+GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
+GLAPI void APIENTRY glColorTableParameterfv (GLenum target, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glCopyColorTable (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+GLAPI void APIENTRY glGetColorTable (GLenum target, GLenum format, GLenum type, GLvoid *table);
+GLAPI void APIENTRY glGetColorTableParameterfv (GLenum target, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetColorTableParameteriv (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data);
+GLAPI void APIENTRY glCopyColorSubTable (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);
+GLAPI void APIENTRY glConvolutionFilter1D (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image);
+GLAPI void APIENTRY glConvolutionFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image);
+GLAPI void APIENTRY glConvolutionParameterf (GLenum target, GLenum pname, GLfloat params);
+GLAPI void APIENTRY glConvolutionParameterfv (GLenum target, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glConvolutionParameteri (GLenum target, GLenum pname, GLint params);
+GLAPI void APIENTRY glConvolutionParameteriv (GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glGetConvolutionFilter (GLenum target, GLenum format, GLenum type, GLvoid *image);
+GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum target, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetSeparableFilter (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span);
+GLAPI void APIENTRY glSeparableFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column);
+GLAPI void APIENTRY glGetHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+GLAPI void APIENTRY glGetHistogramParameterfv (GLenum target, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetHistogramParameteriv (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum target, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glHistogram (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);
+GLAPI void APIENTRY glMinmax (GLenum target, GLenum internalformat, GLboolean sink);
+GLAPI void APIENTRY glResetHistogram (GLenum target);
+GLAPI void APIENTRY glResetMinmax (GLenum target);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode);
+typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
+typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
+typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image);
+typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image);
+typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span);
+typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column);
+typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);
+typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink);
+typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target);
+#endif
+
+#ifndef GL_VERSION_1_3
+#define GL_VERSION_1_3 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glActiveTexture (GLenum texture);
+GLAPI void APIENTRY glSampleCoverage (GLfloat value, GLboolean invert);
+GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
+GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
+GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
+GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
+GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
+GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
+GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, GLvoid *img);
+GLAPI void APIENTRY glClientActiveTexture (GLenum texture);
+GLAPI void APIENTRY glMultiTexCoord1d (GLenum target, GLdouble s);
+GLAPI void APIENTRY glMultiTexCoord1dv (GLenum target, const GLdouble *v);
+GLAPI void APIENTRY glMultiTexCoord1f (GLenum target, GLfloat s);
+GLAPI void APIENTRY glMultiTexCoord1fv (GLenum target, const GLfloat *v);
+GLAPI void APIENTRY glMultiTexCoord1i (GLenum target, GLint s);
+GLAPI void APIENTRY glMultiTexCoord1iv (GLenum target, const GLint *v);
+GLAPI void APIENTRY glMultiTexCoord1s (GLenum target, GLshort s);
+GLAPI void APIENTRY glMultiTexCoord1sv (GLenum target, const GLshort *v);
+GLAPI void APIENTRY glMultiTexCoord2d (GLenum target, GLdouble s, GLdouble t);
+GLAPI void APIENTRY glMultiTexCoord2dv (GLenum target, const GLdouble *v);
+GLAPI void APIENTRY glMultiTexCoord2f (GLenum target, GLfloat s, GLfloat t);
+GLAPI void APIENTRY glMultiTexCoord2fv (GLenum target, const GLfloat *v);
+GLAPI void APIENTRY glMultiTexCoord2i (GLenum target, GLint s, GLint t);
+GLAPI void APIENTRY glMultiTexCoord2iv (GLenum target, const GLint *v);
+GLAPI void APIENTRY glMultiTexCoord2s (GLenum target, GLshort s, GLshort t);
+GLAPI void APIENTRY glMultiTexCoord2sv (GLenum target, const GLshort *v);
+GLAPI void APIENTRY glMultiTexCoord3d (GLenum target, GLdouble s, GLdouble t, GLdouble r);
+GLAPI void APIENTRY glMultiTexCoord3dv (GLenum target, const GLdouble *v);
+GLAPI void APIENTRY glMultiTexCoord3f (GLenum target, GLfloat s, GLfloat t, GLfloat r);
+GLAPI void APIENTRY glMultiTexCoord3fv (GLenum target, const GLfloat *v);
+GLAPI void APIENTRY glMultiTexCoord3i (GLenum target, GLint s, GLint t, GLint r);
+GLAPI void APIENTRY glMultiTexCoord3iv (GLenum target, const GLint *v);
+GLAPI void APIENTRY glMultiTexCoord3s (GLenum target, GLshort s, GLshort t, GLshort r);
+GLAPI void APIENTRY glMultiTexCoord3sv (GLenum target, const GLshort *v);
+GLAPI void APIENTRY glMultiTexCoord4d (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
+GLAPI void APIENTRY glMultiTexCoord4dv (GLenum target, const GLdouble *v);
+GLAPI void APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+GLAPI void APIENTRY glMultiTexCoord4fv (GLenum target, const GLfloat *v);
+GLAPI void APIENTRY glMultiTexCoord4i (GLenum target, GLint s, GLint t, GLint r, GLint q);
+GLAPI void APIENTRY glMultiTexCoord4iv (GLenum target, const GLint *v);
+GLAPI void APIENTRY glMultiTexCoord4s (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
+GLAPI void APIENTRY glMultiTexCoord4sv (GLenum target, const GLshort *v);
+GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *m);
+GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *m);
+GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *m);
+GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture);
+typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img);
+typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m);
+typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m);
+typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m);
+typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m);
+#endif
+
+#ifndef GL_VERSION_1_4
+#define GL_VERSION_1_4 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount);
+GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount);
+GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param);
+GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param);
+GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params);
+GLAPI void APIENTRY glFogCoordf (GLfloat coord);
+GLAPI void APIENTRY glFogCoordfv (const GLfloat *coord);
+GLAPI void APIENTRY glFogCoordd (GLdouble coord);
+GLAPI void APIENTRY glFogCoorddv (const GLdouble *coord);
+GLAPI void APIENTRY glFogCoordPointer (GLenum type, GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glSecondaryColor3b (GLbyte red, GLbyte green, GLbyte blue);
+GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *v);
+GLAPI void APIENTRY glSecondaryColor3d (GLdouble red, GLdouble green, GLdouble blue);
+GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *v);
+GLAPI void APIENTRY glSecondaryColor3f (GLfloat red, GLfloat green, GLfloat blue);
+GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *v);
+GLAPI void APIENTRY glSecondaryColor3i (GLint red, GLint green, GLint blue);
+GLAPI void APIENTRY glSecondaryColor3iv (const GLint *v);
+GLAPI void APIENTRY glSecondaryColor3s (GLshort red, GLshort green, GLshort blue);
+GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *v);
+GLAPI void APIENTRY glSecondaryColor3ub (GLubyte red, GLubyte green, GLubyte blue);
+GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *v);
+GLAPI void APIENTRY glSecondaryColor3ui (GLuint red, GLuint green, GLuint blue);
+GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *v);
+GLAPI void APIENTRY glSecondaryColor3us (GLushort red, GLushort green, GLushort blue);
+GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *v);
+GLAPI void APIENTRY glSecondaryColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glWindowPos2d (GLdouble x, GLdouble y);
+GLAPI void APIENTRY glWindowPos2dv (const GLdouble *v);
+GLAPI void APIENTRY glWindowPos2f (GLfloat x, GLfloat y);
+GLAPI void APIENTRY glWindowPos2fv (const GLfloat *v);
+GLAPI void APIENTRY glWindowPos2i (GLint x, GLint y);
+GLAPI void APIENTRY glWindowPos2iv (const GLint *v);
+GLAPI void APIENTRY glWindowPos2s (GLshort x, GLshort y);
+GLAPI void APIENTRY glWindowPos2sv (const GLshort *v);
+GLAPI void APIENTRY glWindowPos3d (GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glWindowPos3dv (const GLdouble *v);
+GLAPI void APIENTRY glWindowPos3f (GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glWindowPos3fv (const GLfloat *v);
+GLAPI void APIENTRY glWindowPos3i (GLint x, GLint y, GLint z);
+GLAPI void APIENTRY glWindowPos3iv (const GLint *v);
+GLAPI void APIENTRY glWindowPos3s (GLshort x, GLshort y, GLshort z);
+GLAPI void APIENTRY glWindowPos3sv (const GLshort *v);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount);
+typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord);
+typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord);
+typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord);
+typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord);
+typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v);
+#endif
+
+#ifndef GL_VERSION_1_5
+#define GL_VERSION_1_5 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids);
+GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids);
+GLAPI GLboolean APIENTRY glIsQuery (GLuint id);
+GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id);
+GLAPI void APIENTRY glEndQuery (GLenum target);
+GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params);
+GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer);
+GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers);
+GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers);
+GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer);
+GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
+GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data);
+GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data);
+GLAPI GLvoid* APIENTRY glMapBuffer (GLenum target, GLenum access);
+GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target);
+GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, GLvoid* *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids);
+typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids);
+typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id);
+typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params);
+typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer);
+typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers);
+typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers);
+typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer);
+typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
+typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data);
+typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data);
+typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access);
+typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params);
+#endif
+
+#ifndef GL_VERSION_2_0
+#define GL_VERSION_2_0 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha);
+GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs);
+GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
+GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask);
+GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask);
+GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader);
+GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name);
+GLAPI void APIENTRY glCompileShader (GLuint shader);
+GLAPI GLuint APIENTRY glCreateProgram (void);
+GLAPI GLuint APIENTRY glCreateShader (GLenum type);
+GLAPI void APIENTRY glDeleteProgram (GLuint program);
+GLAPI void APIENTRY glDeleteShader (GLuint shader);
+GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader);
+GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index);
+GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index);
+GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
+GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
+GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj);
+GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name);
+GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source);
+GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name);
+GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params);
+GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params);
+GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params);
+GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid* *pointer);
+GLAPI GLboolean APIENTRY glIsProgram (GLuint program);
+GLAPI GLboolean APIENTRY glIsShader (GLuint shader);
+GLAPI void APIENTRY glLinkProgram (GLuint program);
+GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* const *string, const GLint *length);
+GLAPI void APIENTRY glUseProgram (GLuint program);
+GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0);
+GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1);
+GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+GLAPI void APIENTRY glUniform1i (GLint location, GLint v0);
+GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1);
+GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2);
+GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glValidateProgram (GLuint program);
+GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x);
+GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x);
+GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x);
+GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y);
+GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y);
+GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y);
+GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z);
+GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v);
+GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v);
+GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
+GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v);
+GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v);
+GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v);
+GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v);
+GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v);
+GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
+GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v);
+GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v);
+GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v);
+GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha);
+typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs);
+typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
+typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask);
+typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask);
+typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader);
+typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name);
+typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader);
+typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void);
+typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type);
+typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program);
+typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader);
+typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader);
+typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index);
+typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index);
+typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
+typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
+typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj);
+typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name);
+typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source);
+typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name);
+typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer);
+typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program);
+typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader);
+typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program);
+typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* const *string, const GLint *length);
+typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program);
+typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0);
+typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1);
+typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0);
+typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1);
+typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2);
+typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
+#endif
+
+#ifndef GL_VERSION_2_1
+#define GL_VERSION_2_1 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+#endif
+
+#ifndef GL_VERSION_3_0
+#define GL_VERSION_3_0 1
+/* OpenGL 3.0 also reuses entry points from these extensions: */
+/* ARB_framebuffer_object */
+/* ARB_map_buffer_range */
+/* ARB_vertex_array_object */
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
+GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data);
+GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data);
+GLAPI void APIENTRY glEnablei (GLenum target, GLuint index);
+GLAPI void APIENTRY glDisablei (GLenum target, GLuint index);
+GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index);
+GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode);
+GLAPI void APIENTRY glEndTransformFeedback (void);
+GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
+GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer);
+GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar* const *varyings, GLenum bufferMode);
+GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);
+GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp);
+GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode);
+GLAPI void APIENTRY glEndConditionalRender (void);
+GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params);
+GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x);
+GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y);
+GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z);
+GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w);
+GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x);
+GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y);
+GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z);
+GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v);
+GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v);
+GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v);
+GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v);
+GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v);
+GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v);
+GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v);
+GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v);
+GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v);
+GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v);
+GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v);
+GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params);
+GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name);
+GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name);
+GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0);
+GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1);
+GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2);
+GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value);
+GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value);
+GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value);
+GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value);
+GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params);
+GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params);
+GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value);
+GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value);
+GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value);
+GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);
+GLAPI const GLubyte * APIENTRY glGetStringi (GLenum name, GLuint index);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
+typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data);
+typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data);
+typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index);
+typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index);
+typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index);
+typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode);
+typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void);
+typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
+typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer);
+typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar* const *varyings, GLenum bufferMode);
+typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);
+typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp);
+typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode);
+typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v);
+typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params);
+typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name);
+typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name);
+typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0);
+typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1);
+typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2);
+typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params);
+typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params);
+typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value);
+typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value);
+typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value);
+typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);
+typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index);
+#endif
+
+#ifndef GL_VERSION_3_1
+#define GL_VERSION_3_1 1
+/* OpenGL 3.1 also reuses entry points from these extensions: */
+/* ARB_copy_buffer */
+/* ARB_uniform_buffer_object */
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount);
+GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount);
+GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer);
+GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount);
+typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount);
+typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer);
+typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index);
+#endif
+
+#ifndef GL_VERSION_3_2
+#define GL_VERSION_3_2 1
+/* OpenGL 3.2 also reuses entry points from these extensions: */
+/* ARB_draw_elements_base_vertex */
+/* ARB_provoking_vertex */
+/* ARB_sync */
+/* ARB_texture_multisample */
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data);
+GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params);
+GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data);
+typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level);
+#endif
+
+#ifndef GL_VERSION_3_3
+#define GL_VERSION_3_3 1
+/* OpenGL 3.3 also reuses entry points from these extensions: */
+/* ARB_blend_func_extended */
+/* ARB_sampler_objects */
+/* ARB_explicit_attrib_location, but it has none */
+/* ARB_occlusion_query2 (no entry points) */
+/* ARB_shader_bit_encoding (no entry points) */
+/* ARB_texture_rgb10_a2ui (no entry points) */
+/* ARB_texture_swizzle (no entry points) */
+/* ARB_timer_query */
+/* ARB_vertex_type_2_10_10_10_rev */
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor);
+#endif
+
+#ifndef GL_VERSION_4_0
+#define GL_VERSION_4_0 1
+/* OpenGL 4.0 also reuses entry points from these extensions: */
+/* ARB_texture_query_lod (no entry points) */
+/* ARB_draw_indirect */
+/* ARB_gpu_shader5 (no entry points) */
+/* ARB_gpu_shader_fp64 */
+/* ARB_shader_subroutine */
+/* ARB_tessellation_shader */
+/* ARB_texture_buffer_object_rgb32 (no entry points) */
+/* ARB_texture_cube_map_array (no entry points) */
+/* ARB_texture_gather (no entry points) */
+/* ARB_transform_feedback2 */
+/* ARB_transform_feedback3 */
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glMinSampleShading (GLfloat value);
+GLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode);
+GLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha);
+GLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst);
+GLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLfloat value);
+typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode);
+typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha);
+typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst);
+typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+#endif
+
+#ifndef GL_VERSION_4_1
+#define GL_VERSION_4_1 1
+/* OpenGL 4.1 reuses entry points from these extensions: */
+/* ARB_ES2_compatibility */
+/* ARB_get_program_binary */
+/* ARB_separate_shader_objects */
+/* ARB_shader_precision (no entry points) */
+/* ARB_vertex_attrib_64bit */
+/* ARB_viewport_array */
+#endif
+
+#ifndef GL_VERSION_4_2
+#define GL_VERSION_4_2 1
+/* OpenGL 4.2 reuses entry points from these extensions: */
+/* ARB_base_instance */
+/* ARB_shading_language_420pack (no entry points) */
+/* ARB_transform_feedback_instanced */
+/* ARB_compressed_texture_pixel_storage (no entry points) */
+/* ARB_conservative_depth (no entry points) */
+/* ARB_internalformat_query */
+/* ARB_map_buffer_alignment (no entry points) */
+/* ARB_shader_atomic_counters */
+/* ARB_shader_image_load_store */
+/* ARB_shading_language_packing (no entry points) */
+/* ARB_texture_storage */
+#endif
+
+#ifndef GL_VERSION_4_3
+#define GL_VERSION_4_3 1
+/* OpenGL 4.3 reuses entry points from these extensions: */
+/* ARB_arrays_of_arrays (no entry points, GLSL only) */
+/* ARB_fragment_layer_viewport (no entry points, GLSL only) */
+/* ARB_shader_image_size (no entry points, GLSL only) */
+/* ARB_ES3_compatibility (no entry points) */
+/* ARB_clear_buffer_object */
+/* ARB_compute_shader */
+/* ARB_copy_image */
+/* KHR_debug (includes ARB_debug_output commands promoted to KHR without suffixes) */
+/* ARB_explicit_uniform_location (no entry points) */
+/* ARB_framebuffer_no_attachments */
+/* ARB_internalformat_query2 */
+/* ARB_invalidate_subdata */
+/* ARB_multi_draw_indirect */
+/* ARB_program_interface_query */
+/* ARB_robust_buffer_access_behavior (no entry points) */
+/* ARB_shader_storage_buffer_object */
+/* ARB_stencil_texturing (no entry points) */
+/* ARB_texture_buffer_range */
+/* ARB_texture_query_levels (no entry points) */
+/* ARB_texture_storage_multisample */
+/* ARB_texture_view */
+/* ARB_vertex_attrib_binding */
+#endif
+
+#ifndef GL_ARB_multitexture
+#define GL_ARB_multitexture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glActiveTextureARB (GLenum texture);
+GLAPI void APIENTRY glClientActiveTextureARB (GLenum texture);
+GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum target, GLdouble s);
+GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum target, const GLdouble *v);
+GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum target, GLfloat s);
+GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum target, const GLfloat *v);
+GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum target, GLint s);
+GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum target, const GLint *v);
+GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum target, GLshort s);
+GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum target, const GLshort *v);
+GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum target, GLdouble s, GLdouble t);
+GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum target, const GLdouble *v);
+GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t);
+GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum target, const GLfloat *v);
+GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum target, GLint s, GLint t);
+GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum target, const GLint *v);
+GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum target, GLshort s, GLshort t);
+GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum target, const GLshort *v);
+GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r);
+GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum target, const GLdouble *v);
+GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r);
+GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum target, const GLfloat *v);
+GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum target, GLint s, GLint t, GLint r);
+GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum target, const GLint *v);
+GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum target, GLshort s, GLshort t, GLshort r);
+GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum target, const GLshort *v);
+GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
+GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum target, const GLdouble *v);
+GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum target, const GLfloat *v);
+GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum target, GLint s, GLint t, GLint r, GLint q);
+GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum target, const GLint *v);
+GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
+GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum target, const GLshort *v);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture);
+typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v);
+#endif
+
+#ifndef GL_ARB_transpose_matrix
+#define GL_ARB_transpose_matrix 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *m);
+GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *m);
+GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *m);
+GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *m);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m);
+typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m);
+typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m);
+typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m);
+#endif
+
+#ifndef GL_ARB_multisample
+#define GL_ARB_multisample 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glSampleCoverageARB (GLfloat value, GLboolean invert);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLfloat value, GLboolean invert);
+#endif
+
+#ifndef GL_ARB_texture_env_add
+#define GL_ARB_texture_env_add 1
+#endif
+
+#ifndef GL_ARB_texture_cube_map
+#define GL_ARB_texture_cube_map 1
+#endif
+
+#ifndef GL_ARB_texture_compression
+#define GL_ARB_texture_compression 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
+GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
+GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
+GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
+GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
+GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
+GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, GLvoid *img);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img);
+#endif
+
+#ifndef GL_ARB_texture_border_clamp
+#define GL_ARB_texture_border_clamp 1
+#endif
+
+#ifndef GL_ARB_point_parameters
+#define GL_ARB_point_parameters 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPointParameterfARB (GLenum pname, GLfloat param);
+GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params);
+#endif
+
+#ifndef GL_ARB_vertex_blend
+#define GL_ARB_vertex_blend 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glWeightbvARB (GLint size, const GLbyte *weights);
+GLAPI void APIENTRY glWeightsvARB (GLint size, const GLshort *weights);
+GLAPI void APIENTRY glWeightivARB (GLint size, const GLint *weights);
+GLAPI void APIENTRY glWeightfvARB (GLint size, const GLfloat *weights);
+GLAPI void APIENTRY glWeightdvARB (GLint size, const GLdouble *weights);
+GLAPI void APIENTRY glWeightubvARB (GLint size, const GLubyte *weights);
+GLAPI void APIENTRY glWeightusvARB (GLint size, const GLushort *weights);
+GLAPI void APIENTRY glWeightuivARB (GLint size, const GLuint *weights);
+GLAPI void APIENTRY glWeightPointerARB (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glVertexBlendARB (GLint count);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights);
+typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights);
+typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights);
+typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights);
+typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights);
+typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights);
+typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights);
+typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights);
+typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count);
+#endif
+
+#ifndef GL_ARB_matrix_palette
+#define GL_ARB_matrix_palette 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint index);
+GLAPI void APIENTRY glMatrixIndexubvARB (GLint size, const GLubyte *indices);
+GLAPI void APIENTRY glMatrixIndexusvARB (GLint size, const GLushort *indices);
+GLAPI void APIENTRY glMatrixIndexuivARB (GLint size, const GLuint *indices);
+GLAPI void APIENTRY glMatrixIndexPointerARB (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index);
+typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices);
+typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices);
+typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices);
+typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif
+
+#ifndef GL_ARB_texture_env_combine
+#define GL_ARB_texture_env_combine 1
+#endif
+
+#ifndef GL_ARB_texture_env_crossbar
+#define GL_ARB_texture_env_crossbar 1
+#endif
+
+#ifndef GL_ARB_texture_env_dot3
+#define GL_ARB_texture_env_dot3 1
+#endif
+
+#ifndef GL_ARB_texture_mirrored_repeat
+#define GL_ARB_texture_mirrored_repeat 1
+#endif
+
+#ifndef GL_ARB_depth_texture
+#define GL_ARB_depth_texture 1
+#endif
+
+#ifndef GL_ARB_shadow
+#define GL_ARB_shadow 1
+#endif
+
+#ifndef GL_ARB_shadow_ambient
+#define GL_ARB_shadow_ambient 1
+#endif
+
+#ifndef GL_ARB_window_pos
+#define GL_ARB_window_pos 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glWindowPos2dARB (GLdouble x, GLdouble y);
+GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *v);
+GLAPI void APIENTRY glWindowPos2fARB (GLfloat x, GLfloat y);
+GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *v);
+GLAPI void APIENTRY glWindowPos2iARB (GLint x, GLint y);
+GLAPI void APIENTRY glWindowPos2ivARB (const GLint *v);
+GLAPI void APIENTRY glWindowPos2sARB (GLshort x, GLshort y);
+GLAPI void APIENTRY glWindowPos2svARB (const GLshort *v);
+GLAPI void APIENTRY glWindowPos3dARB (GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *v);
+GLAPI void APIENTRY glWindowPos3fARB (GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *v);
+GLAPI void APIENTRY glWindowPos3iARB (GLint x, GLint y, GLint z);
+GLAPI void APIENTRY glWindowPos3ivARB (const GLint *v);
+GLAPI void APIENTRY glWindowPos3sARB (GLshort x, GLshort y, GLshort z);
+GLAPI void APIENTRY glWindowPos3svARB (const GLshort *v);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v);
+#endif
+
+#ifndef GL_ARB_vertex_program
+#define GL_ARB_vertex_program 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexAttrib1dARB (GLuint index, GLdouble x);
+GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttrib1fARB (GLuint index, GLfloat x);
+GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint index, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttrib1sARB (GLuint index, GLshort x);
+GLAPI void APIENTRY glVertexAttrib1svARB (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttrib2dARB (GLuint index, GLdouble x, GLdouble y);
+GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttrib2fARB (GLuint index, GLfloat x, GLfloat y);
+GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint index, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttrib2sARB (GLuint index, GLshort x, GLshort y);
+GLAPI void APIENTRY glVertexAttrib2svARB (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttrib3dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttrib3fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint index, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttrib3sARB (GLuint index, GLshort x, GLshort y, GLshort z);
+GLAPI void APIENTRY glVertexAttrib3svARB (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint index, const GLbyte *v);
+GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint index, const GLint *v);
+GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
+GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint index, const GLubyte *v);
+GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint index, const GLuint *v);
+GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint index, const GLushort *v);
+GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint index, const GLbyte *v);
+GLAPI void APIENTRY glVertexAttrib4dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttrib4fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint index, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint index, const GLint *v);
+GLAPI void APIENTRY glVertexAttrib4sARB (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
+GLAPI void APIENTRY glVertexAttrib4svARB (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint index, const GLubyte *v);
+GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint index, const GLuint *v);
+GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint index, const GLushort *v);
+GLAPI void APIENTRY glVertexAttribPointerARB (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint index);
+GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint index);
+GLAPI void APIENTRY glProgramStringARB (GLenum target, GLenum format, GLsizei len, const GLvoid *string);
+GLAPI void APIENTRY glBindProgramARB (GLenum target, GLuint program);
+GLAPI void APIENTRY glDeleteProgramsARB (GLsizei n, const GLuint *programs);
+GLAPI void APIENTRY glGenProgramsARB (GLsizei n, GLuint *programs);
+GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum target, GLuint index, const GLdouble *params);
+GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum target, GLuint index, const GLfloat *params);
+GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum target, GLuint index, const GLdouble *params);
+GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum target, GLuint index, const GLfloat *params);
+GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum target, GLuint index, GLdouble *params);
+GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum target, GLuint index, GLfloat *params);
+GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum target, GLuint index, GLdouble *params);
+GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum target, GLuint index, GLfloat *params);
+GLAPI void APIENTRY glGetProgramivARB (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetProgramStringARB (GLenum target, GLenum pname, GLvoid *string);
+GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint index, GLenum pname, GLdouble *params);
+GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint index, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetVertexAttribivARB (GLuint index, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint index, GLenum pname, GLvoid* *pointer);
+GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index);
+typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index);
+typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string);
+typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program);
+typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs);
+typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer);
+typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program);
+#endif
+
+#ifndef GL_ARB_fragment_program
+#define GL_ARB_fragment_program 1
+/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */
+#endif
+
+#ifndef GL_ARB_vertex_buffer_object
+#define GL_ARB_vertex_buffer_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBindBufferARB (GLenum target, GLuint buffer);
+GLAPI void APIENTRY glDeleteBuffersARB (GLsizei n, const GLuint *buffers);
+GLAPI void APIENTRY glGenBuffersARB (GLsizei n, GLuint *buffers);
+GLAPI GLboolean APIENTRY glIsBufferARB (GLuint buffer);
+GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage);
+GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data);
+GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data);
+GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum target, GLenum access);
+GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum target);
+GLAPI void APIENTRY glGetBufferParameterivARB (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetBufferPointervARB (GLenum target, GLenum pname, GLvoid* *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer);
+typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers);
+typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers);
+typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer);
+typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage);
+typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data);
+typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data);
+typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access);
+typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params);
+#endif
+
+#ifndef GL_ARB_occlusion_query
+#define GL_ARB_occlusion_query 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGenQueriesARB (GLsizei n, GLuint *ids);
+GLAPI void APIENTRY glDeleteQueriesARB (GLsizei n, const GLuint *ids);
+GLAPI GLboolean APIENTRY glIsQueryARB (GLuint id);
+GLAPI void APIENTRY glBeginQueryARB (GLenum target, GLuint id);
+GLAPI void APIENTRY glEndQueryARB (GLenum target);
+GLAPI void APIENTRY glGetQueryivARB (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetQueryObjectivARB (GLuint id, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids);
+typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids);
+typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id);
+typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params);
+#endif
+
+#ifndef GL_ARB_shader_objects
+#define GL_ARB_shader_objects 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB obj);
+GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum pname);
+GLAPI void APIENTRY glDetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj);
+GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum shaderType);
+GLAPI void APIENTRY glShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length);
+GLAPI void APIENTRY glCompileShaderARB (GLhandleARB shaderObj);
+GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void);
+GLAPI void APIENTRY glAttachObjectARB (GLhandleARB containerObj, GLhandleARB obj);
+GLAPI void APIENTRY glLinkProgramARB (GLhandleARB programObj);
+GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB programObj);
+GLAPI void APIENTRY glValidateProgramARB (GLhandleARB programObj);
+GLAPI void APIENTRY glUniform1fARB (GLint location, GLfloat v0);
+GLAPI void APIENTRY glUniform2fARB (GLint location, GLfloat v0, GLfloat v1);
+GLAPI void APIENTRY glUniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+GLAPI void APIENTRY glUniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+GLAPI void APIENTRY glUniform1iARB (GLint location, GLint v0);
+GLAPI void APIENTRY glUniform2iARB (GLint location, GLint v0, GLint v1);
+GLAPI void APIENTRY glUniform3iARB (GLint location, GLint v0, GLint v1, GLint v2);
+GLAPI void APIENTRY glUniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+GLAPI void APIENTRY glUniform1fvARB (GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glUniform2fvARB (GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glUniform3fvARB (GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glUniform4fvARB (GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glUniform1ivARB (GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glUniform2ivARB (GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glUniform3ivARB (GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glUniform4ivARB (GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glUniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glUniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glUniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog);
+GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj);
+GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name);
+GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name);
+GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params);
+GLAPI void APIENTRY glGetUniformivARB (GLhandleARB programObj, GLint location, GLint *params);
+GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj);
+typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname);
+typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj);
+typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType);
+typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length);
+typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj);
+typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void);
+typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj);
+typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj);
+typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj);
+typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj);
+typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0);
+typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1);
+typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0);
+typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1);
+typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2);
+typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog);
+typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj);
+typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name);
+typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name);
+typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params);
+typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source);
+#endif
+
+#ifndef GL_ARB_vertex_shader
+#define GL_ARB_vertex_shader 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name);
+GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name);
+GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name);
+typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name);
+typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name);
+#endif
+
+#ifndef GL_ARB_fragment_shader
+#define GL_ARB_fragment_shader 1
+#endif
+
+#ifndef GL_ARB_shading_language_100
+#define GL_ARB_shading_language_100 1
+#endif
+
+#ifndef GL_ARB_texture_non_power_of_two
+#define GL_ARB_texture_non_power_of_two 1
+#endif
+
+#ifndef GL_ARB_point_sprite
+#define GL_ARB_point_sprite 1
+#endif
+
+#ifndef GL_ARB_fragment_program_shadow
+#define GL_ARB_fragment_program_shadow 1
+#endif
+
+#ifndef GL_ARB_draw_buffers
+#define GL_ARB_draw_buffers 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawBuffersARB (GLsizei n, const GLenum *bufs);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs);
+#endif
+
+#ifndef GL_ARB_texture_rectangle
+#define GL_ARB_texture_rectangle 1
+#endif
+
+#ifndef GL_ARB_color_buffer_float
+#define GL_ARB_color_buffer_float 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glClampColorARB (GLenum target, GLenum clamp);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp);
+#endif
+
+#ifndef GL_ARB_half_float_pixel
+#define GL_ARB_half_float_pixel 1
+#endif
+
+#ifndef GL_ARB_texture_float
+#define GL_ARB_texture_float 1
+#endif
+
+#ifndef GL_ARB_pixel_buffer_object
+#define GL_ARB_pixel_buffer_object 1
+#endif
+
+#ifndef GL_ARB_depth_buffer_float
+#define GL_ARB_depth_buffer_float 1
+#endif
+
+#ifndef GL_ARB_draw_instanced
+#define GL_ARB_draw_instanced 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
+GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
+typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
+#endif
+
+#ifndef GL_ARB_framebuffer_object
+#define GL_ARB_framebuffer_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer);
+GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer);
+GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers);
+GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers);
+GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params);
+GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer);
+GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer);
+GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers);
+GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers);
+GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target);
+GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGenerateMipmap (GLenum target);
+GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers);
+typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers);
+typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer);
+typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer);
+typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers);
+typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers);
+typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
+#endif
+
+#ifndef GL_ARB_framebuffer_sRGB
+#define GL_ARB_framebuffer_sRGB 1
+#endif
+
+#ifndef GL_ARB_geometry_shader4
+#define GL_ARB_geometry_shader4 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value);
+GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level);
+GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
+GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face);
+#endif
+
+#ifndef GL_ARB_half_float_vertex
+#define GL_ARB_half_float_vertex 1
+#endif
+
+#ifndef GL_ARB_instanced_arrays
+#define GL_ARB_instanced_arrays 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor);
+#endif
+
+#ifndef GL_ARB_map_buffer_range
+#define GL_ARB_map_buffer_range 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLvoid* APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length);
+#endif
+
+#ifndef GL_ARB_texture_buffer_object
+#define GL_ARB_texture_buffer_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer);
+#endif
+
+#ifndef GL_ARB_texture_compression_rgtc
+#define GL_ARB_texture_compression_rgtc 1
+#endif
+
+#ifndef GL_ARB_texture_rg
+#define GL_ARB_texture_rg 1
+#endif
+
+#ifndef GL_ARB_vertex_array_object
+#define GL_ARB_vertex_array_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBindVertexArray (GLuint array);
+GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays);
+GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays);
+GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array);
+typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays);
+typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays);
+typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array);
+#endif
+
+#ifndef GL_ARB_uniform_buffer_object
+#define GL_ARB_uniform_buffer_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar* const *uniformNames, GLuint *uniformIndices);
+GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName);
+GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName);
+GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName);
+GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar* const *uniformNames, GLuint *uniformIndices);
+typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName);
+typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName);
+typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName);
+typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
+#endif
+
+#ifndef GL_ARB_compatibility
+#define GL_ARB_compatibility 1
+#endif
+
+#ifndef GL_ARB_copy_buffer
+#define GL_ARB_copy_buffer 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
+#endif
+
+#ifndef GL_ARB_shader_texture_lod
+#define GL_ARB_shader_texture_lod 1
+#endif
+
+#ifndef GL_ARB_depth_clamp
+#define GL_ARB_depth_clamp 1
+#endif
+
+#ifndef GL_ARB_draw_elements_base_vertex
+#define GL_ARB_draw_elements_base_vertex 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex);
+GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex);
+GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount, GLint basevertex);
+GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount, const GLint *basevertex);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex);
+typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex);
+typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount, GLint basevertex);
+typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount, const GLint *basevertex);
+#endif
+
+#ifndef GL_ARB_fragment_coord_conventions
+#define GL_ARB_fragment_coord_conventions 1
+#endif
+
+#ifndef GL_ARB_provoking_vertex
+#define GL_ARB_provoking_vertex 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glProvokingVertex (GLenum mode);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode);
+#endif
+
+#ifndef GL_ARB_seamless_cube_map
+#define GL_ARB_seamless_cube_map 1
+#endif
+
+#ifndef GL_ARB_sync
+#define GL_ARB_sync 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags);
+GLAPI GLboolean APIENTRY glIsSync (GLsync sync);
+GLAPI void APIENTRY glDeleteSync (GLsync sync);
+GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout);
+GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout);
+GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *params);
+GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags);
+typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync);
+typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync);
+typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
+typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
+typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *params);
+typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
+#endif
+
+#ifndef GL_ARB_texture_multisample
+#define GL_ARB_texture_multisample 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
+GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
+GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val);
+GLAPI void APIENTRY glSampleMaski (GLuint index, GLbitfield mask);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
+typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
+typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val);
+typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint index, GLbitfield mask);
+#endif
+
+#ifndef GL_ARB_vertex_array_bgra
+#define GL_ARB_vertex_array_bgra 1
+#endif
+
+#ifndef GL_ARB_draw_buffers_blend
+#define GL_ARB_draw_buffers_blend 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode);
+GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha);
+GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst);
+GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode);
+typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha);
+typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst);
+typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+#endif
+
+#ifndef GL_ARB_sample_shading
+#define GL_ARB_sample_shading 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLfloat value);
+#endif
+
+#ifndef GL_ARB_texture_cube_map_array
+#define GL_ARB_texture_cube_map_array 1
+#endif
+
+#ifndef GL_ARB_texture_gather
+#define GL_ARB_texture_gather 1
+#endif
+
+#ifndef GL_ARB_texture_query_lod
+#define GL_ARB_texture_query_lod 1
+#endif
+
+#ifndef GL_ARB_shading_language_include
+#define GL_ARB_shading_language_include 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string);
+GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name);
+GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length);
+GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name);
+GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string);
+GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string);
+typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name);
+typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length);
+typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name);
+typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string);
+typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params);
+#endif
+
+#ifndef GL_ARB_texture_compression_bptc
+#define GL_ARB_texture_compression_bptc 1
+#endif
+
+#ifndef GL_ARB_blend_func_extended
+#define GL_ARB_blend_func_extended 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name);
+GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name);
+typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name);
+#endif
+
+#ifndef GL_ARB_explicit_attrib_location
+#define GL_ARB_explicit_attrib_location 1
+#endif
+
+#ifndef GL_ARB_occlusion_query2
+#define GL_ARB_occlusion_query2 1
+#endif
+
+#ifndef GL_ARB_sampler_objects
+#define GL_ARB_sampler_objects 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers);
+GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers);
+GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler);
+GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler);
+GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param);
+GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param);
+GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param);
+GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param);
+GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param);
+GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param);
+GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers);
+typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers);
+typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler);
+typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler);
+typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param);
+typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param);
+typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param);
+typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param);
+typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params);
+#endif
+
+#ifndef GL_ARB_shader_bit_encoding
+#define GL_ARB_shader_bit_encoding 1
+#endif
+
+#ifndef GL_ARB_texture_rgb10_a2ui
+#define GL_ARB_texture_rgb10_a2ui 1
+#endif
+
+#ifndef GL_ARB_texture_swizzle
+#define GL_ARB_texture_swizzle 1
+#endif
+
+#ifndef GL_ARB_timer_query
+#define GL_ARB_timer_query 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target);
+GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params);
+GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target);
+typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params);
+typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params);
+#endif
+
+#ifndef GL_ARB_vertex_type_2_10_10_10_rev
+#define GL_ARB_vertex_type_2_10_10_10_rev 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value);
+GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value);
+GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value);
+GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value);
+GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value);
+GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value);
+GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords);
+GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords);
+GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords);
+GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords);
+GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords);
+GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords);
+GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords);
+GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords);
+GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords);
+GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords);
+GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords);
+GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords);
+GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords);
+GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords);
+GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords);
+GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords);
+GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords);
+GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords);
+GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color);
+GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color);
+GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color);
+GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color);
+GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color);
+GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color);
+GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value);
+GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);
+GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value);
+GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);
+GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value);
+GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);
+GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value);
+GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value);
+typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value);
+typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value);
+typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value);
+typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value);
+typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value);
+typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords);
+typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords);
+typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords);
+typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords);
+typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords);
+typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords);
+typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords);
+typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords);
+typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords);
+typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords);
+typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords);
+typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords);
+typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords);
+typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords);
+typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords);
+typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords);
+typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords);
+typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords);
+typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color);
+typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color);
+typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color);
+typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color);
+typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color);
+typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);
+#endif
+
+#ifndef GL_ARB_draw_indirect
+#define GL_ARB_draw_indirect 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const GLvoid *indirect);
+GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const GLvoid *indirect);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const GLvoid *indirect);
+typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const GLvoid *indirect);
+#endif
+
+#ifndef GL_ARB_gpu_shader5
+#define GL_ARB_gpu_shader5 1
+#endif
+
+#ifndef GL_ARB_gpu_shader_fp64
+#define GL_ARB_gpu_shader_fp64 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x);
+GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y);
+GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value);
+GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value);
+GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value);
+GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value);
+GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x);
+typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value);
+typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value);
+typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value);
+typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params);
+#endif
+
+#ifndef GL_ARB_shader_subroutine
+#define GL_ARB_shader_subroutine 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name);
+GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name);
+GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values);
+GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name);
+GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name);
+GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices);
+GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params);
+GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name);
+typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name);
+typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values);
+typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name);
+typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name);
+typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices);
+typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values);
+#endif
+
+#ifndef GL_ARB_tessellation_shader
+#define GL_ARB_tessellation_shader 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value);
+GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value);
+typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values);
+#endif
+
+#ifndef GL_ARB_texture_buffer_object_rgb32
+#define GL_ARB_texture_buffer_object_rgb32 1
+#endif
+
+#ifndef GL_ARB_transform_feedback2
+#define GL_ARB_transform_feedback2 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id);
+GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids);
+GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids);
+GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id);
+GLAPI void APIENTRY glPauseTransformFeedback (void);
+GLAPI void APIENTRY glResumeTransformFeedback (void);
+GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id);
+typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids);
+typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids);
+typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void);
+typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void);
+typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id);
+#endif
+
+#ifndef GL_ARB_transform_feedback3
+#define GL_ARB_transform_feedback3 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream);
+GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id);
+GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index);
+GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream);
+typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id);
+typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index);
+typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params);
+#endif
+
+#ifndef GL_ARB_ES2_compatibility
+#define GL_ARB_ES2_compatibility 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glReleaseShaderCompiler (void);
+GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length);
+GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision);
+GLAPI void APIENTRY glDepthRangef (GLfloat n, GLfloat f);
+GLAPI void APIENTRY glClearDepthf (GLfloat d);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void);
+typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length);
+typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision);
+typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f);
+typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d);
+#endif
+
+#ifndef GL_ARB_get_program_binary
+#define GL_ARB_get_program_binary 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary);
+GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length);
+GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary);
+typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length);
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value);
+#endif
+
+#ifndef GL_ARB_separate_shader_objects
+#define GL_ARB_separate_shader_objects 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program);
+GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program);
+GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar* const *strings);
+GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline);
+GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines);
+GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines);
+GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline);
+GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params);
+GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0);
+GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0);
+GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0);
+GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0);
+GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1);
+GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1);
+GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1);
+GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1);
+GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2);
+GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2);
+GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);
+GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3);
+GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline);
+GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program);
+typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program);
+typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar* const *strings);
+typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline);
+typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines);
+typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines);
+typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline);
+typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline);
+typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+#endif
+
+#ifndef GL_ARB_vertex_attrib_64bit
+#define GL_ARB_vertex_attrib_64bit 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x);
+GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y);
+GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params);
+#endif
+
+#ifndef GL_ARB_viewport_array
+#define GL_ARB_viewport_array 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v);
+GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h);
+GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v);
+GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v);
+GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v);
+GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLdouble *v);
+GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLdouble n, GLdouble f);
+GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data);
+GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h);
+typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v);
+typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLdouble *v);
+typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLdouble n, GLdouble f);
+typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data);
+typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data);
+#endif
+
+#ifndef GL_ARB_cl_event
+#define GL_ARB_cl_event 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context * context, struct _cl_event * event, GLbitfield flags);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (struct _cl_context * context, struct _cl_event * event, GLbitfield flags);
+#endif
+
+#ifndef GL_ARB_debug_output
+#define GL_ARB_debug_output 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
+GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
+GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const GLvoid *userParam);
+GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
+typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
+typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const GLvoid *userParam);
+typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
+#endif
+
+#ifndef GL_ARB_robustness
+#define GL_ARB_robustness 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void);
+GLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v);
+GLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v);
+GLAPI void APIENTRY glGetnMapivARB (GLenum target, GLenum query, GLsizei bufSize, GLint *v);
+GLAPI void APIENTRY glGetnPixelMapfvARB (GLenum map, GLsizei bufSize, GLfloat *values);
+GLAPI void APIENTRY glGetnPixelMapuivARB (GLenum map, GLsizei bufSize, GLuint *values);
+GLAPI void APIENTRY glGetnPixelMapusvARB (GLenum map, GLsizei bufSize, GLushort *values);
+GLAPI void APIENTRY glGetnPolygonStippleARB (GLsizei bufSize, GLubyte *pattern);
+GLAPI void APIENTRY glGetnColorTableARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table);
+GLAPI void APIENTRY glGetnConvolutionFilterARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image);
+GLAPI void APIENTRY glGetnSeparableFilterARB (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span);
+GLAPI void APIENTRY glGetnHistogramARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values);
+GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values);
+GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img);
+GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data);
+GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img);
+GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params);
+GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params);
+GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params);
+GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void);
+typedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v);
+typedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v);
+typedef void (APIENTRYP PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v);
+typedef void (APIENTRYP PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat *values);
+typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint *values);
+typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort *values);
+typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte *pattern);
+typedef void (APIENTRYP PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table);
+typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image);
+typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span);
+typedef void (APIENTRYP PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values);
+typedef void (APIENTRYP PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values);
+typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img);
+typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data);
+typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img);
+typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params);
+typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params);
+typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params);
+#endif
+
+#ifndef GL_ARB_shader_stencil_export
+#define GL_ARB_shader_stencil_export 1
+#endif
+
+#ifndef GL_ARB_base_instance
+#define GL_ARB_base_instance 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance);
+GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance);
+GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance);
+typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance);
+typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance);
+#endif
+
+#ifndef GL_ARB_shading_language_420pack
+#define GL_ARB_shading_language_420pack 1
+#endif
+
+#ifndef GL_ARB_transform_feedback_instanced
+#define GL_ARB_transform_feedback_instanced 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei instancecount);
+GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei instancecount);
+typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount);
+#endif
+
+#ifndef GL_ARB_compressed_texture_pixel_storage
+#define GL_ARB_compressed_texture_pixel_storage 1
+#endif
+
+#ifndef GL_ARB_conservative_depth
+#define GL_ARB_conservative_depth 1
+#endif
+
+#ifndef GL_ARB_internalformat_query
+#define GL_ARB_internalformat_query 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params);
+#endif
+
+#ifndef GL_ARB_map_buffer_alignment
+#define GL_ARB_map_buffer_alignment 1
+#endif
+
+#ifndef GL_ARB_shader_atomic_counters
+#define GL_ARB_shader_atomic_counters 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params);
+#endif
+
+#ifndef GL_ARB_shader_image_load_store
+#define GL_ARB_shader_image_load_store 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format);
+GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format);
+typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers);
+#endif
+
+#ifndef GL_ARB_shading_language_packing
+#define GL_ARB_shading_language_packing 1
+#endif
+
+#ifndef GL_ARB_texture_storage
+#define GL_ARB_texture_storage 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+#endif
+
+#ifndef GL_KHR_texture_compression_astc_ldr
+#define GL_KHR_texture_compression_astc_ldr 1
+#endif
+
+#ifndef GL_KHR_debug
+#define GL_KHR_debug 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
+GLAPI void APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
+GLAPI void APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam);
+GLAPI GLuint APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
+GLAPI void APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message);
+GLAPI void APIENTRY glPopDebugGroup (void);
+GLAPI void APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
+GLAPI void APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);
+GLAPI void APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label);
+GLAPI void APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
+typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
+typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam);
+typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
+typedef void (APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message);
+typedef void (APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void);
+typedef void (APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
+typedef void (APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);
+typedef void (APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label);
+typedef void (APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);
+#endif
+
+#ifndef GL_ARB_arrays_of_arrays
+#define GL_ARB_arrays_of_arrays 1
+#endif
+
+#ifndef GL_ARB_clear_buffer_object
+#define GL_ARB_clear_buffer_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glClearBufferData (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data);
+GLAPI void APIENTRY glClearBufferSubData (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data);
+GLAPI void APIENTRY glClearNamedBufferDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data);
+GLAPI void APIENTRY glClearNamedBufferSubDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, GLsizeiptr offset, GLsizeiptr size, const void *data);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCLEARBUFFERDATAPROC) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data);
+typedef void (APIENTRYP PFNGLCLEARBUFFERSUBDATAPROC) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data);
+typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data);
+typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, GLsizeiptr offset, GLsizeiptr size, const void *data);
+#endif
+
+#ifndef GL_ARB_compute_shader
+#define GL_ARB_compute_shader 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z);
+GLAPI void APIENTRY glDispatchComputeIndirect (GLintptr indirect);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z);
+typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect);
+#endif
+
+#ifndef GL_ARB_copy_image
+#define GL_ARB_copy_image 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth);
+#endif
+
+#ifndef GL_ARB_texture_view
+#define GL_ARB_texture_view 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTextureView (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXTUREVIEWPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);
+#endif
+
+#ifndef GL_ARB_vertex_attrib_binding
+#define GL_ARB_vertex_attrib_binding 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);
+GLAPI void APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);
+GLAPI void APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
+GLAPI void APIENTRY glVertexAttribLFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
+GLAPI void APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex);
+GLAPI void APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor);
+GLAPI void APIENTRY glVertexArrayBindVertexBufferEXT (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);
+GLAPI void APIENTRY glVertexArrayVertexAttribFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);
+GLAPI void APIENTRY glVertexArrayVertexAttribIFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
+GLAPI void APIENTRY glVertexArrayVertexAttribLFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
+GLAPI void APIENTRY glVertexArrayVertexAttribBindingEXT (GLuint vaobj, GLuint attribindex, GLuint bindingindex);
+GLAPI void APIENTRY glVertexArrayVertexBindingDivisorEXT (GLuint vaobj, GLuint bindingindex, GLuint divisor);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex);
+typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor);
+typedef void (APIENTRYP PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);
+typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);
+typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
+typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
+typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex);
+typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor);
+#endif
+
+#ifndef GL_ARB_robustness_isolation
+#define GL_ARB_robustness_isolation 1
+#endif
+
+#ifndef GL_ARB_ES3_compatibility
+#define GL_ARB_ES3_compatibility 1
+#endif
+
+#ifndef GL_ARB_explicit_uniform_location
+#define GL_ARB_explicit_uniform_location 1
+#endif
+
+#ifndef GL_ARB_fragment_layer_viewport
+#define GL_ARB_fragment_layer_viewport 1
+#endif
+
+#ifndef GL_ARB_framebuffer_no_attachments
+#define GL_ARB_framebuffer_no_attachments 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param);
+GLAPI void APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glNamedFramebufferParameteriEXT (GLuint framebuffer, GLenum pname, GLint param);
+GLAPI void APIENTRY glGetNamedFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params);
+#endif
+
+#ifndef GL_ARB_internalformat_query2
+#define GL_ARB_internalformat_query2 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetInternalformati64v (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params);
+#endif
+
+#ifndef GL_ARB_invalidate_subdata
+#define GL_ARB_invalidate_subdata 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glInvalidateTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth);
+GLAPI void APIENTRY glInvalidateTexImage (GLuint texture, GLint level);
+GLAPI void APIENTRY glInvalidateBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr length);
+GLAPI void APIENTRY glInvalidateBufferData (GLuint buffer);
+GLAPI void APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments);
+GLAPI void APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth);
+typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length);
+typedef void (APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer);
+typedef void (APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments);
+typedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height);
+#endif
+
+#ifndef GL_ARB_multi_draw_indirect
+#define GL_ARB_multi_draw_indirect 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glMultiDrawArraysIndirect (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride);
+GLAPI void APIENTRY glMultiDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride);
+typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride);
+#endif
+
+#ifndef GL_ARB_program_interface_query
+#define GL_ARB_program_interface_query 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params);
+GLAPI GLuint APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name);
+GLAPI void APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name);
+GLAPI void APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params);
+GLAPI GLint APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name);
+GLAPI GLint APIENTRY glGetProgramResourceLocationIndex (GLuint program, GLenum programInterface, const GLchar *name);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params);
+typedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name);
+typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name);
+typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params);
+typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name);
+typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name);
+#endif
+
+#ifndef GL_ARB_robust_buffer_access_behavior
+#define GL_ARB_robust_buffer_access_behavior 1
+#endif
+
+#ifndef GL_ARB_shader_image_size
+#define GL_ARB_shader_image_size 1
+#endif
+
+#ifndef GL_ARB_shader_storage_buffer_object
+#define GL_ARB_shader_storage_buffer_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glShaderStorageBlockBinding (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding);
+#endif
+
+#ifndef GL_ARB_stencil_texturing
+#define GL_ARB_stencil_texturing 1
+#endif
+
+#ifndef GL_ARB_texture_buffer_range
+#define GL_ARB_texture_buffer_range 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexBufferRange (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);
+GLAPI void APIENTRY glTextureBufferRangeEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);
+typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);
+#endif
+
+#ifndef GL_ARB_texture_query_levels
+#define GL_ARB_texture_query_levels 1
+#endif
+
+#ifndef GL_ARB_texture_storage_multisample
+#define GL_ARB_texture_storage_multisample 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
+GLAPI void APIENTRY glTexStorage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
+GLAPI void APIENTRY glTextureStorage2DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
+GLAPI void APIENTRY glTextureStorage3DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
+typedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
+typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
+typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
+#endif
+
+#ifndef GL_EXT_abgr
+#define GL_EXT_abgr 1
+#endif
+
+#ifndef GL_EXT_blend_color
+#define GL_EXT_blend_color 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendColorEXT (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+#endif
+
+#ifndef GL_EXT_polygon_offset
+#define GL_EXT_polygon_offset 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat factor, GLfloat bias);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias);
+#endif
+
+#ifndef GL_EXT_texture
+#define GL_EXT_texture 1
+#endif
+
+#ifndef GL_EXT_texture3D
+#define GL_EXT_texture3D 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexImage3DEXT (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+#endif
+
+#ifndef GL_SGIS_texture_filter4
+#define GL_SGIS_texture_filter4 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum target, GLenum filter, GLfloat *weights);
+GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights);
+typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights);
+#endif
+
+#ifndef GL_EXT_subtexture
+#define GL_EXT_subtexture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
+#endif
+
+#ifndef GL_EXT_copy_texture
+#define GL_EXT_copy_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
+GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
+GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
+typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+#endif
+
+#ifndef GL_EXT_histogram
+#define GL_EXT_histogram 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetHistogramEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum target, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetMinmaxEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum target, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glHistogramEXT (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);
+GLAPI void APIENTRY glMinmaxEXT (GLenum target, GLenum internalformat, GLboolean sink);
+GLAPI void APIENTRY glResetHistogramEXT (GLenum target);
+GLAPI void APIENTRY glResetMinmaxEXT (GLenum target);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);
+typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink);
+typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target);
+#endif
+
+#ifndef GL_EXT_convolution
+#define GL_EXT_convolution 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image);
+GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image);
+GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum target, GLenum pname, GLfloat params);
+GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum target, GLenum pname, GLint params);
+GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum target, GLenum format, GLenum type, GLvoid *image);
+GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum target, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span);
+GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image);
+typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image);
+typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span);
+typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column);
+#endif
+
+#ifndef GL_SGI_color_matrix
+#define GL_SGI_color_matrix 1
+#endif
+
+#ifndef GL_SGI_color_table
+#define GL_SGI_color_table 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glColorTableSGI (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
+GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum target, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glColorTableParameterivSGI (GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glCopyColorTableSGI (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+GLAPI void APIENTRY glGetColorTableSGI (GLenum target, GLenum format, GLenum type, GLvoid *table);
+GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum target, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum target, GLenum pname, GLint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
+typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params);
+#endif
+
+#ifndef GL_SGIX_pixel_texture
+#define GL_SGIX_pixel_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPixelTexGenSGIX (GLenum mode);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode);
+#endif
+
+#ifndef GL_SGIS_pixel_texture
+#define GL_SGIS_pixel_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum pname, GLint param);
+GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum pname, const GLint *params);
+GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum pname, GLfloat param);
+GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum pname, GLfloat *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params);
+#endif
+
+#ifndef GL_SGIS_texture4D
+#define GL_SGIS_texture4D 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexImage4DSGIS (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels);
+#endif
+
+#ifndef GL_SGI_texture_color_table
+#define GL_SGI_texture_color_table 1
+#endif
+
+#ifndef GL_EXT_cmyka
+#define GL_EXT_cmyka 1
+#endif
+
+#ifndef GL_EXT_texture_object
+#define GL_EXT_texture_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei n, const GLuint *textures, GLboolean *residences);
+GLAPI void APIENTRY glBindTextureEXT (GLenum target, GLuint texture);
+GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei n, const GLuint *textures);
+GLAPI void APIENTRY glGenTexturesEXT (GLsizei n, GLuint *textures);
+GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint texture);
+GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei n, const GLuint *textures, const GLclampf *priorities);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences);
+typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture);
+typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures);
+typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures);
+typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture);
+typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities);
+#endif
+
+#ifndef GL_SGIS_detail_texture
+#define GL_SGIS_detail_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points);
+GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum target, GLfloat *points);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points);
+typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points);
+#endif
+
+#ifndef GL_SGIS_sharpen_texture
+#define GL_SGIS_sharpen_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points);
+GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum target, GLfloat *points);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points);
+typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points);
+#endif
+
+#ifndef GL_EXT_packed_pixels
+#define GL_EXT_packed_pixels 1
+#endif
+
+#ifndef GL_SGIS_texture_lod
+#define GL_SGIS_texture_lod 1
+#endif
+
+#ifndef GL_SGIS_multisample
+#define GL_SGIS_multisample 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glSampleMaskSGIS (GLclampf value, GLboolean invert);
+GLAPI void APIENTRY glSamplePatternSGIS (GLenum pattern);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert);
+typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern);
+#endif
+
+#ifndef GL_EXT_rescale_normal
+#define GL_EXT_rescale_normal 1
+#endif
+
+#ifndef GL_EXT_vertex_array
+#define GL_EXT_vertex_array 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glArrayElementEXT (GLint i);
+GLAPI void APIENTRY glColorPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+GLAPI void APIENTRY glDrawArraysEXT (GLenum mode, GLint first, GLsizei count);
+GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei stride, GLsizei count, const GLboolean *pointer);
+GLAPI void APIENTRY glGetPointervEXT (GLenum pname, GLvoid* *params);
+GLAPI void APIENTRY glIndexPointerEXT (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+GLAPI void APIENTRY glNormalPointerEXT (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+GLAPI void APIENTRY glTexCoordPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+GLAPI void APIENTRY glVertexPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i);
+typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count);
+typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer);
+typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params);
+typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+#endif
+
+#ifndef GL_EXT_misc_attribute
+#define GL_EXT_misc_attribute 1
+#endif
+
+#ifndef GL_SGIS_generate_mipmap
+#define GL_SGIS_generate_mipmap 1
+#endif
+
+#ifndef GL_SGIX_clipmap
+#define GL_SGIX_clipmap 1
+#endif
+
+#ifndef GL_SGIX_shadow
+#define GL_SGIX_shadow 1
+#endif
+
+#ifndef GL_SGIS_texture_edge_clamp
+#define GL_SGIS_texture_edge_clamp 1
+#endif
+
+#ifndef GL_SGIS_texture_border_clamp
+#define GL_SGIS_texture_border_clamp 1
+#endif
+
+#ifndef GL_EXT_blend_minmax
+#define GL_EXT_blend_minmax 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendEquationEXT (GLenum mode);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode);
+#endif
+
+#ifndef GL_EXT_blend_subtract
+#define GL_EXT_blend_subtract 1
+#endif
+
+#ifndef GL_EXT_blend_logic_op
+#define GL_EXT_blend_logic_op 1
+#endif
+
+#ifndef GL_SGIX_interlace
+#define GL_SGIX_interlace 1
+#endif
+
+#ifndef GL_SGIX_pixel_tiles
+#define GL_SGIX_pixel_tiles 1
+#endif
+
+#ifndef GL_SGIS_texture_select
+#define GL_SGIS_texture_select 1
+/* This used to be SGIX prefix, which was an error in the header */
+#endif
+
+#ifndef GL_SGIX_sprite
+#define GL_SGIX_sprite 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum pname, GLfloat param);
+GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum pname, GLint param);
+GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum pname, const GLint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params);
+#endif
+
+#ifndef GL_SGIX_texture_multi_buffer
+#define GL_SGIX_texture_multi_buffer 1
+#endif
+
+#ifndef GL_EXT_point_parameters
+#define GL_EXT_point_parameters 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPointParameterfEXT (GLenum pname, GLfloat param);
+GLAPI void APIENTRY glPointParameterfvEXT (GLenum pname, const GLfloat *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params);
+#endif
+
+#ifndef GL_SGIS_point_parameters
+#define GL_SGIS_point_parameters 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPointParameterfSGIS (GLenum pname, GLfloat param);
+GLAPI void APIENTRY glPointParameterfvSGIS (GLenum pname, const GLfloat *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params);
+#endif
+
+#ifndef GL_SGIX_instruments
+#define GL_SGIX_instruments 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLint APIENTRY glGetInstrumentsSGIX (void);
+GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei size, GLint *buffer);
+GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *marker_p);
+GLAPI void APIENTRY glReadInstrumentsSGIX (GLint marker);
+GLAPI void APIENTRY glStartInstrumentsSGIX (void);
+GLAPI void APIENTRY glStopInstrumentsSGIX (GLint marker);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void);
+typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer);
+typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p);
+typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker);
+typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void);
+typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker);
+#endif
+
+#ifndef GL_SGIX_texture_scale_bias
+#define GL_SGIX_texture_scale_bias 1
+#endif
+
+#ifndef GL_SGIX_framezoom
+#define GL_SGIX_framezoom 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFrameZoomSGIX (GLint factor);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor);
+#endif
+
+#ifndef GL_SGIX_tag_sample_buffer
+#define GL_SGIX_tag_sample_buffer 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTagSampleBufferSGIX (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void);
+#endif
+
+#ifndef GL_SGIX_polynomial_ffd
+#define GL_SGIX_polynomial_ffd 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points);
+GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points);
+GLAPI void APIENTRY glDeformSGIX (GLbitfield mask);
+GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield mask);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points);
+typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points);
+typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask);
+typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask);
+#endif
+
+#ifndef GL_SGIX_reference_plane
+#define GL_SGIX_reference_plane 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *equation);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation);
+#endif
+
+#ifndef GL_SGIX_flush_raster
+#define GL_SGIX_flush_raster 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFlushRasterSGIX (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void);
+#endif
+
+#ifndef GL_SGIX_depth_texture
+#define GL_SGIX_depth_texture 1
+#endif
+
+#ifndef GL_SGIS_fog_function
+#define GL_SGIS_fog_function 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFogFuncSGIS (GLsizei n, const GLfloat *points);
+GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *points);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points);
+typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points);
+#endif
+
+#ifndef GL_SGIX_fog_offset
+#define GL_SGIX_fog_offset 1
+#endif
+
+#ifndef GL_HP_image_transform
+#define GL_HP_image_transform 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glImageTransformParameteriHP (GLenum target, GLenum pname, GLint param);
+GLAPI void APIENTRY glImageTransformParameterfHP (GLenum target, GLenum pname, GLfloat param);
+GLAPI void APIENTRY glImageTransformParameterivHP (GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum target, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum target, GLenum pname, GLfloat *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params);
+#endif
+
+#ifndef GL_HP_convolution_border_modes
+#define GL_HP_convolution_border_modes 1
+#endif
+
+#ifndef GL_SGIX_texture_add_env
+#define GL_SGIX_texture_add_env 1
+#endif
+
+#ifndef GL_EXT_color_subtable
+#define GL_EXT_color_subtable 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glColorSubTableEXT (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data);
+GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);
+#endif
+
+#ifndef GL_PGI_vertex_hints
+#define GL_PGI_vertex_hints 1
+#endif
+
+#ifndef GL_PGI_misc_hints
+#define GL_PGI_misc_hints 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glHintPGI (GLenum target, GLint mode);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode);
+#endif
+
+#ifndef GL_EXT_paletted_texture
+#define GL_EXT_paletted_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glColorTableEXT (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
+GLAPI void APIENTRY glGetColorTableEXT (GLenum target, GLenum format, GLenum type, GLvoid *data);
+GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum target, GLenum pname, GLfloat *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);
+#endif
+
+#ifndef GL_EXT_clip_volume_hint
+#define GL_EXT_clip_volume_hint 1
+#endif
+
+#ifndef GL_SGIX_list_priority
+#define GL_SGIX_list_priority 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint list, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetListParameterivSGIX (GLuint list, GLenum pname, GLint *params);
+GLAPI void APIENTRY glListParameterfSGIX (GLuint list, GLenum pname, GLfloat param);
+GLAPI void APIENTRY glListParameterfvSGIX (GLuint list, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glListParameteriSGIX (GLuint list, GLenum pname, GLint param);
+GLAPI void APIENTRY glListParameterivSGIX (GLuint list, GLenum pname, const GLint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params);
+#endif
+
+#ifndef GL_SGIX_ir_instrument1
+#define GL_SGIX_ir_instrument1 1
+#endif
+
+#ifndef GL_SGIX_calligraphic_fragment
+#define GL_SGIX_calligraphic_fragment 1
+#endif
+
+#ifndef GL_SGIX_texture_lod_bias
+#define GL_SGIX_texture_lod_bias 1
+#endif
+
+#ifndef GL_SGIX_shadow_ambient
+#define GL_SGIX_shadow_ambient 1
+#endif
+
+#ifndef GL_EXT_index_texture
+#define GL_EXT_index_texture 1
+#endif
+
+#ifndef GL_EXT_index_material
+#define GL_EXT_index_material 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glIndexMaterialEXT (GLenum face, GLenum mode);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode);
+#endif
+
+#ifndef GL_EXT_index_func
+#define GL_EXT_index_func 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glIndexFuncEXT (GLenum func, GLclampf ref);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref);
+#endif
+
+#ifndef GL_EXT_index_array_formats
+#define GL_EXT_index_array_formats 1
+#endif
+
+#ifndef GL_EXT_compiled_vertex_array
+#define GL_EXT_compiled_vertex_array 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glLockArraysEXT (GLint first, GLsizei count);
+GLAPI void APIENTRY glUnlockArraysEXT (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count);
+typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void);
+#endif
+
+#ifndef GL_EXT_cull_vertex
+#define GL_EXT_cull_vertex 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glCullParameterdvEXT (GLenum pname, GLdouble *params);
+GLAPI void APIENTRY glCullParameterfvEXT (GLenum pname, GLfloat *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params);
+typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params);
+#endif
+
+#ifndef GL_SGIX_ycrcb
+#define GL_SGIX_ycrcb 1
+#endif
+
+#ifndef GL_SGIX_fragment_lighting
+#define GL_SGIX_fragment_lighting 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum face, GLenum mode);
+GLAPI void APIENTRY glFragmentLightfSGIX (GLenum light, GLenum pname, GLfloat param);
+GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum light, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glFragmentLightiSGIX (GLenum light, GLenum pname, GLint param);
+GLAPI void APIENTRY glFragmentLightivSGIX (GLenum light, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum pname, GLfloat param);
+GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum pname, GLint param);
+GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum pname, const GLint *params);
+GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum face, GLenum pname, GLfloat param);
+GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum face, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum face, GLenum pname, GLint param);
+GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum face, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum light, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum light, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum face, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum face, GLenum pname, GLint *params);
+GLAPI void APIENTRY glLightEnviSGIX (GLenum pname, GLint param);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param);
+#endif
+
+#ifndef GL_IBM_rasterpos_clip
+#define GL_IBM_rasterpos_clip 1
+#endif
+
+#ifndef GL_HP_texture_lighting
+#define GL_HP_texture_lighting 1
+#endif
+
+#ifndef GL_EXT_draw_range_elements
+#define GL_EXT_draw_range_elements 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
+#endif
+
+#ifndef GL_WIN_phong_shading
+#define GL_WIN_phong_shading 1
+#endif
+
+#ifndef GL_WIN_specular_fog
+#define GL_WIN_specular_fog 1
+#endif
+
+#ifndef GL_EXT_light_texture
+#define GL_EXT_light_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glApplyTextureEXT (GLenum mode);
+GLAPI void APIENTRY glTextureLightEXT (GLenum pname);
+GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode);
+typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname);
+typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode);
+#endif
+
+#ifndef GL_SGIX_blend_alpha_minmax
+#define GL_SGIX_blend_alpha_minmax 1
+#endif
+
+#ifndef GL_EXT_bgra
+#define GL_EXT_bgra 1
+#endif
+
+#ifndef GL_SGIX_async
+#define GL_SGIX_async 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint marker);
+GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *markerp);
+GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *markerp);
+GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei range);
+GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint marker, GLsizei range);
+GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint marker);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker);
+typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp);
+typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp);
+typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range);
+typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range);
+typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker);
+#endif
+
+#ifndef GL_SGIX_async_pixel
+#define GL_SGIX_async_pixel 1
+#endif
+
+#ifndef GL_SGIX_async_histogram
+#define GL_SGIX_async_histogram 1
+#endif
+
+#ifndef GL_INTEL_parallel_arrays
+#define GL_INTEL_parallel_arrays 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer);
+GLAPI void APIENTRY glNormalPointervINTEL (GLenum type, const GLvoid* *pointer);
+GLAPI void APIENTRY glColorPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer);
+GLAPI void APIENTRY glTexCoordPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer);
+typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer);
+typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer);
+typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer);
+#endif
+
+#ifndef GL_HP_occlusion_test
+#define GL_HP_occlusion_test 1
+#endif
+
+#ifndef GL_EXT_pixel_transform
+#define GL_EXT_pixel_transform 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum target, GLenum pname, GLint param);
+GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum target, GLenum pname, GLfloat param);
+GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glGetPixelTransformParameterivEXT (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetPixelTransformParameterfvEXT (GLenum target, GLenum pname, GLfloat *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);
+#endif
+
+#ifndef GL_EXT_pixel_transform_color_table
+#define GL_EXT_pixel_transform_color_table 1
+#endif
+
+#ifndef GL_EXT_shared_texture_palette
+#define GL_EXT_shared_texture_palette 1
+#endif
+
+#ifndef GL_EXT_separate_specular_color
+#define GL_EXT_separate_specular_color 1
+#endif
+
+#ifndef GL_EXT_secondary_color
+#define GL_EXT_secondary_color 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte red, GLbyte green, GLbyte blue);
+GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *v);
+GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble red, GLdouble green, GLdouble blue);
+GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *v);
+GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat red, GLfloat green, GLfloat blue);
+GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *v);
+GLAPI void APIENTRY glSecondaryColor3iEXT (GLint red, GLint green, GLint blue);
+GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *v);
+GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort red, GLshort green, GLshort blue);
+GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *v);
+GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte red, GLubyte green, GLubyte blue);
+GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *v);
+GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint red, GLuint green, GLuint blue);
+GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *v);
+GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort red, GLushort green, GLushort blue);
+GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *v);
+GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif
+
+#ifndef GL_EXT_texture_perturb_normal
+#define GL_EXT_texture_perturb_normal 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTextureNormalEXT (GLenum mode);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode);
+#endif
+
+#ifndef GL_EXT_multi_draw_arrays
+#define GL_EXT_multi_draw_arrays 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);
+GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);
+typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);
+#endif
+
+#ifndef GL_EXT_fog_coord
+#define GL_EXT_fog_coord 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFogCoordfEXT (GLfloat coord);
+GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *coord);
+GLAPI void APIENTRY glFogCoorddEXT (GLdouble coord);
+GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *coord);
+GLAPI void APIENTRY glFogCoordPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord);
+typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord);
+typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord);
+typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord);
+typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif
+
+#ifndef GL_REND_screen_coordinates
+#define GL_REND_screen_coordinates 1
+#endif
+
+#ifndef GL_EXT_coordinate_frame
+#define GL_EXT_coordinate_frame 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTangent3bEXT (GLbyte tx, GLbyte ty, GLbyte tz);
+GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *v);
+GLAPI void APIENTRY glTangent3dEXT (GLdouble tx, GLdouble ty, GLdouble tz);
+GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *v);
+GLAPI void APIENTRY glTangent3fEXT (GLfloat tx, GLfloat ty, GLfloat tz);
+GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *v);
+GLAPI void APIENTRY glTangent3iEXT (GLint tx, GLint ty, GLint tz);
+GLAPI void APIENTRY glTangent3ivEXT (const GLint *v);
+GLAPI void APIENTRY glTangent3sEXT (GLshort tx, GLshort ty, GLshort tz);
+GLAPI void APIENTRY glTangent3svEXT (const GLshort *v);
+GLAPI void APIENTRY glBinormal3bEXT (GLbyte bx, GLbyte by, GLbyte bz);
+GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *v);
+GLAPI void APIENTRY glBinormal3dEXT (GLdouble bx, GLdouble by, GLdouble bz);
+GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *v);
+GLAPI void APIENTRY glBinormal3fEXT (GLfloat bx, GLfloat by, GLfloat bz);
+GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *v);
+GLAPI void APIENTRY glBinormal3iEXT (GLint bx, GLint by, GLint bz);
+GLAPI void APIENTRY glBinormal3ivEXT (const GLint *v);
+GLAPI void APIENTRY glBinormal3sEXT (GLshort bx, GLshort by, GLshort bz);
+GLAPI void APIENTRY glBinormal3svEXT (const GLshort *v);
+GLAPI void APIENTRY glTangentPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glBinormalPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz);
+typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v);
+typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz);
+typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz);
+typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz);
+typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz);
+typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz);
+typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v);
+typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz);
+typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz);
+typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz);
+typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz);
+typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif
+
+#ifndef GL_EXT_texture_env_combine
+#define GL_EXT_texture_env_combine 1
+#endif
+
+#ifndef GL_APPLE_specular_vector
+#define GL_APPLE_specular_vector 1
+#endif
+
+#ifndef GL_APPLE_transform_hint
+#define GL_APPLE_transform_hint 1
+#endif
+
+#ifndef GL_SGIX_fog_scale
+#define GL_SGIX_fog_scale 1
+#endif
+
+#ifndef GL_SUNX_constant_data
+#define GL_SUNX_constant_data 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFinishTextureSUNX (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void);
+#endif
+
+#ifndef GL_SUN_global_alpha
+#define GL_SUN_global_alpha 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte factor);
+GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort factor);
+GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint factor);
+GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat factor);
+GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble factor);
+GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte factor);
+GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort factor);
+GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint factor);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor);
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor);
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor);
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor);
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor);
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor);
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor);
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor);
+#endif
+
+#ifndef GL_SUN_triangle_list
+#define GL_SUN_triangle_list 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint code);
+GLAPI void APIENTRY glReplacementCodeusSUN (GLushort code);
+GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte code);
+GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *code);
+GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *code);
+GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *code);
+GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum type, GLsizei stride, const GLvoid* *pointer);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer);
+#endif
+
+#ifndef GL_SUN_vertex
+#define GL_SUN_vertex 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y);
+GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *c, const GLfloat *v);
+GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *c, const GLfloat *v);
+GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *c, const GLfloat *v);
+GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *n, const GLfloat *v);
+GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *c, const GLfloat *n, const GLfloat *v);
+GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *tc, const GLfloat *v);
+GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *tc, const GLfloat *v);
+GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *tc, const GLubyte *c, const GLfloat *v);
+GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *v);
+GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *n, const GLfloat *v);
+GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
+GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
+GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint rc, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *rc, const GLfloat *v);
+GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *rc, const GLubyte *c, const GLfloat *v);
+GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *v);
+GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *n, const GLfloat *v);
+GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
+GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *v);
+GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v);
+GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v);
+typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v);
+typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v);
+typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v);
+typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v);
+typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v);
+typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v);
+typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
+#endif
+
+#ifndef GL_EXT_blend_func_separate
+#define GL_EXT_blend_func_separate 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+#endif
+
+#ifndef GL_INGR_blend_func_separate
+#define GL_INGR_blend_func_separate 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+#endif
+
+#ifndef GL_INGR_color_clamp
+#define GL_INGR_color_clamp 1
+#endif
+
+#ifndef GL_INGR_interlace_read
+#define GL_INGR_interlace_read 1
+#endif
+
+#ifndef GL_EXT_stencil_wrap
+#define GL_EXT_stencil_wrap 1
+#endif
+
+#ifndef GL_EXT_422_pixels
+#define GL_EXT_422_pixels 1
+#endif
+
+#ifndef GL_NV_texgen_reflection
+#define GL_NV_texgen_reflection 1
+#endif
+
+#ifndef GL_SUN_convolution_border_modes
+#define GL_SUN_convolution_border_modes 1
+#endif
+
+#ifndef GL_EXT_texture_env_add
+#define GL_EXT_texture_env_add 1
+#endif
+
+#ifndef GL_EXT_texture_lod_bias
+#define GL_EXT_texture_lod_bias 1
+#endif
+
+#ifndef GL_EXT_texture_filter_anisotropic
+#define GL_EXT_texture_filter_anisotropic 1
+#endif
+
+#ifndef GL_EXT_vertex_weighting
+#define GL_EXT_vertex_weighting 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexWeightfEXT (GLfloat weight);
+GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *weight);
+GLAPI void APIENTRY glVertexWeightPointerEXT (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight);
+typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight);
+typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif
+
+#ifndef GL_NV_light_max_exponent
+#define GL_NV_light_max_exponent 1
+#endif
+
+#ifndef GL_NV_vertex_array_range
+#define GL_NV_vertex_array_range 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFlushVertexArrayRangeNV (void);
+GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei length, const GLvoid *pointer);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void);
+typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer);
+#endif
+
+#ifndef GL_NV_register_combiners
+#define GL_NV_register_combiners 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glCombinerParameterfvNV (GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glCombinerParameterfNV (GLenum pname, GLfloat param);
+GLAPI void APIENTRY glCombinerParameterivNV (GLenum pname, const GLint *params);
+GLAPI void APIENTRY glCombinerParameteriNV (GLenum pname, GLint param);
+GLAPI void APIENTRY glCombinerInputNV (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
+GLAPI void APIENTRY glCombinerOutputNV (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum);
+GLAPI void APIENTRY glFinalCombinerInputNV (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
+GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum stage, GLenum portion, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum stage, GLenum portion, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum variable, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum variable, GLenum pname, GLint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
+typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum);
+typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
+typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params);
+#endif
+
+#ifndef GL_NV_fog_distance
+#define GL_NV_fog_distance 1
+#endif
+
+#ifndef GL_NV_texgen_emboss
+#define GL_NV_texgen_emboss 1
+#endif
+
+#ifndef GL_NV_blend_square
+#define GL_NV_blend_square 1
+#endif
+
+#ifndef GL_NV_texture_env_combine4
+#define GL_NV_texture_env_combine4 1
+#endif
+
+#ifndef GL_MESA_resize_buffers
+#define GL_MESA_resize_buffers 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glResizeBuffersMESA (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void);
+#endif
+
+#ifndef GL_MESA_window_pos
+#define GL_MESA_window_pos 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glWindowPos2dMESA (GLdouble x, GLdouble y);
+GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *v);
+GLAPI void APIENTRY glWindowPos2fMESA (GLfloat x, GLfloat y);
+GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *v);
+GLAPI void APIENTRY glWindowPos2iMESA (GLint x, GLint y);
+GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *v);
+GLAPI void APIENTRY glWindowPos2sMESA (GLshort x, GLshort y);
+GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *v);
+GLAPI void APIENTRY glWindowPos3dMESA (GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *v);
+GLAPI void APIENTRY glWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *v);
+GLAPI void APIENTRY glWindowPos3iMESA (GLint x, GLint y, GLint z);
+GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *v);
+GLAPI void APIENTRY glWindowPos3sMESA (GLshort x, GLshort y, GLshort z);
+GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *v);
+GLAPI void APIENTRY glWindowPos4dMESA (GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *v);
+GLAPI void APIENTRY glWindowPos4fMESA (GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *v);
+GLAPI void APIENTRY glWindowPos4iMESA (GLint x, GLint y, GLint z, GLint w);
+GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *v);
+GLAPI void APIENTRY glWindowPos4sMESA (GLshort x, GLshort y, GLshort z, GLshort w);
+GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w);
+typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w);
+typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v);
+#endif
+
+#ifndef GL_EXT_texture_compression_s3tc
+#define GL_EXT_texture_compression_s3tc 1
+#endif
+
+#ifndef GL_IBM_cull_vertex
+#define GL_IBM_cull_vertex 1
+#endif
+
+#ifndef GL_IBM_multimode_draw_arrays
+#define GL_IBM_multimode_draw_arrays 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride);
+GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride);
+typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride);
+#endif
+
+#ifndef GL_IBM_vertex_array_lists
+#define GL_IBM_vertex_array_lists 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glColorPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint stride, const GLboolean* *pointer, GLint ptrstride);
+GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+GLAPI void APIENTRY glIndexPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+GLAPI void APIENTRY glNormalPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+GLAPI void APIENTRY glTexCoordPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+GLAPI void APIENTRY glVertexPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride);
+typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+#endif
+
+#ifndef GL_SGIX_subsample
+#define GL_SGIX_subsample 1
+#endif
+
+#ifndef GL_SGIX_ycrcba
+#define GL_SGIX_ycrcba 1
+#endif
+
+#ifndef GL_SGIX_ycrcb_subsample
+#define GL_SGIX_ycrcb_subsample 1
+#endif
+
+#ifndef GL_SGIX_depth_pass_instrument
+#define GL_SGIX_depth_pass_instrument 1
+#endif
+
+#ifndef GL_3DFX_texture_compression_FXT1
+#define GL_3DFX_texture_compression_FXT1 1
+#endif
+
+#ifndef GL_3DFX_multisample
+#define GL_3DFX_multisample 1
+#endif
+
+#ifndef GL_3DFX_tbuffer
+#define GL_3DFX_tbuffer 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTbufferMask3DFX (GLuint mask);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask);
+#endif
+
+#ifndef GL_EXT_multisample
+#define GL_EXT_multisample 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glSampleMaskEXT (GLclampf value, GLboolean invert);
+GLAPI void APIENTRY glSamplePatternEXT (GLenum pattern);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert);
+typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern);
+#endif
+
+#ifndef GL_SGIX_vertex_preclip
+#define GL_SGIX_vertex_preclip 1
+#endif
+
+#ifndef GL_SGIX_convolution_accuracy
+#define GL_SGIX_convolution_accuracy 1
+#endif
+
+#ifndef GL_SGIX_resample
+#define GL_SGIX_resample 1
+#endif
+
+#ifndef GL_SGIS_point_line_texgen
+#define GL_SGIS_point_line_texgen 1
+#endif
+
+#ifndef GL_SGIS_texture_color_mask
+#define GL_SGIS_texture_color_mask 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+#endif
+
+#ifndef GL_SGIX_igloo_interface
+#define GL_SGIX_igloo_interface 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum pname, const GLvoid *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params);
+#endif
+
+#ifndef GL_EXT_texture_env_dot3
+#define GL_EXT_texture_env_dot3 1
+#endif
+
+#ifndef GL_ATI_texture_mirror_once
+#define GL_ATI_texture_mirror_once 1
+#endif
+
+#ifndef GL_NV_fence
+#define GL_NV_fence 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences);
+GLAPI void APIENTRY glGenFencesNV (GLsizei n, GLuint *fences);
+GLAPI GLboolean APIENTRY glIsFenceNV (GLuint fence);
+GLAPI GLboolean APIENTRY glTestFenceNV (GLuint fence);
+GLAPI void APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params);
+GLAPI void APIENTRY glFinishFenceNV (GLuint fence);
+GLAPI void APIENTRY glSetFenceNV (GLuint fence, GLenum condition);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences);
+typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences);
+typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence);
+typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence);
+typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence);
+typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition);
+#endif
+
+#ifndef GL_IBM_static_data
+#define GL_IBM_static_data 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFlushStaticDataIBM (GLenum target);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFLUSHSTATICDATAIBMPROC) (GLenum target);
+#endif
+
+#ifndef GL_IBM_texture_mirrored_repeat
+#define GL_IBM_texture_mirrored_repeat 1
+#endif
+
+#ifndef GL_NV_evaluators
+#define GL_NV_evaluators 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points);
+GLAPI void APIENTRY glMapParameterivNV (GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glMapParameterfvNV (GLenum target, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glGetMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points);
+GLAPI void APIENTRY glGetMapParameterivNV (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetMapParameterfvNV (GLenum target, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum target, GLuint index, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glEvalMapsNV (GLenum target, GLenum mode);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points);
+typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points);
+typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode);
+#endif
+
+#ifndef GL_NV_packed_depth_stencil
+#define GL_NV_packed_depth_stencil 1
+#endif
+
+#ifndef GL_NV_register_combiners2
+#define GL_NV_register_combiners2 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, GLfloat *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params);
+#endif
+
+#ifndef GL_NV_texture_compression_vtc
+#define GL_NV_texture_compression_vtc 1
+#endif
+
+#ifndef GL_NV_texture_rectangle
+#define GL_NV_texture_rectangle 1
+#endif
+
+#ifndef GL_NV_texture_shader
+#define GL_NV_texture_shader 1
+#endif
+
+#ifndef GL_NV_texture_shader2
+#define GL_NV_texture_shader2 1
+#endif
+
+#ifndef GL_NV_vertex_array_range2
+#define GL_NV_vertex_array_range2 1
+#endif
+
+#ifndef GL_NV_vertex_program
+#define GL_NV_vertex_program 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei n, const GLuint *programs, GLboolean *residences);
+GLAPI void APIENTRY glBindProgramNV (GLenum target, GLuint id);
+GLAPI void APIENTRY glDeleteProgramsNV (GLsizei n, const GLuint *programs);
+GLAPI void APIENTRY glExecuteProgramNV (GLenum target, GLuint id, const GLfloat *params);
+GLAPI void APIENTRY glGenProgramsNV (GLsizei n, GLuint *programs);
+GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum target, GLuint index, GLenum pname, GLdouble *params);
+GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetProgramivNV (GLuint id, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetProgramStringNV (GLuint id, GLenum pname, GLubyte *program);
+GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum target, GLuint address, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint index, GLenum pname, GLdouble *params);
+GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint index, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetVertexAttribivNV (GLuint index, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint index, GLenum pname, GLvoid* *pointer);
+GLAPI GLboolean APIENTRY glIsProgramNV (GLuint id);
+GLAPI void APIENTRY glLoadProgramNV (GLenum target, GLuint id, GLsizei len, const GLubyte *program);
+GLAPI void APIENTRY glProgramParameter4dNV (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI void APIENTRY glProgramParameter4dvNV (GLenum target, GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glProgramParameter4fNV (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GLAPI void APIENTRY glProgramParameter4fvNV (GLenum target, GLuint index, const GLfloat *v);
+GLAPI void APIENTRY glProgramParameters4dvNV (GLenum target, GLuint index, GLsizei count, const GLdouble *v);
+GLAPI void APIENTRY glProgramParameters4fvNV (GLenum target, GLuint index, GLsizei count, const GLfloat *v);
+GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei n, const GLuint *programs);
+GLAPI void APIENTRY glTrackMatrixNV (GLenum target, GLuint address, GLenum matrix, GLenum transform);
+GLAPI void APIENTRY glVertexAttribPointerNV (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glVertexAttrib1dNV (GLuint index, GLdouble x);
+GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttrib1fNV (GLuint index, GLfloat x);
+GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint index, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttrib1sNV (GLuint index, GLshort x);
+GLAPI void APIENTRY glVertexAttrib1svNV (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttrib2dNV (GLuint index, GLdouble x, GLdouble y);
+GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttrib2fNV (GLuint index, GLfloat x, GLfloat y);
+GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint index, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttrib2sNV (GLuint index, GLshort x, GLshort y);
+GLAPI void APIENTRY glVertexAttrib2svNV (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttrib3dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttrib3fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint index, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttrib3sNV (GLuint index, GLshort x, GLshort y, GLshort z);
+GLAPI void APIENTRY glVertexAttrib3svNV (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttrib4dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttrib4fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint index, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttrib4sNV (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
+GLAPI void APIENTRY glVertexAttrib4svNV (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
+GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint index, const GLubyte *v);
+GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint index, GLsizei count, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint index, GLsizei count, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttribs1svNV (GLuint index, GLsizei count, const GLshort *v);
+GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint index, GLsizei count, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint index, GLsizei count, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttribs2svNV (GLuint index, GLsizei count, const GLshort *v);
+GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint index, GLsizei count, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint index, GLsizei count, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttribs3svNV (GLuint index, GLsizei count, const GLshort *v);
+GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint index, GLsizei count, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint index, GLsizei count, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttribs4svNV (GLuint index, GLsizei count, const GLshort *v);
+GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint index, GLsizei count, const GLubyte *v);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences);
+typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id);
+typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs);
+typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params);
+typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs);
+typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program);
+typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer);
+typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program);
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLdouble *v);
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs);
+typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v);
+#endif
+
+#ifndef GL_SGIX_texture_coordinate_clamp
+#define GL_SGIX_texture_coordinate_clamp 1
+#endif
+
+#ifndef GL_SGIX_scalebias_hint
+#define GL_SGIX_scalebias_hint 1
+#endif
+
+#ifndef GL_OML_interlace
+#define GL_OML_interlace 1
+#endif
+
+#ifndef GL_OML_subsample
+#define GL_OML_subsample 1
+#endif
+
+#ifndef GL_OML_resample
+#define GL_OML_resample 1
+#endif
+
+#ifndef GL_NV_copy_depth_to_color
+#define GL_NV_copy_depth_to_color 1
+#endif
+
+#ifndef GL_ATI_envmap_bumpmap
+#define GL_ATI_envmap_bumpmap 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexBumpParameterivATI (GLenum pname, const GLint *param);
+GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum pname, const GLfloat *param);
+GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum pname, GLint *param);
+GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum pname, GLfloat *param);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param);
+typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param);
+typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param);
+typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param);
+#endif
+
+#ifndef GL_ATI_fragment_shader
+#define GL_ATI_fragment_shader 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint range);
+GLAPI void APIENTRY glBindFragmentShaderATI (GLuint id);
+GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint id);
+GLAPI void APIENTRY glBeginFragmentShaderATI (void);
+GLAPI void APIENTRY glEndFragmentShaderATI (void);
+GLAPI void APIENTRY glPassTexCoordATI (GLuint dst, GLuint coord, GLenum swizzle);
+GLAPI void APIENTRY glSampleMapATI (GLuint dst, GLuint interp, GLenum swizzle);
+GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);
+GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);
+GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);
+GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);
+GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);
+GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);
+GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint dst, const GLfloat *value);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range);
+typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void);
+typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void);
+typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle);
+typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle);
+typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);
+typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);
+typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);
+typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);
+typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);
+typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);
+typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value);
+#endif
+
+#ifndef GL_ATI_pn_triangles
+#define GL_ATI_pn_triangles 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPNTrianglesiATI (GLenum pname, GLint param);
+GLAPI void APIENTRY glPNTrianglesfATI (GLenum pname, GLfloat param);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param);
+#endif
+
+#ifndef GL_ATI_vertex_array_object
+#define GL_ATI_vertex_array_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei size, const GLvoid *pointer, GLenum usage);
+GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint buffer);
+GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve);
+GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint buffer, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetObjectBufferivATI (GLuint buffer, GLenum pname, GLint *params);
+GLAPI void APIENTRY glFreeObjectBufferATI (GLuint buffer);
+GLAPI void APIENTRY glArrayObjectATI (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset);
+GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum array, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetArrayObjectivATI (GLenum array, GLenum pname, GLint *params);
+GLAPI void APIENTRY glVariantArrayObjectATI (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset);
+GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint id, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint id, GLenum pname, GLint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage);
+typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer);
+typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve);
+typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer);
+typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset);
+typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset);
+typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params);
+#endif
+
+#ifndef GL_EXT_vertex_shader
+#define GL_EXT_vertex_shader 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBeginVertexShaderEXT (void);
+GLAPI void APIENTRY glEndVertexShaderEXT (void);
+GLAPI void APIENTRY glBindVertexShaderEXT (GLuint id);
+GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint range);
+GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint id);
+GLAPI void APIENTRY glShaderOp1EXT (GLenum op, GLuint res, GLuint arg1);
+GLAPI void APIENTRY glShaderOp2EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2);
+GLAPI void APIENTRY glShaderOp3EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3);
+GLAPI void APIENTRY glSwizzleEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW);
+GLAPI void APIENTRY glWriteMaskEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW);
+GLAPI void APIENTRY glInsertComponentEXT (GLuint res, GLuint src, GLuint num);
+GLAPI void APIENTRY glExtractComponentEXT (GLuint res, GLuint src, GLuint num);
+GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum datatype, GLenum storagetype, GLenum range, GLuint components);
+GLAPI void APIENTRY glSetInvariantEXT (GLuint id, GLenum type, const GLvoid *addr);
+GLAPI void APIENTRY glSetLocalConstantEXT (GLuint id, GLenum type, const GLvoid *addr);
+GLAPI void APIENTRY glVariantbvEXT (GLuint id, const GLbyte *addr);
+GLAPI void APIENTRY glVariantsvEXT (GLuint id, const GLshort *addr);
+GLAPI void APIENTRY glVariantivEXT (GLuint id, const GLint *addr);
+GLAPI void APIENTRY glVariantfvEXT (GLuint id, const GLfloat *addr);
+GLAPI void APIENTRY glVariantdvEXT (GLuint id, const GLdouble *addr);
+GLAPI void APIENTRY glVariantubvEXT (GLuint id, const GLubyte *addr);
+GLAPI void APIENTRY glVariantusvEXT (GLuint id, const GLushort *addr);
+GLAPI void APIENTRY glVariantuivEXT (GLuint id, const GLuint *addr);
+GLAPI void APIENTRY glVariantPointerEXT (GLuint id, GLenum type, GLuint stride, const GLvoid *addr);
+GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint id);
+GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint id);
+GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum light, GLenum value);
+GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum face, GLenum value);
+GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum unit, GLenum coord, GLenum value);
+GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum unit, GLenum value);
+GLAPI GLuint APIENTRY glBindParameterEXT (GLenum value);
+GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint id, GLenum cap);
+GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data);
+GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint id, GLenum value, GLint *data);
+GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint id, GLenum value, GLfloat *data);
+GLAPI void APIENTRY glGetVariantPointervEXT (GLuint id, GLenum value, GLvoid* *data);
+GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data);
+GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint id, GLenum value, GLint *data);
+GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint id, GLenum value, GLfloat *data);
+GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint id, GLenum value, GLboolean *data);
+GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint id, GLenum value, GLint *data);
+GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint id, GLenum value, GLfloat *data);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void);
+typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void);
+typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id);
+typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range);
+typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1);
+typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2);
+typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3);
+typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW);
+typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW);
+typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num);
+typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num);
+typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components);
+typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr);
+typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr);
+typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr);
+typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr);
+typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr);
+typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr);
+typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr);
+typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr);
+typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr);
+typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr);
+typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr);
+typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id);
+typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value);
+typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value);
+typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value);
+typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value);
+typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value);
+typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap);
+typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data);
+typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data);
+typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data);
+typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data);
+typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data);
+typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data);
+typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data);
+typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data);
+typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data);
+typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data);
+#endif
+
+#ifndef GL_ATI_vertex_streams
+#define GL_ATI_vertex_streams 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexStream1sATI (GLenum stream, GLshort x);
+GLAPI void APIENTRY glVertexStream1svATI (GLenum stream, const GLshort *coords);
+GLAPI void APIENTRY glVertexStream1iATI (GLenum stream, GLint x);
+GLAPI void APIENTRY glVertexStream1ivATI (GLenum stream, const GLint *coords);
+GLAPI void APIENTRY glVertexStream1fATI (GLenum stream, GLfloat x);
+GLAPI void APIENTRY glVertexStream1fvATI (GLenum stream, const GLfloat *coords);
+GLAPI void APIENTRY glVertexStream1dATI (GLenum stream, GLdouble x);
+GLAPI void APIENTRY glVertexStream1dvATI (GLenum stream, const GLdouble *coords);
+GLAPI void APIENTRY glVertexStream2sATI (GLenum stream, GLshort x, GLshort y);
+GLAPI void APIENTRY glVertexStream2svATI (GLenum stream, const GLshort *coords);
+GLAPI void APIENTRY glVertexStream2iATI (GLenum stream, GLint x, GLint y);
+GLAPI void APIENTRY glVertexStream2ivATI (GLenum stream, const GLint *coords);
+GLAPI void APIENTRY glVertexStream2fATI (GLenum stream, GLfloat x, GLfloat y);
+GLAPI void APIENTRY glVertexStream2fvATI (GLenum stream, const GLfloat *coords);
+GLAPI void APIENTRY glVertexStream2dATI (GLenum stream, GLdouble x, GLdouble y);
+GLAPI void APIENTRY glVertexStream2dvATI (GLenum stream, const GLdouble *coords);
+GLAPI void APIENTRY glVertexStream3sATI (GLenum stream, GLshort x, GLshort y, GLshort z);
+GLAPI void APIENTRY glVertexStream3svATI (GLenum stream, const GLshort *coords);
+GLAPI void APIENTRY glVertexStream3iATI (GLenum stream, GLint x, GLint y, GLint z);
+GLAPI void APIENTRY glVertexStream3ivATI (GLenum stream, const GLint *coords);
+GLAPI void APIENTRY glVertexStream3fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glVertexStream3fvATI (GLenum stream, const GLfloat *coords);
+GLAPI void APIENTRY glVertexStream3dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glVertexStream3dvATI (GLenum stream, const GLdouble *coords);
+GLAPI void APIENTRY glVertexStream4sATI (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w);
+GLAPI void APIENTRY glVertexStream4svATI (GLenum stream, const GLshort *coords);
+GLAPI void APIENTRY glVertexStream4iATI (GLenum stream, GLint x, GLint y, GLint z, GLint w);
+GLAPI void APIENTRY glVertexStream4ivATI (GLenum stream, const GLint *coords);
+GLAPI void APIENTRY glVertexStream4fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GLAPI void APIENTRY glVertexStream4fvATI (GLenum stream, const GLfloat *coords);
+GLAPI void APIENTRY glVertexStream4dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI void APIENTRY glVertexStream4dvATI (GLenum stream, const GLdouble *coords);
+GLAPI void APIENTRY glNormalStream3bATI (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz);
+GLAPI void APIENTRY glNormalStream3bvATI (GLenum stream, const GLbyte *coords);
+GLAPI void APIENTRY glNormalStream3sATI (GLenum stream, GLshort nx, GLshort ny, GLshort nz);
+GLAPI void APIENTRY glNormalStream3svATI (GLenum stream, const GLshort *coords);
+GLAPI void APIENTRY glNormalStream3iATI (GLenum stream, GLint nx, GLint ny, GLint nz);
+GLAPI void APIENTRY glNormalStream3ivATI (GLenum stream, const GLint *coords);
+GLAPI void APIENTRY glNormalStream3fATI (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz);
+GLAPI void APIENTRY glNormalStream3fvATI (GLenum stream, const GLfloat *coords);
+GLAPI void APIENTRY glNormalStream3dATI (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz);
+GLAPI void APIENTRY glNormalStream3dvATI (GLenum stream, const GLdouble *coords);
+GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum stream);
+GLAPI void APIENTRY glVertexBlendEnviATI (GLenum pname, GLint param);
+GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords);
+typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream);
+typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param);
+#endif
+
+#ifndef GL_ATI_element_array
+#define GL_ATI_element_array 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glElementPointerATI (GLenum type, const GLvoid *pointer);
+GLAPI void APIENTRY glDrawElementArrayATI (GLenum mode, GLsizei count);
+GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum mode, GLuint start, GLuint end, GLsizei count);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count);
+typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count);
+#endif
+
+#ifndef GL_SUN_mesh_array
+#define GL_SUN_mesh_array 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum mode, GLint first, GLsizei count, GLsizei width);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width);
+#endif
+
+#ifndef GL_SUN_slice_accum
+#define GL_SUN_slice_accum 1
+#endif
+
+#ifndef GL_NV_multisample_filter_hint
+#define GL_NV_multisample_filter_hint 1
+#endif
+
+#ifndef GL_NV_depth_clamp
+#define GL_NV_depth_clamp 1
+#endif
+
+#ifndef GL_NV_occlusion_query
+#define GL_NV_occlusion_query 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei n, GLuint *ids);
+GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei n, const GLuint *ids);
+GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint id);
+GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint id);
+GLAPI void APIENTRY glEndOcclusionQueryNV (void);
+GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint id, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint id, GLenum pname, GLuint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids);
+typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids);
+typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void);
+typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params);
+#endif
+
+#ifndef GL_NV_point_sprite
+#define GL_NV_point_sprite 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPointParameteriNV (GLenum pname, GLint param);
+GLAPI void APIENTRY glPointParameterivNV (GLenum pname, const GLint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params);
+#endif
+
+#ifndef GL_NV_texture_shader3
+#define GL_NV_texture_shader3 1
+#endif
+
+#ifndef GL_NV_vertex_program1_1
+#define GL_NV_vertex_program1_1 1
+#endif
+
+#ifndef GL_EXT_shadow_funcs
+#define GL_EXT_shadow_funcs 1
+#endif
+
+#ifndef GL_EXT_stencil_two_side
+#define GL_EXT_stencil_two_side 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum face);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face);
+#endif
+
+#ifndef GL_ATI_text_fragment_shader
+#define GL_ATI_text_fragment_shader 1
+#endif
+
+#ifndef GL_APPLE_client_storage
+#define GL_APPLE_client_storage 1
+#endif
+
+#ifndef GL_APPLE_element_array
+#define GL_APPLE_element_array 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glElementPointerAPPLE (GLenum type, const GLvoid *pointer);
+GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum mode, GLint first, GLsizei count);
+GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count);
+GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);
+GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count);
+typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count);
+typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);
+typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount);
+#endif
+
+#ifndef GL_APPLE_fence
+#define GL_APPLE_fence 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGenFencesAPPLE (GLsizei n, GLuint *fences);
+GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei n, const GLuint *fences);
+GLAPI void APIENTRY glSetFenceAPPLE (GLuint fence);
+GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint fence);
+GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint fence);
+GLAPI void APIENTRY glFinishFenceAPPLE (GLuint fence);
+GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum object, GLuint name);
+GLAPI void APIENTRY glFinishObjectAPPLE (GLenum object, GLint name);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences);
+typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences);
+typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence);
+typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence);
+typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence);
+typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence);
+typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name);
+typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name);
+#endif
+
+#ifndef GL_APPLE_vertex_array_object
+#define GL_APPLE_vertex_array_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint array);
+GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei n, const GLuint *arrays);
+GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei n, GLuint *arrays);
+GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint array);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array);
+typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays);
+typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays);
+typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array);
+#endif
+
+#ifndef GL_APPLE_vertex_array_range
+#define GL_APPLE_vertex_array_range 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei length, GLvoid *pointer);
+GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei length, GLvoid *pointer);
+GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum pname, GLint param);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer);
+typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer);
+typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param);
+#endif
+
+#ifndef GL_APPLE_ycbcr_422
+#define GL_APPLE_ycbcr_422 1
+#endif
+
+#ifndef GL_S3_s3tc
+#define GL_S3_s3tc 1
+#endif
+
+#ifndef GL_ATI_draw_buffers
+#define GL_ATI_draw_buffers 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawBuffersATI (GLsizei n, const GLenum *bufs);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs);
+#endif
+
+#ifndef GL_ATI_pixel_format_float
+#define GL_ATI_pixel_format_float 1
+/* This is really a WGL extension, but defines some associated GL enums.
+ * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string.
+ */
+#endif
+
+#ifndef GL_ATI_texture_env_combine3
+#define GL_ATI_texture_env_combine3 1
+#endif
+
+#ifndef GL_ATI_texture_float
+#define GL_ATI_texture_float 1
+#endif
+
+#ifndef GL_NV_float_buffer
+#define GL_NV_float_buffer 1
+#endif
+
+#ifndef GL_NV_fragment_program
+#define GL_NV_fragment_program 1
+/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v);
+GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v);
+GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params);
+GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v);
+typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v);
+typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params);
+#endif
+
+#ifndef GL_NV_half_float
+#define GL_NV_half_float 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertex2hNV (GLhalfNV x, GLhalfNV y);
+GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *v);
+GLAPI void APIENTRY glVertex3hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z);
+GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *v);
+GLAPI void APIENTRY glVertex4hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w);
+GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *v);
+GLAPI void APIENTRY glNormal3hNV (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz);
+GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *v);
+GLAPI void APIENTRY glColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue);
+GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *v);
+GLAPI void APIENTRY glColor4hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha);
+GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *v);
+GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV s);
+GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *v);
+GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV s, GLhalfNV t);
+GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *v);
+GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r);
+GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *v);
+GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q);
+GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *v);
+GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum target, GLhalfNV s);
+GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum target, const GLhalfNV *v);
+GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum target, GLhalfNV s, GLhalfNV t);
+GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum target, const GLhalfNV *v);
+GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r);
+GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum target, const GLhalfNV *v);
+GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q);
+GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum target, const GLhalfNV *v);
+GLAPI void APIENTRY glFogCoordhNV (GLhalfNV fog);
+GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *fog);
+GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue);
+GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *v);
+GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV weight);
+GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *weight);
+GLAPI void APIENTRY glVertexAttrib1hNV (GLuint index, GLhalfNV x);
+GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint index, const GLhalfNV *v);
+GLAPI void APIENTRY glVertexAttrib2hNV (GLuint index, GLhalfNV x, GLhalfNV y);
+GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint index, const GLhalfNV *v);
+GLAPI void APIENTRY glVertexAttrib3hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z);
+GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint index, const GLhalfNV *v);
+GLAPI void APIENTRY glVertexAttrib4hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w);
+GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint index, const GLhalfNV *v);
+GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint index, GLsizei n, const GLhalfNV *v);
+GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint index, GLsizei n, const GLhalfNV *v);
+GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint index, GLsizei n, const GLhalfNV *v);
+GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint index, GLsizei n, const GLhalfNV *v);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y);
+typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z);
+typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w);
+typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz);
+typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue);
+typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha);
+typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s);
+typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t);
+typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r);
+typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q);
+typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog);
+typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight);
+typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
+#endif
+
+#ifndef GL_NV_pixel_data_range
+#define GL_NV_pixel_data_range 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, const GLvoid *pointer);
+GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum target);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target);
+#endif
+
+#ifndef GL_NV_primitive_restart
+#define GL_NV_primitive_restart 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPrimitiveRestartNV (void);
+GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void);
+typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index);
+#endif
+
+#ifndef GL_NV_texture_expand_normal
+#define GL_NV_texture_expand_normal 1
+#endif
+
+#ifndef GL_NV_vertex_program2
+#define GL_NV_vertex_program2 1
+#endif
+
+#ifndef GL_ATI_map_object_buffer
+#define GL_ATI_map_object_buffer 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint buffer);
+GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint buffer);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer);
+typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer);
+#endif
+
+#ifndef GL_ATI_separate_stencil
+#define GL_ATI_separate_stencil 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glStencilOpSeparateATI (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
+GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
+typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);
+#endif
+
+#ifndef GL_ATI_vertex_attrib_array_object
+#define GL_ATI_vertex_attrib_array_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset);
+GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint index, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint index, GLenum pname, GLint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params);
+#endif
+
+#ifndef GL_OES_byte_coordinates
+#define GL_OES_byte_coordinates 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glMultiTexCoord1bOES (GLenum texture, GLbyte s);
+GLAPI void APIENTRY glMultiTexCoord1bvOES (GLenum texture, const GLbyte *coords);
+GLAPI void APIENTRY glMultiTexCoord2bOES (GLenum texture, GLbyte s, GLbyte t);
+GLAPI void APIENTRY glMultiTexCoord2bvOES (GLenum texture, const GLbyte *coords);
+GLAPI void APIENTRY glMultiTexCoord3bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r);
+GLAPI void APIENTRY glMultiTexCoord3bvOES (GLenum texture, const GLbyte *coords);
+GLAPI void APIENTRY glMultiTexCoord4bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q);
+GLAPI void APIENTRY glMultiTexCoord4bvOES (GLenum texture, const GLbyte *coords);
+GLAPI void APIENTRY glTexCoord1bOES (GLbyte s);
+GLAPI void APIENTRY glTexCoord1bvOES (const GLbyte *coords);
+GLAPI void APIENTRY glTexCoord2bOES (GLbyte s, GLbyte t);
+GLAPI void APIENTRY glTexCoord2bvOES (const GLbyte *coords);
+GLAPI void APIENTRY glTexCoord3bOES (GLbyte s, GLbyte t, GLbyte r);
+GLAPI void APIENTRY glTexCoord3bvOES (const GLbyte *coords);
+GLAPI void APIENTRY glTexCoord4bOES (GLbyte s, GLbyte t, GLbyte r, GLbyte q);
+GLAPI void APIENTRY glTexCoord4bvOES (const GLbyte *coords);
+GLAPI void APIENTRY glVertex2bOES (GLbyte x);
+GLAPI void APIENTRY glVertex2bvOES (const GLbyte *coords);
+GLAPI void APIENTRY glVertex3bOES (GLbyte x, GLbyte y);
+GLAPI void APIENTRY glVertex3bvOES (const GLbyte *coords);
+GLAPI void APIENTRY glVertex4bOES (GLbyte x, GLbyte y, GLbyte z);
+GLAPI void APIENTRY glVertex4bvOES (const GLbyte *coords);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1BOESPROC) (GLenum texture, GLbyte s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1BVOESPROC) (GLenum texture, const GLbyte *coords);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2BOESPROC) (GLenum texture, GLbyte s, GLbyte t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2BVOESPROC) (GLenum texture, const GLbyte *coords);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3BVOESPROC) (GLenum texture, const GLbyte *coords);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4BVOESPROC) (GLenum texture, const GLbyte *coords);
+typedef void (APIENTRYP PFNGLTEXCOORD1BOESPROC) (GLbyte s);
+typedef void (APIENTRYP PFNGLTEXCOORD1BVOESPROC) (const GLbyte *coords);
+typedef void (APIENTRYP PFNGLTEXCOORD2BOESPROC) (GLbyte s, GLbyte t);
+typedef void (APIENTRYP PFNGLTEXCOORD2BVOESPROC) (const GLbyte *coords);
+typedef void (APIENTRYP PFNGLTEXCOORD3BOESPROC) (GLbyte s, GLbyte t, GLbyte r);
+typedef void (APIENTRYP PFNGLTEXCOORD3BVOESPROC) (const GLbyte *coords);
+typedef void (APIENTRYP PFNGLTEXCOORD4BOESPROC) (GLbyte s, GLbyte t, GLbyte r, GLbyte q);
+typedef void (APIENTRYP PFNGLTEXCOORD4BVOESPROC) (const GLbyte *coords);
+typedef void (APIENTRYP PFNGLVERTEX2BOESPROC) (GLbyte x);
+typedef void (APIENTRYP PFNGLVERTEX2BVOESPROC) (const GLbyte *coords);
+typedef void (APIENTRYP PFNGLVERTEX3BOESPROC) (GLbyte x, GLbyte y);
+typedef void (APIENTRYP PFNGLVERTEX3BVOESPROC) (const GLbyte *coords);
+typedef void (APIENTRYP PFNGLVERTEX4BOESPROC) (GLbyte x, GLbyte y, GLbyte z);
+typedef void (APIENTRYP PFNGLVERTEX4BVOESPROC) (const GLbyte *coords);
+#endif
+
+#ifndef GL_OES_fixed_point
+#define GL_OES_fixed_point 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glAccumxOES (GLenum op, GLfixed value);
+GLAPI void APIENTRY glAlphaFuncxOES (GLenum func, GLfixed ref);
+GLAPI void APIENTRY glBitmapxOES (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap);
+GLAPI void APIENTRY glBlendColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
+GLAPI void APIENTRY glClearAccumxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
+GLAPI void APIENTRY glClearColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
+GLAPI void APIENTRY glClearDepthxOES (GLfixed depth);
+GLAPI void APIENTRY glClipPlanexOES (GLenum plane, const GLfixed *equation);
+GLAPI void APIENTRY glColor3xOES (GLfixed red, GLfixed green, GLfixed blue);
+GLAPI void APIENTRY glColor4xOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
+GLAPI void APIENTRY glColor3xvOES (const GLfixed *components);
+GLAPI void APIENTRY glColor4xvOES (const GLfixed *components);
+GLAPI void APIENTRY glConvolutionParameterxOES (GLenum target, GLenum pname, GLfixed param);
+GLAPI void APIENTRY glConvolutionParameterxvOES (GLenum target, GLenum pname, const GLfixed *params);
+GLAPI void APIENTRY glDepthRangexOES (GLfixed n, GLfixed f);
+GLAPI void APIENTRY glEvalCoord1xOES (GLfixed u);
+GLAPI void APIENTRY glEvalCoord2xOES (GLfixed u, GLfixed v);
+GLAPI void APIENTRY glEvalCoord1xvOES (const GLfixed *coords);
+GLAPI void APIENTRY glEvalCoord2xvOES (const GLfixed *coords);
+GLAPI void APIENTRY glFeedbackBufferxOES (GLsizei n, GLenum type, const GLfixed *buffer);
+GLAPI void APIENTRY glFogxOES (GLenum pname, GLfixed param);
+GLAPI void APIENTRY glFogxvOES (GLenum pname, const GLfixed *param);
+GLAPI void APIENTRY glFrustumxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f);
+GLAPI void APIENTRY glGetClipPlanexOES (GLenum plane, GLfixed *equation);
+GLAPI void APIENTRY glGetConvolutionParameterxvOES (GLenum target, GLenum pname, GLfixed *params);
+GLAPI void APIENTRY glGetFixedvOES (GLenum pname, GLfixed *params);
+GLAPI void APIENTRY glGetHistogramParameterxvOES (GLenum target, GLenum pname, GLfixed *params);
+GLAPI void APIENTRY glGetLightxOES (GLenum light, GLenum pname, GLfixed *params);
+GLAPI void APIENTRY glGetMapxvOES (GLenum target, GLenum query, GLfixed *v);
+GLAPI void APIENTRY glGetMaterialxOES (GLenum face, GLenum pname, GLfixed param);
+GLAPI void APIENTRY glGetPixelMapxv (GLenum map, GLint size, GLfixed *values);
+GLAPI void APIENTRY glGetTexEnvxvOES (GLenum target, GLenum pname, GLfixed *params);
+GLAPI void APIENTRY glGetTexGenxvOES (GLenum coord, GLenum pname, GLfixed *params);
+GLAPI void APIENTRY glGetTexLevelParameterxvOES (GLenum target, GLint level, GLenum pname, GLfixed *params);
+GLAPI void APIENTRY glGetTexParameterxvOES (GLenum target, GLenum pname, GLfixed *params);
+GLAPI void APIENTRY glIndexxOES (GLfixed component);
+GLAPI void APIENTRY glIndexxvOES (const GLfixed *component);
+GLAPI void APIENTRY glLightModelxOES (GLenum pname, GLfixed param);
+GLAPI void APIENTRY glLightModelxvOES (GLenum pname, const GLfixed *param);
+GLAPI void APIENTRY glLightxOES (GLenum light, GLenum pname, GLfixed param);
+GLAPI void APIENTRY glLightxvOES (GLenum light, GLenum pname, const GLfixed *params);
+GLAPI void APIENTRY glLineWidthxOES (GLfixed width);
+GLAPI void APIENTRY glLoadMatrixxOES (const GLfixed *m);
+GLAPI void APIENTRY glLoadTransposeMatrixxOES (const GLfixed *m);
+GLAPI void APIENTRY glMap1xOES (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points);
+GLAPI void APIENTRY glMap2xOES (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points);
+GLAPI void APIENTRY glMapGrid1xOES (GLint n, GLfixed u1, GLfixed u2);
+GLAPI void APIENTRY glMapGrid2xOES (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2);
+GLAPI void APIENTRY glMaterialxOES (GLenum face, GLenum pname, GLfixed param);
+GLAPI void APIENTRY glMaterialxvOES (GLenum face, GLenum pname, const GLfixed *param);
+GLAPI void APIENTRY glMultMatrixxOES (const GLfixed *m);
+GLAPI void APIENTRY glMultTransposeMatrixxOES (const GLfixed *m);
+GLAPI void APIENTRY glMultiTexCoord1xOES (GLenum texture, GLfixed s);
+GLAPI void APIENTRY glMultiTexCoord2xOES (GLenum texture, GLfixed s, GLfixed t);
+GLAPI void APIENTRY glMultiTexCoord3xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r);
+GLAPI void APIENTRY glMultiTexCoord4xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
+GLAPI void APIENTRY glMultiTexCoord1xvOES (GLenum texture, const GLfixed *coords);
+GLAPI void APIENTRY glMultiTexCoord2xvOES (GLenum texture, const GLfixed *coords);
+GLAPI void APIENTRY glMultiTexCoord3xvOES (GLenum texture, const GLfixed *coords);
+GLAPI void APIENTRY glMultiTexCoord4xvOES (GLenum texture, const GLfixed *coords);
+GLAPI void APIENTRY glNormal3xOES (GLfixed nx, GLfixed ny, GLfixed nz);
+GLAPI void APIENTRY glNormal3xvOES (const GLfixed *coords);
+GLAPI void APIENTRY glOrthoxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f);
+GLAPI void APIENTRY glPassThroughxOES (GLfixed token);
+GLAPI void APIENTRY glPixelMapx (GLenum map, GLint size, const GLfixed *values);
+GLAPI void APIENTRY glPixelStorex (GLenum pname, GLfixed param);
+GLAPI void APIENTRY glPixelTransferxOES (GLenum pname, GLfixed param);
+GLAPI void APIENTRY glPixelZoomxOES (GLfixed xfactor, GLfixed yfactor);
+GLAPI void APIENTRY glPointParameterxvOES (GLenum pname, const GLfixed *params);
+GLAPI void APIENTRY glPointSizexOES (GLfixed size);
+GLAPI void APIENTRY glPolygonOffsetxOES (GLfixed factor, GLfixed units);
+GLAPI void APIENTRY glPrioritizeTexturesxOES (GLsizei n, const GLuint *textures, const GLfixed *priorities);
+GLAPI void APIENTRY glRasterPos2xOES (GLfixed x, GLfixed y);
+GLAPI void APIENTRY glRasterPos3xOES (GLfixed x, GLfixed y, GLfixed z);
+GLAPI void APIENTRY glRasterPos4xOES (GLfixed x, GLfixed y, GLfixed z, GLfixed w);
+GLAPI void APIENTRY glRasterPos2xvOES (const GLfixed *coords);
+GLAPI void APIENTRY glRasterPos3xvOES (const GLfixed *coords);
+GLAPI void APIENTRY glRasterPos4xvOES (const GLfixed *coords);
+GLAPI void APIENTRY glRectxOES (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2);
+GLAPI void APIENTRY glRectxvOES (const GLfixed *v1, const GLfixed *v2);
+GLAPI void APIENTRY glRotatexOES (GLfixed angle, GLfixed x, GLfixed y, GLfixed z);
+GLAPI void APIENTRY glSampleCoverageOES (GLfixed value, GLboolean invert);
+GLAPI void APIENTRY glScalexOES (GLfixed x, GLfixed y, GLfixed z);
+GLAPI void APIENTRY glTexCoord1xOES (GLfixed s);
+GLAPI void APIENTRY glTexCoord2xOES (GLfixed s, GLfixed t);
+GLAPI void APIENTRY glTexCoord3xOES (GLfixed s, GLfixed t, GLfixed r);
+GLAPI void APIENTRY glTexCoord4xOES (GLfixed s, GLfixed t, GLfixed r, GLfixed q);
+GLAPI void APIENTRY glTexCoord1xvOES (const GLfixed *coords);
+GLAPI void APIENTRY glTexCoord2xvOES (const GLfixed *coords);
+GLAPI void APIENTRY glTexCoord3xvOES (const GLfixed *coords);
+GLAPI void APIENTRY glTexCoord4xvOES (const GLfixed *coords);
+GLAPI void APIENTRY glTexEnvxOES (GLenum target, GLenum pname, GLfixed param);
+GLAPI void APIENTRY glTexEnvxvOES (GLenum target, GLenum pname, const GLfixed *params);
+GLAPI void APIENTRY glTexGenxOES (GLenum coord, GLenum pname, GLfixed param);
+GLAPI void APIENTRY glTexGenxvOES (GLenum coord, GLenum pname, const GLfixed *params);
+GLAPI void APIENTRY glTexParameterxOES (GLenum target, GLenum pname, GLfixed param);
+GLAPI void APIENTRY glTexParameterxvOES (GLenum target, GLenum pname, const GLfixed *params);
+GLAPI void APIENTRY glTranslatexOES (GLfixed x, GLfixed y, GLfixed z);
+GLAPI void APIENTRY glVertex2xOES (GLfixed x);
+GLAPI void APIENTRY glVertex3xOES (GLfixed x, GLfixed y);
+GLAPI void APIENTRY glVertex4xOES (GLfixed x, GLfixed y, GLfixed z);
+GLAPI void APIENTRY glVertex2xvOES (const GLfixed *coords);
+GLAPI void APIENTRY glVertex3xvOES (const GLfixed *coords);
+GLAPI void APIENTRY glVertex4xvOES (const GLfixed *coords);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLACCUMXOESPROC) (GLenum op, GLfixed value);
+typedef void (APIENTRYP PFNGLALPHAFUNCXOESPROC) (GLenum func, GLfixed ref);
+typedef void (APIENTRYP PFNGLBITMAPXOESPROC) (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap);
+typedef void (APIENTRYP PFNGLBLENDCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
+typedef void (APIENTRYP PFNGLCLEARACCUMXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
+typedef void (APIENTRYP PFNGLCLEARCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
+typedef void (APIENTRYP PFNGLCLEARDEPTHXOESPROC) (GLfixed depth);
+typedef void (APIENTRYP PFNGLCLIPPLANEXOESPROC) (GLenum plane, const GLfixed *equation);
+typedef void (APIENTRYP PFNGLCOLOR3XOESPROC) (GLfixed red, GLfixed green, GLfixed blue);
+typedef void (APIENTRYP PFNGLCOLOR4XOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
+typedef void (APIENTRYP PFNGLCOLOR3XVOESPROC) (const GLfixed *components);
+typedef void (APIENTRYP PFNGLCOLOR4XVOESPROC) (const GLfixed *components);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params);
+typedef void (APIENTRYP PFNGLDEPTHRANGEXOESPROC) (GLfixed n, GLfixed f);
+typedef void (APIENTRYP PFNGLEVALCOORD1XOESPROC) (GLfixed u);
+typedef void (APIENTRYP PFNGLEVALCOORD2XOESPROC) (GLfixed u, GLfixed v);
+typedef void (APIENTRYP PFNGLEVALCOORD1XVOESPROC) (const GLfixed *coords);
+typedef void (APIENTRYP PFNGLEVALCOORD2XVOESPROC) (const GLfixed *coords);
+typedef void (APIENTRYP PFNGLFEEDBACKBUFFERXOESPROC) (GLsizei n, GLenum type, const GLfixed *buffer);
+typedef void (APIENTRYP PFNGLFOGXOESPROC) (GLenum pname, GLfixed param);
+typedef void (APIENTRYP PFNGLFOGXVOESPROC) (GLenum pname, const GLfixed *param);
+typedef void (APIENTRYP PFNGLFRUSTUMXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f);
+typedef void (APIENTRYP PFNGLGETCLIPPLANEXOESPROC) (GLenum plane, GLfixed *equation);
+typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params);
+typedef void (APIENTRYP PFNGLGETFIXEDVOESPROC) (GLenum pname, GLfixed *params);
+typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params);
+typedef void (APIENTRYP PFNGLGETLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed *params);
+typedef void (APIENTRYP PFNGLGETMAPXVOESPROC) (GLenum target, GLenum query, GLfixed *v);
+typedef void (APIENTRYP PFNGLGETMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param);
+typedef void (APIENTRYP PFNGLGETPIXELMAPXVPROC) (GLenum map, GLint size, GLfixed *values);
+typedef void (APIENTRYP PFNGLGETTEXENVXVOESPROC) (GLenum target, GLenum pname, GLfixed *params);
+typedef void (APIENTRYP PFNGLGETTEXGENXVOESPROC) (GLenum coord, GLenum pname, GLfixed *params);
+typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERXVOESPROC) (GLenum target, GLint level, GLenum pname, GLfixed *params);
+typedef void (APIENTRYP PFNGLGETTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params);
+typedef void (APIENTRYP PFNGLINDEXXOESPROC) (GLfixed component);
+typedef void (APIENTRYP PFNGLINDEXXVOESPROC) (const GLfixed *component);
+typedef void (APIENTRYP PFNGLLIGHTMODELXOESPROC) (GLenum pname, GLfixed param);
+typedef void (APIENTRYP PFNGLLIGHTMODELXVOESPROC) (GLenum pname, const GLfixed *param);
+typedef void (APIENTRYP PFNGLLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed param);
+typedef void (APIENTRYP PFNGLLIGHTXVOESPROC) (GLenum light, GLenum pname, const GLfixed *params);
+typedef void (APIENTRYP PFNGLLINEWIDTHXOESPROC) (GLfixed width);
+typedef void (APIENTRYP PFNGLLOADMATRIXXOESPROC) (const GLfixed *m);
+typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXXOESPROC) (const GLfixed *m);
+typedef void (APIENTRYP PFNGLMAP1XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points);
+typedef void (APIENTRYP PFNGLMAP2XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points);
+typedef void (APIENTRYP PFNGLMAPGRID1XOESPROC) (GLint n, GLfixed u1, GLfixed u2);
+typedef void (APIENTRYP PFNGLMAPGRID2XOESPROC) (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2);
+typedef void (APIENTRYP PFNGLMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param);
+typedef void (APIENTRYP PFNGLMATERIALXVOESPROC) (GLenum face, GLenum pname, const GLfixed *param);
+typedef void (APIENTRYP PFNGLMULTMATRIXXOESPROC) (const GLfixed *m);
+typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXXOESPROC) (const GLfixed *m);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1XOESPROC) (GLenum texture, GLfixed s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2XOESPROC) (GLenum texture, GLfixed s, GLfixed t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1XVOESPROC) (GLenum texture, const GLfixed *coords);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2XVOESPROC) (GLenum texture, const GLfixed *coords);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3XVOESPROC) (GLenum texture, const GLfixed *coords);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4XVOESPROC) (GLenum texture, const GLfixed *coords);
+typedef void (APIENTRYP PFNGLNORMAL3XOESPROC) (GLfixed nx, GLfixed ny, GLfixed nz);
+typedef void (APIENTRYP PFNGLNORMAL3XVOESPROC) (const GLfixed *coords);
+typedef void (APIENTRYP PFNGLORTHOXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f);
+typedef void (APIENTRYP PFNGLPASSTHROUGHXOESPROC) (GLfixed token);
+typedef void (APIENTRYP PFNGLPIXELMAPXPROC) (GLenum map, GLint size, const GLfixed *values);
+typedef void (APIENTRYP PFNGLPIXELSTOREXPROC) (GLenum pname, GLfixed param);
+typedef void (APIENTRYP PFNGLPIXELTRANSFERXOESPROC) (GLenum pname, GLfixed param);
+typedef void (APIENTRYP PFNGLPIXELZOOMXOESPROC) (GLfixed xfactor, GLfixed yfactor);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERXVOESPROC) (GLenum pname, const GLfixed *params);
+typedef void (APIENTRYP PFNGLPOINTSIZEXOESPROC) (GLfixed size);
+typedef void (APIENTRYP PFNGLPOLYGONOFFSETXOESPROC) (GLfixed factor, GLfixed units);
+typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESXOESPROC) (GLsizei n, const GLuint *textures, const GLfixed *priorities);
+typedef void (APIENTRYP PFNGLRASTERPOS2XOESPROC) (GLfixed x, GLfixed y);
+typedef void (APIENTRYP PFNGLRASTERPOS3XOESPROC) (GLfixed x, GLfixed y, GLfixed z);
+typedef void (APIENTRYP PFNGLRASTERPOS4XOESPROC) (GLfixed x, GLfixed y, GLfixed z, GLfixed w);
+typedef void (APIENTRYP PFNGLRASTERPOS2XVOESPROC) (const GLfixed *coords);
+typedef void (APIENTRYP PFNGLRASTERPOS3XVOESPROC) (const GLfixed *coords);
+typedef void (APIENTRYP PFNGLRASTERPOS4XVOESPROC) (const GLfixed *coords);
+typedef void (APIENTRYP PFNGLRECTXOESPROC) (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2);
+typedef void (APIENTRYP PFNGLRECTXVOESPROC) (const GLfixed *v1, const GLfixed *v2);
+typedef void (APIENTRYP PFNGLROTATEXOESPROC) (GLfixed angle, GLfixed x, GLfixed y, GLfixed z);
+typedef void (APIENTRYP PFNGLSAMPLECOVERAGEOESPROC) (GLfixed value, GLboolean invert);
+typedef void (APIENTRYP PFNGLSCALEXOESPROC) (GLfixed x, GLfixed y, GLfixed z);
+typedef void (APIENTRYP PFNGLTEXCOORD1XOESPROC) (GLfixed s);
+typedef void (APIENTRYP PFNGLTEXCOORD2XOESPROC) (GLfixed s, GLfixed t);
+typedef void (APIENTRYP PFNGLTEXCOORD3XOESPROC) (GLfixed s, GLfixed t, GLfixed r);
+typedef void (APIENTRYP PFNGLTEXCOORD4XOESPROC) (GLfixed s, GLfixed t, GLfixed r, GLfixed q);
+typedef void (APIENTRYP PFNGLTEXCOORD1XVOESPROC) (const GLfixed *coords);
+typedef void (APIENTRYP PFNGLTEXCOORD2XVOESPROC) (const GLfixed *coords);
+typedef void (APIENTRYP PFNGLTEXCOORD3XVOESPROC) (const GLfixed *coords);
+typedef void (APIENTRYP PFNGLTEXCOORD4XVOESPROC) (const GLfixed *coords);
+typedef void (APIENTRYP PFNGLTEXENVXOESPROC) (GLenum target, GLenum pname, GLfixed param);
+typedef void (APIENTRYP PFNGLTEXENVXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params);
+typedef void (APIENTRYP PFNGLTEXGENXOESPROC) (GLenum coord, GLenum pname, GLfixed param);
+typedef void (APIENTRYP PFNGLTEXGENXVOESPROC) (GLenum coord, GLenum pname, const GLfixed *params);
+typedef void (APIENTRYP PFNGLTEXPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param);
+typedef void (APIENTRYP PFNGLTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params);
+typedef void (APIENTRYP PFNGLTRANSLATEXOESPROC) (GLfixed x, GLfixed y, GLfixed z);
+typedef void (APIENTRYP PFNGLVERTEX2XOESPROC) (GLfixed x);
+typedef void (APIENTRYP PFNGLVERTEX3XOESPROC) (GLfixed x, GLfixed y);
+typedef void (APIENTRYP PFNGLVERTEX4XOESPROC) (GLfixed x, GLfixed y, GLfixed z);
+typedef void (APIENTRYP PFNGLVERTEX2XVOESPROC) (const GLfixed *coords);
+typedef void (APIENTRYP PFNGLVERTEX3XVOESPROC) (const GLfixed *coords);
+typedef void (APIENTRYP PFNGLVERTEX4XVOESPROC) (const GLfixed *coords);
+#endif
+
+#ifndef GL_OES_single_precision
+#define GL_OES_single_precision 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDepthRangefOES (GLclampf n, GLclampf f);
+GLAPI void APIENTRY glFrustumfOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f);
+GLAPI void APIENTRY glOrthofOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f);
+GLAPI void APIENTRY glClipPlanefOES (GLenum plane, const GLfloat *equation);
+GLAPI void APIENTRY glClearDepthfOES (GLclampf depth);
+GLAPI void APIENTRY glGetClipPlanefOES (GLenum plane, GLfloat *equation);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDEPTHRANGEFOESPROC) (GLclampf n, GLclampf f);
+typedef void (APIENTRYP PFNGLFRUSTUMFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f);
+typedef void (APIENTRYP PFNGLORTHOFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f);
+typedef void (APIENTRYP PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat *equation);
+typedef void (APIENTRYP PFNGLCLEARDEPTHFOESPROC) (GLclampf depth);
+typedef void (APIENTRYP PFNGLGETCLIPPLANEFOESPROC) (GLenum plane, GLfloat *equation);
+#endif
+
+#ifndef GL_OES_compressed_paletted_texture
+#define GL_OES_compressed_paletted_texture 1
+#endif
+
+#ifndef GL_OES_read_format
+#define GL_OES_read_format 1
+#endif
+
+#ifndef GL_OES_query_matrix
+#define GL_OES_query_matrix 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLbitfield APIENTRY glQueryMatrixxOES (GLfixed *mantissa, GLint *exponent);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLbitfield (APIENTRYP PFNGLQUERYMATRIXXOESPROC) (GLfixed *mantissa, GLint *exponent);
+#endif
+
+#ifndef GL_EXT_depth_bounds_test
+#define GL_EXT_depth_bounds_test 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDepthBoundsEXT (GLclampd zmin, GLclampd zmax);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax);
+#endif
+
+#ifndef GL_EXT_texture_mirror_clamp
+#define GL_EXT_texture_mirror_clamp 1
+#endif
+
+#ifndef GL_EXT_blend_equation_separate
+#define GL_EXT_blend_equation_separate 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum modeRGB, GLenum modeAlpha);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha);
+#endif
+
+#ifndef GL_MESA_pack_invert
+#define GL_MESA_pack_invert 1
+#endif
+
+#ifndef GL_MESA_ycbcr_texture
+#define GL_MESA_ycbcr_texture 1
+#endif
+
+#ifndef GL_EXT_pixel_buffer_object
+#define GL_EXT_pixel_buffer_object 1
+#endif
+
+#ifndef GL_NV_fragment_program_option
+#define GL_NV_fragment_program_option 1
+#endif
+
+#ifndef GL_NV_fragment_program2
+#define GL_NV_fragment_program2 1
+#endif
+
+#ifndef GL_NV_vertex_program2_option
+#define GL_NV_vertex_program2_option 1
+#endif
+
+#ifndef GL_NV_vertex_program3
+#define GL_NV_vertex_program3 1
+#endif
+
+#ifndef GL_EXT_framebuffer_object
+#define GL_EXT_framebuffer_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint renderbuffer);
+GLAPI void APIENTRY glBindRenderbufferEXT (GLenum target, GLuint renderbuffer);
+GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers);
+GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers);
+GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum target, GLenum pname, GLint *params);
+GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint framebuffer);
+GLAPI void APIENTRY glBindFramebufferEXT (GLenum target, GLuint framebuffer);
+GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers);
+GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei n, GLuint *framebuffers);
+GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum target);
+GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum target, GLenum attachment, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGenerateMipmapEXT (GLenum target);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers);
+typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers);
+typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer);
+typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer);
+typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers);
+typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers);
+typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target);
+#endif
+
+#ifndef GL_GREMEDY_string_marker
+#define GL_GREMEDY_string_marker 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei len, const GLvoid *string);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string);
+#endif
+
+#ifndef GL_EXT_packed_depth_stencil
+#define GL_EXT_packed_depth_stencil 1
+#endif
+
+#ifndef GL_EXT_stencil_clear_tag
+#define GL_EXT_stencil_clear_tag 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glStencilClearTagEXT (GLsizei stencilTagBits, GLuint stencilClearTag);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag);
+#endif
+
+#ifndef GL_EXT_texture_sRGB
+#define GL_EXT_texture_sRGB 1
+#endif
+
+#ifndef GL_EXT_framebuffer_blit
+#define GL_EXT_framebuffer_blit 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+#endif
+
+#ifndef GL_EXT_framebuffer_multisample
+#define GL_EXT_framebuffer_multisample 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+#endif
+
+#ifndef GL_MESAX_texture_stack
+#define GL_MESAX_texture_stack 1
+#endif
+
+#ifndef GL_EXT_timer_query
+#define GL_EXT_timer_query 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64EXT *params);
+GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64EXT *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params);
+typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params);
+#endif
+
+#ifndef GL_EXT_gpu_program_parameters
+#define GL_EXT_gpu_program_parameters 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params);
+GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params);
+#endif
+
+#ifndef GL_APPLE_flush_buffer_range
+#define GL_APPLE_flush_buffer_range 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum target, GLenum pname, GLint param);
+GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum target, GLintptr offset, GLsizeiptr size);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size);
+#endif
+
+#ifndef GL_NV_gpu_program4
+#define GL_NV_gpu_program4 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);
+GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum target, GLuint index, const GLint *params);
+GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params);
+GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum target, GLuint index, const GLuint *params);
+GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params);
+GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);
+GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum target, GLuint index, const GLint *params);
+GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params);
+GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum target, GLuint index, const GLuint *params);
+GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params);
+GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum target, GLuint index, GLint *params);
+GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum target, GLuint index, GLuint *params);
+GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum target, GLuint index, GLint *params);
+GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum target, GLuint index, GLuint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params);
+#endif
+
+#ifndef GL_NV_geometry_program4
+#define GL_NV_geometry_program4 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glProgramVertexLimitNV (GLenum target, GLint limit);
+GLAPI void APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level);
+GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
+GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face);
+#endif
+
+#ifndef GL_EXT_geometry_shader4
+#define GL_EXT_geometry_shader4 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value);
+#endif
+
+#ifndef GL_NV_vertex_program4
+#define GL_NV_vertex_program4 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint index, GLint x);
+GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint index, GLint x, GLint y);
+GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint index, GLint x, GLint y, GLint z);
+GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint index, GLint x, GLint y, GLint z, GLint w);
+GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint index, GLuint x);
+GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint index, GLuint x, GLuint y);
+GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint index, GLuint x, GLuint y, GLuint z);
+GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint index, const GLint *v);
+GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint index, const GLint *v);
+GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint index, const GLint *v);
+GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint index, const GLint *v);
+GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint index, const GLuint *v);
+GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint index, const GLuint *v);
+GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint index, const GLuint *v);
+GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint index, const GLuint *v);
+GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint index, const GLbyte *v);
+GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint index, const GLubyte *v);
+GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint index, const GLushort *v);
+GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint index, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params);
+#endif
+
+#ifndef GL_EXT_gpu_shader4
+#define GL_EXT_gpu_shader4 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetUniformuivEXT (GLuint program, GLint location, GLuint *params);
+GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name);
+GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint program, const GLchar *name);
+GLAPI void APIENTRY glUniform1uiEXT (GLint location, GLuint v0);
+GLAPI void APIENTRY glUniform2uiEXT (GLint location, GLuint v0, GLuint v1);
+GLAPI void APIENTRY glUniform3uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2);
+GLAPI void APIENTRY glUniform4uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+GLAPI void APIENTRY glUniform1uivEXT (GLint location, GLsizei count, const GLuint *value);
+GLAPI void APIENTRY glUniform2uivEXT (GLint location, GLsizei count, const GLuint *value);
+GLAPI void APIENTRY glUniform3uivEXT (GLint location, GLsizei count, const GLuint *value);
+GLAPI void APIENTRY glUniform4uivEXT (GLint location, GLsizei count, const GLuint *value);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params);
+typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name);
+typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name);
+typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0);
+typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1);
+typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2);
+typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value);
+#endif
+
+#ifndef GL_EXT_draw_instanced
+#define GL_EXT_draw_instanced 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount);
+GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount);
+typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
+#endif
+
+#ifndef GL_EXT_packed_float
+#define GL_EXT_packed_float 1
+#endif
+
+#ifndef GL_EXT_texture_array
+#define GL_EXT_texture_array 1
+#endif
+
+#ifndef GL_EXT_texture_buffer_object
+#define GL_EXT_texture_buffer_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer);
+#endif
+
+#ifndef GL_EXT_texture_compression_latc
+#define GL_EXT_texture_compression_latc 1
+#endif
+
+#ifndef GL_EXT_texture_compression_rgtc
+#define GL_EXT_texture_compression_rgtc 1
+#endif
+
+#ifndef GL_EXT_texture_shared_exponent
+#define GL_EXT_texture_shared_exponent 1
+#endif
+
+#ifndef GL_NV_depth_buffer_float
+#define GL_NV_depth_buffer_float 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar);
+GLAPI void APIENTRY glClearDepthdNV (GLdouble depth);
+GLAPI void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar);
+typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth);
+typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax);
+#endif
+
+#ifndef GL_NV_fragment_program4
+#define GL_NV_fragment_program4 1
+#endif
+
+#ifndef GL_NV_framebuffer_multisample_coverage
+#define GL_NV_framebuffer_multisample_coverage 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height);
+#endif
+
+#ifndef GL_EXT_framebuffer_sRGB
+#define GL_EXT_framebuffer_sRGB 1
+#endif
+
+#ifndef GL_NV_geometry_shader4
+#define GL_NV_geometry_shader4 1
+#endif
+
+#ifndef GL_NV_parameter_buffer_object
+#define GL_NV_parameter_buffer_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params);
+GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params);
+GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params);
+typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params);
+typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params);
+#endif
+
+#ifndef GL_EXT_draw_buffers2
+#define GL_EXT_draw_buffers2 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
+GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data);
+GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data);
+GLAPI void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index);
+GLAPI void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index);
+GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
+typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data);
+typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data);
+typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index);
+typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index);
+typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index);
+#endif
+
+#ifndef GL_NV_transform_feedback
+#define GL_NV_transform_feedback 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum primitiveMode);
+GLAPI void APIENTRY glEndTransformFeedbackNV (void);
+GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLuint count, const GLint *attribs, GLenum bufferMode);
+GLAPI void APIENTRY glBindBufferRangeNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
+GLAPI void APIENTRY glBindBufferOffsetNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset);
+GLAPI void APIENTRY glBindBufferBaseNV (GLenum target, GLuint index, GLuint buffer);
+GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode);
+GLAPI void APIENTRY glActiveVaryingNV (GLuint program, const GLchar *name);
+GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint program, const GLchar *name);
+GLAPI void APIENTRY glGetActiveVaryingNV (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);
+GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint program, GLuint index, GLint *location);
+GLAPI void APIENTRY glTransformFeedbackStreamAttribsNV (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode);
+typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void);
+typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode);
+typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
+typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset);
+typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer);
+typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode);
+typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name);
+typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name);
+typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);
+typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location);
+typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKSTREAMATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode);
+#endif
+
+#ifndef GL_EXT_bindable_uniform
+#define GL_EXT_bindable_uniform 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glUniformBufferEXT (GLuint program, GLint location, GLuint buffer);
+GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint program, GLint location);
+GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint program, GLint location);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer);
+typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location);
+typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location);
+#endif
+
+#ifndef GL_EXT_texture_integer
+#define GL_EXT_texture_integer 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params);
+GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params);
+GLAPI void APIENTRY glClearColorIiEXT (GLint red, GLint green, GLint blue, GLint alpha);
+GLAPI void APIENTRY glClearColorIuiEXT (GLuint red, GLuint green, GLuint blue, GLuint alpha);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params);
+typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params);
+typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha);
+typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha);
+#endif
+
+#ifndef GL_GREMEDY_frame_terminator
+#define GL_GREMEDY_frame_terminator 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFrameTerminatorGREMEDY (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void);
+#endif
+
+#ifndef GL_NV_conditional_render
+#define GL_NV_conditional_render 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode);
+GLAPI void APIENTRY glEndConditionalRenderNV (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode);
+typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void);
+#endif
+
+#ifndef GL_NV_present_video
+#define GL_NV_present_video 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPresentFrameKeyedNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1);
+GLAPI void APIENTRY glPresentFrameDualFillNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3);
+GLAPI void APIENTRY glGetVideoivNV (GLuint video_slot, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetVideouivNV (GLuint video_slot, GLenum pname, GLuint *params);
+GLAPI void APIENTRY glGetVideoi64vNV (GLuint video_slot, GLenum pname, GLint64EXT *params);
+GLAPI void APIENTRY glGetVideoui64vNV (GLuint video_slot, GLenum pname, GLuint64EXT *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1);
+typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3);
+typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params);
+typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params);
+typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params);
+#endif
+
+#ifndef GL_EXT_transform_feedback
+#define GL_EXT_transform_feedback 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum primitiveMode);
+GLAPI void APIENTRY glEndTransformFeedbackEXT (void);
+GLAPI void APIENTRY glBindBufferRangeEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
+GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset);
+GLAPI void APIENTRY glBindBufferBaseEXT (GLenum target, GLuint index, GLuint buffer);
+GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode);
+GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode);
+typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void);
+typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
+typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset);
+typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer);
+typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode);
+typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);
+#endif
+
+#ifndef GL_EXT_direct_state_access
+#define GL_EXT_direct_state_access 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield mask);
+GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield mask);
+GLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m);
+GLAPI void APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m);
+GLAPI void APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m);
+GLAPI void APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m);
+GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum mode);
+GLAPI void APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
+GLAPI void APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
+GLAPI void APIENTRY glMatrixPopEXT (GLenum mode);
+GLAPI void APIENTRY glMatrixPushEXT (GLenum mode);
+GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m);
+GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m);
+GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m);
+GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m);
+GLAPI void APIENTRY glTextureParameterfEXT (GLuint texture, GLenum target, GLenum pname, GLfloat param);
+GLAPI void APIENTRY glTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glTextureParameteriEXT (GLuint texture, GLenum target, GLenum pname, GLint param);
+GLAPI void APIENTRY glTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
+GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
+GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glGetTextureImageEXT (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);
+GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params);
+GLAPI void APIENTRY glTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param);
+GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum texunit, GLenum target, GLenum pname, GLint param);
+GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
+GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
+GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);
+GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params);
+GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glBindMultiTextureEXT (GLenum texunit, GLenum target, GLuint texture);
+GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum array, GLuint index);
+GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum array, GLuint index);
+GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param);
+GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glMultiTexEnviEXT (GLenum texunit, GLenum target, GLenum pname, GLint param);
+GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glMultiTexGendEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble param);
+GLAPI void APIENTRY glMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params);
+GLAPI void APIENTRY glMultiTexGenfEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat param);
+GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glMultiTexGeniEXT (GLenum texunit, GLenum coord, GLenum pname, GLint param);
+GLAPI void APIENTRY glMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params);
+GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum target, GLuint index, GLfloat *data);
+GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum target, GLuint index, GLdouble *data);
+GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum target, GLuint index, GLvoid* *data);
+GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits);
+GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits);
+GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits);
+GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits);
+GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits);
+GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits);
+GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint texture, GLenum target, GLint lod, GLvoid *img);
+GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits);
+GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits);
+GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits);
+GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits);
+GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits);
+GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits);
+GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target, GLint lod, GLvoid *img);
+GLAPI void APIENTRY glNamedProgramStringEXT (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string);
+GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint program, GLenum target, GLuint index, const GLdouble *params);
+GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint program, GLenum target, GLuint index, const GLfloat *params);
+GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint program, GLenum target, GLuint index, GLdouble *params);
+GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint program, GLenum target, GLuint index, GLfloat *params);
+GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint program, GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint program, GLenum target, GLenum pname, GLvoid *string);
+GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params);
+GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);
+GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint program, GLenum target, GLuint index, const GLint *params);
+GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params);
+GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint program, GLenum target, GLuint index, const GLuint *params);
+GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params);
+GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint program, GLenum target, GLuint index, GLint *params);
+GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint program, GLenum target, GLuint index, GLuint *params);
+GLAPI void APIENTRY glTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, const GLuint *params);
+GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, GLuint *params);
+GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, const GLuint *params);
+GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, GLuint *params);
+GLAPI void APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0);
+GLAPI void APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1);
+GLAPI void APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+GLAPI void APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+GLAPI void APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0);
+GLAPI void APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1);
+GLAPI void APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2);
+GLAPI void APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0);
+GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1);
+GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);
+GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GLAPI void APIENTRY glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage);
+GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data);
+GLAPI GLvoid* APIENTRY glMapNamedBufferEXT (GLuint buffer, GLenum access);
+GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint buffer);
+GLAPI GLvoid* APIENTRY glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access);
+GLAPI void APIENTRY glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length);
+GLAPI void APIENTRY glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
+GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint buffer, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint buffer, GLenum pname, GLvoid* *params);
+GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data);
+GLAPI void APIENTRY glTextureBufferEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer);
+GLAPI void APIENTRY glMultiTexBufferEXT (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer);
+GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint renderbuffer, GLenum pname, GLint *params);
+GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint framebuffer, GLenum target);
+GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint texture, GLenum target);
+GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum texunit, GLenum target);
+GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint framebuffer, GLenum mode);
+GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint framebuffer, GLsizei n, const GLenum *bufs);
+GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint framebuffer, GLenum mode);
+GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params);
+GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level);
+GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer);
+GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face);
+GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint texture, GLenum target, GLuint renderbuffer);
+GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum texunit, GLenum target, GLuint renderbuffer);
+GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x);
+GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y);
+GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask);
+typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask);
+typedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m);
+typedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m);
+typedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m);
+typedef void (APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m);
+typedef void (APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode);
+typedef void (APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
+typedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
+typedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode);
+typedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode);
+typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m);
+typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m);
+typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m);
+typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m);
+typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
+typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);
+typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
+typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);
+typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture);
+typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index);
+typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index);
+typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param);
+typedef void (APIENTRYP PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params);
+typedef void (APIENTRYP PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params);
+typedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data);
+typedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data);
+typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLvoid* *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint lod, GLvoid *img);
+typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, GLvoid *img);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params);
+typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params);
+typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, GLvoid *string);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params);
+typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params);
+typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params);
+typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params);
+typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params);
+typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params);
+typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage);
+typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data);
+typedef GLvoid* (APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access);
+typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer);
+typedef GLvoid* (APIENTRYP PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access);
+typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length);
+typedef void (APIENTRYP PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
+typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, GLvoid* *params);
+typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data);
+typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer);
+typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer);
+typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params);
+typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target);
+typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target);
+typedef void (APIENTRYP PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode);
+typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer);
+typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face);
+typedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+#endif
+
+#ifndef GL_EXT_vertex_array_bgra
+#define GL_EXT_vertex_array_bgra 1
+#endif
+
+#ifndef GL_EXT_texture_swizzle
+#define GL_EXT_texture_swizzle 1
+#endif
+
+#ifndef GL_NV_explicit_multisample
+#define GL_NV_explicit_multisample 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetMultisamplefvNV (GLenum pname, GLuint index, GLfloat *val);
+GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint index, GLbitfield mask);
+GLAPI void APIENTRY glTexRenderbufferNV (GLenum target, GLuint renderbuffer);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val);
+typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask);
+typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer);
+#endif
+
+#ifndef GL_NV_transform_feedback2
+#define GL_NV_transform_feedback2 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBindTransformFeedbackNV (GLenum target, GLuint id);
+GLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei n, const GLuint *ids);
+GLAPI void APIENTRY glGenTransformFeedbacksNV (GLsizei n, GLuint *ids);
+GLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint id);
+GLAPI void APIENTRY glPauseTransformFeedbackNV (void);
+GLAPI void APIENTRY glResumeTransformFeedbackNV (void);
+GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum mode, GLuint id);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id);
+typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids);
+typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids);
+typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void);
+typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void);
+typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id);
+#endif
+
+#ifndef GL_ATI_meminfo
+#define GL_ATI_meminfo 1
+#endif
+
+#ifndef GL_AMD_performance_monitor
+#define GL_AMD_performance_monitor 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups);
+GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters);
+GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString);
+GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString);
+GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, GLvoid *data);
+GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors);
+GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors);
+GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList);
+GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint monitor);
+GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint monitor);
+GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups);
+typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters);
+typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString);
+typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString);
+typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, GLvoid *data);
+typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors);
+typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors);
+typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList);
+typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor);
+typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor);
+typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten);
+#endif
+
+#ifndef GL_AMD_texture_texture4
+#define GL_AMD_texture_texture4 1
+#endif
+
+#ifndef GL_AMD_vertex_shader_tessellator
+#define GL_AMD_vertex_shader_tessellator 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTessellationFactorAMD (GLfloat factor);
+GLAPI void APIENTRY glTessellationModeAMD (GLenum mode);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor);
+typedef void (APIENTRYP PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode);
+#endif
+
+#ifndef GL_EXT_provoking_vertex
+#define GL_EXT_provoking_vertex 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glProvokingVertexEXT (GLenum mode);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode);
+#endif
+
+#ifndef GL_EXT_texture_snorm
+#define GL_EXT_texture_snorm 1
+#endif
+
+#ifndef GL_AMD_draw_buffers_blend
+#define GL_AMD_draw_buffers_blend 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendFuncIndexedAMD (GLuint buf, GLenum src, GLenum dst);
+GLAPI void APIENTRY glBlendFuncSeparateIndexedAMD (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+GLAPI void APIENTRY glBlendEquationIndexedAMD (GLuint buf, GLenum mode);
+GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRGB, GLenum modeAlpha);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst);
+typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+typedef void (APIENTRYP PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode);
+typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha);
+#endif
+
+#ifndef GL_APPLE_texture_range
+#define GL_APPLE_texture_range 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTextureRangeAPPLE (GLenum target, GLsizei length, const GLvoid *pointer);
+GLAPI void APIENTRY glGetTexParameterPointervAPPLE (GLenum target, GLenum pname, GLvoid* *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, GLvoid* *params);
+#endif
+
+#ifndef GL_APPLE_float_pixels
+#define GL_APPLE_float_pixels 1
+#endif
+
+#ifndef GL_APPLE_vertex_program_evaluators
+#define GL_APPLE_vertex_program_evaluators 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glEnableVertexAttribAPPLE (GLuint index, GLenum pname);
+GLAPI void APIENTRY glDisableVertexAttribAPPLE (GLuint index, GLenum pname);
+GLAPI GLboolean APIENTRY glIsVertexAttribEnabledAPPLE (GLuint index, GLenum pname);
+GLAPI void APIENTRY glMapVertexAttrib1dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points);
+GLAPI void APIENTRY glMapVertexAttrib1fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points);
+GLAPI void APIENTRY glMapVertexAttrib2dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points);
+GLAPI void APIENTRY glMapVertexAttrib2fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname);
+typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname);
+typedef GLboolean (APIENTRYP PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname);
+typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points);
+typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points);
+typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points);
+typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points);
+#endif
+
+#ifndef GL_APPLE_aux_depth_stencil
+#define GL_APPLE_aux_depth_stencil 1
+#endif
+
+#ifndef GL_APPLE_object_purgeable
+#define GL_APPLE_object_purgeable 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLenum APIENTRY glObjectPurgeableAPPLE (GLenum objectType, GLuint name, GLenum option);
+GLAPI GLenum APIENTRY glObjectUnpurgeableAPPLE (GLenum objectType, GLuint name, GLenum option);
+GLAPI void APIENTRY glGetObjectParameterivAPPLE (GLenum objectType, GLuint name, GLenum pname, GLint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option);
+typedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option);
+typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint *params);
+#endif
+
+#ifndef GL_APPLE_row_bytes
+#define GL_APPLE_row_bytes 1
+#endif
+
+#ifndef GL_APPLE_rgb_422
+#define GL_APPLE_rgb_422 1
+#endif
+
+#ifndef GL_NV_video_capture
+#define GL_NV_video_capture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint video_capture_slot);
+GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset);
+GLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture);
+GLAPI void APIENTRY glEndVideoCaptureNV (GLuint video_capture_slot);
+GLAPI void APIENTRY glGetVideoCaptureivNV (GLuint video_capture_slot, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetVideoCaptureStreamivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetVideoCaptureStreamfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetVideoCaptureStreamdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params);
+GLAPI GLenum APIENTRY glVideoCaptureNV (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time);
+GLAPI void APIENTRY glVideoCaptureStreamParameterivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glVideoCaptureStreamParameterfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot);
+typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset);
+typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture);
+typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot);
+typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params);
+typedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time);
+typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params);
+#endif
+
+#ifndef GL_NV_copy_image
+#define GL_NV_copy_image 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glCopyImageSubDataNV (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
+#endif
+
+#ifndef GL_EXT_separate_shader_objects
+#define GL_EXT_separate_shader_objects 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glUseShaderProgramEXT (GLenum type, GLuint program);
+GLAPI void APIENTRY glActiveProgramEXT (GLuint program);
+GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *string);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program);
+typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program);
+typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string);
+#endif
+
+#ifndef GL_NV_parameter_buffer_object2
+#define GL_NV_parameter_buffer_object2 1
+#endif
+
+#ifndef GL_NV_shader_buffer_load
+#define GL_NV_shader_buffer_load 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access);
+GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target);
+GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target);
+GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access);
+GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer);
+GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer);
+GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params);
+GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params);
+GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result);
+GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value);
+GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value);
+GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params);
+GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value);
+GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access);
+typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target);
+typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access);
+typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer);
+typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer);
+typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params);
+typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params);
+typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result);
+typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value);
+typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value);
+typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
+#endif
+
+#ifndef GL_NV_vertex_buffer_unified_memory
+#define GL_NV_vertex_buffer_unified_memory 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length);
+GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride);
+GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride);
+GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride);
+GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride);
+GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride);
+GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride);
+GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride);
+GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride);
+GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride);
+GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride);
+GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length);
+typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);
+typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride);
+typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);
+typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride);
+typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);
+typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride);
+typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);
+typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride);
+typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result);
+#endif
+
+#ifndef GL_NV_texture_barrier
+#define GL_NV_texture_barrier 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTextureBarrierNV (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void);
+#endif
+
+#ifndef GL_AMD_shader_stencil_export
+#define GL_AMD_shader_stencil_export 1
+#endif
+
+#ifndef GL_AMD_seamless_cubemap_per_texture
+#define GL_AMD_seamless_cubemap_per_texture 1
+#endif
+
+#ifndef GL_AMD_conservative_depth
+#define GL_AMD_conservative_depth 1
+#endif
+
+#ifndef GL_EXT_shader_image_load_store
+#define GL_EXT_shader_image_load_store 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBindImageTextureEXT (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format);
+GLAPI void APIENTRY glMemoryBarrierEXT (GLbitfield barriers);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format);
+typedef void (APIENTRYP PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers);
+#endif
+
+#ifndef GL_EXT_vertex_attrib_64bit
+#define GL_EXT_vertex_attrib_64bit 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexAttribL1dEXT (GLuint index, GLdouble x);
+GLAPI void APIENTRY glVertexAttribL2dEXT (GLuint index, GLdouble x, GLdouble y);
+GLAPI void APIENTRY glVertexAttribL3dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glVertexAttribL4dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI void APIENTRY glVertexAttribL1dvEXT (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttribL2dvEXT (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttribL3dvEXT (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttribL4dvEXT (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttribLPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glGetVertexAttribLdvEXT (GLuint index, GLenum pname, GLdouble *params);
+GLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble *params);
+typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset);
+#endif
+
+#ifndef GL_NV_gpu_program5
+#define GL_NV_gpu_program5 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glProgramSubroutineParametersuivNV (GLenum target, GLsizei count, const GLuint *params);
+GLAPI void APIENTRY glGetProgramSubroutineParameteruivNV (GLenum target, GLuint index, GLuint *param);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPROGRAMSUBROUTINEPARAMETERSUIVNVPROC) (GLenum target, GLsizei count, const GLuint *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMSUBROUTINEPARAMETERUIVNVPROC) (GLenum target, GLuint index, GLuint *param);
+#endif
+
+#ifndef GL_NV_gpu_shader5
+#define GL_NV_gpu_shader5 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glUniform1i64NV (GLint location, GLint64EXT x);
+GLAPI void APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y);
+GLAPI void APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z);
+GLAPI void APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w);
+GLAPI void APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value);
+GLAPI void APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value);
+GLAPI void APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value);
+GLAPI void APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value);
+GLAPI void APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x);
+GLAPI void APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y);
+GLAPI void APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z);
+GLAPI void APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w);
+GLAPI void APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value);
+GLAPI void APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value);
+GLAPI void APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value);
+GLAPI void APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value);
+GLAPI void APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params);
+GLAPI void APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x);
+GLAPI void APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y);
+GLAPI void APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z);
+GLAPI void APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w);
+GLAPI void APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);
+GLAPI void APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);
+GLAPI void APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);
+GLAPI void APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);
+GLAPI void APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x);
+GLAPI void APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y);
+GLAPI void APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z);
+GLAPI void APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w);
+GLAPI void APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
+GLAPI void APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
+GLAPI void APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
+GLAPI void APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x);
+typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y);
+typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z);
+typedef void (APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w);
+typedef void (APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value);
+typedef void (APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value);
+typedef void (APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value);
+typedef void (APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value);
+typedef void (APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x);
+typedef void (APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y);
+typedef void (APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z);
+typedef void (APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w);
+typedef void (APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value);
+typedef void (APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value);
+typedef void (APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value);
+typedef void (APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value);
+typedef void (APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
+#endif
+
+#ifndef GL_NV_shader_buffer_store
+#define GL_NV_shader_buffer_store 1
+#endif
+
+#ifndef GL_NV_tessellation_program5
+#define GL_NV_tessellation_program5 1
+#endif
+
+#ifndef GL_NV_vertex_attrib_integer_64bit
+#define GL_NV_vertex_attrib_integer_64bit 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexAttribL1i64NV (GLuint index, GLint64EXT x);
+GLAPI void APIENTRY glVertexAttribL2i64NV (GLuint index, GLint64EXT x, GLint64EXT y);
+GLAPI void APIENTRY glVertexAttribL3i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z);
+GLAPI void APIENTRY glVertexAttribL4i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w);
+GLAPI void APIENTRY glVertexAttribL1i64vNV (GLuint index, const GLint64EXT *v);
+GLAPI void APIENTRY glVertexAttribL2i64vNV (GLuint index, const GLint64EXT *v);
+GLAPI void APIENTRY glVertexAttribL3i64vNV (GLuint index, const GLint64EXT *v);
+GLAPI void APIENTRY glVertexAttribL4i64vNV (GLuint index, const GLint64EXT *v);
+GLAPI void APIENTRY glVertexAttribL1ui64NV (GLuint index, GLuint64EXT x);
+GLAPI void APIENTRY glVertexAttribL2ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y);
+GLAPI void APIENTRY glVertexAttribL3ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z);
+GLAPI void APIENTRY glVertexAttribL4ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w);
+GLAPI void APIENTRY glVertexAttribL1ui64vNV (GLuint index, const GLuint64EXT *v);
+GLAPI void APIENTRY glVertexAttribL2ui64vNV (GLuint index, const GLuint64EXT *v);
+GLAPI void APIENTRY glVertexAttribL3ui64vNV (GLuint index, const GLuint64EXT *v);
+GLAPI void APIENTRY glVertexAttribL4ui64vNV (GLuint index, const GLuint64EXT *v);
+GLAPI void APIENTRY glGetVertexAttribLi64vNV (GLuint index, GLenum pname, GLint64EXT *params);
+GLAPI void APIENTRY glGetVertexAttribLui64vNV (GLuint index, GLenum pname, GLuint64EXT *params);
+GLAPI void APIENTRY glVertexAttribLFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT *v);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT *params);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride);
+#endif
+
+#ifndef GL_NV_multisample_coverage
+#define GL_NV_multisample_coverage 1
+#endif
+
+#ifndef GL_AMD_name_gen_delete
+#define GL_AMD_name_gen_delete 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGenNamesAMD (GLenum identifier, GLuint num, GLuint *names);
+GLAPI void APIENTRY glDeleteNamesAMD (GLenum identifier, GLuint num, const GLuint *names);
+GLAPI GLboolean APIENTRY glIsNameAMD (GLenum identifier, GLuint name);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint *names);
+typedef void (APIENTRYP PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint *names);
+typedef GLboolean (APIENTRYP PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name);
+#endif
+
+#ifndef GL_AMD_debug_output
+#define GL_AMD_debug_output 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
+GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf);
+GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, GLvoid *userParam);
+GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
+typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf);
+typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, GLvoid *userParam);
+typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message);
+#endif
+
+#ifndef GL_NV_vdpau_interop
+#define GL_NV_vdpau_interop 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVDPAUInitNV (const GLvoid *vdpDevice, const GLvoid *getProcAddress);
+GLAPI void APIENTRY glVDPAUFiniNV (void);
+GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (const GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames);
+GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterOutputSurfaceNV (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames);
+GLAPI void APIENTRY glVDPAUIsSurfaceNV (GLvdpauSurfaceNV surface);
+GLAPI void APIENTRY glVDPAUUnregisterSurfaceNV (GLvdpauSurfaceNV surface);
+GLAPI void APIENTRY glVDPAUGetSurfaceivNV (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
+GLAPI void APIENTRY glVDPAUSurfaceAccessNV (GLvdpauSurfaceNV surface, GLenum access);
+GLAPI void APIENTRY glVDPAUMapSurfacesNV (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces);
+GLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVDPAUINITNVPROC) (const GLvoid *vdpDevice, const GLvoid *getProcAddress);
+typedef void (APIENTRYP PFNGLVDPAUFININVPROC) (void);
+typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (const GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames);
+typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames);
+typedef void (APIENTRYP PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface);
+typedef void (APIENTRYP PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface);
+typedef void (APIENTRYP PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
+typedef void (APIENTRYP PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access);
+typedef void (APIENTRYP PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces);
+typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces);
+#endif
+
+#ifndef GL_AMD_transform_feedback3_lines_triangles
+#define GL_AMD_transform_feedback3_lines_triangles 1
+#endif
+
+#ifndef GL_AMD_depth_clamp_separate
+#define GL_AMD_depth_clamp_separate 1
+#endif
+
+#ifndef GL_EXT_texture_sRGB_decode
+#define GL_EXT_texture_sRGB_decode 1
+#endif
+
+#ifndef GL_NV_texture_multisample
+#define GL_NV_texture_multisample 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);
+GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);
+GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);
+GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);
+GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);
+GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);
+typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);
+typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);
+typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);
+typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);
+typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);
+#endif
+
+#ifndef GL_AMD_blend_minmax_factor
+#define GL_AMD_blend_minmax_factor 1
+#endif
+
+#ifndef GL_AMD_sample_positions
+#define GL_AMD_sample_positions 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val);
+#endif
+
+#ifndef GL_EXT_x11_sync_object
+#define GL_EXT_x11_sync_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLsync (APIENTRYP PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags);
+#endif
+
+#ifndef GL_AMD_multi_draw_indirect
+#define GL_AMD_multi_draw_indirect 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride);
+GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride);
+typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride);
+#endif
+
+#ifndef GL_EXT_framebuffer_multisample_blit_scaled
+#define GL_EXT_framebuffer_multisample_blit_scaled 1
+#endif
+
+#ifndef GL_NV_path_rendering
+#define GL_NV_path_rendering 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLuint APIENTRY glGenPathsNV (GLsizei range);
+GLAPI void APIENTRY glDeletePathsNV (GLuint path, GLsizei range);
+GLAPI GLboolean APIENTRY glIsPathNV (GLuint path);
+GLAPI void APIENTRY glPathCommandsNV (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords);
+GLAPI void APIENTRY glPathCoordsNV (GLuint path, GLsizei numCoords, GLenum coordType, const GLvoid *coords);
+GLAPI void APIENTRY glPathSubCommandsNV (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords);
+GLAPI void APIENTRY glPathSubCoordsNV (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const GLvoid *coords);
+GLAPI void APIENTRY glPathStringNV (GLuint path, GLenum format, GLsizei length, const GLvoid *pathString);
+GLAPI void APIENTRY glPathGlyphsNV (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const GLvoid *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale);
+GLAPI void APIENTRY glPathGlyphRangeNV (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale);
+GLAPI void APIENTRY glWeightPathsNV (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights);
+GLAPI void APIENTRY glCopyPathNV (GLuint resultPath, GLuint srcPath);
+GLAPI void APIENTRY glInterpolatePathsNV (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight);
+GLAPI void APIENTRY glTransformPathNV (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues);
+GLAPI void APIENTRY glPathParameterivNV (GLuint path, GLenum pname, const GLint *value);
+GLAPI void APIENTRY glPathParameteriNV (GLuint path, GLenum pname, GLint value);
+GLAPI void APIENTRY glPathParameterfvNV (GLuint path, GLenum pname, const GLfloat *value);
+GLAPI void APIENTRY glPathParameterfNV (GLuint path, GLenum pname, GLfloat value);
+GLAPI void APIENTRY glPathDashArrayNV (GLuint path, GLsizei dashCount, const GLfloat *dashArray);
+GLAPI void APIENTRY glPathStencilFuncNV (GLenum func, GLint ref, GLuint mask);
+GLAPI void APIENTRY glPathStencilDepthOffsetNV (GLfloat factor, GLfloat units);
+GLAPI void APIENTRY glStencilFillPathNV (GLuint path, GLenum fillMode, GLuint mask);
+GLAPI void APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint mask);
+GLAPI void APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues);
+GLAPI void APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues);
+GLAPI void APIENTRY glPathCoverDepthFuncNV (GLenum func);
+GLAPI void APIENTRY glPathColorGenNV (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs);
+GLAPI void APIENTRY glPathTexGenNV (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs);
+GLAPI void APIENTRY glPathFogGenNV (GLenum genMode);
+GLAPI void APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode);
+GLAPI void APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode);
+GLAPI void APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);
+GLAPI void APIENTRY glCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);
+GLAPI void APIENTRY glGetPathParameterivNV (GLuint path, GLenum pname, GLint *value);
+GLAPI void APIENTRY glGetPathParameterfvNV (GLuint path, GLenum pname, GLfloat *value);
+GLAPI void APIENTRY glGetPathCommandsNV (GLuint path, GLubyte *commands);
+GLAPI void APIENTRY glGetPathCoordsNV (GLuint path, GLfloat *coords);
+GLAPI void APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray);
+GLAPI void APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics);
+GLAPI void APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics);
+GLAPI void APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing);
+GLAPI void APIENTRY glGetPathColorGenivNV (GLenum color, GLenum pname, GLint *value);
+GLAPI void APIENTRY glGetPathColorGenfvNV (GLenum color, GLenum pname, GLfloat *value);
+GLAPI void APIENTRY glGetPathTexGenivNV (GLenum texCoordSet, GLenum pname, GLint *value);
+GLAPI void APIENTRY glGetPathTexGenfvNV (GLenum texCoordSet, GLenum pname, GLfloat *value);
+GLAPI GLboolean APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y);
+GLAPI GLboolean APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y);
+GLAPI GLfloat APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments);
+GLAPI GLboolean APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLuint (APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range);
+typedef void (APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range);
+typedef GLboolean (APIENTRYP PFNGLISPATHNVPROC) (GLuint path);
+typedef void (APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords);
+typedef void (APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const GLvoid *coords);
+typedef void (APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords);
+typedef void (APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const GLvoid *coords);
+typedef void (APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const GLvoid *pathString);
+typedef void (APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const GLvoid *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale);
+typedef void (APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale);
+typedef void (APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights);
+typedef void (APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath);
+typedef void (APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight);
+typedef void (APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues);
+typedef void (APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value);
+typedef void (APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value);
+typedef void (APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value);
+typedef void (APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray);
+typedef void (APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask);
+typedef void (APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units);
+typedef void (APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask);
+typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask);
+typedef void (APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues);
+typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues);
+typedef void (APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func);
+typedef void (APIENTRYP PFNGLPATHCOLORGENNVPROC) (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs);
+typedef void (APIENTRYP PFNGLPATHTEXGENNVPROC) (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs);
+typedef void (APIENTRYP PFNGLPATHFOGGENNVPROC) (GLenum genMode);
+typedef void (APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode);
+typedef void (APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode);
+typedef void (APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);
+typedef void (APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);
+typedef void (APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value);
+typedef void (APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value);
+typedef void (APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands);
+typedef void (APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords);
+typedef void (APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray);
+typedef void (APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics);
+typedef void (APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics);
+typedef void (APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing);
+typedef void (APIENTRYP PFNGLGETPATHCOLORGENIVNVPROC) (GLenum color, GLenum pname, GLint *value);
+typedef void (APIENTRYP PFNGLGETPATHCOLORGENFVNVPROC) (GLenum color, GLenum pname, GLfloat *value);
+typedef void (APIENTRYP PFNGLGETPATHTEXGENIVNVPROC) (GLenum texCoordSet, GLenum pname, GLint *value);
+typedef void (APIENTRYP PFNGLGETPATHTEXGENFVNVPROC) (GLenum texCoordSet, GLenum pname, GLfloat *value);
+typedef GLboolean (APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y);
+typedef GLboolean (APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y);
+typedef GLfloat (APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments);
+typedef GLboolean (APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY);
+#endif
+
+#ifndef GL_AMD_pinned_memory
+#define GL_AMD_pinned_memory 1
+#endif
+
+#ifndef GL_AMD_stencil_operation_extended
+#define GL_AMD_stencil_operation_extended 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSTENCILOPVALUEAMDPROC) (GLenum face, GLuint value);
+#endif
+
+#ifndef GL_AMD_vertex_shader_viewport_index
+#define GL_AMD_vertex_shader_viewport_index 1
+#endif
+
+#ifndef GL_AMD_vertex_shader_layer
+#define GL_AMD_vertex_shader_layer 1
+#endif
+
+#ifndef GL_NV_bindless_texture
+#define GL_NV_bindless_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLuint64 APIENTRY glGetTextureHandleNV (GLuint texture);
+GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler);
+GLAPI void APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle);
+GLAPI void APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle);
+GLAPI GLuint64 APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format);
+GLAPI void APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access);
+GLAPI void APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle);
+GLAPI void APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value);
+GLAPI void APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value);
+GLAPI void APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value);
+GLAPI void APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values);
+GLAPI GLboolean APIENTRY glIsTextureHandleResidentNV (GLuint64 handle);
+GLAPI GLboolean APIENTRY glIsImageHandleResidentNV (GLuint64 handle);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture);
+typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler);
+typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle);
+typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle);
+typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format);
+typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access);
+typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle);
+typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value);
+typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values);
+typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle);
+typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle);
+#endif
+
+#ifndef GL_NV_shader_atomic_float
+#define GL_NV_shader_atomic_float 1
+#endif
+
+#ifndef GL_AMD_query_buffer_object
+#define GL_AMD_query_buffer_object 1
+#endif
+
+#ifndef GL_NV_compute_program5
+#define GL_NV_compute_program5 1
+#endif
+
+#ifndef GL_NV_shader_storage_buffer_object
+#define GL_NV_shader_storage_buffer_object 1
+#endif
+
+#ifndef GL_NV_shader_atomic_counters
+#define GL_NV_shader_atomic_counters 1
+#endif
+
+#ifndef GL_NV_deep_texture3D
+#define GL_NV_deep_texture3D 1
+#endif
+
+#ifndef GL_NVX_conditional_render
+#define GL_NVX_conditional_render 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBeginConditionalRenderNVX (GLuint id);
+GLAPI void APIENTRY glEndConditionalRenderNVX (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVXPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVXPROC) (void);
+#endif
+
+#ifndef GL_AMD_sparse_texture
+#define GL_AMD_sparse_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexStorageSparseAMD (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags);
+GLAPI void APIENTRY glTextureStorageSparseAMD (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXSTORAGESPARSEAMDPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags);
+typedef void (APIENTRYP PFNGLTEXTURESTORAGESPARSEAMDPROC) (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags);
+#endif
+
+#ifndef GL_AMD_shader_trinary_minmax
+#define GL_AMD_shader_trinary_minmax 1
+#endif
+
+#ifndef GL_INTEL_map_texture
+#define GL_INTEL_map_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glSyncTextureINTEL (GLuint texture);
+GLAPI void APIENTRY glUnmapTexture2DINTEL (GLuint texture, GLint level);
+GLAPI GLvoid* APIENTRY glMapTexture2DINTEL (GLuint texture, GLint level, GLbitfield access, const GLint *stride, const GLenum *layout);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSYNCTEXTUREINTELPROC) (GLuint texture);
+typedef void (APIENTRYP PFNGLUNMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level);
+typedef GLvoid* (APIENTRYP PFNGLMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level, GLbitfield access, const GLint *stride, const GLenum *layout);
+#endif
+
+#ifndef GL_NV_draw_texture
+#define GL_NV_draw_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawTextureNV (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWTEXTURENVPROC) (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1);
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif \ No newline at end of file
diff --git a/Source/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp b/Source/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp
index 063f7cb69..90b0cfc6a 100644
--- a/Source/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp
+++ b/Source/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp
@@ -122,9 +122,9 @@ void GraphicsContext::drawWindowsBitmap(WindowsBitmap* image, const IntPoint& po
{
// FIXME: Creating CFData is non-optimal, but needed to avoid crashing when printing. Ideally we should
// make a custom CGDataProvider that controls the WindowsBitmap lifetime. see <rdar://6394455>
- RetainPtr<CFDataRef> imageData(AdoptCF, CFDataCreate(kCFAllocatorDefault, image->buffer(), image->bufferLength()));
- RetainPtr<CGDataProviderRef> dataProvider(AdoptCF, CGDataProviderCreateWithCFData(imageData.get()));
- RetainPtr<CGImageRef> cgImage(AdoptCF, CGImageCreate(image->size().width(), image->size().height(), 8, 32, image->bytesPerRow(), deviceRGBColorSpaceRef(),
+ RetainPtr<CFDataRef> imageData = adoptCF(CFDataCreate(kCFAllocatorDefault, image->buffer(), image->bufferLength()));
+ RetainPtr<CGDataProviderRef> dataProvider = adoptCF(CGDataProviderCreateWithCFData(imageData.get()));
+ RetainPtr<CGImageRef> cgImage = adoptCF(CGImageCreate(image->size().width(), image->size().height(), 8, 32, image->bytesPerRow(), deviceRGBColorSpaceRef(),
kCGBitmapByteOrder32Little | kCGImageAlphaFirst, dataProvider.get(), 0, true, kCGRenderingIntentDefault));
CGContextDrawImage(m_data->m_cgContext.get(), CGRectMake(point.x(), point.y(), image->size().width(), image->size().height()), cgImage.get());
}
diff --git a/Source/WebCore/platform/graphics/win/IconWin.cpp b/Source/WebCore/platform/graphics/win/IconWin.cpp
index cb7ddb72a..50cf3e59c 100644
--- a/Source/WebCore/platform/graphics/win/IconWin.cpp
+++ b/Source/WebCore/platform/graphics/win/IconWin.cpp
@@ -58,7 +58,7 @@ PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>& filenames)
memset(&sfi, 0, sizeof(sfi));
String tmpFilename = filenames[0];
- if (!SHGetFileInfo(tmpFilename.charactersWithNullTermination(), 0, &sfi, sizeof(sfi), SHGFI_ICON | SHGFI_SHELLICONSIZE | SHGFI_SMALLICON))
+ if (!SHGetFileInfo(tmpFilename.charactersWithNullTermination().data(), 0, &sfi, sizeof(sfi), SHGFI_ICON | SHGFI_SHELLICONSIZE | SHGFI_SMALLICON))
return 0;
return adoptRef(new Icon(sfi.hIcon));
diff --git a/Source/WebCore/platform/graphics/win/ImageCGWin.cpp b/Source/WebCore/platform/graphics/win/ImageCGWin.cpp
index d20eb3710..7d0ef8e29 100644
--- a/Source/WebCore/platform/graphics/win/ImageCGWin.cpp
+++ b/Source/WebCore/platform/graphics/win/ImageCGWin.cpp
@@ -50,7 +50,7 @@ PassRefPtr<BitmapImage> BitmapImage::create(HBITMAP hBitmap)
if (!dibSection.dsBm.bmBits)
return 0;
- RetainPtr<CGContextRef> bitmapContext(AdoptCF, CGBitmapContextCreate(dibSection.dsBm.bmBits, dibSection.dsBm.bmWidth, dibSection.dsBm.bmHeight, 8,
+ RetainPtr<CGContextRef> bitmapContext = adoptCF(CGBitmapContextCreate(dibSection.dsBm.bmBits, dibSection.dsBm.bmWidth, dibSection.dsBm.bmHeight, 8,
dibSection.dsBm.bmWidthBytes, deviceRGBColorSpaceRef(), kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst));
// The BitmapImage takes ownership of this.
@@ -78,7 +78,7 @@ bool BitmapImage::getHBITMAPOfSize(HBITMAP bmp, LPSIZE size)
if (size)
drawFrameMatchingSourceSize(&gc, FloatRect(0.0f, 0.0f, bmpInfo.bmWidth, bmpInfo.bmHeight), IntSize(*size), ColorSpaceDeviceRGB, CompositeCopy);
else
- draw(&gc, FloatRect(0.0f, 0.0f, bmpInfo.bmWidth, bmpInfo.bmHeight), FloatRect(0.0f, 0.0f, imageSize.width(), imageSize.height()), ColorSpaceDeviceRGB, CompositeCopy);
+ draw(&gc, FloatRect(0.0f, 0.0f, bmpInfo.bmWidth, bmpInfo.bmHeight), FloatRect(0.0f, 0.0f, imageSize.width(), imageSize.height()), ColorSpaceDeviceRGB, CompositeCopy, BlendModeNormal);
// Do cleanup
CGContextRelease(cgContext);
@@ -94,7 +94,7 @@ void BitmapImage::drawFrameMatchingSourceSize(GraphicsContext* ctxt, const Float
if (image && CGImageGetHeight(image) == static_cast<size_t>(srcSize.height()) && CGImageGetWidth(image) == static_cast<size_t>(srcSize.width())) {
size_t currentFrame = m_currentFrame;
m_currentFrame = i;
- draw(ctxt, dstRect, FloatRect(0.0f, 0.0f, srcSize.width(), srcSize.height()), styleColorSpace, compositeOp);
+ draw(ctxt, dstRect, FloatRect(0.0f, 0.0f, srcSize.width(), srcSize.height()), styleColorSpace, compositeOp, BlendModeNormal);
m_currentFrame = currentFrame;
return;
}
@@ -102,7 +102,7 @@ void BitmapImage::drawFrameMatchingSourceSize(GraphicsContext* ctxt, const Float
// No image of the correct size was found, fallback to drawing the current frame
IntSize imageSize = BitmapImage::size();
- draw(ctxt, dstRect, FloatRect(0.0f, 0.0f, imageSize.width(), imageSize.height()), styleColorSpace, compositeOp);
+ draw(ctxt, dstRect, FloatRect(0.0f, 0.0f, imageSize.width(), imageSize.height()), styleColorSpace, compositeOp, BlendModeNormal);
}
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/win/ImageCairoWin.cpp b/Source/WebCore/platform/graphics/win/ImageCairoWin.cpp
index c60d2a564..665cef480 100644
--- a/Source/WebCore/platform/graphics/win/ImageCairoWin.cpp
+++ b/Source/WebCore/platform/graphics/win/ImageCairoWin.cpp
@@ -27,6 +27,7 @@
#include "Image.h"
#include "BitmapImage.h"
#include "GraphicsContext.h"
+#include "RefPtrCairo.h"
#include <cairo.h>
#include <cairo-win32.h>
@@ -49,9 +50,9 @@ PassRefPtr<BitmapImage> BitmapImage::create(HBITMAP hBitmap)
if (!dibSection.dsBm.bmBits)
return 0;
- cairo_surface_t* surface = cairo_win32_surface_create_with_dib (CAIRO_FORMAT_ARGB32, dibSection.dsBm.bmWidth, dibSection.dsBm.bmHeight);
+ RefPtr<cairo_surface_t> surface = adoptRef(cairo_win32_surface_create_with_dib(CAIRO_FORMAT_ARGB32, dibSection.dsBm.bmWidth, dibSection.dsBm.bmHeight));
- return BitmapImage::create(new NativeImageCairo(surface));
+ return BitmapImage::create(surface.release());
}
bool BitmapImage::getHBITMAPOfSize(HBITMAP bmp, LPSIZE size)
@@ -83,7 +84,7 @@ bool BitmapImage::getHBITMAPOfSize(HBITMAP bmp, LPSIZE size)
if (size)
drawFrameMatchingSourceSize(&gc, FloatRect(0.0f, 0.0f, bmpInfo.bmWidth, bmpInfo.bmHeight), IntSize(*size), ColorSpaceDeviceRGB, CompositeCopy);
else
- draw(&gc, FloatRect(0.0f, 0.0f, bmpInfo.bmWidth, bmpInfo.bmHeight), FloatRect(0.0f, 0.0f, imageSize.width(), imageSize.height()), ColorSpaceDeviceRGB, CompositeCopy);
+ draw(&gc, FloatRect(0.0f, 0.0f, bmpInfo.bmWidth, bmpInfo.bmHeight), FloatRect(0.0f, 0.0f, imageSize.width(), imageSize.height()), ColorSpaceDeviceRGB, CompositeCopy, BlendModeNormal);
// Do cleanup
cairo_destroy(targetRef);
@@ -95,17 +96,14 @@ void BitmapImage::drawFrameMatchingSourceSize(GraphicsContext* ctxt, const Float
{
size_t frames = frameCount();
for (size_t i = 0; i < frames; ++i) {
- NativeImageCairo* nativeImage = frameAtIndex(i);
- if (!nativeImage)
- continue;
- cairo_surface_t* image = nativeImage->surface();
- if (!image)
+ RefPtr<cairo_surface_t> surface = frameAtIndex(i);
+ if (!surface)
continue;
- if (cairo_image_surface_get_height(image) == static_cast<size_t>(srcSize.height()) && cairo_image_surface_get_width(image) == static_cast<size_t>(srcSize.width())) {
+ if (cairo_image_surface_get_height(surface.get()) == static_cast<size_t>(srcSize.height()) && cairo_image_surface_get_width(surface.get()) == static_cast<size_t>(srcSize.width())) {
size_t currentFrame = m_currentFrame;
m_currentFrame = i;
- draw(ctxt, dstRect, FloatRect(0.0f, 0.0f, srcSize.width(), srcSize.height()), ColorSpaceDeviceRGB, compositeOp);
+ draw(ctxt, dstRect, FloatRect(0.0f, 0.0f, srcSize.width(), srcSize.height()), ColorSpaceDeviceRGB, compositeOp, BlendModeNormal);
m_currentFrame = currentFrame;
return;
}
@@ -113,7 +111,7 @@ void BitmapImage::drawFrameMatchingSourceSize(GraphicsContext* ctxt, const Float
// No image of the correct size was found, fallback to drawing the current frame
IntSize imageSize = BitmapImage::size();
- draw(ctxt, dstRect, FloatRect(0.0f, 0.0f, imageSize.width(), imageSize.height()), ColorSpaceDeviceRGB, compositeOp);
+ draw(ctxt, dstRect, FloatRect(0.0f, 0.0f, imageSize.width(), imageSize.height()), ColorSpaceDeviceRGB, compositeOp, BlendModeNormal);
}
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp
index f6e6cbe7b..2d60d2185 100644
--- a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp
+++ b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp
@@ -120,7 +120,7 @@ void MediaPlayerPrivateFullscreenWindow::setRootChildLayer(PassRefPtr<PlatformCA
m_rootChild->setFrame(rootBounds);
m_rootChild->setBackgroundColor(CGColorGetConstantColor(kCGColorBlack));
#ifndef NDEBUG
- RetainPtr<CGColorRef> redColor(AdoptCF, CGColorCreateGenericRGB(1, 0, 0, 1));
+ RetainPtr<CGColorRef> redColor = adoptCF(CGColorCreateGenericRGB(1, 0, 0, 1));
rootLayer->setBackgroundColor(redColor.get());
#else
rootLayer->setBackgroundColor(CGColorGetConstantColor(kCGColorBlack));
diff --git a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp
index 35c3d7778..8a828e25a 100644
--- a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp
+++ b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp
@@ -30,6 +30,7 @@
#include "Cookie.h"
#include "CookieJar.h"
+#include "Document.h"
#include "DocumentLoader.h"
#include "Frame.h"
#include "FrameView.h"
@@ -234,7 +235,7 @@ String MediaPlayerPrivateQuickTimeVisualContext::rfc2616DateStringFromTime(CFAbs
time = CFGregorianDateGetAbsoluteTime(dateValue, gmtTimeZone);
SInt32 day = CFAbsoluteTimeGetDayOfWeek(time, 0);
- RetainPtr<CFStringRef> dateCFString(AdoptCF, CFStringCreateWithFormat(0, 0, dateFormatString, dayStrings[day - 1], dateValue.day,
+ RetainPtr<CFStringRef> dateCFString = adoptCF(CFStringCreateWithFormat(0, 0, dateFormatString, dayStrings[day - 1], dateValue.day,
monthStrings[dateValue.month - 1], dateValue.year, dateValue.hour, dateValue.minute, (int)dateValue.second));
return dateCFString.get();
}
@@ -306,7 +307,7 @@ void MediaPlayerPrivateQuickTimeVisualContext::setUpCookiesForQuickTime(const St
cookieURL = movieURL;
String string = cookieBuilder.toString();
- InternetSetCookieExW(cookieURL.charactersWithNullTermination(), 0, string.charactersWithNullTermination(), 0, 0);
+ InternetSetCookieExW(cookieURL.charactersWithNullTermination().data(), 0, string.charactersWithNullTermination().data(), 0, 0);
}
}
@@ -574,7 +575,7 @@ PassRefPtr<TimeRanges> MediaPlayerPrivateQuickTimeVisualContext::buffered() cons
float MediaPlayerPrivateQuickTimeVisualContext::maxTimeSeekable() const
{
// infinite duration means live stream
- return !isfinite(duration()) ? 0 : maxTimeLoaded();
+ return !std::isfinite(duration()) ? 0 : maxTimeLoaded();
}
float MediaPlayerPrivateQuickTimeVisualContext::maxTimeLoaded() const
@@ -798,7 +799,7 @@ void MediaPlayerPrivateQuickTimeVisualContext::visualContextTimerFired(Timer<Med
static CFDictionaryRef QTCFDictionaryCreateWithDataCallback(CFAllocatorRef allocator, const UInt8* bytes, CFIndex length)
{
- RetainPtr<CFDataRef> data(AdoptCF, CFDataCreateWithBytesNoCopy(allocator, bytes, length, kCFAllocatorNull));
+ RetainPtr<CFDataRef> data = adoptCF(CFDataCreateWithBytesNoCopy(allocator, bytes, length, kCFAllocatorNull));
if (!data)
return 0;
@@ -889,7 +890,7 @@ void MediaPlayerPrivateQuickTimeVisualContext::retrieveCurrentImage()
// CAImageQueue without being converted to a non-Debug CFDictionary. Additionally,
// old versions of QuickTime used a non-AAS CoreFoundation, so the types are not
// interchangable even in the release case.
- RetainPtr<CFDictionaryRef> attachments(AdoptCF, QTCFDictionaryCreateCopyWithDataCallback(kCFAllocatorDefault, buffer.attachments(), &QTCFDictionaryCreateWithDataCallback));
+ RetainPtr<CFDictionaryRef> attachments = adoptCF(QTCFDictionaryCreateCopyWithDataCallback(kCFAllocatorDefault, buffer.attachments(), &QTCFDictionaryCreateWithDataCallback));
CFTimeInterval imageTime = QTMovieVisualContext::currentHostTime();
m_imageQueue->collect();
diff --git a/Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp b/Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp
index 537b0e374..01d9fc757 100644
--- a/Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp
+++ b/Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp
@@ -126,7 +126,7 @@ void SimpleFontData::platformDestroy()
#endif
}
-PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
+PassRefPtr<SimpleFontData> SimpleFontData::platformCreateScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
{
float scaledSize = scaleFactor * m_platformData.size();
if (isCustomFont()) {
diff --git a/Source/WebCore/platform/graphics/win/WKCAImageQueue.cpp b/Source/WebCore/platform/graphics/win/WKCAImageQueue.cpp
index 2bf025960..ef8a1c573 100644
--- a/Source/WebCore/platform/graphics/win/WKCAImageQueue.cpp
+++ b/Source/WebCore/platform/graphics/win/WKCAImageQueue.cpp
@@ -56,7 +56,7 @@ static void WKCAImageQueueRelease(CAImageQueueRef iq)
WKCAImageQueue::WKCAImageQueue(uint32_t width, uint32_t height, uint32_t capacity)
: m_private(adoptPtr(new WKCAImageQueuePrivate()))
{
- m_private->m_imageQueue.adoptCF(wkCAImageQueueCreate(width, height, capacity));
+ m_private->m_imageQueue = adoptCF(wkCAImageQueueCreate(width, height, capacity));
}
WKCAImageQueue::WKCAImageQueue(const WKCAImageQueue& o)
diff --git a/Source/WebCore/platform/graphics/wince/FontCacheWinCE.cpp b/Source/WebCore/platform/graphics/wince/FontCacheWinCE.cpp
index 9ab91a119..2cd8ca637 100644
--- a/Source/WebCore/platform/graphics/wince/FontCacheWinCE.cpp
+++ b/Source/WebCore/platform/graphics/wince/FontCacheWinCE.cpp
@@ -64,9 +64,9 @@ IMLangFontLinkType* FontCache::getFontLinkInterface()
return langFontLink;
}
-#if defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2)
-static bool currentFontContainsCharacter(IMLangFontLink2* langFontLink, HDC hdc, UChar character)
+static bool currentFontContainsCharacter(IMLangFontLinkType* langFontLink, HDC hdc, HFONT hfont, UChar character, const wchar_t* faceName)
{
+#if USE(IMLANG_FONT_LINK2)
UINT unicodeRanges;
if (S_OK != langFontLink->GetFontUnicodeRanges(hdc, &unicodeRanges, 0))
return false;
@@ -82,12 +82,7 @@ static bool currentFontContainsCharacter(IMLangFontLink2* langFontLink, HDC hdc,
if (i->wcTo >= character)
return i->wcFrom <= character;
}
-
- return false;
-}
#else
-static bool currentFontContainsCharacter(IMLangFontLink* langFontLink, HDC hdc, HFONT hfont, UChar character, const wchar_t* faceName)
-{
DWORD fontCodePages = 0, charCodePages = 0;
HRESULT result = langFontLink->GetFontCodePages(hdc, hfont, &fontCodePages);
if (result != S_OK)
@@ -99,29 +94,25 @@ static bool currentFontContainsCharacter(IMLangFontLink* langFontLink, HDC hdc,
fontCodePages |= FontPlatformData::getKnownFontCodePages(faceName);
if (fontCodePages & charCodePages)
return true;
+#endif
return false;
}
-#endif
-#if defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2)
-static HFONT createMLangFont(IMLangFontLink2* langFontLink, HDC hdc, DWORD codePageMask, UChar character = 0)
+static HFONT createMLangFont(IMLangFontLinkType* langFontLink, HDC hdc, const FontPlatformData& refFont, DWORD codePageMask, UChar character = 0)
{
HFONT mlangFont;
- if (SUCCEEDED(langFontLink->MapFont(hdc, codePageMask, character, &mlangFont)))
- return mlangFont;
- return 0;
-}
+#if USE(IMLANG_FONT_LINK2)
+ HRESULT result = langFontLink->MapFont(hdc, codePageMask, character, &mlangFont);
#else
-static HFONT createMLangFont(IMLangFontLink* langFontLink, HDC hdc, const FontPlatformData& refFont, DWORD codePageMask)
-{
- HFONT mlangFont;
- LRESULT result = langFontLink->MapFont(hdc, codePageMask, refFont.hfont(), &mlangFont);
+ HRESULT result = langFontLink->MapFont(hdc, codePageMask, refFont.hfont(), &mlangFont);
+#endif
- return result == S_OK ? mlangFont : 0;
+ if (SUCCEEDED(result))
+ return mlangFont;
+ return 0;
}
-#endif
static const Vector<DWORD, 4>& getCJKCodePageMasks()
{
@@ -212,13 +203,13 @@ void FontCache::comUninitialize()
}
}
-PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
+PassRefPtr<SimpleFontData> FontCache::systemFallbackForCharacters(const FontDescription& description, const SimpleFontData* originalFontData, bool, const UChar* characters, int length)
{
String familyName;
WCHAR name[LF_FACESIZE];
UChar character = characters[0];
- const FontPlatformData& origFont = font.primaryFont()->fontDataForCharacter(character)->platformData();
+ const FontPlatformData& origFont = originalFontData->platformData();
unsigned unicodeRange = findCharUnicodeRange(character);
if (IMLangFontLinkType* langFontLink = getFontLinkInterface()) {
@@ -235,11 +226,7 @@ PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font,
const Vector<DWORD, 4>& CJKCodePageMasks = getCJKCodePageMasks();
unsigned numCodePages = CJKCodePageMasks.size();
for (unsigned i = 0; i < numCodePages; ++i) {
-#if defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2)
- hfont = createMLangFont(langFontLink, g_screenDC, CJKCodePageMasks[i]);
-#else
hfont = createMLangFont(langFontLink, g_screenDC, origFont, CJKCodePageMasks[i]);
-#endif
if (!hfont)
continue;
@@ -249,11 +236,7 @@ PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font,
if (hfont && !(codePages & CJKCodePageMasks[i])) {
// We asked about a code page that is not one of the code pages
// returned by MLang, so the font might not contain the character.
-#if defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2)
- if (!currentFontContainsCharacter(langFontLink, g_screenDC, character))
-#else
if (!currentFontContainsCharacter(langFontLink, g_screenDC, hfont, character, name))
-#endif
{
SelectObject(g_screenDC, oldFont);
langFontLink->ReleaseFont(hfont);
@@ -264,11 +247,7 @@ PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font,
break;
}
} else {
-#if defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2)
- hfont = createMLangFont(langFontLink, g_screenDC, codePages, character);
-#else
- hfont = createMLangFont(langFontLink, g_screenDC, origFont, codePages);
-#endif
+ hfont = createMLangFont(langFontLink, g_screenDC, origFont, codePages, character);
SelectObject(g_screenDC, hfont);
GetTextFace(g_screenDC, LF_FACESIZE, name);
}
@@ -286,7 +265,7 @@ PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font,
if (!familyName.isEmpty()) {
// FIXME: temporary workaround for Thai font problem
- FontDescription fontDescription(font.fontDescription());
+ FontDescription fontDescription(description);
if (unicodeRange == cRangeThai && fontDescription.weight() > FontWeightNormal)
fontDescription.setWeight(FontWeightNormal);
@@ -300,11 +279,6 @@ PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font,
return 0;
}
-PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font&)
-{
- return 0;
-}
-
PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& fontDesc, ShouldRetain shouldRetain)
{
// FIXME: Would be even better to somehow get the user's default font here. For now we'll pick
@@ -312,10 +286,9 @@ PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescri
return getCachedFontData(fontDesc, FontPlatformData::defaultFontFamily(), false, shouldRetain);
}
-FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
+PassOwnPtr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
{
- FontPlatformData* result = new FontPlatformData(fontDescription, family);
- return result;
+ return adoptPtr(new FontPlatformData(fontDescription, family));
}
void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigned>& traitsMasks)
diff --git a/Source/WebCore/platform/graphics/wince/FontCustomPlatformData.cpp b/Source/WebCore/platform/graphics/wince/FontCustomPlatformData.cpp
index 844f8ec04..e1e5afa85 100644
--- a/Source/WebCore/platform/graphics/wince/FontCustomPlatformData.cpp
+++ b/Source/WebCore/platform/graphics/wince/FontCustomPlatformData.cpp
@@ -45,7 +45,7 @@ FontCustomPlatformData::~FontCustomPlatformData()
g_customFontCache->unregisterFont(m_name);
}
-FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation, TextOrientation, FontWidthVariant, FontRenderingMode renderingMode)
+FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation, FontWidthVariant, FontRenderingMode renderingMode)
{
FontDescription fontDesc;
fontDesc.setComputedSize(size);
diff --git a/Source/WebCore/platform/graphics/wince/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/wince/FontCustomPlatformData.h
index ade3d66a6..a3a8a2962 100644
--- a/Source/WebCore/platform/graphics/wince/FontCustomPlatformData.h
+++ b/Source/WebCore/platform/graphics/wince/FontCustomPlatformData.h
@@ -24,7 +24,6 @@
#include "FontDescription.h"
#include "FontRenderingMode.h"
#include "FontWidthVariant.h"
-#include "TextOrientation.h"
#include <wtf/Noncopyable.h>
#include <wtf/text/WTFString.h>
@@ -50,7 +49,7 @@ namespace WebCore {
~FontCustomPlatformData();
- FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation = Horizontal, TextOrientation = TextOrientationVerticalRight, FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode);
+ FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation = Horizontal, FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode);
static bool supportsFormat(const String&);
diff --git a/Source/WebCore/platform/graphics/wince/FontPlatformData.cpp b/Source/WebCore/platform/graphics/wince/FontPlatformData.cpp
index 1a4806217..5aa0d9ea2 100644
--- a/Source/WebCore/platform/graphics/wince/FontPlatformData.cpp
+++ b/Source/WebCore/platform/graphics/wince/FontPlatformData.cpp
@@ -336,7 +336,7 @@ public:
FontPlatformData::FontPlatformData(const FontDescription& fontDescription, const AtomicString& desiredFamily, bool useDefaultFontIfNotPresent)
{
String family(desiredFamily);
- if (!equalIgnoringCase(family, defaultFontFamily()) && !FontFamilyChecker(family.charactersWithNullTermination()).isSupported()) {
+ if (!equalIgnoringCase(family, defaultFontFamily()) && !FontFamilyChecker(family.charactersWithNullTermination().data()).isSupported()) {
if (equalIgnoringCase(family, String(heiTiStr)) && isSongTiSupported())
family = String(songTiStr);
else if (useDefaultFontIfNotPresent)
diff --git a/Source/WebCore/platform/graphics/wince/FontWinCE.cpp b/Source/WebCore/platform/graphics/wince/FontWinCE.cpp
index b98c46671..65c5b8881 100644
--- a/Source/WebCore/platform/graphics/wince/FontWinCE.cpp
+++ b/Source/WebCore/platform/graphics/wince/FontWinCE.cpp
@@ -33,7 +33,7 @@
#include "FloatRect.h"
#include "FontCache.h"
#include "FontData.h"
-#include "FontFallbackList.h"
+#include "FontGlyphs.h"
#include "GlyphBuffer.h"
#include "GraphicsContext.h"
#include "IntRect.h"
@@ -137,7 +137,7 @@ static int generateComponents(TextRunComponents* components, const Font &font, c
start = 1;
}
for (int i = 1; i < run.length(); ++i) {
- uint ch = run[i];
+ UChar ch = run[i];
if (U16_IS_LEAD(ch) && U16_IS_TRAIL(run[i-1]))
ch = U16_GET_SUPPLEMENTARY(ch, run[i-1]);
if (U16_IS_TRAIL(ch) || category(ch) == Mark_NonSpacing)
diff --git a/Source/WebCore/platform/graphics/wince/GlyphPageTreeNodeWinCE.cpp b/Source/WebCore/platform/graphics/wince/GlyphPageTreeNodeWinCE.cpp
index dd67c7f49..025689cc5 100644
--- a/Source/WebCore/platform/graphics/wince/GlyphPageTreeNodeWinCE.cpp
+++ b/Source/WebCore/platform/graphics/wince/GlyphPageTreeNodeWinCE.cpp
@@ -48,7 +48,7 @@ bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned b
if (!actualCodePages || (actualCodePages & fontCodePages))
setGlyphDataForIndex(offset + i, buffer[i], fontData);
else
- setGlyphDataForIndex(offset + i, buffer[i], 0);
+ setGlyphDataForIndex(offset + i, 0, 0);
}
return true;
} else if (IMLangFontLinkType* langFontLink = fontCache()->getFontLinkInterface()) {
@@ -58,7 +58,7 @@ bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned b
if (!actualCodePages || (actualCodePages & fontCodePages))
setGlyphDataForIndex(offset + i, buffer[i], fontData);
else
- setGlyphDataForIndex(offset + i, buffer[i], 0);
+ setGlyphDataForIndex(offset + i, 0, 0);
}
return true;
}
diff --git a/Source/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp b/Source/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp
index c89e84c15..911c3ad74 100644
--- a/Source/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp
+++ b/Source/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp
@@ -783,81 +783,6 @@ void getEllipsePointByAngle(double angle, double a, double b, float& x, float& y
}
}
-void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan)
-{
- if (!m_data->m_opacity || paintingDisabled() || strokeStyle() == NoStroke || rect.isEmpty())
- return;
-
- ScopeDCProvider dcProvider(m_data);
- if (!m_data->m_dc)
- return;
-
- IntRect trRect = m_data->mapRect(rect);
- TransparentLayerDC transparentDC(m_data, trRect, &rect);
- HDC dc = transparentDC.hdc();
- if (!dc)
- return;
- trRect.move(transparentDC.toShift());
-
- OwnPtr<HPEN> pen = createPen(strokeColor(), strokeThickness(), strokeStyle());
- HGDIOBJ oldPen = SelectObject(dc, pen.get());
-
- double a = trRect.width() * 0.5;
- double b = trRect.height() * 0.5;
- int centerX = stableRound(trRect.x() + a);
- int centerY = stableRound(trRect.y() + b);
- float fstartX, fstartY, fendX, fendY;
- int startX, startY, endX, endY;
- getEllipsePointByAngle(deg2rad((double)startAngle), a, b, fstartX, fstartY);
- getEllipsePointByAngle(deg2rad((double)startAngle + angleSpan), a, b, fendX, fendY);
- startX = stableRound(fstartX);
- startY = stableRound(fstartY);
- endX = stableRound(fendX);
- endY = stableRound(fendY);
-
- startX += centerX;
- startY = centerY - startY;
- endX += centerX;
- endY = centerY - endY;
- RECT clipRect;
- if (startX < endX) {
- clipRect.left = startX;
- clipRect.right = endX;
- } else {
- clipRect.left = endX;
- clipRect.right = startX;
- }
- if (startY < endY) {
- clipRect.top = startY;
- clipRect.bottom = endY;
- } else {
- clipRect.top = endY;
- clipRect.bottom = startY;
- }
-
- OwnPtr<HRGN> clipRgn = adoptPtr(CreateRectRgn(0, 0, 0, 0));
- bool newClip;
- if (GetClipRgn(dc, clipRgn.get()) <= 0) {
- newClip = true;
- clipRgn = adoptPtr(CreateRectRgn(clipRect.left, clipRect.top, clipRect.right, clipRect.bottom));
- SelectClipRgn(dc, clipRgn.get());
- } else {
- newClip = false;
- IntersectClipRect(dc, clipRect.left, clipRect.top, clipRect.right, clipRect.bottom);
- }
-
- HGDIOBJ oldBrush = SelectObject(dc, GetStockObject(NULL_BRUSH));
- Ellipse(dc, trRect.x(), trRect.y(), trRect.maxX(), trRect.maxY());
- SelectObject(dc, oldBrush);
-
- if (newClip)
- SelectClipRgn(dc, 0);
- else
- SelectClipRgn(dc, clipRgn.get());
-
- SelectObject(dc, oldPen);
-}
-
void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points, bool shouldAntialias)
{
if (!m_data->m_opacity || paintingDisabled() || npoints <= 1 || !points)
@@ -1061,12 +986,6 @@ void GraphicsContext::setURLForRect(const KURL& link, const IntRect& destRect)
notImplemented();
}
-void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness)
-{
- // We can only clip rectangles on WINCE
- clip(rect);
-}
-
void GraphicsContext::clearRect(const FloatRect& rect)
{
if (paintingDisabled())
@@ -1193,19 +1112,19 @@ void GraphicsContext::setAlpha(float alpha)
m_data->m_opacity = alpha;
}
-void GraphicsContext::setPlatformCompositeOperation(CompositeOperator op)
+void GraphicsContext::setPlatformCompositeOperation(CompositeOperator op, BlendMode blendMode)
{
notImplemented();
}
-void GraphicsContext::clip(const Path& path)
+void GraphicsContext::clip(const Path& path, WindRule)
{
notImplemented();
}
-void GraphicsContext::canvasClip(const Path& path)
+void GraphicsContext::canvasClip(const Path& path, WindRule fillRule)
{
- clip(path);
+ clip(path, fillRule);
}
void GraphicsContext::clipOut(const Path&)
@@ -1829,7 +1748,7 @@ void GraphicsContext::paintTextField(const IntRect& rect, unsigned state)
FillRect(dc, &rectWin, reinterpret_cast<HBRUSH>(((state & DFCS_INACTIVE) ? COLOR_BTNFACE : COLOR_WINDOW) + 1));
}
-void GraphicsContext::drawBitmap(SharedBitmap* bmp, const IntRect& dstRectIn, const IntRect& srcRect, ColorSpace styleColorSpace, CompositeOperator compositeOp)
+void GraphicsContext::drawBitmap(SharedBitmap* bmp, const IntRect& dstRectIn, const IntRect& srcRect, ColorSpace styleColorSpace, CompositeOperator compositeOp, BlendMode blendMode)
{
if (!m_data->m_opacity)
return;
@@ -1845,7 +1764,7 @@ void GraphicsContext::drawBitmap(SharedBitmap* bmp, const IntRect& dstRectIn, co
return;
dstRect.move(transparentDC.toShift());
- bmp->draw(dc, dstRect, srcRect, compositeOp);
+ bmp->draw(dc, dstRect, srcRect, compositeOp, blendMode);
if (bmp->is16bit())
transparentDC.fillAlphaChannel();
diff --git a/Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp b/Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp
index 22c37f2c9..a139bc97b 100644
--- a/Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp
+++ b/Source/WebCore/platform/graphics/wince/ImageBufferWinCE.cpp
@@ -26,7 +26,6 @@
#include "ImageData.h"
#include "NotImplemented.h"
#include "SharedBitmap.h"
-#include <wtf/UnusedParam.h>
namespace WebCore {
@@ -38,21 +37,22 @@ public:
{
}
+ virtual bool currentFrameKnownToBeOpaque() { return !m_data->m_bitmap->hasAlpha() ; }
virtual IntSize size() const { return IntSize(m_data->m_bitmap->width(), m_data->m_bitmap->height()); }
virtual void destroyDecodedData(bool destroyAll = true) {}
virtual unsigned decodedSize() const { return 0; }
- virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator);
+ virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator, BlendMode);
virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform,
const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect);
const ImageBufferData* m_data;
};
-void BufferedImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator compositeOp)
+void BufferedImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator compositeOp, BlendMode blendMode)
{
IntRect intDstRect = enclosingIntRect(dstRect);
IntRect intSrcRect(srcRect);
- m_data->m_bitmap->draw(ctxt, intDstRect, intSrcRect, styleColorSpace, compositeOp);
+ m_data->m_bitmap->draw(ctxt, intDstRect, intSrcRect, styleColorSpace, compositeOp, blendMode);
}
void BufferedImage::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRectIn, const AffineTransform& patternTransform,
@@ -70,7 +70,7 @@ ImageBufferData::ImageBufferData(const IntSize& size)
m_bitmap->setHasAlpha(true);
}
-ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace colorSpace, RenderingMode, DeferralMode, bool& success)
+ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace colorSpace, RenderingMode, bool& success)
: m_data(size)
, m_size(size)
, m_logicalSize(size)
@@ -100,16 +100,21 @@ PassRefPtr<Image> ImageBuffer::copyImage(BackingStoreCopy copyBehavior, ScaleBeh
return adoptRef(new BufferedImage(&m_data));
}
+BackingStoreCopy ImageBuffer::fastCopyImageMode()
+{
+ return CopyBackingStore;
+}
+
void ImageBuffer::clip(GraphicsContext*, const FloatRect&) const
{
notImplemented();
}
void ImageBuffer::draw(GraphicsContext* context, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect,
- CompositeOperator op , bool useLowQualityScale)
+ CompositeOperator op, BlendMode blendMode, bool useLowQualityScale)
{
RefPtr<Image> imageCopy = copyImage(CopyBackingStore);
- context->drawImage(imageCopy.get(), styleColorSpace, destRect, srcRect, op, DoNotRespectImageOrientation, useLowQualityScale);
+ context->drawImage(imageCopy.get(), styleColorSpace, destRect, srcRect, op, blendMode, DoNotRespectImageOrientation, useLowQualityScale);
}
void ImageBuffer::drawPattern(GraphicsContext* context, const FloatRect& srcRect, const AffineTransform& patternTransform,
diff --git a/Source/WebCore/platform/graphics/wince/ImageWinCE.cpp b/Source/WebCore/platform/graphics/wince/ImageWinCE.cpp
index b9dfd907f..1f75275dc 100644
--- a/Source/WebCore/platform/graphics/wince/ImageWinCE.cpp
+++ b/Source/WebCore/platform/graphics/wince/ImageWinCE.cpp
@@ -41,7 +41,7 @@
namespace WebCore {
-NativeImagePtr ImageFrame::asNewNativeImage() const
+PassNativeImagePtr ImageFrame::asNewNativeImage() const
{
return SharedBitmap::create(m_backingStore, m_size, hasAlpha());
}
@@ -80,7 +80,7 @@ bool BitmapImage::getHBITMAPOfSize(HBITMAP bmp, LPSIZE size)
if (size)
drawFrameMatchingSourceSize(&gc, FloatRect(0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight), IntSize(*size), ColorSpaceDeviceRGB, CompositeCopy);
else
- draw(&gc, FloatRect(0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight), FloatRect(0, 0, imageSize.width(), imageSize.height()), ColorSpaceDeviceRGB, CompositeCopy);
+ draw(&gc, FloatRect(0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight), FloatRect(0, 0, imageSize.width(), imageSize.height()), ColorSpaceDeviceRGB, CompositeCopy, BlendModeNormal);
}
SelectObject(hdc.get(), hOldBmp);
@@ -98,17 +98,17 @@ void BitmapImage::drawFrameMatchingSourceSize(GraphicsContext* ctxt, const Float
size_t currentFrame = m_currentFrame;
m_currentFrame = i;
- draw(ctxt, dstRect, FloatRect(0, 0, srcSize.width(), srcSize.height()), styleColorSpace, compositeOp);
+ draw(ctxt, dstRect, FloatRect(0, 0, srcSize.width(), srcSize.height()), styleColorSpace, compositeOp, BlendModeNormal);
m_currentFrame = currentFrame;
return;
}
// No image of the correct size was found, fallback to drawing the current frame
IntSize imageSize = BitmapImage::size();
- draw(ctxt, dstRect, FloatRect(0, 0, imageSize.width(), imageSize.height()), styleColorSpace, compositeOp);
+ draw(ctxt, dstRect, FloatRect(0, 0, imageSize.width(), imageSize.height()), styleColorSpace, compositeOp, BlendModeNormal);
}
-void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect, const FloatRect& srcRectIn, ColorSpace styleColorSpace, CompositeOperator compositeOp)
+void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect, const FloatRect& srcRectIn, ColorSpace styleColorSpace, CompositeOperator compositeOp, BlendMode blendMode)
{
if (!m_source.initialized())
return;
@@ -127,7 +127,7 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect, const Fl
intSrcRect.setY(stableRound(srcRectIn.y() * scaleFactor));
intSrcRect.setHeight(stableRound(srcRectIn.height() * scaleFactor));
}
- bmp->draw(ctxt, enclosingIntRect(dstRect), intSrcRect, styleColorSpace, compositeOp);
+ bmp->draw(ctxt, enclosingIntRect(dstRect), intSrcRect, styleColorSpace, compositeOp, blendMode);
}
}
@@ -135,7 +135,7 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect, const Fl
}
void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const AffineTransform& patternTransform,
- const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect)
+ const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect, BlendMode blendMode)
{
notImplemented();
}
diff --git a/Source/WebCore/platform/graphics/wince/MediaPlayerProxy.cpp b/Source/WebCore/platform/graphics/wince/MediaPlayerProxy.cpp
index 658d698ee..d02e2b5cd 100644
--- a/Source/WebCore/platform/graphics/wince/MediaPlayerProxy.cpp
+++ b/Source/WebCore/platform/graphics/wince/MediaPlayerProxy.cpp
@@ -89,7 +89,7 @@ void WebMediaPlayerProxy::load(const String& url)
void WebMediaPlayerProxy::initEngine()
{
- HTMLMediaElement* element = static_cast<HTMLMediaElement*>(m_mediaPlayer->mediaPlayerClient());
+ HTMLMediaElement* element = toHTMLMediaElement(m_mediaPlayer->mediaPlayerClient());
String url = element->initialURL();
if (url.isEmpty())
@@ -116,7 +116,7 @@ void WebMediaPlayerProxy::initEngine()
HTMLMediaElement* WebMediaPlayerProxy::element()
{
- return static_cast<HTMLMediaElement*>(m_mediaPlayer->mediaPlayerClient());
+ return toHTMLMediaElement(m_mediaPlayer->mediaPlayerClient());
}
diff --git a/Source/WebCore/platform/graphics/wince/MediaPlayerProxy.h b/Source/WebCore/platform/graphics/wince/MediaPlayerProxy.h
index b02e0f432..1495a26d4 100644
--- a/Source/WebCore/platform/graphics/wince/MediaPlayerProxy.h
+++ b/Source/WebCore/platform/graphics/wince/MediaPlayerProxy.h
@@ -24,7 +24,6 @@
#if ENABLE(VIDEO)
#include <wtf/Forward.h>
-#include "ScriptInstance.h"
namespace WebCore {
@@ -54,7 +53,7 @@ namespace WebCore {
void load(const String& url);
HTMLMediaElement* element();
void invokeMethod(const String& methodName);
- ScriptInstance pluginInstance();
+ RefPtr<JSC::Bindings::Instance> pluginInstance();
private:
MediaPlayer* m_mediaPlayer;
diff --git a/Source/WebCore/platform/graphics/wince/SharedBitmap.cpp b/Source/WebCore/platform/graphics/wince/SharedBitmap.cpp
index acb82470c..287196e8e 100644
--- a/Source/WebCore/platform/graphics/wince/SharedBitmap.cpp
+++ b/Source/WebCore/platform/graphics/wince/SharedBitmap.cpp
@@ -235,14 +235,14 @@ bool SharedBitmap::ensureHandle()
return true;
}
-void SharedBitmap::draw(GraphicsContext* ctxt, const IntRect& dstRect, const IntRect& srcRect, ColorSpace styleColorSpace, CompositeOperator compositeOp)
+void SharedBitmap::draw(GraphicsContext* ctxt, const IntRect& dstRect, const IntRect& srcRect, ColorSpace styleColorSpace, CompositeOperator compositeOp, BlendMode blendMode)
{
if (!m_pixels)
return;
- ctxt->drawBitmap(this, dstRect, srcRect, styleColorSpace, compositeOp);
+ ctxt->drawBitmap(this, dstRect, srcRect, styleColorSpace, compositeOp, blendMode);
}
-void SharedBitmap::draw(HDC hdc, const IntRect& dstRect, const IntRect& srcRect, CompositeOperator compositeOp)
+void SharedBitmap::draw(HDC hdc, const IntRect& dstRect, const IntRect& srcRect, CompositeOperator compositeOp, BlendMode blendMode)
{
if (!m_pixels)
return;
diff --git a/Source/WebCore/platform/graphics/wince/SharedBitmap.h b/Source/WebCore/platform/graphics/wince/SharedBitmap.h
index 82f5d54e9..0d1c738f1 100644
--- a/Source/WebCore/platform/graphics/wince/SharedBitmap.h
+++ b/Source/WebCore/platform/graphics/wince/SharedBitmap.h
@@ -81,10 +81,10 @@ public:
PassRefPtr<SharedBitmap> clipBitmap(const IntRect& rect, bool useAlpha);
- void draw(GraphicsContext* ctxt, const IntRect& dstRect, const IntRect& srcRect, ColorSpace styleColorSpace, CompositeOperator compositeOp);
+ void draw(GraphicsContext* ctxt, const IntRect& dstRect, const IntRect& srcRect, ColorSpace styleColorSpace, CompositeOperator compositeOp, BlendMode blendMode);
void drawPattern(GraphicsContext* ctxt, const FloatRect& tileRectIn, const AffineTransform& patternTransform,
const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect, const IntSize& origSourceSize);
- void draw(HDC, const IntRect& dstRect, const IntRect& srcRect, CompositeOperator compositeOp);
+ void draw(HDC, const IntRect& dstRect, const IntRect& srcRect, CompositeOperator compositeOp, BlendMode blendMode);
void drawPattern(HDC, const AffineTransform&, const FloatRect& tileRectIn, const AffineTransform& patternTransform,
const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect, const IntSize& origSourceSize);
diff --git a/Source/WebCore/platform/graphics/wince/SimpleFontDataWinCE.cpp b/Source/WebCore/platform/graphics/wince/SimpleFontDataWinCE.cpp
index 842fad5f3..76b4ec055 100644
--- a/Source/WebCore/platform/graphics/wince/SimpleFontDataWinCE.cpp
+++ b/Source/WebCore/platform/graphics/wince/SimpleFontDataWinCE.cpp
@@ -63,7 +63,7 @@ void SimpleFontData::platformDestroy()
{
}
-PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
+PassRefPtr<SimpleFontData> SimpleFontData::platformCreateScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
{
FontDescription fontDesc(fontDescription);
fontDesc.setComputedSize(lroundf(scaleFactor * fontDesc.computedSize()));
@@ -87,11 +87,7 @@ bool SimpleFontData::containsCharacters(const UChar* characters, int length) con
// cover a given code page?
// FIXME: in the case that we failed to get the interface, still use the font.
-#if defined(IMLANG_FONT_LINK) && (IMLANG_FONT_LINK == 2)
- IMLangFontLink2* langFontLink = fontCache()->getFontLinkInterface();
-#else
- IMLangFontLink* langFontLink = fontCache()->getFontLinkInterface();
-#endif
+ IMLangFontLinkType* langFontLink = fontCache()->getFontLinkInterface();
if (!langFontLink)
return true;
diff --git a/Source/WebCore/platform/graphics/wx/ColorWx.cpp b/Source/WebCore/platform/graphics/wx/ColorWx.cpp
deleted file mode 100644
index 0381c5910..000000000
--- a/Source/WebCore/platform/graphics/wx/ColorWx.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Kevin Ollivier. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Color.h"
-
-#include <wx/defs.h>
-#include <wx/colour.h>
-
-namespace WebCore {
-
-Color::Color(const wxColour& color)
-{
- m_color = makeRGBA((int)color.Red(), (int)color.Green(), (int)color.Blue(), (int)color.Alpha());
-}
-
-Color::operator wxColour() const
-{
- return wxColour(red(), green(), blue(), alpha());
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/wx/FloatRectWx.cpp b/Source/WebCore/platform/graphics/wx/FloatRectWx.cpp
deleted file mode 100644
index bb460e55e..000000000
--- a/Source/WebCore/platform/graphics/wx/FloatRectWx.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FloatRect.h"
-
-#include <wx/defs.h>
-#include <wx/graphics.h>
-
-namespace WebCore {
-
-#if USE(WXGC)
-FloatRect::FloatRect(const wxRect2DDouble& r)
- : m_location(FloatPoint(r.m_x, r.m_y))
- , m_size(FloatSize(r.m_width, r.m_height))
-{
-}
-
-FloatRect::operator wxRect2DDouble() const
-{
- return wxRect2DDouble(x(), y(), width(), height());
-}
-#endif
-
-}
diff --git a/Source/WebCore/platform/graphics/wx/FontCacheWx.cpp b/Source/WebCore/platform/graphics/wx/FontCacheWx.cpp
deleted file mode 100644
index 5e90e059a..000000000
--- a/Source/WebCore/platform/graphics/wx/FontCacheWx.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FontCache.h"
-#include "Font.h"
-#include "FontPlatformData.h"
-#include "NotImplemented.h"
-#include "SimpleFontData.h"
-#include <wtf/text/WTFString.h>
-
-#include <wx/defs.h>
-#include <wx/fontenum.h>
-
-namespace WebCore {
-
-void FontCache::platformInit()
-{
-}
-
-PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
-{
- RefPtr<SimpleFontData> fontData = 0;
- fontData = getCachedFontData(font.fontDescription(), font.family().family(), false, DoNotRetain);
- if (!fontData->containsCharacters(characters, length))
- fontData = getSimilarFontPlatformData(font);
- if (!fontData->containsCharacters(characters, length))
- fontData = getLastResortFallbackFont(font.fontDescription());
-
- ASSERT(fontData);
- return fontData.release();
-}
-
-PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font& font)
-{
- RefPtr<SimpleFontData> simpleFontData = 0;
-#if OS(DARWIN)
- // Attempt to find an appropriate font using a match based on
- // the presence of keywords in the the requested names. For example, we'll
- // match any name that contains "Arabic" to Geeza Pro.
- const FontFamily* currFamily = &font.fontDescription().family();
- while (currFamily && !simpleFontData) {
- if (currFamily->family().length()) {
- static String* matchWords[3] = { new String("Arabic"), new String("Pashto"), new String("Urdu") };
- DEFINE_STATIC_LOCAL(AtomicString, geezaStr, ("Geeza Pro", AtomicString::ConstructFromLiteral));
- for (int j = 0; j < 3 && !simpleFontData; ++j)
- if (currFamily->family().contains(*matchWords[j], false))
- simpleFontData = getCachedFontData(font.fontDescription(), geezaStr);
- }
- currFamily = currFamily->next();
- }
-#endif
- if (!simpleFontData)
- simpleFontData = getCachedFontData(font.fontDescription(), font.family().family());
-
- return simpleFontData.release();
-}
-
-PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)
-{
- // FIXME: Would be even better to somehow get the user's default font here. For now we'll pick
- // the default that the user would get without changing any prefs.
- RefPtr<SimpleFontData> fallback = 0;
-#if OS(WINDOWS)
- static AtomicString fallbackName("Arial Unicode MS");
-#else
- static AtomicString fallbackName("Times New Roman");
-#endif
- fallback = getCachedFontData(fontDescription, fallbackName, false, shouldRetain);
- ASSERT(fallback);
-
- return fallback.release();
-}
-
-FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
-{
- // wx will ALWAYS create a valid font, even if the font family we're looking for is not available.
- // So we check to make sure the font is the one we're looking for before creating the font.
- if (!wxFontEnumerator::IsValidFacename(family.string()))
- return 0;
-
- return new FontPlatformData(fontDescription,family);
-}
-
-void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigned>& traitsMasks)
-{
- notImplemented();
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/wx/FontCustomPlatformData.cpp b/Source/WebCore/platform/graphics/wx/FontCustomPlatformData.cpp
deleted file mode 100644
index 055f0fcab..000000000
--- a/Source/WebCore/platform/graphics/wx/FontCustomPlatformData.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2008 Alp Toker <alp@atoker.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "FontCustomPlatformData.h"
-
-#include "SharedBuffer.h"
-#include "FontPlatformData.h"
-
-
-namespace WebCore {
-
-FontCustomPlatformData::~FontCustomPlatformData()
-{
-}
-
-FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation, FontWidthVariant, FontRenderingMode)
-{
- return FontPlatformData(size, bold, italic);
-}
-
-FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
-{
- return 0;
-}
-
-bool FontCustomPlatformData::supportsFormat(const String& /* format */)
-{
- return false;
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/wx/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/wx/FontCustomPlatformData.h
deleted file mode 100644
index c97529651..000000000
--- a/Source/WebCore/platform/graphics/wx/FontCustomPlatformData.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2008 Alp Toker <alp@atoker.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef FontCustomPlatformData_h
-#define FontCustomPlatformData_h
-
-#include "FontOrientation.h"
-#include "FontRenderingMode.h"
-#include "FontWidthVariant.h"
-#include <wtf/Forward.h>
-#include <wtf/Noncopyable.h>
-
-namespace WebCore {
-
- class FontPlatformData;
- class SharedBuffer;
-
- struct FontCustomPlatformData {
- WTF_MAKE_NONCOPYABLE(FontCustomPlatformData);
- public:
- FontCustomPlatformData() { }
- ~FontCustomPlatformData();
-
- static bool supportsFormat(const String&);
-
- FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation = Horizontal, FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode);
- };
-
- FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer*);
-
-}
-
-#endif
diff --git a/Source/WebCore/platform/graphics/wx/FontPlatformData.h b/Source/WebCore/platform/graphics/wx/FontPlatformData.h
deleted file mode 100644
index 12cb1ee4c..000000000
--- a/Source/WebCore/platform/graphics/wx/FontPlatformData.h
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright (C) 2006 Kevin Ollivier All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef FontPlatformData_h
-#define FontPlatformData_h
-
-#include "FontDescription.h"
-#include "FontWidthVariant.h"
-#include "FontOrientation.h"
-#include <wtf/Forward.h>
-#include <wtf/RefPtr.h>
-#include <wtf/text/AtomicString.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/StringImpl.h>
-
-#include <wx/defs.h>
-#include <wx/font.h>
-#include <wx/gdicmn.h>
-
-#if OS(DARWIN)
-#include <ApplicationServices/ApplicationServices.h>
-
-#if __OBJC__
-@class NSFont;
-#else
-class NSFont;
-#endif
-
-inline CTFontRef toCTFontRef(NSFont *nsFont) { return reinterpret_cast<CTFontRef>(nsFont); }
-
-#endif
-
-namespace WebCore {
-
-class FontHolder: public WTF::RefCounted<FontHolder>
-{
-public:
- FontHolder()
- : m_font(0)
- {}
-
- FontHolder(wxFont* font)
- : m_font(font)
- {}
-
- ~FontHolder()
- {
- delete m_font;
- }
-
- wxFont* font() { return m_font; }
-
-private:
- wxFont* m_font;
-};
-
-class FontPlatformData {
-public:
- enum FontState { UNINITIALIZED, DELETED, VALID };
-
- FontPlatformData(WTF::HashTableDeletedValueType)
- : m_fontState(DELETED)
- , m_font(0)
- , m_size(0)
-#if OS(DARWIN)
- , m_atsuFontID(0)
-#endif
- { }
-
- ~FontPlatformData();
-
- FontPlatformData(const FontDescription&, const AtomicString&);
-
- FontPlatformData(float size, bool bold, bool italic)
- : m_fontState(UNINITIALIZED)
- , m_font(0)
- , m_size(size)
-#if OS(DARWIN)
- , m_atsuFontID(0)
-#endif
- {
- }
-
- FontPlatformData()
- : m_fontState(UNINITIALIZED)
- , m_font(0)
- , m_size(0)
-#if OS(DARWIN)
- , m_atsuFontID(0)
-#endif
- {
- }
-
- wxFont* font() const {
- return m_font->font();
- }
-
- unsigned hash() const {
- switch (m_fontState) {
- case DELETED:
- return -1;
- case UNINITIALIZED:
- return 0;
- case VALID:
- return computeHash();
- }
- }
-
- unsigned computeHash() const;
-
- float size() const { return m_size; }
-
- bool operator==(const FontPlatformData& other) const
- {
- if (m_font && m_fontState == VALID && other.m_fontState == VALID && other.m_font) {
- wxFont* thisFont = m_font->font();
- wxFont* otherFont = other.m_font->font();
- return thisFont->IsOk() && otherFont->IsOk() && thisFont->IsSameAs(*otherFont);
- }
- else
- return m_fontState == other.m_fontState;
- }
-
- bool isHashTableDeletedValue() const { return m_fontState == DELETED; }
-
- bool roundsGlyphAdvances() const { return false; }
-
- bool allowsLigatures() const { return false; }
-
- FontOrientation orientation() const { return Horizontal; } // FIXME: Implement.
- void setOrientation(FontOrientation) { } // FIXME: Implement.
-
- // We don't support this yet, so just return the default value for now.
- FontWidthVariant widthVariant() const { return RegularWidth; }
-
- bool isCompositeFontReference() const { return false; }
-
-#if OS(WINDOWS)
- bool useGDI() const;
- HFONT hfont() const;
-#endif
-
-#if OS(DARWIN)
- ATSUFontID m_atsuFontID;
- CGFontRef cgFont() const;
- NSFont* nsFont() const { return m_nsFont; }
- CTFontRef ctFont() const { return reinterpret_cast<CTFontRef>(m_nsFont); }
- void cacheNSFont();
-#endif
-
-#ifndef NDEBUG
- String description() const;
-#endif
-
-private:
- FontState m_fontState;
- WTF::RefPtr<FontHolder> m_font;
- float m_size;
-#if OS(DARWIN)
- NSFont* m_nsFont;
-#endif
-};
-
-}
-
-#endif
diff --git a/Source/WebCore/platform/graphics/wx/FontPlatformDataWx.cpp b/Source/WebCore/platform/graphics/wx/FontPlatformDataWx.cpp
deleted file mode 100644
index d50cac171..000000000
--- a/Source/WebCore/platform/graphics/wx/FontPlatformDataWx.cpp
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FontPlatformData.h"
-
-#include "FontDescription.h"
-#include <wtf/text/WTFString.h>
-#include <wx/defs.h>
-#include <wx/font.h>
-#include <wx/gdicmn.h>
-
-namespace WebCore {
-
-static wxFontFamily fontFamilyToWxFontFamily(const int family)
-{
- switch (family) {
- case FontDescription::StandardFamily:
- return wxFONTFAMILY_DEFAULT;
- case FontDescription::SerifFamily:
- return wxFONTFAMILY_ROMAN;
- case FontDescription::SansSerifFamily:
- return wxFONTFAMILY_MODERN;
- case FontDescription::MonospaceFamily:
- return wxFONTFAMILY_TELETYPE; // TODO: Check these are equivalent
- case FontDescription::CursiveFamily:
- return wxFONTFAMILY_SCRIPT;
- case FontDescription::FantasyFamily:
- return wxFONTFAMILY_DECORATIVE;
- default:
- return wxFONTFAMILY_DEFAULT;
- }
-}
-
-static wxFontWeight fontWeightToWxFontWeight(FontWeight weight)
-{
- if (weight >= FontWeight600)
- return wxFONTWEIGHT_BOLD;
-
- if (weight <= FontWeight300)
- return wxFONTWEIGHT_LIGHT;
-
- return wxFONTWEIGHT_NORMAL;
-}
-
-static int italicToWxFontStyle(bool isItalic)
-{
- if (isItalic)
- return wxFONTSTYLE_ITALIC;
-
- return wxFONTSTYLE_NORMAL;
-}
-
-FontPlatformData::FontPlatformData(const FontDescription& desc, const AtomicString& family)
-{
-// NB: The Windows wxFont constructor has two forms, one taking a wxSize (with pixels)
-// and one taking an int (points). When points are used, Windows calculates
-// a pixel size using an algorithm which causes the size to be way off. However,
-// this is a moot issue on Linux and Mac as they only accept the point argument. So,
-// we use the pixel size constructor on Windows, but we use point size on Linux and Mac.
-#if __WXMSW__
- m_font = adoptRef(new FontHolder(new wxFont( wxSize(0, -desc.computedPixelSize()),
- fontFamilyToWxFontFamily(desc.genericFamily()),
- italicToWxFontStyle(desc.italic()),
- fontWeightToWxFontWeight(desc.weight()),
- false,
- family.string()
- )
- ));
-#else
- m_font = adoptRef(new FontHolder(new wxFont( desc.computedPixelSize(),
- fontFamilyToWxFontFamily(desc.genericFamily()),
- italicToWxFontStyle(desc.italic()),
- fontWeightToWxFontWeight(desc.weight()),
- false,
- family.string()
- )
- ));
-#endif
-#if OS(DARWIN)
-#if !wxOSX_USE_CORE_TEXT
-#if wxCHECK_VERSION(2,9,0)
- m_atsuFontID = m_font->font()->OSXGetATSUFontID();
-#else
- m_atsuFontID = m_font->font()->MacGetATSUFontID();
-#endif
-#endif
- m_nsFont = 0;
- cacheNSFont();
-#endif
- m_size = desc.computedPixelSize();
- m_fontState = VALID;
- m_size = desc.computedPixelSize();
-}
-
-unsigned FontPlatformData::computeHash() const
-{
- wxFont* thisFont = m_font->font();
- ASSERT(thisFont && thisFont->IsOk());
-
- // make a hash that is unique for this font, but not globally unique - that is,
- // a font whose properties are equal should generate the same hash
- const char* fontName = thisFont->GetFaceName().utf8_str();
- uintptr_t hashCodes[6] = {
- thisFont->GetPointSize(),
- thisFont->GetFamily(),
- thisFont->GetStyle(),
- thisFont->GetWeight(),
- thisFont->GetUnderlined(),
- (uintptr_t)thisFont
- };
-
- return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes);
-}
-
-FontPlatformData::~FontPlatformData()
-{
- m_fontState = UNINITIALIZED;
- m_font = 0;
-}
-
-#ifndef NDEBUG
-String FontPlatformData::description() const
-{
- return String();
-}
-#endif
-
-#if OS(WINDOWS)
-bool FontPlatformData::useGDI() const
-{
- return true;
-}
-
-HFONT FontPlatformData::hfont() const
-{
- return static_cast<HFONT>(m_font->font()->GetHFONT());
-}
-#endif
-
-#if OS(DARWIN)
-CGFontRef FontPlatformData::cgFont() const
-{
- CGFontRef cgFont = 0;
-#ifdef wxOSX_USE_CORE_TEXT && wxOSX_USE_CORE_TEXT
- cgFont = CTFontCopyGraphicsFont((CTFontRef)m_font->font()->OSXGetCTFont(), 0);
-#else
- ATSFontRef fontRef;
-
- fontRef = FMGetATSFontRefFromFont(m_atsuFontID);
-
- if (fontRef)
- cgFont = CGFontCreateWithPlatformFont((void*)&fontRef);
-#endif
- return cgFont;
-}
-#endif
-
-
-
-}
diff --git a/Source/WebCore/platform/graphics/wx/FontPlatformDataWxMac.mm b/Source/WebCore/platform/graphics/wx/FontPlatformDataWxMac.mm
deleted file mode 100644
index efc43e51f..000000000
--- a/Source/WebCore/platform/graphics/wx/FontPlatformDataWxMac.mm
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (C) 2010 Kevin Ollivier, Stefan Csomor All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FontPlatformData.h"
-
-#include <wtf/MathExtras.h>
-#include <wx/defs.h>
-#include <wx/font.h>
-#include <wx/fontutil.h>
-
-#if !wxCHECK_VERSION(2,9,0)
-#include <wx/mac/private.h>
-#else
-#include <wx/osx/private.h>
-#endif
-
-#if !wxCHECK_VERSION(2,9,0) || !wxOSX_USE_COCOA
-
-static const NSAffineTransformStruct kSlantNSTransformStruct = { 1, 0, tan(deg2rad(11)), 1, 0, 0 };
-
-NSFont* OSXCreateNSFont(const wxNativeFontInfo* info)
-{
- NSFont* nsFont;
- int weight = 5;
- NSFontTraitMask traits = 0;
- if (info->GetWeight() == wxFONTWEIGHT_BOLD)
- {
- traits |= NSBoldFontMask;
- weight = 9;
- }
- else if (info->GetWeight() == wxFONTWEIGHT_LIGHT)
- weight = 3;
-
- if (info->GetStyle() == wxFONTSTYLE_ITALIC || info->GetStyle() == wxFONTSTYLE_SLANT)
- traits |= NSItalicFontMask;
-
- nsFont = [[NSFontManager sharedFontManager] fontWithFamily:(NSString*)(CFStringRef)wxMacCFStringHolder(info->GetFaceName())
- traits:traits weight:weight size:info->GetPointSize()];
-
- if ( nsFont == nil )
- {
- NSFontTraitMask remainingTraits = traits;
- nsFont = [[NSFontManager sharedFontManager] fontWithFamily:(NSString*)(CFStringRef)wxMacCFStringHolder(info->GetFaceName())
- traits:0 weight:5 size:info->GetPointSize()];
- if ( nsFont == nil )
- {
- if ( info->GetWeight() == wxFONTWEIGHT_BOLD )
- {
- nsFont = [NSFont boldSystemFontOfSize:info->GetPointSize()];
- remainingTraits &= ~NSBoldFontMask;
- }
- else
- nsFont = [NSFont systemFontOfSize:info->GetPointSize()];
- }
-
- // fallback - if in doubt, let go of the bold attribute
- if ( nsFont && (remainingTraits & NSItalicFontMask) )
- {
- NSFont* nsFontWithTraits = nil;
- if ( remainingTraits & NSBoldFontMask)
- {
- nsFontWithTraits = [[NSFontManager sharedFontManager] convertFont:nsFont toHaveTrait:NSBoldFontMask];
- if ( nsFontWithTraits == nil )
- {
- nsFontWithTraits = [[NSFontManager sharedFontManager] convertFont:nsFont toHaveTrait:NSItalicFontMask];
- if ( nsFontWithTraits != nil )
- remainingTraits &= ~NSItalicFontMask;
- }
- else
- {
- remainingTraits &= ~NSBoldFontMask;
- }
- }
- if ( remainingTraits & NSItalicFontMask)
- {
- if ( nsFontWithTraits == nil )
- nsFontWithTraits = nsFont;
-
- NSAffineTransform* transform = [NSAffineTransform transform];
- [transform setTransformStruct:kSlantNSTransformStruct];
- [transform scaleBy:info->GetPointSize()];
- NSFontDescriptor* italicDesc = [[nsFontWithTraits fontDescriptor] fontDescriptorWithMatrix:transform];
- if ( italicDesc != nil )
- {
- NSFont* f = [NSFont fontWithDescriptor:italicDesc size:(CGFloat)(info->GetPointSize())];
- if ( f != nil )
- nsFontWithTraits = f;
- }
- }
- if ( nsFontWithTraits != nil )
- nsFont = nsFontWithTraits;
- }
- }
-
- wxASSERT_MSG(nsFont != nil,wxT("Couldn't create nsFont")) ;
- wxMacCocoaRetain(nsFont);
- return nsFont;
-}
-
-#endif
-
-namespace WebCore {
-
-void FontPlatformData::cacheNSFont()
-{
- if (m_nsFont)
- return;
-
-#if wxCHECK_VERSION(2,9,1) && wxOSX_USE_COCOA
- if (m_font && m_font->font())
- m_nsFont = (NSFont*)m_font->font()->OSXGetNSFont();
-#else
- m_nsFont = OSXCreateNSFont(m_font->font()->GetNativeFontInfo());
-#endif
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/wx/FontWx.cpp b/Source/WebCore/platform/graphics/wx/FontWx.cpp
deleted file mode 100644
index 6c265b884..000000000
--- a/Source/WebCore/platform/graphics/wx/FontWx.cpp
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Font.h"
-
-#include "FontFallbackList.h"
-#include "GlyphBuffer.h"
-#include "GraphicsContext.h"
-#include "IntRect.h"
-#include "NotImplemented.h"
-#include "SimpleFontData.h"
-#include "TextRun.h"
-
-#if OS(WINDOWS)
-#include "UniscribeController.h"
-typedef WebCore::UniscribeController ComplexTextController;
-#endif
-
-#if OS(DARWIN)
-#include "mac/ComplexTextController.h"
-#endif
-
-#include <wx/dcclient.h>
-#include "fontprops.h"
-#include "non-kerned-drawing.h"
-
-namespace WebCore {
-
-bool Font::canReturnFallbackFontsForComplexText()
-{
-#if OS(WINDOWS) || OS(DARWIN)
- return true;
-#else
- return false;
-#endif
-}
-
-bool Font::canExpandAroundIdeographsInComplexText()
-{
-#if OS(DARWIN)
- return true;
-#else
- return false;
-#endif
-}
-
-void Font::drawGlyphs(GraphicsContext* graphicsContext, const SimpleFontData* font, const GlyphBuffer& glyphBuffer,
- int from, int numGlyphs, const FloatPoint& point) const
-{
- // prepare DC
- Color color = graphicsContext->fillColor();
-
- // We can't use wx drawing methods on Win/Linux because they automatically kern text
- // so we've created a function with platform dependent drawing implementations that
- // will hopefully be folded into wx once the API has solidified.
- // see platform/wx/wxcode/<platform> for the implementations.
- graphicsContext->save();
- drawTextWithSpacing(graphicsContext, font, color, glyphBuffer, from, numGlyphs, point);
- graphicsContext->restore();
-}
-
-FloatRect Font::selectionRectForComplexText(const TextRun& run, const FloatPoint& point, int h, int from, int to) const
-{
-#if OS(WINDOWS) || OS(DARWIN)
- ComplexTextController it(this, run);
- it.advance(from);
- float beforeWidth = it.runWidthSoFar();
- it.advance(to);
- float afterWidth = it.runWidthSoFar();
-
- // Using roundf() rather than ceilf() for the right edge as a compromise to ensure correct caret positioning
- if (run.rtl()) {
-#if OS(WINDOWS)
- it.advance(run.length());
- float totalWidth = it.runWidthSoFar();
- return FloatRect(point.x() + floorf(totalWidth - afterWidth), point.y(), roundf(totalWidth - beforeWidth) - floorf(totalWidth - afterWidth), h);
-#else
- float totalWidth = it.totalWidth();
- return FloatRect(point.x() + floorf(totalWidth - afterWidth), point.y(), roundf(totalWidth - beforeWidth) - floorf(totalWidth - afterWidth), h);
-#endif
- }
-
- return FloatRect(point.x() + floorf(beforeWidth), point.y(), roundf(afterWidth) - floorf(beforeWidth), h);
-#else
- notImplemented();
- return FloatRect();
-#endif
-}
-
-float Font::getGlyphsAndAdvancesForComplexText(const TextRun& /* run */, int /* from */, int /* to */, GlyphBuffer& /* glyphBuffer */, ForTextEmphasisOrNot /* forTextEmphasis */) const
-{
- // FIXME: Implement this by moving most of the drawComplexText() implementation in here. Set up the
- // ComplexTextController according to forTextEmphasis.
- notImplemented();
- return 0;
-}
-
-void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
-{
-#if OS(WINDOWS) || OS(DARWIN)
- // This glyph buffer holds our glyphs + advances + font data for each glyph.
- GlyphBuffer glyphBuffer;
-
- float startX = point.x();
- ComplexTextController controller(this, run);
- controller.advance(from);
- float beforeWidth = controller.runWidthSoFar();
- controller.advance(to, &glyphBuffer);
-
- // We couldn't generate any glyphs for the run. Give up.
- if (glyphBuffer.isEmpty())
- return;
-
- float afterWidth = controller.runWidthSoFar();
-
- if (run.rtl()) {
-#if OS(WINDOWS)
- controller.advance(run.length());
- startX += controller.runWidthSoFar() - afterWidth;
-#else
- startX += controller.totalWidth() - afterWidth;
- for (int i = 0, end = glyphBuffer.size() - 1; i < glyphBuffer.size() / 2; ++i, --end)
- glyphBuffer.swap(i, end);
-#endif
- } else
- startX += beforeWidth;
-
- // Draw the glyph buffer now at the starting point returned in startX.
- FloatPoint startPoint(startX, point.y());
- drawGlyphBuffer(context, run, glyphBuffer, startPoint);
-#else
- notImplemented();
-#endif
-}
-
-void Font::drawEmphasisMarksForComplexText(GraphicsContext* context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, int from, int to) const
-{
- GlyphBuffer glyphBuffer;
- float initialAdvance = getGlyphsAndAdvancesForComplexText(run, from, to, glyphBuffer, ForTextEmphasis);
-
- if (glyphBuffer.isEmpty())
- return;
-
- drawEmphasisMarks(context, run, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y()));
-}
-
-float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow*) const
-{
-#if OS(WINDOWS) || OS(DARWIN)
- ComplexTextController controller(this, run, fallbackFonts);
-#if OS(WINDOWS)
- controller.advance(run.length());
- return controller.runWidthSoFar();
-#else
- return controller.totalWidth();
-#endif
-#else
- notImplemented();
- return 0;
-#endif
-}
-
-int Font::offsetForPositionForComplexText(const TextRun& run, float x, bool includePartialGlyphs) const
-{
-#if OS(WINDOWS) || OS(DARWIN)
- ComplexTextController controller(this, run);
- return controller.offsetForPosition(x, includePartialGlyphs);
-#else
- notImplemented();
- return 0;
-#endif
-}
-}
diff --git a/Source/WebCore/platform/graphics/wx/GlyphMapWx.cpp b/Source/WebCore/platform/graphics/wx/GlyphMapWx.cpp
deleted file mode 100644
index ebf86e4dd..000000000
--- a/Source/WebCore/platform/graphics/wx/GlyphMapWx.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "GlyphPageTreeNode.h"
-
-#include "SimpleFontData.h"
-#include <unicode/utf16.h>
-
-namespace WebCore
-{
-
-bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData)
-{
- bool isUtf16 = bufferLength != length;
-
- for (unsigned i = 0; i < length; i++) {
- UChar32 character;
-
- if(isUtf16) {
- UChar lead = buffer[i * 2];
- UChar trail = buffer[i * 2 + 1];
- character = U16_GET_SUPPLEMENTARY(lead, trail);
- } else {
- character = buffer[i];
- }
-
- setGlyphDataForIndex(offset + i, character, fontData);
- }
-
- return true;
-}
-
-} \ No newline at end of file
diff --git a/Source/WebCore/platform/graphics/wx/GradientWx.cpp b/Source/WebCore/platform/graphics/wx/GradientWx.cpp
deleted file mode 100644
index 056deda13..000000000
--- a/Source/WebCore/platform/graphics/wx/GradientWx.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (C) 2008 Kevin Ollivier <kevino@theolliviers.com> All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Gradient.h"
-
-#include "CSSParser.h"
-#include "GraphicsContext.h"
-#include "NotImplemented.h"
-
-#include <algorithm>
-
-#include <wx/dc.h>
-#include <wx/dcgraph.h>
-#include <wx/graphics.h>
-
-using namespace std;
-
-namespace WebCore {
-
-void Gradient::platformDestroy()
-{
- delete m_gradient;
-}
-
-PlatformGradient Gradient::platformGradient()
-{
- if (m_gradient)
- return m_gradient;
-
-#if wxCHECK_VERSION(2, 9, 1)
- sortStopsIfNecessary();
-
- wxGraphicsRenderer* renderer = 0;
-#if wxUSE_CAIRO
- renderer = wxGraphicsRenderer::GetCairoRenderer();
-#else
- renderer = wxGraphicsRenderer::GetDefaultRenderer();
-#endif
- if (renderer) {
- wxGraphicsGradientStops stops;
- Vector<ColorStop>::iterator stopIterator = m_stops.begin();
- int numStops = 0;
- stops.SetStartColour(wxColour(255*stopIterator->red, 255*stopIterator->green, 255*stopIterator->blue, 255*stopIterator->alpha));
-
- while (stopIterator != m_stops.end()) {
- double position = stopIterator->stop;
- if (m_radial && m_r0)
- position = min((m_r0 / m_r1+position*(1.0f-m_r0 / m_r1)), 1.0);
- stops.Add(wxGraphicsGradientStop(wxColour(255*stopIterator->red, 255*stopIterator->green, 255*stopIterator->blue, 255*stopIterator->alpha), position));
- stopIterator++;
- numStops++;
- }
- stopIterator--;
- stops.SetEndColour(wxColour(255*stopIterator->red, 255*stopIterator->green, 255*stopIterator->blue, 255*stopIterator->alpha));
-
- wxGraphicsBrush gradient;
- if (numStops >= 2) {
- if (m_radial)
- gradient = renderer->CreateRadialGradientBrush(m_p1.x(), m_p1.y(), m_p0.x(), m_p0.y(), m_r1, stops);
- else
- gradient = renderer->CreateLinearGradientBrush(m_p0.x(), m_p0.y(), m_p1.x(), m_p1.y(), stops);
- }
- m_gradient = new wxGraphicsBrush(gradient);
- }
-#endif
- return m_gradient;
-}
-
-void Gradient::fill(GraphicsContext* c, const FloatRect& r)
-{
-#if wxCHECK_VERSION(2, 9, 1)
- wxGCDC* context = dynamic_cast<wxGCDC*>(c->platformContext());
-
- if (!context)
- return;
- wxGraphicsContext* gradientContext = context->GetGraphicsContext();
-
- gradientContext->SetPen(*wxTRANSPARENT_PEN);
- gradientContext->SetBrush(*platformGradient());
- gradientContext->DrawRectangle(r.x(), r.y(), r.width(), r.height());
-#endif
-}
-
-} //namespace
diff --git a/Source/WebCore/platform/graphics/wx/GraphicsContextWx.cpp b/Source/WebCore/platform/graphics/wx/GraphicsContextWx.cpp
deleted file mode 100644
index 29c9ad2f8..000000000
--- a/Source/WebCore/platform/graphics/wx/GraphicsContextWx.cpp
+++ /dev/null
@@ -1,828 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "GraphicsContext.h"
-
-#include "AffineTransform.h"
-#include "FloatRect.h"
-#include "Font.h"
-#include "IntRect.h"
-#include "NotImplemented.h"
-#include "Path.h"
-#include <wtf/MathExtras.h>
-
-#include <math.h>
-#include <stdio.h>
-
-// see http://trac.wxwidgets.org/ticket/11482
-#ifdef __WXMSW__
-# include "wx/msw/winundef.h"
-#endif
-
-#include <wx/defs.h>
-#include <wx/window.h>
-#include <wx/dcclient.h>
-#include <wx/dcgraph.h>
-#include <wx/graphics.h>
-
-#if wxUSE_CAIRO
-#include <cairo.h>
-#endif
-
-#if __WXMAC__
-#include <Carbon/Carbon.h>
-#elif __WXMSW__
-
-#include "wx/msw/private.h"
-// TODO remove this dependency (gdiplus needs the macros)
-
-#undef max
-#define max(a, b) (((a) > (b)) ? (a) : (b))
-
-#undef min
-#define min(a, b) (((a) < (b)) ? (a) : (b))
-
-#include <windows.h>
-
-#include <gdiplus.h>
-#endif
-
-namespace WebCore {
-
-int getWxCompositingOperation(CompositeOperator op, bool hasAlpha)
-{
- // FIXME: Add support for more operators.
- if (op == CompositeSourceOver && !hasAlpha)
- op = CompositeCopy;
-
- int function;
- switch (op) {
- case CompositeClear:
- function = wxCLEAR;
- case CompositeCopy:
- function = wxCOPY;
- break;
- default:
- function = wxCOPY;
- }
- return function;
-}
-
-static int strokeStyleToWxPenStyle(int p)
-{
- if (p == SolidStroke)
- return wxSOLID;
- if (p == DottedStroke)
- return wxDOT;
- if (p == DashedStroke)
- return wxLONG_DASH;
-#if ENABLE(CSS3_TEXT)
- if (p == DoubleStroke)
- return wxSOLID;
- if (p == WavyStroke) // FIXME: https://bugs.webkit.org/show_bug.cgi?id=94111 - Needs platform support.
- return wxSOLID;
-#endif // CSS3_TEXT
- if (p == NoStroke)
- return wxTRANSPARENT;
-
- return wxSOLID;
-}
-
-class GraphicsContextPlatformPrivate {
-public:
- GraphicsContextPlatformPrivate();
- ~GraphicsContextPlatformPrivate();
-
-#if USE(WXGC)
- wxGCDC* context;
-#else
- wxWindowDC* context;
-#endif
- int mswDCStateID;
- FloatSize currentScale;
- wxRegion gtkCurrentClipRgn;
- wxRegion gtkPaintClipRgn;
-};
-
-GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate() :
- context(0),
- mswDCStateID(0),
- gtkCurrentClipRgn(wxRegion()),
- gtkPaintClipRgn(wxRegion()),
- currentScale(1.0, 1.0)
-{
-}
-
-GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate()
-{
-}
-
-
-void GraphicsContext::platformInit(PlatformGraphicsContext* context)
-{
- m_data = new GraphicsContextPlatformPrivate;
- setPaintingDisabled(!context);
-
- if (context) {
- // Make sure the context starts in sync with our state.
- setPlatformFillColor(fillColor(), ColorSpaceDeviceRGB);
- setPlatformStrokeColor(strokeColor(), ColorSpaceDeviceRGB);
- }
-#if USE(WXGC)
- m_data->context = (wxGCDC*)context;
-#else
- m_data->context = (wxWindowDC*)context;
-#endif
-}
-
-void GraphicsContext::platformDestroy()
-{
- delete m_data;
-}
-
-PlatformGraphicsContext* GraphicsContext::platformContext() const
-{
- return (PlatformGraphicsContext*)m_data->context;
-}
-
-void GraphicsContext::savePlatformState()
-{
- if (m_data->context)
- {
-#if USE(WXGC)
- wxGraphicsContext* gc = m_data->context->GetGraphicsContext();
- gc->PushState();
-#else
- // when everything is working with USE_WXGC, we can remove this
- #if __WXMAC__
- CGContextRef context;
- wxGraphicsContext* gc = m_data->context->GetGraphicsContext();
- if (gc)
- context = (CGContextRef)gc->GetNativeContext();
- if (context)
- CGContextSaveGState(context);
- #elif __WXMSW__
- HDC dc = (HDC)m_data->context->GetHDC();
- m_data->mswDCStateID = ::SaveDC(dc);
- #elif __WXGTK__
- m_data->gtkCurrentClipRgn = m_data->context->m_currentClippingRegion;
- m_data->gtkPaintClipRgn = m_data->context->m_paintClippingRegion;
- #endif
-#endif // __WXMAC__
- }
-}
-
-void GraphicsContext::restorePlatformState()
-{
- if (m_data->context)
- {
-#if USE(WXGC)
- wxGraphicsContext* gc = m_data->context->GetGraphicsContext();
- gc->PopState();
-#else
- #if __WXMAC__
- CGContextRef context;
- wxGraphicsContext* gc = m_data->context->GetGraphicsContext();
- if (gc)
- context = (CGContextRef)gc->GetNativeContext();
- if (context)
- CGContextRestoreGState(context);
- #elif __WXMSW__
- HDC dc = (HDC)m_data->context->GetHDC();
- ::RestoreDC(dc, m_data->mswDCStateID);
- #elif __WXGTK__
- m_data->context->m_currentClippingRegion = m_data->gtkCurrentClipRgn;
- m_data->context->m_paintClippingRegion = m_data->gtkPaintClipRgn;
- #endif
-
-#endif // USE_WXGC
- }
-}
-
-// Draws a filled rectangle with a stroked border.
-void GraphicsContext::drawRect(const IntRect& rect)
-{
- if (paintingDisabled())
- return;
-
- ASSERT(!rect.isEmpty());
-
- save();
- m_data->context->SetPen(wxPen(strokeColor(), strokeThickness(), strokeStyleToWxPenStyle(strokeStyle())));
- m_data->context->DrawRectangle(rect.x(), rect.y(), rect.width(), rect.height());
- restore();
-}
-
-// This is only used to draw borders.
-void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2)
-{
- if (paintingDisabled())
- return;
-
- FloatPoint p1 = point1;
- FloatPoint p2 = point2;
-
- save();
- m_data->context->SetPen(wxPen(strokeColor(), strokeThickness(), strokeStyleToWxPenStyle(strokeStyle())));
- m_data->context->DrawLine(point1.x(), point1.y(), point2.x(), point2.y());
- restore();
-}
-
-// This method is only used to draw the little circles used in lists.
-void GraphicsContext::drawEllipse(const IntRect& rect)
-{
- if (paintingDisabled())
- return;
-
- save();
- m_data->context->SetPen(wxPen(strokeColor(), strokeThickness(), strokeStyleToWxPenStyle(strokeStyle())));
- m_data->context->DrawEllipse(rect.x(), rect.y(), rect.width(), rect.height());
- restore();
-}
-
-void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan)
-{
- if (paintingDisabled())
- return;
-
- save();
- m_data->context->SetPen(wxPen(strokeColor(), strokeThickness(), strokeStyleToWxPenStyle(strokeStyle())));
- m_data->context->DrawEllipticArc(rect.x(), rect.y(), rect.width(), rect.height(), startAngle, startAngle + angleSpan);
- restore();
-}
-
-void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points, bool shouldAntialias)
-{
- if (paintingDisabled())
- return;
-
- if (npoints <= 1)
- return;
-
- save();
- wxPoint* polygon = new wxPoint[npoints];
- for (size_t i = 0; i < npoints; i++)
- polygon[i] = wxPoint(points[i].x(), points[i].y());
- m_data->context->SetPen(wxPen(strokeColor(), strokeThickness(), strokeStyleToWxPenStyle(strokeStyle())));
- m_data->context->DrawPolygon((int)npoints, polygon);
- delete [] polygon;
- restore();
-}
-
-void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* points, bool antialiased)
-{
- if (paintingDisabled())
- return;
-
- if (numPoints <= 1)
- return;
-
- notImplemented();
-}
-
-void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorSpace colorSpace)
-{
- if (paintingDisabled())
- return;
-
- save();
-
- m_data->context->SetPen(*wxTRANSPARENT_PEN);
- m_data->context->SetBrush(wxBrush(color));
- m_data->context->DrawRectangle(rect.x(), rect.y(), rect.width(), rect.height());
-
- restore();
-}
-
-void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color, ColorSpace colorSpace)
-{
- if (paintingDisabled())
- return;
-
-#if USE(WXGC)
- Path path;
- path.addRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight);
- m_data->context->SetBrush(wxBrush(color));
- wxGraphicsContext* gc = m_data->context->GetGraphicsContext();
- gc->FillPath(*path.platformPath());
-#endif
-}
-
-void GraphicsContext::drawFocusRing(const Path& path, int width, int offset, const Color& color)
-{
- // FIXME: implement
- notImplemented();
-}
-
-void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int offset, const Color& color)
-{
- if (paintingDisabled())
- return;
-
- notImplemented();
-}
-
-void GraphicsContext::clip(const FloatRect& r)
-{
- m_data->context->SetClippingRegion(r.x(), r.y(), r.width(), r.height());
-}
-
-void GraphicsContext::clipOut(const Path&)
-{
- if (paintingDisabled())
- return;
-
- notImplemented();
-}
-
-void GraphicsContext::clipOut(const IntRect& rect)
-{
- if (paintingDisabled())
- return;
-
-#if USE(WXGC)
- wxGraphicsContext* gc = m_data->context->GetGraphicsContext();
-
-#if wxUSE_CAIRO
- double x1, y1, x2, y2;
- cairo_t* cr = (cairo_t*)gc->GetNativeContext();
- cairo_clip_extents(cr, &x1, &y1, &x2, &y2);
- cairo_rectangle(cr, x1, y1, x2 - x1, y2 - y1);
- cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
- cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
- cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD);
- cairo_clip(cr);
- cairo_set_fill_rule(cr, savedFillRule);
-
-#elif __WXMAC__
- CGContextRef context = (CGContextRef)gc->GetNativeContext();
-
- CGRect rects[2] = { CGContextGetClipBoundingBox(context), CGRectMake(rect.x(), rect.y(), rect.width(), rect.height()) };
- CGContextBeginPath(context);
- CGContextAddRects(context, rects, 2);
- CGContextEOClip(context);
- return;
-
-#elif __WXMSW__
- Gdiplus::Graphics* g = (Gdiplus::Graphics*)gc->GetNativeContext();
- Gdiplus::Region excludeRegion(Gdiplus::Rect(rect.x(), rect.y(), rect.width(), rect.height()));
- g->ExcludeClip(&excludeRegion);
- return;
-#endif
-
-#endif // USE(WXGC)
-
- notImplemented();
-}
-
-void GraphicsContext::clipPath(const Path& path, WindRule clipRule)
-{
- if (paintingDisabled())
- return;
-
- // FIXME: Why does this method ignore empty paths?
- if (path.isEmpty())
- return;
-
- wxGraphicsContext* gc = m_data->context->GetGraphicsContext();
-
-#if wxUSE_CAIRO
- cairo_t* cr = (cairo_t*)gc->GetNativeContext();
- cairo_path_t* nativePath = (cairo_path_t*)path.platformPath()->GetNativePath();
-
- cairo_new_path(cr);
- cairo_append_path(cr, nativePath);
-
- cairo_set_fill_rule(cr, clipRule == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
- cairo_clip(cr);
-#elif __WXMAC__
- CGContextRef context = (CGContextRef)gc->GetNativeContext();
- CGPathRef nativePath = (CGPathRef)path.platformPath()->GetNativePath();
-
- CGContextBeginPath(context);
- CGContextAddPath(context, nativePath);
- if (clipRule == RULE_EVENODD)
- CGContextEOClip(context);
- else
- CGContextClip(context);
-#elif __WXMSW__
- Gdiplus::Graphics* g = (Gdiplus::Graphics*)gc->GetNativeContext();
- Gdiplus::GraphicsPath* nativePath = (Gdiplus::GraphicsPath*)path.platformPath()->GetNativePath();
- if (clipRule == RULE_EVENODD)
- nativePath->SetFillMode(Gdiplus::FillModeAlternate);
- else
- nativePath->SetFillMode(Gdiplus::FillModeWinding);
- g->SetClip(nativePath);
-#endif
-}
-
-void GraphicsContext::drawLineForText(const FloatPoint& origin, float width, bool printing)
-{
- if (paintingDisabled())
- return;
-
- save();
- FloatPoint endPoint = origin + FloatSize(width, 0);
- m_data->context->SetPen(wxPen(strokeColor(), strokeThickness(), wxSOLID));
- m_data->context->DrawLine(origin.x(), origin.y(), endPoint.x(), endPoint.y());
- restore();
-}
-
-void GraphicsContext::drawLineForDocumentMarker(const FloatPoint& origin, float width, DocumentMarkerLineStyle style)
-{
- switch (style) {
- case DocumentMarkerSpellingLineStyle:
- m_data->context->SetPen(wxPen(*wxRED, 2, wxLONG_DASH));
- break;
- case DocumentMarkerGrammarLineStyle:
- m_data->context->SetPen(wxPen(*wxGREEN, 2, wxLONG_DASH));
- break;
- default:
- return;
- }
- m_data->context->DrawLine(origin.x(), origin.y(), origin.x() + width, origin.y());
-}
-
-void GraphicsContext::clip(const Path& path)
-{
- if (paintingDisabled())
- return;
-
- // if the path is empty, we clip against a zero rect to reduce the clipping region to
- // nothing - which is the intended behavior of clip() if the path is empty.
- if (path.isEmpty())
- m_data->context->SetClippingRegion(0, 0, 0, 0);
- else
- clipPath(path, RULE_NONZERO);
-}
-
-void GraphicsContext::canvasClip(const Path& path)
-{
- clip(path);
-}
-
-AffineTransform GraphicsContext::getCTM(IncludeDeviceScale) const
-{
- if (paintingDisabled())
- return AffineTransform();
-
-#if USE(WXGC)
- wxGraphicsContext* gc = m_data->context->GetGraphicsContext();
- if (gc) {
- wxGraphicsMatrix matrix = gc->GetTransform();
- double a, b, c, d, e, f;
- matrix.Get(&a, &b, &c, &d, &e, &f);
- return AffineTransform(a, b, c, d, e, f);
- }
-#endif
- return AffineTransform();
-}
-
-void GraphicsContext::translate(float tx, float ty)
-{
-#if USE(WXGC)
- if (m_data->context) {
- wxGraphicsContext* gc = m_data->context->GetGraphicsContext();
- gc->Translate(tx, ty);
- }
-#endif
-}
-
-void GraphicsContext::rotate(float angle)
-{
-#if USE(WXGC)
- if (m_data->context) {
- wxGraphicsContext* gc = m_data->context->GetGraphicsContext();
- gc->Rotate(angle);
- }
-#endif
-}
-
-void GraphicsContext::scale(const FloatSize& scale)
-{
-#if USE(WXGC)
- if (m_data->context) {
- wxGraphicsContext* gc = m_data->context->GetGraphicsContext();
- gc->Scale(scale.width(), scale.height());
- m_data->currentScale = scale;
- }
-#endif
-}
-
-FloatSize GraphicsContext::currentScale()
-{
- return m_data->currentScale;
-}
-FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& frect, RoundingMode)
-{
- FloatRect result;
-
- wxCoord x = (wxCoord)frect.x();
- wxCoord y = (wxCoord)frect.y();
-
- x = m_data->context->LogicalToDeviceX(x);
- y = m_data->context->LogicalToDeviceY(y);
- result.setX((float)x);
- result.setY((float)y);
- x = (wxCoord)frect.width();
- y = (wxCoord)frect.height();
- x = m_data->context->LogicalToDeviceXRel(x);
- y = m_data->context->LogicalToDeviceYRel(y);
- result.setWidth((float)x);
- result.setHeight((float)y);
- return result;
-}
-
-void GraphicsContext::setURLForRect(const KURL&, const IntRect&)
-{
- notImplemented();
-}
-
-void GraphicsContext::setPlatformCompositeOperation(CompositeOperator op)
-{
- if (m_data->context)
- {
-#if wxCHECK_VERSION(2,9,0)
- m_data->context->SetLogicalFunction(static_cast<wxRasterOperationMode>(getWxCompositingOperation(op, false)));
-#else
- m_data->context->SetLogicalFunction(getWxCompositingOperation(op, false));
-#endif
- }
-}
-
-void GraphicsContext::setPlatformStrokeColor(const Color& color, ColorSpace colorSpace)
-{
- if (paintingDisabled())
- return;
-
- if (m_data->context)
- m_data->context->SetPen(wxPen(color, strokeThickness(), strokeStyleToWxPenStyle(strokeStyle())));
-}
-
-void GraphicsContext::setPlatformStrokeThickness(float thickness)
-{
- if (paintingDisabled())
- return;
-
- if (m_data->context)
- m_data->context->SetPen(wxPen(strokeColor(), thickness, strokeStyleToWxPenStyle(strokeStyle())));
-
-}
-
-void GraphicsContext::setPlatformFillColor(const Color& color, ColorSpace colorSpace)
-{
- if (paintingDisabled())
- return;
-
- if (m_data->context)
- m_data->context->SetBrush(wxBrush(color));
-}
-
-void GraphicsContext::concatCTM(const AffineTransform& transform)
-{
- if (paintingDisabled())
- return;
-
-#if USE(WXGC)
- wxGraphicsContext* gc = m_data->context->GetGraphicsContext();
- if (gc)
- gc->ConcatTransform(transform);
-#endif
- return;
-}
-
-void GraphicsContext::setCTM(const AffineTransform& transform)
-{
- if (paintingDisabled())
- return;
-
-#if USE(WXGC)
- wxGraphicsContext* gc = m_data->context->GetGraphicsContext();
- if (gc)
- gc->SetTransform(transform);
-#endif
- return;
-}
-
-void GraphicsContext::setPlatformShouldAntialias(bool enable)
-{
- if (paintingDisabled())
- return;
- notImplemented();
-}
-
-void GraphicsContext::setImageInterpolationQuality(InterpolationQuality)
-{
-}
-
-InterpolationQuality GraphicsContext::imageInterpolationQuality() const
-{
- return InterpolationDefault;
-}
-
-void GraphicsContext::fillPath(const Path& path)
-{
- if (path.isNull())
- return;
-
-#if USE(WXGC)
- wxGraphicsContext* gc = m_data->context->GetGraphicsContext();
- if (gc)
- gc->FillPath(*path.platformPath());
-#endif
-}
-
-void GraphicsContext::strokePath(const Path& path)
-{
- if (path.isNull())
- return;
-
-#if USE(WXGC)
- wxGraphicsContext* gc = m_data->context->GetGraphicsContext();
- if (gc)
- gc->StrokePath(*path.platformPath());
-#endif
-}
-
-void GraphicsContext::fillRect(const FloatRect& rect)
-{
- if (paintingDisabled())
- return;
-}
-
-void GraphicsContext::setPlatformShadow(FloatSize const&, float, Color const&, ColorSpace)
-{
- notImplemented();
-}
-
-void GraphicsContext::clearPlatformShadow()
-{
- notImplemented();
-}
-
-void GraphicsContext::beginPlatformTransparencyLayer(float opacity)
-{
- if (paintingDisabled())
- return;
-
- wxGraphicsContext* gc = m_data->context->GetGraphicsContext();
- if (gc)
- gc->BeginLayer(opacity);
-}
-
-void GraphicsContext::endPlatformTransparencyLayer()
-{
- if (paintingDisabled())
- return;
-
- wxGraphicsContext* gc = m_data->context->GetGraphicsContext();
- if (gc)
- gc->EndLayer();
-}
-
-bool GraphicsContext::supportsTransparencyLayers()
-{
- return true;
-}
-
-void GraphicsContext::clearRect(const FloatRect&)
-{
- notImplemented();
-}
-
-void GraphicsContext::strokeRect(const FloatRect&, float)
-{
- notImplemented();
-}
-
-void GraphicsContext::setLineCap(LineCap)
-{
- notImplemented();
-}
-
-void GraphicsContext::setLineDash(const DashArray&, float dashOffset)
-{
- notImplemented();
-}
-
-void GraphicsContext::setLineJoin(LineJoin)
-{
- notImplemented();
-}
-
-void GraphicsContext::setMiterLimit(float)
-{
- notImplemented();
-}
-
-void GraphicsContext::setAlpha(float)
-{
- notImplemented();
-}
-
-void GraphicsContext::addInnerRoundedRectClip(const IntRect& r, int thickness)
-{
- if (paintingDisabled())
- return;
-
- FloatRect rect(r);
- clip(rect);
- Path path;
- path.addEllipse(rect);
- rect.inflate(-thickness);
- path.addEllipse(rect);
- clipPath(path, RULE_EVENODD);
-}
-
-#if OS(WINDOWS)
-HDC GraphicsContext::getWindowsContext(const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap)
-{
- if (dstRect.isEmpty())
- return 0;
-
- // Create a bitmap DC in which to draw.
- BITMAPINFO bitmapInfo;
- bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bitmapInfo.bmiHeader.biWidth = dstRect.width();
- bitmapInfo.bmiHeader.biHeight = dstRect.height();
- bitmapInfo.bmiHeader.biPlanes = 1;
- bitmapInfo.bmiHeader.biBitCount = 32;
- bitmapInfo.bmiHeader.biCompression = BI_RGB;
- bitmapInfo.bmiHeader.biSizeImage = 0;
- bitmapInfo.bmiHeader.biXPelsPerMeter = 0;
- bitmapInfo.bmiHeader.biYPelsPerMeter = 0;
- bitmapInfo.bmiHeader.biClrUsed = 0;
- bitmapInfo.bmiHeader.biClrImportant = 0;
-
- void* pixels = 0;
- HBITMAP bitmap = ::CreateDIBSection(0, &bitmapInfo, DIB_RGB_COLORS, &pixels, 0, 0);
- if (!bitmap)
- return 0;
-
- HDC displayDC = ::GetDC(0);
- HDC bitmapDC = ::CreateCompatibleDC(displayDC);
- ::ReleaseDC(0, displayDC);
-
- ::SelectObject(bitmapDC, bitmap);
-
- // Fill our buffer with clear if we're going to alpha blend.
- if (supportAlphaBlend) {
- BITMAP bmpInfo;
- GetObject(bitmap, sizeof(bmpInfo), &bmpInfo);
- int bufferSize = bmpInfo.bmWidthBytes * bmpInfo.bmHeight;
- memset(bmpInfo.bmBits, 0, bufferSize);
- }
- return bitmapDC;
-}
-
-void GraphicsContext::releaseWindowsContext(HDC hdc, const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap)
-{
- if (hdc) {
-
- if (!dstRect.isEmpty()) {
-
- HBITMAP bitmap = static_cast<HBITMAP>(GetCurrentObject(hdc, OBJ_BITMAP));
- BITMAP info;
- GetObject(bitmap, sizeof(info), &info);
- ASSERT(info.bmBitsPixel == 32);
-
- wxBitmap bmp;
- bmp.SetHBITMAP(bitmap);
-#if !wxCHECK_VERSION(2,9,0)
- if (supportAlphaBlend)
- bmp.UseAlpha();
-#endif
- m_data->context->DrawBitmap(bmp, dstRect.x(), dstRect.y(), supportAlphaBlend);
-
- ::DeleteObject(bitmap);
- }
-
- ::DeleteDC(hdc);
- }
-}
-#endif
-
-}
diff --git a/Source/WebCore/platform/graphics/wx/IconWx.cpp b/Source/WebCore/platform/graphics/wx/IconWx.cpp
deleted file mode 100644
index 41fa4eb13..000000000
--- a/Source/WebCore/platform/graphics/wx/IconWx.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2009 Apple Inc. All Rights Reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "Icon.h"
-
-#include "GraphicsContext.h"
-#include "IntRect.h"
-#include "NotImplemented.h"
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
-
-Icon::~Icon()
-{
-}
-
-PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>& filenames)
-{
- notImplemented();
- return 0;
-}
-
-void Icon::paint(GraphicsContext* ctx, const IntRect& rect)
-{
- notImplemented();
-}
-
-}
-
diff --git a/Source/WebCore/platform/graphics/wx/ImageBufferDataWx.h b/Source/WebCore/platform/graphics/wx/ImageBufferDataWx.h
deleted file mode 100644
index 8430e8102..000000000
--- a/Source/WebCore/platform/graphics/wx/ImageBufferDataWx.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2008 Kevin Ollivier. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <wtf/OwnPtr.h>
-
-// see http://trac.wxwidgets.org/ticket/11482
-#ifdef __WXMSW__
-# include "wx/msw/winundef.h"
-#endif
-
-#include <wx/bitmap.h>
-#include <wx/dcmemory.h>
-
-class wxGCDC;
-class wxGraphicsContext;
-class wxMemoryDC;
-
-namespace WebCore {
-
-class IntSize;
-
-class ImageBufferData {
-public:
- ImageBufferData(const IntSize&);
- ~ImageBufferData();
- wxBitmap m_bitmap;
- wxMemoryDC* m_memDC;
- wxGCDC* m_gcdc;
- wxGraphicsContext* m_graphics;
-};
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/wx/ImageBufferWx.cpp b/Source/WebCore/platform/graphics/wx/ImageBufferWx.cpp
deleted file mode 100644
index e5c4e7acc..000000000
--- a/Source/WebCore/platform/graphics/wx/ImageBufferWx.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com>
- * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ImageBuffer.h"
-
-#include "BitmapImage.h"
-#include "GraphicsContext.h"
-#include "Image.h"
-#include "ImageData.h"
-#include "NotImplemented.h"
-#include "UnusedParam.h"
-#include <wtf/UnusedParam.h>
-
-// see http://trac.wxwidgets.org/ticket/11482
-#ifdef __WXMSW__
-# include "wx/msw/winundef.h"
-#endif
-
-#include <wx/defs.h>
-#include <wx/bitmap.h>
-#include <wx/dc.h>
-#include <wx/dcgraph.h>
-#include <wx/dcmemory.h>
-#include <wx/graphics.h>
-#include <wx/image.h>
-#include <wx/rawbmp.h>
-
-
-namespace WebCore {
-
-ImageBufferData::ImageBufferData(const IntSize& size)
-{
- m_bitmap.Create(size.width(), size.height(), 32);
- {
- wxAlphaPixelData pixData(m_bitmap, wxPoint(0, 0), wxSize(size.width(), size.height()));
- ASSERT(pixData);
- if (pixData) {
- wxAlphaPixelData::Iterator p(pixData);
- for (int y = 0; y < size.height(); y++) {
- wxAlphaPixelData::Iterator rowStart = p;
- for (int x = 0; x < size.width(); x++) {
- p.Red() = 0;
- p.Blue() = 0;
- p.Green() = 0;
- // FIXME: The below should be transparent but cannot be on GDI/GDK (see wxWidgets bugs #10066 and #2474)
-#if wxUSE_CAIRO || defined(__WXMAC__)
- p.Alpha() = 0;
-#endif
- ++p;
- }
- p = rowStart;
- p.OffsetY(pixData, 1);
- }
- }
- }
- // http://www.w3.org/TR/2009/WD-html5-20090212/the-canvas-element.html#canvaspixelarray
- // "When the canvas is initialized it must be set to fully transparent black."
-
- m_memDC = new wxMemoryDC(m_bitmap);
- wxGraphicsRenderer* renderer = wxGraphicsRenderer::GetCairoRenderer();
- if (!renderer)
- renderer = wxGraphicsRenderer::GetDefaultRenderer();
- m_graphics = renderer->CreateContext(*m_memDC);
- m_gcdc = new wxGCDC(m_graphics);
-}
-
-ImageBufferData::~ImageBufferData()
-{
- delete m_gcdc;
- delete m_memDC;
-}
-
-ImageBuffer::ImageBuffer(const IntSize& size, float resolutionScale, ColorSpace colorSpace, RenderingMode, DeferralMode, bool& success)
- : m_data(size)
- , m_size(size)
- , m_logicalSize(size)
-{
- // FIXME: Respect resoutionScale to support high-DPI canvas.
- UNUSED_PARAM(resolutionScale);
- // FIXME: colorSpace is not used
- UNUSED_PARAM(colorSpace);
-
- if (m_data.m_gcdc->IsOk()) {
- m_context = adoptPtr(new WebCore::GraphicsContext(m_data.m_gcdc));
- success = true;
- } else
- success = false;
-}
-
-ImageBuffer::~ImageBuffer()
-{
-
-}
-
-GraphicsContext* ImageBuffer::context() const
-{
- return m_context.get();
-}
-
-PassRefPtr<Uint8ClampedArray> ImageBuffer::getUnmultipliedImageData(const IntRect& rect, CoordinateSystem) const
-{
- notImplemented();
- return 0;
-}
-
-PassRefPtr<Uint8ClampedArray> ImageBuffer::getPremultipliedImageData(const IntRect& rect, CoordinateSystem) const
-{
- notImplemented();
- return 0;
-}
-
-void ImageBuffer::putByteArray(Multiply multiplied, Uint8ClampedArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, CoordinateSystem)
-{
- notImplemented();
-}
-
-String ImageBuffer::toDataURL(const String& mimeType, const double*, CoordinateSystem) const
-{
- notImplemented();
- return String();
-}
-
-PassRefPtr<Image> ImageBuffer::copyImage(BackingStoreCopy copyBehavior, ScaleBehavior) const
-{
- ASSERT(copyBehavior == CopyBackingStore);
-
- RefPtr<BitmapImage> img = BitmapImage::create(m_data.m_bitmap);
- return img.release();
-}
-
-void ImageBuffer::clip(GraphicsContext* context, const FloatRect& rect) const
-{
- context->clip(rect);
-}
-
-void ImageBuffer::draw(GraphicsContext* context, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator op, bool useLowQualityScale)
-{
- RefPtr<Image> imageCopy = copyImage(CopyBackingStore);
- context->drawImage(imageCopy.get(), styleColorSpace, destRect, srcRect, op, DoNotRespectImageOrientation, useLowQualityScale);
-}
-
-void ImageBuffer::drawPattern(GraphicsContext* context, const FloatRect& srcRect, const AffineTransform& patternTransform,
- const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect)
-{
- ASSERT(context);
- RefPtr<Image> imageCopy = copyImage(CopyBackingStore);
- imageCopy->drawPattern(context, srcRect, patternTransform, phase, styleColorSpace, op, destRect);
-}
-
-void ImageBuffer::platformTransformColorSpace(const Vector<int>&)
-{
- notImplemented();
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/wx/ImageWx.cpp b/Source/WebCore/platform/graphics/wx/ImageWx.cpp
deleted file mode 100644
index 54bbdbb8c..000000000
--- a/Source/WebCore/platform/graphics/wx/ImageWx.cpp
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Computer, Kevin Ollivier. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Image.h"
-
-#include "AffineTransform.h"
-#include "BitmapImage.h"
-#include "FloatConversion.h"
-#include "FloatRect.h"
-#include "GraphicsContext.h"
-#include "ImageObserver.h"
-#include "NotImplemented.h"
-#include "SharedBuffer.h"
-
-#include <math.h>
-#include <stdio.h>
-
-#include <wx/defs.h>
-#include <wx/bitmap.h>
-#include <wx/dc.h>
-#include <wx/dcmemory.h>
-#include <wx/dcgraph.h>
-#include <wx/graphics.h>
-#include <wx/image.h>
-#include <wx/thread.h>
-
-namespace WebCore {
-
-// this is in GraphicsContextWx.cpp
-int getWxCompositingOperation(CompositeOperator op, bool hasAlpha);
-
-bool FrameData::clear(bool clearMetadata)
-{
- if (clearMetadata)
- m_haveMetadata = false;
-
- if (m_frame) {
- delete m_frame;
- m_frame = 0;
- return true;
- }
- return false;
-}
-
-// ================================================
-// Image Class
-// ================================================
-
-PassRefPtr<Image> Image::loadPlatformResource(const char *name)
-{
- // FIXME: We need to have some 'placeholder' graphics for things like missing
- // plugins or broken images.
- Vector<char> arr;
- RefPtr<Image> img = BitmapImage::create();
- RefPtr<SharedBuffer> buffer = SharedBuffer::create(arr.data(), arr.size());
- img->setData(buffer, true);
- return img.release();
-}
-
-BitmapImage::BitmapImage(const wxBitmap& bitmap)
- : Image(0)
- , m_currentFrame(0)
- , m_frames(0)
- , m_frameTimer(0)
- , m_repetitionCount(cAnimationNone)
- , m_repetitionCountStatus(Unknown)
- , m_repetitionsComplete(0)
- , m_isSolidColor(false)
- , m_checkedForSolidColor(false)
- , m_animationFinished(true)
- , m_allDataReceived(true)
- , m_haveSize(true)
- , m_sizeAvailable(true)
- , m_decodedSize(0)
- , m_haveFrameCount(true)
- , m_frameCount(1)
-{
- m_decodedSize = bitmap.GetWidth() * bitmap.GetHeight() * 4;
- m_size = IntSize(bitmap.GetWidth(), bitmap.GetHeight());
-
- wxGraphicsRenderer* renderer = 0;
-#if wxUSE_CAIRO
- renderer = wxGraphicsRenderer::GetCairoRenderer();
-#else
- renderer = wxGraphicsRenderer::GetDefaultRenderer();
-#endif
- if (renderer) {
- wxGraphicsBitmap* gbmp = new wxGraphicsBitmap(renderer->CreateBitmap(bitmap));
- ASSERT(!gbmp->IsNull());
-
- m_frames.grow(1);
- m_frames[0].m_frame = gbmp;
- m_frames[0].m_haveMetadata = true;
- checkForSolidColor();
- }
-}
-
-
-// Drawing Routines
-
-void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst, const FloatRect& src, ColorSpace styleColorSpace, CompositeOperator op)
-{
- if (mayFillWithSolidColor()) {
- fillWithSolidColor(ctxt, dst, solidColor(), styleColorSpace, op);
- return;
- }
-
-#if USE(WXGC)
- wxGCDC* context = (wxGCDC*)ctxt->platformContext();
- wxGraphicsContext* gc = context->GetGraphicsContext();
- wxGraphicsBitmap* bitmap = frameAtIndex(m_currentFrame);
-#else
- wxWindowDC* context = ctxt->platformContext();
- wxBitmap* bitmap = frameAtIndex(m_currentFrame);
-#endif
-
- startAnimation();
- if (!bitmap) // If it's too early we won't have an image yet.
- return;
-
- // If we're drawing a sub portion of the image or scaling then create
- // a pattern transformation on the image and draw the transformed pattern.
- // Test using example site at http://www.meyerweb.com/eric/css/edge/complexspiral/demo.html
- // FIXME: NYI
-
- ctxt->save();
-
- // Set the compositing operation.
- ctxt->setCompositeOperation(op);
-
-#if USE(WXGC)
- float scaleX = src.width() / dst.width();
- float scaleY = src.height() / dst.height();
-
- FloatRect adjustedDestRect = dst;
- FloatSize selfSize = currentFrameSize();
-
- if (src.size() != selfSize) {
- adjustedDestRect.setLocation(FloatPoint(dst.x() - src.x() / scaleX, dst.y() - src.y() / scaleY));
- adjustedDestRect.setSize(FloatSize(selfSize.width() / scaleX, selfSize.height() / scaleY));
- }
-
- gc->Clip(dst.x(), dst.y(), dst.width(), dst.height());
-#if wxCHECK_VERSION(2,9,0)
- gc->DrawBitmap(*bitmap, adjustedDestRect.x(), adjustedDestRect.y(), adjustedDestRect.width(), adjustedDestRect.height());
-#else
- gc->DrawGraphicsBitmap(*bitmap, adjustedDestRect.x(), adjustedDestRect.y(), adjustedDestRect.width(), adjustedDestRect.height());
-#endif
-
-#else // USE(WXGC)
- IntRect srcIntRect(src);
- IntRect dstIntRect(dst);
- bool rescaling = false;
- if ((dstIntRect.width() != srcIntRect.width()) || (dstIntRect.height() != srcIntRect.height()))
- {
- rescaling = true;
- wxImage img = bitmap->ConvertToImage();
- img.Rescale(dstIntRect.width(), dstIntRect.height());
- bitmap = new wxBitmap(img);
- }
-
- wxMemoryDC mydc;
- ASSERT(bitmap->GetRefData());
- mydc.SelectObject(*bitmap);
-
- context->Blit((wxCoord)dstIntRect.x(),(wxCoord)dstIntRect.y(), (wxCoord)dstIntRect.width(), (wxCoord)dstIntRect.height(), &mydc,
- (wxCoord)srcIntRect.x(), (wxCoord)srcIntRect.y(), wxCOPY, true);
- mydc.SelectObject(wxNullBitmap);
-
- // NB: delete is causing crashes during page load, but not during the deletion
- // itself. It occurs later on when a valid bitmap created in frameAtIndex
- // suddenly becomes invalid after returning. It's possible these errors deal
- // with reentrancy and threding problems.
- //delete bitmap;
- if (rescaling)
- {
- delete bitmap;
- bitmap = NULL;
- }
-#endif
-
- ctxt->restore();
-
- if (ImageObserver* observer = imageObserver())
- observer->didDraw(this);
-}
-
-void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace, CompositeOperator, const FloatRect& dstRect)
-{
-#if USE(WXGC)
- wxGCDC* context = (wxGCDC*)ctxt->platformContext();
- wxGraphicsBitmap* bitmap = nativeImageForCurrentFrame();
-#else
- wxWindowDC* context = ctxt->platformContext();
- wxBitmap* bitmap = nativeImageForCurrentFrame();
-#endif
-
- if (!bitmap) // If it's too early we won't have an image yet.
- return;
-
- ctxt->save();
- ctxt->clip(IntRect(dstRect.x(), dstRect.y(), dstRect.width(), dstRect.height()));
-
- float adjustedX = dstRect.x();
- float adjustedY = dstRect.y();
-
- adjustedX += phase.x() - dstRect.x() *
- narrowPrecisionToFloat(patternTransform.a());
- adjustedY += (phase.y() - dstRect.y() *
- narrowPrecisionToFloat(patternTransform.d()));
-
-#if USE(WXGC)
- wxGraphicsContext* gc = context->GetGraphicsContext();
- gc->ConcatTransform(patternTransform);
-#else
- wxMemoryDC mydc;
- mydc.SelectObject(*bitmap);
-#endif
-
- float currentW = adjustedX;
- float currentH = adjustedY;
-
- while (currentW <= dstRect.x() + dstRect.width()) {
- while (currentH <= dstRect.y() + dstRect.height()) {
-#if USE(WXGC)
-#if wxCHECK_VERSION(2,9,0)
- gc->DrawBitmap(*bitmap, currentW, currentH, (wxDouble)srcRect.width(), (wxDouble)srcRect.height());
-#else
- gc->DrawGraphicsBitmap(*bitmap, currentW, currentH, (wxDouble)srcRect.width(), (wxDouble)srcRect.height());
-#endif
-#else
- context->Blit((wxCoord)dstRect.x() + currentW, (wxCoord)dstRect.y() + currentH,
- (wxCoord)srcRect.width(), (wxCoord)srcRect.height(), &mydc,
- (wxCoord)srcRect.x(), (wxCoord)srcRect.y(), wxCOPY, true);
-#endif
- currentH += srcRect.height();
- }
- currentW += srcRect.width();
- currentH = adjustedY;
- }
- ctxt->restore();
-
-#if !USE(WXGC)
- mydc.SelectObject(wxNullBitmap);
-#endif
-
- // NB: delete is causing crashes during page load, but not during the deletion
- // itself. It occurs later on when a valid bitmap created in frameAtIndex
- // suddenly becomes invalid after returning. It's possible these errors deal
- // with reentrancy and threding problems.
- //delete bitmap;
-
- startAnimation();
-
- if (ImageObserver* observer = imageObserver())
- observer->didDraw(this);
-}
-
-void BitmapImage::checkForSolidColor()
-{
- m_checkedForSolidColor = true;
-}
-
-void BitmapImage::invalidatePlatformData()
-{
-
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/wx/IntPointWx.cpp b/Source/WebCore/platform/graphics/wx/IntPointWx.cpp
deleted file mode 100644
index 389ac9f7e..000000000
--- a/Source/WebCore/platform/graphics/wx/IntPointWx.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Kevin Ollivier <kevino@theolliviers.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "IntPoint.h"
-
-#include <wx/defs.h>
-#include <wx/gdicmn.h>
-
-namespace WebCore {
-
-IntPoint::IntPoint(const wxPoint& p)
- : m_x(p.x)
- , m_y(p.y)
-{
-}
-
-IntPoint::operator wxPoint() const
-{
- return wxPoint(m_x, m_y);
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/wx/IntRectWx.cpp b/Source/WebCore/platform/graphics/wx/IntRectWx.cpp
deleted file mode 100644
index 10c1b55c2..000000000
--- a/Source/WebCore/platform/graphics/wx/IntRectWx.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Kevin Ollivier <kevino@theolliviers.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "IntRect.h"
-
-#include <wx/defs.h>
-#include <wx/gdicmn.h>
-
-namespace WebCore {
-
-IntRect::IntRect(const wxRect& r)
- : m_location(IntPoint(r.x, r.y))
- , m_size(IntSize(r.width, r.height))
-{
-}
-
-IntRect::operator wxRect() const
-{
- return wxRect(x(), y(), width(), height());
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/wx/IntSizeWx.cpp b/Source/WebCore/platform/graphics/wx/IntSizeWx.cpp
deleted file mode 100644
index 8c82854e1..000000000
--- a/Source/WebCore/platform/graphics/wx/IntSizeWx.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2009 Kevin Watters. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "IntSize.h"
-
-#include <wx/defs.h>
-#include <wx/gdicmn.h>
-
-namespace WebCore {
-
-IntSize::IntSize(const wxSize& s)
- : m_width(s.x)
- , m_height(s.y)
-{
-}
-
-IntSize::operator wxSize() const
-{
- return wxSize(m_width, m_height);
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/wx/PathWx.cpp b/Source/WebCore/platform/graphics/wx/PathWx.cpp
deleted file mode 100644
index c2d3052db..000000000
--- a/Source/WebCore/platform/graphics/wx/PathWx.cpp
+++ /dev/null
@@ -1,255 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Path.h"
-
-#include "AffineTransform.h"
-#include "FloatPoint.h"
-#include "FloatRect.h"
-#include "NotImplemented.h"
-#include "StrokeStyleApplier.h"
-#include <wtf/text/WTFString.h>
-
-#include <stdio.h>
-
-#include <wx/defs.h>
-#include <wx/graphics.h>
-
-namespace WebCore {
-
-int getWxWindRuleForWindRule(WindRule rule)
-{
- if (rule == RULE_EVENODD)
- return wxODDEVEN_RULE;
-
- return wxWINDING_RULE;
-}
-
-Path::Path()
- : m_path(0)
-{
-}
-
-Path::~Path()
-{
- if (m_path)
- delete m_path;
-}
-
-Path::Path(const Path& path)
-{
- m_path = new wxGraphicsPath(*path.m_path);
-}
-
-bool Path::contains(const FloatPoint& point, const WindRule rule) const
-{
-#if USE(WXGC)
- if (m_path) {
-#if wxCHECK_VERSION(2,9,0)
- return m_path->Contains(point.x(), point.y(), static_cast<wxPolygonFillMode>(getWxWindRuleForWindRule(rule)));
-#else
- return m_path->Contains(point.x(), point.y(), getWxWindRuleForWindRule(rule));
-#endif
- }
-#endif
- return false;
-}
-
-void Path::translate(const FloatSize&)
-{
- notImplemented();
-}
-
-FloatRect Path::boundingRect() const
-{
-#if USE(WXGC)
- if (m_path)
- return m_path->GetBox();
-#endif
-
- return FloatRect();
-}
-
-FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier) const
-{
- notImplemented();
- return FloatRect();
-}
-
-bool Path::strokeContains(StrokeStyleApplier*, const FloatPoint&) const
-{
- notImplemented();
- return false;
-}
-
-Path& Path::operator=(const Path& path)
-{
- *ensurePlatformPath() = *path.platformPath();
- return *this;
-}
-
-PlatformPathPtr Path::ensurePlatformPath()
-{
- if (m_path)
- return m_path;
-
- // NB: This only supports the 'default' renderer as determined by wx on
- // each platform. If an app uses a non-default renderer (e.g. Cairo on Win),
- // there will be problems, but there's no way we can determine which
- // renderer an app is using right now with wx API, so we will just handle
- // the common case.
-#if USE(WXGC)
- wxGraphicsRenderer* renderer = 0;
-#if wxUSE_CAIRO
- renderer = wxGraphicsRenderer::GetCairoRenderer();
-#else
- renderer = wxGraphicsRenderer::GetDefaultRenderer();
-#endif
- if (renderer) {
- wxGraphicsPath path = renderer->CreatePath();
- m_path = new wxGraphicsPath(path);
- }
-#endif
- return m_path;
-}
-
-void Path::clear()
-{
- if (m_path)
- delete m_path;
- m_path = 0;
-}
-
-void Path::moveTo(const FloatPoint& point)
-{
-#if USE(WXGC)
- if (ensurePlatformPath())
- m_path->MoveToPoint(point.x(), point.y());
-#endif
-}
-
-void Path::addLineTo(const FloatPoint& point)
-{
-#if USE(WXGC)
- if (ensurePlatformPath())
- m_path->AddLineToPoint(point.x(), point.y());
-#endif
-}
-
-void Path::addQuadCurveTo(const FloatPoint& control, const FloatPoint& end)
-{
-#if USE(WXGC)
- if (ensurePlatformPath())
- m_path->AddQuadCurveToPoint(control.x(), control.y(), end.x(), end.y());
-#endif
-}
-
-void Path::addBezierCurveTo(const FloatPoint& control1, const FloatPoint& control2, const FloatPoint& end)
-{
-#if USE(WXGC)
- if (ensurePlatformPath())
- m_path->AddCurveToPoint(control1.x(), control1.y(), control2.x(), control2.y(), end.x(), end.y());
-#endif
-}
-
-void Path::addArcTo(const FloatPoint& point1, const FloatPoint& point2, float radius)
-{
-#if USE(WXGC)
- if (ensurePlatformPath())
- m_path->AddArcToPoint(point1.x(), point1.y(), point2.x(), point2.y(), radius);
-#endif
-}
-
-void Path::closeSubpath()
-{
-#if USE(WXGC)
- if (ensurePlatformPath())
- m_path->CloseSubpath();
-#endif
-}
-
-void Path::addArc(const FloatPoint& point, float radius, float startAngle, float endAngle, bool clockwise)
-{
-#if USE(WXGC)
- if (ensurePlatformPath())
- m_path->AddArc(point.x(), point.y(), radius, startAngle, endAngle, clockwise);
-#endif
-}
-
-void Path::addRect(const FloatRect& rect)
-{
-#if USE(WXGC)
- if (ensurePlatformPath())
- m_path->AddRectangle(rect.x(), rect.y(), rect.width(), rect.height());
-#endif
-}
-
-void Path::addEllipse(const FloatRect& rect)
-{
-#if USE(WXGC)
- if (ensurePlatformPath())
- m_path->AddEllipse(rect.x(), rect.y(), rect.width(), rect.height());
-#endif
-}
-
-void Path::transform(const AffineTransform& transform)
-{
-#if USE(WXGC)
- if (ensurePlatformPath())
- m_path->Transform(transform);
-#endif
-}
-
-void Path::apply(void* info, PathApplierFunction function) const
-{
- notImplemented();
-}
-
-bool Path::isEmpty() const
-{
-#if USE(WXGC)
- if (m_path) {
- wxDouble x, y, width, height;
- m_path->GetBox(&x, &y, &width, &height);
- return (width == 0 && height == 0);
- }
-#endif
- return true;
-}
-
-bool Path::hasCurrentPoint() const
-{
- return !isEmpty();
-}
-
-FloatPoint Path::currentPoint() const
-{
- // FIXME: return current point of subpath.
- float quietNaN = std::numeric_limits<float>::quiet_NaN();
- return FloatPoint(quietNaN, quietNaN);
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/wx/SimpleFontDataWx.cpp b/Source/WebCore/platform/graphics/wx/SimpleFontDataWx.cpp
deleted file mode 100644
index a58d3e512..000000000
--- a/Source/WebCore/platform/graphics/wx/SimpleFontDataWx.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SimpleFontData.h"
-
-#include "FontCache.h"
-#include "FloatRect.h"
-#include "FontDescription.h"
-#include <wtf/MathExtras.h>
-#include <unicode/uchar.h>
-#include <unicode/unorm.h>
-
-#if OS(DARWIN)
-#include "WebCoreSystemInterface.h"
-#endif
-
-#include <wx/defs.h>
-#include <wx/dcscreen.h>
-#include <wx/string.h>
-#include "fontprops.h"
-
-namespace WebCore
-{
-
-void SimpleFontData::platformInit()
-{
- wxFont *font = m_platformData.font();
- if (font && font->IsOk()) {
- wxFontProperties props = wxFontProperties(font);
- m_fontMetrics.setAscent(props.GetAscent());
- m_fontMetrics.setDescent(props.GetDescent());
- m_fontMetrics.setXHeight(props.GetXHeight());
- m_fontMetrics.setUnitsPerEm(1); // FIXME!
- m_fontMetrics.setLineGap(props.GetLineGap());
- m_fontMetrics.setLineSpacing(props.GetLineSpacing());
- }
-
- m_syntheticBoldOffset = 0.0f;
-
-#if OS(WINDOWS)
- m_scriptCache = 0;
- m_scriptFontProperties = 0;
- m_isSystemFont = false;
-#endif
-}
-
-void SimpleFontData::platformCharWidthInit()
-{
- m_avgCharWidth = 0.f;
- m_maxCharWidth = 0.f;
- initCharWidths();
-}
-
-void SimpleFontData::platformDestroy()
-{
-#if OS(WINDOWS)
- if (m_scriptFontProperties) {
- delete m_scriptFontProperties;
- m_scriptFontProperties = 0;
- }
-
- if (m_scriptCache)
- ScriptFreeCache(&m_scriptCache);
-#endif
-}
-
-PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
-{
- FontDescription desc = FontDescription(fontDescription);
- desc.setSpecifiedSize(scaleFactor * fontDescription.computedSize());
- FontPlatformData platformData(desc, desc.family().family());
- return SimpleFontData::create(platformData, isCustomFont(), false);
-}
-
-bool SimpleFontData::containsCharacters(const UChar* characters, int length) const
-{
- // FIXME: We will need to implement this to load non-ASCII encoding sites
-#if OS(WINDOWS)
- return wxFontContainsCharacters(m_platformData.hfont(), characters, length);
-#elif OS(DARWIN)
- return wxFontContainsCharacters(m_platformData.nsFont(), characters, length);
-#endif
- return true;
-}
-
-void SimpleFontData::determinePitch()
-{
- if (m_platformData.font() && m_platformData.font()->Ok())
- m_treatAsFixedPitch = m_platformData.font()->IsFixedWidth();
- else
- m_treatAsFixedPitch = false;
-}
-
-FloatRect SimpleFontData::platformBoundsForGlyph(Glyph) const
-{
- return FloatRect();
-}
-
-float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
-{
-#if __WXMSW__
- // under Windows / wxMSW we currently always use GDI fonts.
- return widthForGDIGlyph(glyph);
-#elif OS(DARWIN)
- float pointSize = m_platformData.size();
- CGAffineTransform m = CGAffineTransformMakeScale(pointSize, pointSize);
- CGSize advance;
- NSFont* nsfont = (NSFont*)m_platformData.nsFont();
- if (!wkGetGlyphTransformedAdvances(m_platformData.cgFont(), nsfont, &m, &glyph, &advance)) {
- // LOG_ERROR("Unable to cache glyph widths for %@ %f", [nsfont displayName], pointSize);
- advance.width = 0;
- }
- return advance.width + m_syntheticBoldOffset;
-#else
- // TODO: fix this! Make GetTextExtents a method of wxFont in 2.9
- int width = 10;
- GetTextExtent(*m_platformData.font(), (wxChar)glyph, &width, NULL);
- return width;
-#endif
-}
-
-#if OS(WINDOWS)
-SCRIPT_FONTPROPERTIES* SimpleFontData::scriptFontProperties() const
-{
- // AFAICT this is never called even by the Win port anymore.
- return 0;
-}
-
-void SimpleFontData::initGDIFont()
-{
- // unused by wx port
-}
-
-void SimpleFontData::platformCommonDestroy()
-{
- // unused by wx port
-}
-
-float SimpleFontData::widthForGDIGlyph(Glyph glyph) const
-{
- HDC hdc = GetDC(0);
- HGDIOBJ oldFont = SelectObject(hdc, m_platformData.hfont());
- int width;
- GetCharWidthI(hdc, glyph, 1, 0, &width);
- SelectObject(hdc, oldFont);
- ReleaseDC(0, hdc);
- return width;
-}
-#endif
-
-#if OS(DARWIN)
-const SimpleFontData* SimpleFontData::getCompositeFontReferenceFontData(NSFont *key) const
-{
- return 0;
-}
-
-#endif
-
-}
diff --git a/Source/WebCore/platform/graphics/wx/TransformationMatrixWx.cpp b/Source/WebCore/platform/graphics/wx/TransformationMatrixWx.cpp
deleted file mode 100644
index 0f4230df8..000000000
--- a/Source/WebCore/platform/graphics/wx/TransformationMatrixWx.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "AffineTransform.h"
-#include "TransformationMatrix.h"
-
-#include <wtf/Assertions.h>
-#include "FloatRect.h"
-#include "IntRect.h"
-
-#include <stdio.h>
-#include <wx/defs.h>
-#include <wx/graphics.h>
-
-namespace WebCore {
-
-#if USE(WXGC)
-TransformationMatrix::operator wxGraphicsMatrix() const
-{
- wxGraphicsRenderer* renderer = 0;
-#if wxUSE_CAIRO
- renderer = wxGraphicsRenderer::GetCairoRenderer();
-#else
- renderer = wxGraphicsRenderer::GetDefaultRenderer();
-#endif
- ASSERT(renderer);
-
- wxGraphicsMatrix matrix = renderer->CreateMatrix(a(), b(), c(), d(), e(), f());
- return matrix;
-}
-
-AffineTransform::operator wxGraphicsMatrix() const
-{
- wxGraphicsRenderer* renderer = 0;
-#if wxUSE_CAIRO
- renderer = wxGraphicsRenderer::GetCairoRenderer();
-#else
- renderer = wxGraphicsRenderer::GetDefaultRenderer();
-#endif
- ASSERT(renderer);
-
- wxGraphicsMatrix matrix = renderer->CreateMatrix(a(), b(), c(), d(), e(), f());
- return matrix;
-}
-#endif
-
-}