Changeset 180287 in webkit


Ignore:
Timestamp:
Feb 18, 2015 1:13:29 PM (9 years ago)
Author:
ddkilzer@apple.com
Message:

Consolidate soft-linked CMTimeMakeWithSeconds() function
<http://webkit.org/b/141655>

Reviewed by Brent Fulgham.

  • Configurations/WebCore.unexp: Remove workaround for

CMTimeMakeWithSeconds() weak external.

  • WebCore.vcxproj/WebCore.vcxproj:
  • WebCore.vcxproj/WebCore.vcxproj.filters:
  • WebCore.xcodeproj/project.pbxproj:
  • Add CoreMediaSoftLink.{cpp,h} to the project.
  • platform/cf/CoreMediaSoftLink.cpp: Add.
  • platform/cf/CoreMediaSoftLink.h: Add.
  • Implement new strategy where code for soft-linking is only in one place, and the header can simply be included wherever a soft-linked method is needed.
  • platform/graphics/avfoundation/MediaTimeAVFoundation.cpp:
  • platform/graphics/avfoundation/cf/CoreMediaSoftLinking.h:
  • platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
  • platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
  • platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
  • platform/mac/PlatformClockCM.mm:
  • Remove old soft-linking strategy and include CoreMediaSoftLink.h.
  • platform/mac/SoftLinking.h:

(SOFT_LINK_FUNCTION_DECL): Add. New macro function used for
header declaration. Split out from SOFT_LINK() macro. Also
stop violating C++ standards by redeclaring an inline function
with the exact same signature as an extern "C" function. This
now matches what we do on Windows (where Visual C++ already
prevented these shenanigans).
(SOFT_LINK_FUNCTION_IMPL): Add. New macro function used for
source implementation. Split out the from SOFT_LINK() macro.

  • platform/win/SoftLinking.h:

(SOFT_LINK_FRAMEWORK): Map mac/SoftLinking.h macro name to
Windows macros so we can simplify CoreMediaSoftLink.{cpp,h}.
(SOFT_LINK_FUNCTION_DECL): Add.
(SOFT_LINK_FUNCTION_IMPL): Add.

  • New macro functions split out from SOFT_LINK_DLL_IMPORT() macro for header declaration and source implementation.
  • We assume the cdecl calling convention because that's what all Apple libraries use, and so we are able to use the exact same macro function on both Mac and Windows to simplify CoreMediaSoftLink.{cpp,h}.
