first cut at making iOS work

Replace __arm__ with SK_CPU_ARM
add support for iOS simulator and device
fix const warning in iOSSampleApp
update gyp files

https://code.google.com/p/skia/issues/detail?id=900
tracks fixing missing arm assembly
Review URL: https://codereview.appspot.com/6552045

git-svn-id: http://skia.googlecode.com/svn/trunk@5606 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
caryclark@google.com 2012-09-20 15:45:41 +00:00
parent db545aec72
commit 867cbd8bc2
20 changed files with 155 additions and 85 deletions

View File

@ -29,8 +29,8 @@
@property (nonatomic, retain) SkOptionListItem* fCurrentList;
- (void)registerMenus:(const SkTDArray<SkOSMenu*>*)menus;
- (void)updateMenu:(const SkOSMenu*)menu;
- (void)loadMenu:(const SkOSMenu*)menu;
- (void)updateMenu:(SkOSMenu*)menu;
- (void)loadMenu:(SkOSMenu*)menu;
- (UITableViewCell*)createAction:(NSString*)title;
- (UITableViewCell*)createSlider:(NSString*)title min:(float)min max:(float)max default:(float)value;

View File

@ -1,5 +1,6 @@
#import "SkOptionsTableViewController.h"
#include "SkEvent.h"
#include "SkTArray.h"
@implementation SkOptionItem
@synthesize fCell, fItem;
@ -31,7 +32,7 @@
//SkUIViewOptionsDelegate
- (void) view:(SkUIView*)view didAddMenu:(const SkOSMenu*)menu {}
- (void) view:(SkUIView*)view didUpdateMenu:(const SkOSMenu*)menu {
- (void) view:(SkUIView*)view didUpdateMenu:(SkOSMenu*)menu {
[self updateMenu:menu];
}
@ -65,7 +66,7 @@
[self.tableView reloadData];
}
- (void)loadMenu:(const SkOSMenu*)menu {
- (void)loadMenu:(SkOSMenu*)menu {
const SkOSMenu::Item* menuitems[menu->getCount()];
menu->getItems(menuitems);
for (int i = 0; i < menu->getCount(); ++i) {
@ -81,8 +82,9 @@
int count = 0;
SkOSMenu::FindListItemCount(*item->getEvent(), &count);
SkString options[count];
SkOSMenu::FindListItems(*item->getEvent(), options);
SkTArray<SkString> options;
options.resize_back(count);
SkOSMenu::FindListItems(*item->getEvent(), &options.front());
for (int i = 0; i < count; ++i)
[List.fOptions addOption:[NSString stringWithUTF8String:options[i].c_str()]];
SkOSMenu::FindListIndex(*item->getEvent(), item->getSlotName(), &value);

View File

@ -20,7 +20,7 @@ class SkEvent;
@optional
// Called when the view needs to handle adding an SkOSMenu
- (void) view:(SkUIView*)view didAddMenu:(const SkOSMenu*)menu;
- (void) view:(SkUIView*)view didUpdateMenu:(const SkOSMenu*)menu;
- (void) view:(SkUIView*)view didUpdateMenu:(SkOSMenu*)menu;
@end
@interface SkUIView : UIView {
@ -40,7 +40,7 @@ class SkEvent;
- (void)setSkTitle:(const char*)title;
- (void)onAddMenu:(const SkOSMenu*)menu;
- (void)onUpdateMenu:(const SkOSMenu*)menu;
- (void)onUpdateMenu:(SkOSMenu*)menu;
- (void)postInvalWithRect:(const SkIRect*)rectOrNil;
- (BOOL)onHandleEvent:(const SkEvent&)event;
@end

View File

@ -97,7 +97,7 @@
- (void)onAddMenu:(const SkOSMenu*)menu {
[self.fOptionsDelegate view:self didAddMenu:menu];
}
- (void)onUpdateMenu:(const SkOSMenu*)menu {
- (void)onUpdateMenu:(SkOSMenu*)menu {
[self.fOptionsDelegate view:self didUpdateMenu:menu];
}

View File

@ -204,28 +204,75 @@
'../samplecode/SampleDecode.cpp',
],
'sources': [
'../experimental/iOSSampleApp/SkIOSNotifier.mm',
'../experimental/iOSSampleApp/SkTime_iOS.mm',
'../experimental/iOSSampleApp/SkUIDetailViewController.mm',
'../experimental/iOSSampleApp/SkUIRootViewController.mm',
'../experimental/iOSSampleApp/SkUIView_shell.mm',
'../src/views/mac/SkEventNotifier.h',
'../src/views/mac/SkEventNotifier.mm',
'../experimental/iOSSampleApp/SkiOSSampleApp-Base.xcconfig',
'../experimental/iOSSampleApp/SkiOSSampleApp-Debug.xcconfig',
'../experimental/iOSSampleApp/SkiOSSampleApp-Release.xcconfig',
'../experimental/iOSSampleApp/iOSSampleApp-Info.plist',
'../experimental/iOSSampleApp/iOSSampleApp_Prefix.pch',
'../experimental/iOSSampleApp/Shared/main.m',
'../experimental/iOSSampleApp/Shared/SkOptionListController.h',
'../experimental/iOSSampleApp/Shared/SkOptionListController.mm',
'../experimental/iOSSampleApp/Shared/SkUIRootViewController.h',
'../experimental/iOSSampleApp/Shared/SkUIRootViewController.mm',
'../experimental/iOSSampleApp/Shared/SkOptionsTableViewController.h',
'../experimental/iOSSampleApp/Shared/SkOptionsTableViewController.mm',
'../experimental/iOSSampleApp/Shared/SkUIView.h',
'../experimental/iOSSampleApp/Shared/SkUIView.mm',
'../experimental/iOSSampleApp/Shared/SkUIDetailViewController.h',
'../experimental/iOSSampleApp/Shared/SkUIDetailViewController.mm',
'../experimental/iOSSampleApp/Shared/skia_ios.mm',
# iPad
'../experimental/iOSSampleApp/iPad/AppDelegate_iPad.h',
'../experimental/iOSSampleApp/iPad/AppDelegate_iPad.mm',
'../experimental/iOSSampleApp/iPad/SkUISplitViewController.h',
'../experimental/iOSSampleApp/iPad/SkUISplitViewController.mm',
'../experimental/iOSSampleApp/iPad/MainWindow_iPad.xib',
# iPhone
'../experimental/iOSSampleApp/iPhone/AppDelegate_iPhone.h',
'../experimental/iOSSampleApp/iPhone/AppDelegate_iPhone.mm',
'../experimental/iOSSampleApp/iPhone/SkUINavigationController.h',
'../experimental/iOSSampleApp/iPhone/SkUINavigationController.mm',
'../experimental/iOSSampleApp/iPhone/MainWindow_iPhone.xib',
'../src/views/ios/SkOSWindow_iOS.mm',
'../src/utils/ios/SkImageDecoder_iOS.mm',
'../src/utils/ios/SkStream_NSData.mm',
'../src/utils/ios/SkOSFile_iOS.mm',
'../include/utils/mac/SkCGUtils.h',
'../src/utils/mac/SkCreateCGImageRef.cpp',
'../experimental/iOSSampleApp/SkiOSSampleApp-Debug.xcconfig',
'../experimental/iOSSampleApp/SkiOSSampleApp-Release.xcconfig',
],
'link_settings': {
'variables': {
'ios_sdk_version%': '5.1',
},
'conditions' : [
[ 'skia_arch_type == "x86"', {
'variables': {
'ios_sdk_dir%': '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator',
},
}],
[ 'skia_arch_type == "arm"', {
'variables': {
'ios_sdk_dir%': '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS',
},
}],
],
'libraries': [
'<(ios_sdk_dir)<(ios_sdk_version).sdk/System/Library/Frameworks/CoreFoundation.framework',
'<(ios_sdk_dir)<(ios_sdk_version).sdk/System/Library/Frameworks/CoreGraphics.framework',
'<(ios_sdk_dir)<(ios_sdk_version).sdk/System/Library/Frameworks/CoreText.framework',
'<(ios_sdk_dir)<(ios_sdk_version).sdk/System/Library/Frameworks/UIKit.framework',
'<(ios_sdk_dir)<(ios_sdk_version).sdk/System/Library/Frameworks/Foundation.framework',
'<(ios_sdk_dir)<(ios_sdk_version).sdk/System/Library/Frameworks/QuartzCore.framework',
'<(ios_sdk_dir)<(ios_sdk_version).sdk/System/Library/Frameworks/OpenGLES.framework',
],
},
'include_dirs' : [
'../experimental/iOSSampleApp',
'../experimental/iOSSampleApp/iPad',

View File

@ -221,7 +221,12 @@
},
},
'xcode_settings': {
'ARCHS': 'armv7',
'CODE_SIGNING_REQUIRED': 'NO',
'CODE_SIGN_IDENTITY[sdk=iphoneos*]': '',
'SYMROOT': '<(DEPTH)/xcodebuild',
'SDKROOT': 'iphoneos',
'OTHER_CPLUSPLUSFLAGS': '-fvisibility=hidden -fvisibility-inlines-hidden',
},
},
],

View File

@ -57,14 +57,29 @@
'../include/utils/mac/SkCGUtils.h',
],
'link_settings': {
'variables': {
'ios_sdk_version%': '5.1',
},
'conditions' : [
[ 'skia_arch_type == "x86"', {
'variables': {
'ios_sdk_dir%': '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator',
},
}],
[ 'skia_arch_type == "arm"', {
'variables': {
'ios_sdk_dir%': '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS',
},
}],
],
'libraries': [
'/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/System/Library/Frameworks/CoreFoundation.framework',
'/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/System/Library/Frameworks/CoreGraphics.framework',
'/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/System/Library/Frameworks/CoreText.framework',
'/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/System/Library/Frameworks/UIKit.framework',
'/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/System/Library/Frameworks/Foundation.framework',
'/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/System/Library/Frameworks/QuartzCore.framework',
'/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/System/Library/Frameworks/OpenGLES.framework',
'<(ios_sdk_dir)<(ios_sdk_version).sdk/System/Library/Frameworks/CoreFoundation.framework',
'<(ios_sdk_dir)<(ios_sdk_version).sdk/System/Library/Frameworks/CoreGraphics.framework',
'<(ios_sdk_dir)<(ios_sdk_version).sdk/System/Library/Frameworks/CoreText.framework',
'<(ios_sdk_dir)<(ios_sdk_version).sdk/System/Library/Frameworks/UIKit.framework',
'<(ios_sdk_dir)<(ios_sdk_version).sdk/System/Library/Frameworks/Foundation.framework',
'<(ios_sdk_dir)<(ios_sdk_version).sdk/System/Library/Frameworks/QuartzCore.framework',
'<(ios_sdk_dir)<(ios_sdk_version).sdk/System/Library/Frameworks/OpenGLES.framework',
],
},
}],

