Changeset 172197 in webkit


Ignore:
Timestamp:
Aug 6, 2014 5:58:45 PM (10 years ago)
Author:
mmaxfield@apple.com
Message:

[iOS] Make document marker assets not specific to particular scale factors
https://bugs.webkit.org/show_bug.cgi?id=135671

Reviewed by Simon Fraser.

No new tests.

  • WebCore.xcodeproj/project.pbxproj:
  • platform/ios/wak/WKGraphics.mm:

(imageResourcePath):
(WKGraphicsCreateImageFromBundleWithName):

Location:
trunk/Source/WebCore
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r172195 r172197  
     12014-08-06  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        [iOS] Make document marker assets not specific to particular scale factors
     4        https://bugs.webkit.org/show_bug.cgi?id=135671
     5
     6        Reviewed by Simon Fraser.
     7
     8        No new tests.
     9
     10        * WebCore.xcodeproj/project.pbxproj:
     11        * platform/ios/wak/WKGraphics.mm:
     12        (imageResourcePath):
     13        (WKGraphicsCreateImageFromBundleWithName):
     14
    1152014-08-06  Enrica Casucci  <enrica@apple.com>
    216
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r172192 r172197  
    934934                1C21E57C183ED1FF001C289D /* IOSurfacePool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C21E57A183ED1FF001C289D /* IOSurfacePool.cpp */; };
    935935                1C21E57D183ED1FF001C289D /* IOSurfacePool.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C21E57B183ED1FF001C289D /* IOSurfacePool.h */; settings = {ATTRIBUTES = (Private, ); }; };
     936                1C2417BA1992C04100EF9938 /* SpellingDot@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1C2417B91992C04100EF9938 /* SpellingDot@3x.png */; };
    936937                1C26497A0D7E248A00BD10F2 /* DocumentLoaderMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C2649790D7E248A00BD10F2 /* DocumentLoaderMac.cpp */; };
    937938                1C26497C0D7E24EC00BD10F2 /* PageMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C26497B0D7E24EC00BD10F2 /* PageMac.cpp */; };
     
    79127913                1C21E57A183ED1FF001C289D /* IOSurfacePool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = IOSurfacePool.cpp; path = ../cg/IOSurfacePool.cpp; sourceTree = "<group>"; };
    79137914                1C21E57B183ED1FF001C289D /* IOSurfacePool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IOSurfacePool.h; path = ../cg/IOSurfacePool.h; sourceTree = "<group>"; };
     7915                1C2417B91992C04100EF9938 /* SpellingDot@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "SpellingDot@3x.png"; sourceTree = "<group>"; };
    79147916                1C2649790D7E248A00BD10F2 /* DocumentLoaderMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentLoaderMac.cpp; sourceTree = "<group>"; };
    79157917                1C26497B0D7E24EC00BD10F2 /* PageMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageMac.cpp; sourceTree = "<group>"; };
     
    1652516527                        isa = PBXGroup;
    1652616528                        children = (
     16529                                1C2417B91992C04100EF9938 /* SpellingDot@3x.png */,
    1652716530                                D02B64B014089E56006EFA21 /* DictationPhraseWithAlternativesDot.png */,
    1652816531                                D02B64B114089E56006EFA21 /* DictationPhraseWithAlternativesDot@2x.png */,
     
    2688726890                        files = (
    2688826891                                46F9D5DD0B0D60170028EE36 /* aliasCursor.png in Resources */,
     26892                                1C2417BA1992C04100EF9938 /* SpellingDot@3x.png in Resources */,
    2688926893                                46D4F2490AF97E810035385A /* cellCursor.png in Resources */,
    2689026894                                93153BDE141959F400FCF5BE /* deleteButton.png in Resources */,
  • trunk/Source/WebCore/platform/ios/wak/WKGraphics.mm

    r161603 r172197  
    9292}
    9393
    94 static NSString *imageResourcePath(const char* imageFile, bool is2x)
     94static NSString *imageResourcePath(const char* imageFile, unsigned scaleFactor)
    9595{
    96     NSString *fileName = is2x ? [NSString stringWithFormat:@"%s@2x", imageFile] : [NSString stringWithUTF8String:imageFile];
     96    NSString *fileName = scaleFactor == 1 ? [NSString stringWithUTF8String:imageFile] : [NSString stringWithFormat:@"%s@%dx", imageFile, scaleFactor];
    9797#if PLATFORM(IOS_SIMULATOR)
    9898    NSBundle *bundle = [NSBundle bundleWithIdentifier:@"com.apple.WebCore"];
     
    105105}
    106106
    107 CGImageRef WKGraphicsCreateImageFromBundleWithName (const char *image_file)
     107CGImageRef WKGraphicsCreateImageFromBundleWithName(const char *image_file)
    108108{
    109109    if (!image_file)
     
    111111
    112112    CGImageRef image = nullptr;
    113     NSData *imageData = nil;
    114 
    115     if (wkGetScreenScaleFactor() == 2) {
    116         NSString* full2xPath = imageResourcePath(image_file, true);
    117         imageData = [NSData dataWithContentsOfFile:full2xPath];
    118     }
    119     if (!imageData) {
    120         // We got here either because we didn't request hi-dpi or the @2x file doesn't exist.
    121         NSString* full1xPath = imageResourcePath(image_file, false);
    122         imageData = [NSData dataWithContentsOfFile:full1xPath];
     113    NSData *imageData = nullptr;
     114    for (unsigned scaleFactor = wkGetScreenScaleFactor(); scaleFactor > 0; --scaleFactor) {
     115        imageData = [NSData dataWithContentsOfFile:imageResourcePath(image_file, scaleFactor)];
     116        ASSERT(scaleFactor != wkGetScreenScaleFactor() || imageData);
     117        if (imageData)
     118            break;
    123119    }
    124120   
Note: See TracChangeset for help on using the changeset viewer.