Location:
trunk/Source/WebCore
Files:
2 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r180286 r180287  
     12015-02-18  David Kilzer  <ddkilzer@apple.com>
     2
     3        Consolidate soft-linked CMTimeMakeWithSeconds() function
     4        <http://webkit.org/b/141655>
     5
     6        Reviewed by Brent Fulgham.
     7
     8        * Configurations/WebCore.unexp: Remove workaround for
     9        CMTimeMakeWithSeconds() weak external.
     10
     11        * WebCore.vcxproj/WebCore.vcxproj:
     12        * WebCore.vcxproj/WebCore.vcxproj.filters:
     13        * WebCore.xcodeproj/project.pbxproj:
     14        - Add CoreMediaSoftLink.{cpp,h} to the project.
     15
     16        * platform/cf/CoreMediaSoftLink.cpp: Add.
     17        * platform/cf/CoreMediaSoftLink.h: Add.
     18        - Implement new strategy where code for soft-linking is only
     19          in one place, and the header can simply be included wherever a
     20          soft-linked method is needed.
     21
     22        * platform/graphics/avfoundation/MediaTimeAVFoundation.cpp:
     23        * platform/graphics/avfoundation/cf/CoreMediaSoftLinking.h:
     24        * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
     25        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
     26        * platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
     27        * platform/mac/PlatformClockCM.mm:
     28        - Remove old soft-linking strategy and include
     29          CoreMediaSoftLink.h.
     30
     31        * platform/mac/SoftLinking.h:
     32        (SOFT_LINK_FUNCTION_DECL): Add.  New macro function used for
     33        header declaration.  Split out from SOFT_LINK() macro.  Also
     34        stop violating C++ standards by redeclaring an inline function
     35        with the exact same signature as an extern "C" function.  This
     36        now matches what we do on Windows (where Visual C++ already
     37        prevented these shenanigans).
     38        (SOFT_LINK_FUNCTION_IMPL): Add.  New macro function used for
     39        source implementation.  Split out the from SOFT_LINK() macro.
     40
     41        * platform/win/SoftLinking.h:
     42        (SOFT_LINK_FRAMEWORK): Map mac/SoftLinking.h macro name to
     43        Windows macros so we can simplify CoreMediaSoftLink.{cpp,h}.
     44        (SOFT_LINK_FUNCTION_DECL): Add.
     45        (SOFT_LINK_FUNCTION_IMPL): Add.
     46        - New macro functions split out from SOFT_LINK_DLL_IMPORT()
     47          macro for header declaration and source implementation.
     48        - We assume the __cdecl calling convention because that's what
     49          all Apple libraries use, and so we are able to use the exact
     50          same macro function on both Mac and Windows to simplify
     51          CoreMediaSoftLink.{cpp,h}.
     52
    1532015-02-18  Brady Eidson  <beidson@apple.com>
    254
  • trunk/Source/WebCore/Configurations/WebCore.unexp

    r180282 r180287  
    5353
    5454# Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm
    55 _CMTimeMakeWithSeconds
    5655_CMTimeRangeGetEnd
    5756
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj

    r180193 r180287  
    82238223    <ClCompile Include="..\platform\win\WindowMessageBroadcaster.cpp" />
    82248224    <ClCompile Include="..\platform\cf\CFURLExtras.cpp" />
     8225    <ClCompile Include="..\platform\cf\CoreMediaSoftLink.cpp" />
    82258226    <ClCompile Include="..\platform\cf\FileSystemCF.cpp" />
    82268227    <ClCompile Include="..\platform\cf\URLCF.cpp" />
     
    1976219763    <ClInclude Include="..\platform\win\WindowsTouch.h" />
    1976319764    <ClInclude Include="..\platform\cf\CFURLExtras.h" />
     19765    <ClInclude Include="..\platform\cf\CoreMediaSoftLink.h" />
    1976419766    <ClInclude Include="..\platform\cf\win\CertificateCFWin.h" />
    1976519767    <ClInclude Include="..\platform\graphics\BitmapImage.h" />
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters

    r179810 r180287  
    1217012170      <Filter>platform\cf</Filter>
    1217112171    </ClInclude>
     12172    <ClInclude Include="..\platform\cf\CoreMediaSoftLink.h">
     12173      <Filter>platform\cf</Filter>
     12174    </ClInclude>
    1217212175    <ClInclude Include="..\platform\cf\win\CertificateCFWin.h">
    1217312176      <Filter>platform\cf\win</Filter>
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r180266 r180287  
    15941594                44311CD912E4E257000A8D19 /* DOMDocumentFragmentPrivate.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 44311CD412E4E22D000A8D19 /* DOMDocumentFragmentPrivate.h */; };
    15951595                44311F8212E4E66C000A8D19 /* DOMDocumentFragmentInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 85E711450AC5D5340053270F /* DOMDocumentFragmentInternal.h */; };
     1596                443817FF1A91B2F8006E04F2 /* CoreMediaSoftLink.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 443817FD1A91B2F8006E04F2 /* CoreMediaSoftLink.cpp */; };
     1597                443818001A91B2F8006E04F2 /* CoreMediaSoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 443817FE1A91B2F8006E04F2 /* CoreMediaSoftLink.h */; };
    15961598                443F04270E75C8FB007E5407 /* NetworkStateNotifierIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 443F04260E75C8FB007E5407 /* NetworkStateNotifierIOS.mm */; };
    15971599                444D4E230F708B2E003158E0 /* WebCoreURLResponseIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 444D4E210F708B2E003158E0 /* WebCoreURLResponseIOS.mm */; };
     
    86718673                44311CD412E4E22D000A8D19 /* DOMDocumentFragmentPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMDocumentFragmentPrivate.h; sourceTree = "<group>"; };
    86728674                44311CD512E4E22D000A8D19 /* DOMDocumentPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMDocumentPrivate.h; sourceTree = "<group>"; };
     8675                443817FD1A91B2F8006E04F2 /* CoreMediaSoftLink.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CoreMediaSoftLink.cpp; sourceTree = "<group>"; };
     8676                443817FE1A91B2F8006E04F2 /* CoreMediaSoftLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CoreMediaSoftLink.h; sourceTree = "<group>"; };
    86738677                443F04260E75C8FB007E5407 /* NetworkStateNotifierIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetworkStateNotifierIOS.mm; sourceTree = "<group>"; };
    86748678                444D4E210F708B2E003158E0 /* WebCoreURLResponseIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreURLResponseIOS.mm; sourceTree = "<group>"; };
     
    1509515099                        isa = PBXGroup;
    1509615100                        children = (
     15101                                443817FD1A91B2F8006E04F2 /* CoreMediaSoftLink.cpp */,
     15102                                443817FE1A91B2F8006E04F2 /* CoreMediaSoftLink.h */,
    1509715103                                E1A8E56417552B2A007488E7 /* CFURLExtras.cpp */,
    1509815104                                E1A8E56517552B2A007488E7 /* CFURLExtras.h */,
     
    2370223708                                9746AF2114F4DDE6003E7A71 /* Coordinates.h in Headers */,
    2370323709                                CE1252371A15BDBE00864480 /* CoreGraphicsSPI.h in Headers */,
     23710                                443818001A91B2F8006E04F2 /* CoreMediaSoftLink.h in Headers */,
    2370423711                                1C6466251A12C38E0094603C /* CoreTextSPI.h in Headers */,
    2370523712                                862F129E18C1576F005C54AF /* CountedUserActivity.h in Headers */,
     
    2739427401                                E13F01F11270E19000DFBA71 /* CookieStorageMac.mm in Sources */,
    2739527402                                9746AF2114F4DDE6003E7A72 /* Coordinates.cpp in Sources */,
     27403                                443817FF1A91B2F8006E04F2 /* CoreMediaSoftLink.cpp in Sources */,
    2739627404                                BC5EB9500E82056B00B25965 /* CounterDirectives.cpp in Sources */,
    2739727405                                9392F1500AD1862300691BD4 /* CounterNode.cpp in Sources */,
  • trunk/Source/WebCore/platform/graphics/avfoundation/MediaTimeAVFoundation.cpp

    r176863 r180287  
    2929#if USE(AVFOUNDATION)
    3030
     31#include "CoreMediaSoftLink.h"
     32
    3133#if PLATFORM(WIN)
    3234#include <CoreMedia/CoreMedia.h>
     
    3537#include "SoftLinking.h"
    3638SOFT_LINK_FRAMEWORK(CoreMedia)
    37 SOFT_LINK(CoreMedia, CMTimeMakeWithSeconds, CMTime, (Float64 seconds, int32_t preferredTimeScale), (seconds, preferredTimeScale))
    3839SOFT_LINK(CoreMedia, CMTimeMake, CMTime, (int64_t value, int32_t timescale), (value, timescale))
    3940#endif
  • trunk/Source/WebCore/platform/graphics/avfoundation/cf/CoreMediaSoftLinking.h

    r165676 r180287  
    5151#define CMTimeMakeFromDictionary softLink_CMTimeMakeFromDictionary
    5252
    53 SOFT_LINK_DLL_IMPORT(CoreMedia, CMTimeMakeWithSeconds, CMTime, __cdecl, (Float64 seconds, int32_t preferredTimeScale), (seconds, preferredTimeScale))
    54 #define CMTimeMakeWithSeconds softLink_CMTimeMakeWithSeconds
    55 
    5653SOFT_LINK_DLL_IMPORT(CoreMedia, CMTimeRangeGetEnd, CMTime, __cdecl, (CMTimeRange range), (range))
    5754#define CMTimeRangeGetEnd softLink_CMTimeRangeGetEnd
  • trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp

    r178367 r180287  
    7575// The softlink header files must be included after the AVCF and CoreMedia header files.
    7676#include "AVFoundationCFSoftLinking.h"
     77#include "CoreMediaSoftLink.h"
    7778#include "CoreMediaSoftLinking.h"
    7879
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

    r180187 r180287  
    3636#import "CDMSessionAVFoundationObjC.h"
    3737#import "Cookie.h"
     38#import "CoreMediaSoftLink.h"
    3839#import "ExceptionCodePlaceholder.h"
    3940#import "FloatConversion.h"
     
    156157
    157158SOFT_LINK(CoreMedia, CMTimeCompare, int32_t, (CMTime time1, CMTime time2), (time1, time2))
    158 SOFT_LINK(CoreMedia, CMTimeMakeWithSeconds, CMTime, (Float64 seconds, int32_t preferredTimeScale), (seconds, preferredTimeScale))
    159159SOFT_LINK(CoreMedia, CMTimeGetSeconds, Float64, (CMTime time), (time))
    160160SOFT_LINK(CoreMedia, CMTimeRangeGetEnd, CMTime, (CMTimeRange range), (range))
  • trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm

    r179827 r180287  
    3232
    3333#import "AVKitSPI.h"
     34#import "CoreMediaSoftLink.h"
    3435#import "Logging.h"
    3536#import "GeometryUtilities.h"
     
    6667
    6768SOFT_LINK_FRAMEWORK(CoreMedia)
    68 SOFT_LINK(CoreMedia, CMTimeMakeWithSeconds, CMTime, (Float64 seconds, int32_t preferredTimeScale), (seconds, preferredTimeScale))
    6969SOFT_LINK(CoreMedia, CMTimeGetSeconds, Float64, (CMTime time), (time))
    7070SOFT_LINK(CoreMedia, CMTimeMake, CMTime, (int64_t value, int32_t timescale), (value, timescale))
  • trunk/Source/WebCore/platform/mac/PlatformClockCM.mm

    r173318 r180287  
    3030#import "PlatformClockCM.h"
    3131
     32#import "CoreMediaSoftLink.h"
    3233#import "MediaTimeAVFoundation.h"
    3334#import "SoftLinking.h"
     
    4950SOFT_LINK(CoreMedia, CMTimebaseGetTime, CMTime, (CMTimebaseRef timebase), (timebase))
    5051SOFT_LINK(CoreMedia, CMTimebaseSetRate, OSStatus, (CMTimebaseRef timebase, Float64 rate), (timebase, rate))
    51 SOFT_LINK(CoreMedia, CMTimeMakeWithSeconds, CMTime, (Float64 seconds, int32_t preferredTimeScale), (seconds, preferredTimeScale))
    5252SOFT_LINK(CoreMedia, CMTimeGetSeconds, Float64, (CMTime time), (time))
    5353
  • trunk/Source/WebCore/platform/mac/SoftLinking.h

    r180154 r180287  
    110110    }
    111111
     112#define SOFT_LINK_FUNCTION_DECL(functionName, resultType, parameterDeclarations, parameterNames) \
     113    WTF_EXTERN_C_BEGIN \
     114    resultType functionName parameterDeclarations; \
     115    WTF_EXTERN_C_END \
     116    namespace WebCore { \
     117    extern resultType (*softLink##functionName) parameterDeclarations; \
     118    } \
     119    inline resultType softLink_##functionName parameterDeclarations \
     120    { \
     121        return WebCore::softLink##functionName parameterNames; \
     122    }
     123
     124#define SOFT_LINK_FUNCTION_IMPL(framework, functionName, resultType, parameterDeclarations, parameterNames) \
     125    WTF_EXTERN_C_BEGIN \
     126    resultType functionName parameterDeclarations; \
     127    WTF_EXTERN_C_END \
     128    namespace WebCore { \
     129    static resultType init##functionName parameterDeclarations; \
     130    resultType (*softLink##functionName) parameterDeclarations = init##functionName; \
     131    static resultType init##functionName parameterDeclarations \
     132    { \
     133        static dispatch_once_t once; \
     134        dispatch_once(&once, ^{ \
     135            softLink##functionName = (resultType (*) parameterDeclarations) dlsym(framework##Library(), #functionName); \
     136            ASSERT_WITH_MESSAGE(softLink##functionName, "%s", dlerror()); \
     137        }); \
     138        return softLink##functionName parameterNames; \
     139    } \
     140    }
     141
    112142#define SOFT_LINK_MAY_FAIL(framework, functionName, resultType, parameterDeclarations, parameterNames) \
    113143    WTF_EXTERN_C_BEGIN \
  • trunk/Source/WebCore/platform/win/SoftLinking.h

    r180250 r180287  
    2828#include <windows.h>
    2929#include <wtf/Assertions.h>
     30
     31#ifdef DEBUG_ALL
     32#define SOFT_LINK_FRAMEWORK(framework) SOFT_LINK_DEBUG_LIBRARY(framework)
     33#else
     34#define SOFT_LINK_FRAMEWORK(framework) SOFT_LINK_LIBRARY(framework)
     35#endif
    3036
    3137#define SOFT_LINK_LIBRARY_HELPER(lib, suffix) \
     
    111117    }
    112118
     119#define SOFT_LINK_FUNCTION_DECL(functionName, resultType, parameterDeclarations, parameterNames) \
     120    namespace WebCore { \
     121    extern resultType(__cdecl*softLink##functionName) parameterDeclarations; \
     122    } \
     123    inline resultType softLink_##functionName parameterDeclarations \
     124    { \
     125        return WebCore::softLink##functionName parameterNames; \
     126    }
     127
     128#define SOFT_LINK_FUNCTION_IMPL(library, functionName, resultType, parameterDeclarations, parameterNames) \
     129    namespace WebCore { \
     130    static resultType __cdecl init##functionName parameterDeclarations; \
     131    resultType(__cdecl*softLink##functionName) parameterDeclarations = init##functionName; \
     132    static resultType __cdecl init##functionName parameterDeclarations \
     133    { \
     134        softLink##functionName = reinterpret_cast<resultType (__cdecl*)parameterDeclarations>(SOFT_LINK_GETPROCADDRESS(library##Library(), #functionName)); \
     135        ASSERT(softLink##functionName); \
     136        return softLink##functionName parameterNames; \
     137    } \
     138    }
     139
    113140#define SOFT_LINK_DLL_IMPORT_OPTIONAL(library, functionName, resultType, callingConvention, parameterDeclarations) \
    114141    typedef resultType (callingConvention *functionName##PtrType) parameterDeclarations; \
Note: See TracChangeset for help on using the changeset viewer.