View File

@ -28,7 +28,7 @@
'../src/opts',
],
'conditions': [
[ 'skia_arch_type == "x86"', {
[ 'skia_arch_type == "x86" and skia_os != "ios"', {
'conditions': [
[ 'skia_os in ["linux", "freebsd", "openbsd", "solaris"]', {
'cflags': [
@ -71,10 +71,16 @@
'dependencies': [
'opts_neon',
]
}]
}],
[ 'skia_os == "ios"', {
'sources!': [
# this needs to be rewritten to be xcode-friendly
'../src/opts/memset.arm.S',
],
}],
],
}],
[ 'skia_arch_type == "arm" and armv7 != 1', {
[ '(skia_arch_type == "arm" and armv7 == 0) or (skia_arch_type == "x86" and skia_os == "ios")', {
'sources': [
'../src/opts/SkBitmapProcState_opts_none.cpp',
'../src/opts/SkBlitRow_opts_none.cpp',

View File

@ -92,8 +92,12 @@
],
'sources': [
'../src/ports/SkFontHost_mac_coretext.cpp',
'../src/utils/mac/SkStream_mac.cpp',
'../src/ports/SkThread_pthread.cpp',
],
'sources!': [
'../src/ports/SkFontHost_tables.cpp',
],
}],
[ 'skia_os == "win"', {
'include_dirs': [

View File

@ -190,7 +190,7 @@ inline bool SkFixedNearlyZero(SkFixed x, SkFixed tolerance = SK_FixedNearlyZero)
#define SkFixedSquare(a) SkFixedSquare_longlong(a)
#endif
#if defined(__arm__) && !defined(__thumb__)
#if defined(SK_CPU_ARM) && !defined(__thumb__)
/* This guy does not handle NaN or other obscurities, but is faster than
than (int)(x*65536) when we only have software floats
*/

View File

@ -40,7 +40,7 @@ int32_t SkSqrtBits(int32_t value, int bitBias);
//! Returns the number of leading zero bits (0...32)
int SkCLZ_portable(uint32_t);
#if defined(__arm__)
#if defined(SK_CPU_ARM)
#define SkCLZ(x) __builtin_clz(x)
#endif

View File

@ -13,7 +13,7 @@
#include "SkString.h"
#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID)
#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_IOS)
#include <dirent.h>
#endif
@ -58,7 +58,7 @@ public:
#ifdef SK_BUILD_FOR_WIN
HANDLE fHandle;
uint16_t* fPath16;
#elif defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID)
#elif defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_IOS)
DIR* fDIR;
SkString fPath, fSuffix;
#endif

View File

@ -285,7 +285,7 @@
#ifndef SK_OVERRIDE
#if defined(_MSC_VER)
#define SK_OVERRIDE override
#elif defined(__clang__)
#elif defined(__clang__) && !defined(SK_BUILD_FOR_IOS)
#if __has_feature(cxx_override_control)
// Some documentation suggests we should be using __attribute__((override)),
// but it doesn't work.
@ -326,48 +326,3 @@
#ifndef SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
#define SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 1
#endif
//////////////////////////////////////////////////////////////////////
// ARM defines
#if defined(__GNUC__) && defined(__arm__)
# define SK_ARM_ARCH 3
# if defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__) \
|| defined(_ARM_ARCH_4)
# undef SK_ARM_ARCH
# define SK_ARM_ARCH 4
# endif
# if defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) \
|| defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) \
|| defined(__ARM_ARCH_5TEJ__) || defined(_ARM_ARCH_5)
# undef SK_ARM_ARCH
# define SK_ARM_ARCH 5
# endif
# if defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \
|| defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) \
|| defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) \
|| defined(__ARM_ARCH_6M__) || defined(_ARM_ARCH_6)
# undef SK_ARM_ARCH
# define SK_ARM_ARCH 6
# endif
# if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \
|| defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) \
|| defined(__ARM_ARCH_7EM__) || defined(_ARM_ARCH_7)
# undef SK_ARM_ARCH
# define SK_ARM_ARCH 7
# endif
# undef SK_ARM_HAS_EDSP
# if defined(__thumb2__) && (SK_ARM_ARCH >= 6) \
|| !defined(__thumb__) \
&& ((SK_ARM_ARCH > 5) || defined(__ARM_ARCH_5E__) \
|| defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_5TEJ__))
# define SK_ARM_HAS_EDSP 1
# endif
#endif

View File

@ -143,6 +143,40 @@
#endif
#endif
//////////////////////////////////////////////////////////////////////
// ARM defines
#if defined(__arm__) && (!defined(__APPLE__) || !TARGET_IPHONE_SIMULATOR)
#define SK_CPU_ARM
#if defined(__GNUC__)
#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \
|| defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) \
|| defined(__ARM_ARCH_7EM__) || defined(_ARM_ARCH_7)
#define SK_ARM_ARCH 7
#elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \
|| defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) \
|| defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) \
|| defined(__ARM_ARCH_6M__) || defined(_ARM_ARCH_6)
#define SK_ARM_ARCH 6
#elif defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) \
|| defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) \
|| defined(__ARM_ARCH_5TEJ__) || defined(_ARM_ARCH_5)
#define SK_ARM_ARCH 5
#elif defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__) || defined(_ARM_ARCH_4)
#define SK_ARM_ARCH 4
#else
#define SK_ARM_ARCH 3
#endif
#if defined(__thumb2__) && (SK_ARM_ARCH >= 6) \
|| !defined(__thumb__) && ((SK_ARM_ARCH > 5) || defined(__ARM_ARCH_5E__) \
|| defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_5TEJ__))
#define SK_ARM_HAS_EDSP
#endif
#endif
#endif
//////////////////////////////////////////////////////////////////////
/**

View File

@ -35,7 +35,7 @@ protected:
virtual void onHandleInval(const SkIRect&);
// overrides from SkView
virtual void onAddMenu(const SkOSMenu*);
virtual void onUpdateMenu(const SkOSMenu*);
virtual void onUpdateMenu(SkOSMenu*);
virtual void onSetTitle(const char[]);
private:

View File

@ -21,9 +21,9 @@
#define SK_ARM_NEON_MODE_ALWAYS 1
#define SK_ARM_NEON_MODE_DYNAMIC 2
#if defined(__arm__) && defined(__ARM_HAVE_OPTIONAL_NEON_SUPPORT)
#if defined(SK_CPU_ARM) && defined(__ARM_HAVE_OPTIONAL_NEON_SUPPORT)
# define SK_ARM_NEON_MODE SK_ARM_NEON_MODE_DYNAMIC
#elif defined(__arm__) && defined(__ARM_HAVE_NEON)
#elif defined(SK_CPU_ARM) && defined(__ARM_HAVE_NEON)
# define SK_ARM_NEON_MODE SK_ARM_NEON_MODE_ALWAYS
#else
# define SK_ARM_NEON_MODE SK_ARM_NEON_MODE_NONE

View File

@ -29,7 +29,8 @@ extern "C" void arm_memset32(uint32_t* dst, uint32_t value, int count);
#endif
SkMemset16Proc SkMemset16GetPlatformProc() {
#if !defined(SK_CPU_LENDIAN)
// FIXME: memset.arm.S is using syntax incompatible with XCode
#if !defined(SK_CPU_LENDIAN) || defined(SK_BUILD_FOR_IOS)
return NULL;
#elif SK_ARM_NEON_IS_DYNAMIC
if (sk_cpu_arm_has_neon()) {
@ -45,7 +46,8 @@ SkMemset16Proc SkMemset16GetPlatformProc() {
}
SkMemset32Proc SkMemset32GetPlatformProc() {
#if !defined(SK_CPU_LENDIAN)
// FIXME: memset.arm.S is using syntax incompatible with XCode
#if !defined(SK_CPU_LENDIAN) || defined(SK_BUILD_FOR_IOS)
return NULL;
#elif SK_ARM_NEON_IS_DYNAMIC
if (sk_cpu_arm_has_neon()) {

View File

@ -138,11 +138,11 @@ static void toString(const void* text, size_t byteLen, SkPaint::TextEncoding enc
byteLen > 32 ? "..." : "");
break;
case SkPaint::kUTF16_TextEncoding:
str->appendf("\"%.*S\"%s", SkMax32(byteLen, 32), (const wchar_t*) text,
str->appendf("\"%.*ls\"%s", SkMax32(byteLen, 32), (const wchar_t*) text,
byteLen > 64 ? "..." : "");
break;
case SkPaint::kUTF32_TextEncoding:
str->appendf("\"%.*S\"%s", SkMax32(byteLen, 32), (const wchar_t*) text,
str->appendf("\"%.*ls\"%s", SkMax32(byteLen, 32), (const wchar_t*) text,
byteLen > 128 ? "..." : "");
break;
case SkPaint::kGlyphID_TextEncoding:

View File

@ -132,7 +132,7 @@ bool SkOSFile::Iter::next(SkString* name, bool getDir)
return fHandle != (HANDLE)~0 && get_the_file(fHandle, name, dataPtr, getDir);
}
#elif defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID)
#elif defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_IOS)
#if 0
OSStatus FSPathMakeRef (

View File

@ -50,7 +50,7 @@ void SkOSWindow::onAddMenu(const SkOSMenu* menu) {
[(SkUIView*)fHWND onAddMenu:menu];
}
void SkOSWindow::onUpdateMenu(const SkOSMenu* menu) {
void SkOSWindow::onUpdateMenu(SkOSMenu* menu) {
[(SkUIView*)fHWND onUpdateMenu:menu];
}