Title: [172197] trunk/Source/WebCore
Revision
172197
Author
mmaxfi...@apple.com
Date
2014-08-06 17:58:45 -0700 (Wed, 06 Aug 2014)

Log 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):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (172196 => 172197)


--- trunk/Source/WebCore/ChangeLog	2014-08-07 00:48:01 UTC (rev 172196)
+++ trunk/Source/WebCore/ChangeLog	2014-08-07 00:58:45 UTC (rev 172197)
@@ -1,3 +1,17 @@
+2014-08-06  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        [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):
+
 2014-08-06  Enrica Casucci  <enr...@apple.com>
 
         Services menu doesn't show up after you defocus/refocus the Safari window.

Added: trunk/Source/WebCore/Resources/spelling...@3x.png (0 => 172197)


--- trunk/Source/WebCore/Resources/spelling...@3x.png	                        (rev 0)
+++ trunk/Source/WebCore/Resources/spelling...@3x.png	2014-08-07 00:58:45 UTC (rev 172197)
@@ -0,0 +1,5 @@
+\x89PNG
+
+
+IHDR	\xB8\xCDTtEXtSoftwareAdobe ImageReadyq\xC9e<\xB0IDATx\xDAt\x91\xB1
+\x830E\xEF\xA4\x92:\xA5;f\xF0a\x8AԑX6\xF0.\xA9\xD9\x92\xDB\xCB\xCFq\x8E\xED"_\xFE\x96u\xFEe\xBA\xC3=\xECaG8\xC0\xBC\xD28R\xD6\xCD\xC2o\xF8IE\x9D\xF9\xBF\xFA)\xF5Č\xB0\xE8"b\xB2\xC3\xF7\x88:/\xD6Ѐ\xF3\xF0W\xC8$3_\x8C\x96ŷ\xC0\xB6;\xBB\xC0\xE2\xC2*\xA0\x9B\xAB^\xC0\xBEE\v\xA5\xC4W0?A8\xB6\xC0q\xFD\xC0ұt%B\xA44\xD94\xEA)e\xCD6\xDAf\xAC\xAB\x8Dn\xF9\xFB*}\x9C\xAC:\xF2\xED%IEND\xAEB`\x82
\ No newline at end of file

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (172196 => 172197)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2014-08-07 00:48:01 UTC (rev 172196)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2014-08-07 00:58:45 UTC (rev 172197)
@@ -933,6 +933,7 @@
 		1C18DA59181AF6A500C4EF22 /* TextPainter.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C18DA57181AF6A500C4EF22 /* TextPainter.h */; };
 		1C21E57C183ED1FF001C289D /* IOSurfacePool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C21E57A183ED1FF001C289D /* IOSurfacePool.cpp */; };
 		1C21E57D183ED1FF001C289D /* IOSurfacePool.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C21E57B183ED1FF001C289D /* IOSurfacePool.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		1C2417BA1992C04100EF9938 /* spelling...@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1C2417B91992C04100EF9938 /* spelling...@3x.png */; };
 		1C26497A0D7E248A00BD10F2 /* DocumentLoaderMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C2649790D7E248A00BD10F2 /* DocumentLoaderMac.cpp */; };
 		1C26497C0D7E24EC00BD10F2 /* PageMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C26497B0D7E24EC00BD10F2 /* PageMac.cpp */; };
 		1C4C8F020AD85D87009475CE /* DeleteButtonController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C4C8F000AD85D87009475CE /* DeleteButtonController.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -7911,6 +7912,7 @@
 		1C18DA57181AF6A500C4EF22 /* TextPainter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextPainter.h; sourceTree = "<group>"; };
 		1C21E57A183ED1FF001C289D /* IOSurfacePool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = IOSurfacePool.cpp; path = ../cg/IOSurfacePool.cpp; sourceTree = "<group>"; };
 		1C21E57B183ED1FF001C289D /* IOSurfacePool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IOSurfacePool.h; path = ../cg/IOSurfacePool.h; sourceTree = "<group>"; };
+		1C2417B91992C04100EF9938 /* spelling...@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "spelling...@3x.png"; sourceTree = "<group>"; };
 		1C2649790D7E248A00BD10F2 /* DocumentLoaderMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentLoaderMac.cpp; sourceTree = "<group>"; };
 		1C26497B0D7E24EC00BD10F2 /* PageMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageMac.cpp; sourceTree = "<group>"; };
 		1C4C8EFF0AD85D87009475CE /* DeleteButtonController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeleteButtonController.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
@@ -16524,6 +16526,7 @@
 		65998A650E5F5FD3004E097A /* images */ = {
 			isa = PBXGroup;
 			children = (
+				1C2417B91992C04100EF9938 /* spelling...@3x.png */,
 				D02B64B014089E56006EFA21 /* DictationPhraseWithAlternativesDot.png */,
 				D02B64B114089E56006EFA21 /* dictationphrasewithalternatives...@2x.png */,
 				BE8C753010681324001E93F5 /* SpellingDot.png */,
@@ -26886,6 +26889,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				46F9D5DD0B0D60170028EE36 /* aliasCursor.png in Resources */,
+				1C2417BA1992C04100EF9938 /* spelling...@3x.png in Resources */,
 				46D4F2490AF97E810035385A /* cellCursor.png in Resources */,
 				93153BDE141959F400FCF5BE /* deleteButton.png in Resources */,
 				93153BCD1417FBBF00FCF5BE /* deletebut...@2x.png in Resources */,

Modified: trunk/Source/WebCore/platform/ios/wak/WKGraphics.mm (172196 => 172197)


--- trunk/Source/WebCore/platform/ios/wak/WKGraphics.mm	2014-08-07 00:48:01 UTC (rev 172196)
+++ trunk/Source/WebCore/platform/ios/wak/WKGraphics.mm	2014-08-07 00:58:45 UTC (rev 172197)
@@ -91,9 +91,9 @@
     return threadContext->currentCGContext;
 }
 
-static NSString *imageResourcePath(const char* imageFile, bool is2x)
+static NSString *imageResourcePath(const char* imageFile, unsigned scaleFactor)
 {
-    NSString *fileName = is2x ? [NSString stringWithFormat:@"%s@2x", imageFile] : [NSString stringWithUTF8String:imageFile];
+    NSString *fileName = scaleFactor == 1 ? [NSString stringWithUTF8String:imageFile] : [NSString stringWithFormat:@"%s@%dx", imageFile, scaleFactor];
 #if PLATFORM(IOS_SIMULATOR)
     NSBundle *bundle = [NSBundle bundleWithIdentifier:@"com.apple.WebCore"];
     return [bundle pathForResource:fileName ofType:@"png"];
@@ -104,23 +104,19 @@
 #endif
 }
 
-CGImageRef WKGraphicsCreateImageFromBundleWithName (const char *image_file)
+CGImageRef WKGraphicsCreateImageFromBundleWithName(const char *image_file)
 {
     if (!image_file)
         return NULL;
 
     CGImageRef image = nullptr;
-    NSData *imageData = nil;
-
-    if (wkGetScreenScaleFactor() == 2) {
-        NSString* full2xPath = imageResourcePath(image_file, true);
-        imageData = [NSData dataWithContentsOfFile:full2xPath];
+    NSData *imageData = nullptr;
+    for (unsigned scaleFactor = wkGetScreenScaleFactor(); scaleFactor > 0; --scaleFactor) {
+        imageData = [NSData dataWithContentsOfFile:imageResourcePath(image_file, scaleFactor)];
+        ASSERT(scaleFactor != wkGetScreenScaleFactor() || imageData);
+        if (imageData)
+            break;
     }
-    if (!imageData) {
-        // We got here either because we didn't request hi-dpi or the @2x file doesn't exist.
-        NSString* full1xPath = imageResourcePath(image_file, false);
-        imageData = [NSData dataWithContentsOfFile:full1xPath];
-    }
     
     if (imageData) {
         RetainPtr<CGDataProviderRef> dataProvider = adoptCF(CGDataProviderCreateWithCFData(reinterpret_cast<CFDataRef>(imageData)));
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to