iOS/Cocoa SampleApp, Drawingboard, and Networking updates

http://codereview.appspot.com/4843041/
http://codereview.appspot.com/4826061/
http://codereview.appspot.com/4832044/
http://codereview.appspot.com/4798055/


git-svn-id: http://skia.googlecode.com/svn/trunk@2058 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
yangsu@google.com 2011-08-08 15:12:05 +00:00
parent 0168afc719
commit f3493f0e1f
29 changed files with 1523 additions and 698 deletions

View File

@ -11,9 +11,9 @@
<string key="NS.object.0">851</string>
</object>
<array class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<integer value="296"/>
<integer value="372"/>
<integer value="634"/>
<integer value="296"/>
</array>
<array key="IBDocument.PluginDependencies">
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@ -58,7 +58,7 @@
</object>
<object class="NSCustomView" id="758604943">
<reference key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<int key="NSvFlags">4352</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="NSScrollView" id="1038370525">
<reference key="NSNextResponder" ref="758604943"/>
@ -109,14 +109,10 @@
</object>
</object>
<object class="NSTextFieldCell" key="NSDataCell" id="241301801">
<int key="NSCellFlags">67239488</int>
<int key="NSCellFlags2">67110912</int>
<int key="NSCellFlags">68288064</int>
<int key="NSCellFlags2">67241216</int>
<string key="NSContents">Text Cell</string>
<object class="NSFont" key="NSSupport" id="109605427">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">13</double>
<int key="NSfFlags">1044</int>
</object>
<reference key="NSSupport" ref="26"/>
<reference key="NSControlView" ref="429436769"/>
<object class="NSColor" key="NSBackgroundColor" id="598476436">
<int key="NSColorSpace">6</int>
@ -156,7 +152,11 @@
<int key="NSCellFlags">67239488</int>
<int key="NSCellFlags2">272630784</int>
<string key="NSContents">Text</string>
<reference key="NSSupport" ref="109605427"/>
<object class="NSFont" key="NSSupport">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">13</double>
<int key="NSfFlags">1044</int>
</object>
<reference key="NSControlView" ref="429436769"/>
<object class="NSColor" key="NSBackgroundColor">
<int key="NSColorSpace">6</int>
@ -192,7 +192,7 @@
<bytes key="NSWhite">MC41AA</bytes>
</object>
</object>
<double key="NSRowHeight">25</double>
<double key="NSRowHeight">35</double>
<int key="NSTvFlags">1128267776</int>
<reference key="NSDelegate"/>
<reference key="NSDataSource"/>
@ -239,11 +239,12 @@
<reference key="NSVScroller" ref="617550661"/>
<reference key="NSHScroller" ref="977018641"/>
<reference key="NSContentView" ref="250930136"/>
<bytes key="NSScrollAmts">QSAAAEEgAABB2AAAQdgAAA</bytes>
<bytes key="NSScrollAmts">QSAAAEEgAABCFAAAQhQAAA</bytes>
</object>
</array>
<string key="NSFrameSize">{341, 321}</string>
<reference key="NSSuperview"/>
<bool key="NSViewCanDrawConcurrently">YES</bool>
<string key="NSClassName">NSView</string>
</object>
<object class="NSDrawer" id="764451088">
@ -969,6 +970,15 @@
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
</object>
<object class="NSMenuItem" id="87708234">
<reference key="NSMenu" ref="466310130"/>
<string key="NSTitle">Show Menu Key Equivalents</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<int key="NSState">1</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
</object>
<object class="NSMenuItem" id="102151532">
<reference key="NSMenu" ref="466310130"/>
<string key="NSTitle">Show Toolbar</string>
@ -2298,6 +2308,14 @@
</object>
<int key="connectionID">712</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">toggleKeyEquivalents:</string>
<reference key="source" ref="429436769"/>
<reference key="destination" ref="87708234"/>
</object>
<int key="connectionID">719</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
@ -2738,6 +2756,7 @@
<reference ref="237841660"/>
<reference ref="962976284"/>
<reference ref="368680108"/>
<reference ref="87708234"/>
</array>
<reference key="parent" ref="586577488"/>
</object>
@ -3396,6 +3415,11 @@
<reference key="object" ref="368680108"/>
<reference key="parent" ref="466310130"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">718</int>
<reference key="object" ref="87708234"/>
<reference key="parent" ref="466310130"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
@ -3509,7 +3533,7 @@
<string key="29.WindowOrigin">{74, 862}</string>
<string key="29.editorWindowContentRectSynchronizationRect">{{6, 978}, {478, 20}}</string>
<string key="295.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="296.IBEditorWindowLastContentRect">{{591, 416}, {242, 83}}</string>
<string key="296.IBEditorWindowLastContentRect">{{591, 396}, {279, 103}}</string>
<string key="296.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="296.editorWindowContentRectSynchronizationRect">{{475, 832}, {234, 43}}</string>
<string key="297.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
@ -3631,7 +3655,7 @@
<integer value="1" key="58.ImportedFromIB2"/>
<string key="629.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSAffineTransform" key="629.IBViewBoundsToFrameTransform">
<bytes key="NSTransformStruct">P4AAAL+AAAAAAAAAxBNAAA</bytes>
<bytes key="NSTransformStruct">P4AAAL+AAAAAAAAAw5+AAA</bytes>
</object>
<string key="630.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="631.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
@ -3640,6 +3664,7 @@
<object class="NSAffineTransform" key="632.IBViewBoundsToFrameTransform"/>
<string key="634.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="635.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="637.CustomClassName">SkTextFieldCell</string>
<string key="637.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="661.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="698.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
@ -3647,6 +3672,7 @@
<string key="706.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="708.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="710.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="718.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="72.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1" key="72.ImportedFromIB2"/>
<string key="73.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
@ -3678,7 +3704,7 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">712</int>
<int key="maxID">719</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
@ -3745,11 +3771,30 @@
<object class="IBPartialClassDescription">
<string key="className">SkOptionsTableView</string>
<string key="superclassName">NSTableView</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">toggleKeyEquivalents:</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<string key="NS.key.0">toggleKeyEquivalents:</string>
<object class="IBActionInfo" key="NS.object.0">
<string key="name">toggleKeyEquivalents:</string>
<string key="candidateClassName">id</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">../../experimental/CocoaSampleApp/SkOptionsTableView.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">SkTextFieldCell</string>
<string key="superclassName">NSTextFieldCell</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">../../experimental/CocoaSampleApp/SkTextFieldCell.h</string>
</object>
</object>
</array>
<array class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+">
<object class="IBPartialClassDescription">
@ -3926,7 +3971,7 @@
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<string key="IBDocument.LastKnownRelativeProjectPath">../../out/gyp/SampleAppCocoa.xcodeproj</string>
<string key="IBDocument.LastKnownRelativeProjectPath">../../out/gyp/CocoaSampleApp.xcodeproj</string>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<dictionary class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
<string key="NSMenuCheckmark">{9, 8}</string>

View File

@ -2,8 +2,8 @@
#import <Cocoa/Cocoa.h>
#include "SampleApp.h"
class SkOSWindow;
class SkEvent;
class SkOSWindow;
@class SkNSView;
@protocol SkNSViewOptionsDelegate <NSObject>
@ -18,7 +18,6 @@ class SkEvent;
NSString* fTitle;
SkOSWindow* fWind;
NSOpenGLContext* fGLContext;
id<SkNSViewOptionsDelegate> fOptionsDelegate;
}

View File

@ -1,11 +1,8 @@
#import "SkNSView.h"
#include "SkApplication.h"
#include "SkCanvas.h"
#include "GrContext.h"
#include "SkCGUtils.h"
#include "SkEvent.h"
#include "GrGLInterface.h"
#include "SkGpuDevice.h"
//#define FORCE_REDRAW
@implementation SkNSView
@ -43,8 +40,8 @@
}
-(BOOL) inLiveResize {
if (fWind != NULL) {
NSSize s = [self frame].size;
NSSize s = [self frame].size;
if (fWind != NULL && fWind->width() != s.width && fWind->height() != s.height) {
fWind->resize(s.width, s.height);
[fGLContext update];
}
@ -59,27 +56,40 @@
[super dealloc];
}
- (void)layoutSubviews {
NSSize rect = self.bounds.size;
fWind->resize(rect.width, rect.height);
fWind->inval(NULL);
}
///////////////////////////////////////////////////////////////////////////////
- (void)drawWithCanvas:(SkCanvas*)canvas {
- (void)drawSkia {
fRedrawRequestPending = false;
fWind->draw(canvas);
SkCanvas canvas(fWind->getBitmap());
fWind->draw(&canvas);
#ifdef FORCE_REDRAW
fWind->inval(NULL);
#endif
}
- (void)drawRect:(NSRect)dirtyRect {
SkCanvas canvas(fWind->getBitmap());
[self drawWithCanvas:&canvas];
CGContextRef ctx = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
SkCGDrawBitmap(ctx, fWind->getBitmap(), 0, 0);
- (void)setSkTitle:(const char *)title {
self.fTitle = [NSString stringWithUTF8String:title];
[[self window] setTitle:self.fTitle];
}
- (BOOL)onHandleEvent:(const SkEvent&)evt {
return false;
}
#include "SkOSMenu.h"
- (void)onAddMenu:(const SkOSMenu*)menu {
[self.fOptionsDelegate view:self didAddMenu:menu];
}
- (void)onUpdateMenu:(const SkOSMenu*)menu {
[self.fOptionsDelegate view:self didUpdateMenu:menu];
}
- (void)postInvalWithRect:(const SkIRect*)r {
if (!fRedrawRequestPending) {
fRedrawRequestPending = true;
[self performSelector:@selector(drawSkia) withObject:nil afterDelay:0];
}
}
///////////////////////////////////////////////////////////////////////////////
@ -121,7 +131,7 @@ static SkKey raw2key(UInt32 raw)
{ SK_Mac1Key, k1_SkKey },
{ SK_Mac2Key, k2_SkKey },
{ SK_Mac3Key, k3_SkKey },
{ SK_Mac4Key, k4_SkKey },
{ SK_Mac4Key, k4_SkKey },
{ SK_Mac5Key, k5_SkKey },
{ SK_Mac6Key, k6_SkKey },
{ SK_Mac7Key, k7_SkKey },
@ -179,34 +189,16 @@ static SkKey raw2key(UInt32 raw)
}
}
///////////////////////////////////////////////////////////////////////////////
- (void)setSkTitle:(const char *)title {
NSString* text = [NSString stringWithUTF8String:title];
if ([text length] > 0)
self.fTitle = text;
[[self window] setTitle:fTitle];
- (void)swipeWithEvent:(NSEvent *)event {
CGFloat x = [event deltaX];
if (x < 0)
((SampleWindow*)fWind)->previousSample();
else if (x > 0)
((SampleWindow*)fWind)->nextSample();
else
((SampleWindow*)fWind)->showOverview();
}
- (BOOL)onHandleEvent:(const SkEvent&)evt {
return false;
}
#include "SkOSMenu.h"
- (void)onAddMenu:(const SkOSMenu*)menu {
[self.fOptionsDelegate view:self didAddMenu:menu];
}
- (void)onUpdateMenu:(const SkOSMenu*)menu {
[self.fOptionsDelegate view:self didUpdateMenu:menu];
}
- (void)postInvalWithRect:(const SkIRect*)r {
if (!fRedrawRequestPending) {
fRedrawRequestPending = true;
[self performSelector:@selector(display) withObject:nil afterDelay:0];
}
}
///////////////////////////////////////////////////////////////////////////////
#include <OpenGL/OpenGL.h>

View File

@ -19,7 +19,7 @@ SkOSWindow::~SkOSWindow() {
void SkOSWindow::onHandleInval(const SkIRect& r) {
if (!fInvalEventIsPending) {
fInvalEventIsPending = true;
(new SkEvent(kINVAL_NSVIEW_EventType))->post(this->getSinkID());
(new SkEvent(kINVAL_NSVIEW_EventType, this->getSinkID()))->post();
}
}

View File

@ -13,16 +13,17 @@
@interface SkOptionsTableView : NSTableView <SkNSViewOptionsDelegate, NSTableViewDelegate, NSTableViewDataSource> {
NSMutableArray* fItems;
const SkTDArray<SkOSMenu*>* fMenus;
BOOL fShowKeys;
}
@property (nonatomic, retain) NSMutableArray* fItems;
- (void)registerMenus:(const SkTDArray<SkOSMenu*>*)menus;
- (void)updateMenu:(const SkOSMenu*)menu;
- (void)loadMenu:(const SkOSMenu*)menu;
- (IBAction)toggleKeyEquivalents:(id)sender;
- (NSCell*)createAction;
- (NSCell*)createList:(NSArray*)items current:(int)index;
- (NSCell*)createSegmented:(NSArray*)items current:(int)index;
- (NSCell*)createSlider:(float)value min:(float)min max:(float)max;
- (NSCell*)createSwitch:(BOOL)state;
- (NSCell*)createTextField:(NSString*)placeHolder;

View File

@ -15,6 +15,8 @@
if ((self = [super initWithCoder:coder])) {
self.dataSource = self;
self.delegate = self;
fMenus = NULL;
fShowKeys = YES;
[self setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleNone];
self.fItems = [NSMutableArray array];
}
@ -31,6 +33,13 @@
[self updateMenu:menu];
}
- (IBAction)toggleKeyEquivalents:(id)sender {
fShowKeys = !fShowKeys;
NSMenuItem* item = (NSMenuItem*)sender;
[item setState:fShowKeys];
[self reloadData];
}
- (void)registerMenus:(const SkTDArray<SkOSMenu*>*)menus {
fMenus = menus;
for (NSUInteger i = 0; i < fMenus->count(); ++i) {
@ -65,47 +74,53 @@
- (void)loadMenu:(const SkOSMenu*)menu {
for (int i = 0; i < menu->countItems(); ++i) {
const SkOSMenu::Item* item = menu->getItem(i);
NSString* str;
int index = 0;
NSArray* optionstrs = nil;
SkOptionItem* option = [[SkOptionItem alloc] init];
option.fItem = item;
bool state = false;
SkOSMenu::TriState tristate;
switch (item->getType()) {
case SkOSMenu::kAction_Type:
option.fCell = [self createAction];
break;
case SkOSMenu::kList_Type:
optionstrs = [[NSString stringWithUTF8String:item->getEvent()->findString(SkOSMenu::List_Items_Str)]
componentsSeparatedByString:[NSString stringWithUTF8String:SkOSMenu::Delimiter]];
item->getEvent()->findS32(item->getSlotName(), &index);
option.fCell = [self createList:optionstrs current:index];
break;
case SkOSMenu::kSlider_Type:
SkScalar min, max, value;
item->getEvent()->findScalar(SkOSMenu::Slider_Min_Scalar, &min);
item->getEvent()->findScalar(SkOSMenu::Slider_Max_Scalar, &max);
item->getEvent()->findScalar(item->getSlotName(), &value);
option.fCell = [self createSlider:value
min:min
max:max];
break;
case SkOSMenu::kSwitch_Type:
item->getEvent()->findBool(item->getSlotName(), &state);
option.fCell = [self createSwitch:(BOOL)state];
break;
case SkOSMenu::kTriState_Type:
item->getEvent()->findS32(item->getSlotName(), (int*)&tristate);
option.fCell = [self createTriState:[self triStateToNSState:tristate]];
break;
case SkOSMenu::kTextField_Type:
str = [NSString stringWithUTF8String:item->getEvent()->findString(item->getSlotName())];
option.fCell = [self createTextField:str];
break;
default:
break;
if (SkOSMenu::kList_Type == item->getType()) {
int index = 0, count = 0;
SkOSMenu::FindListItemCount(item->getEvent(), &count);
NSMutableArray* optionstrs = [[NSMutableArray alloc] initWithCapacity:count];
SkString options[count];
SkOSMenu::FindListItems(item->getEvent(), options);
for (int i = 0; i < count; ++i)
[optionstrs addObject:[NSString stringWithUTF8String:options[i].c_str()]];
SkOSMenu::FindListIndex(item->getEvent(), item->getSlotName(), &index);
option.fCell = [self createList:optionstrs current:index];
[optionstrs release];
}
else {
bool state = false;
SkString str;
SkOSMenu::TriState tristate;
switch (item->getType()) {
case SkOSMenu::kAction_Type:
option.fCell = [self createAction];
break;
case SkOSMenu::kSlider_Type:
SkScalar min, max, value;
SkOSMenu::FindSliderValue(item->getEvent(), item->getSlotName(), &value);
SkOSMenu::FindSliderMin(item->getEvent(), &min);
SkOSMenu::FindSliderMax(item->getEvent(), &max);
option.fCell = [self createSlider:value
min:min
max:max];
break;
case SkOSMenu::kSwitch_Type:
SkOSMenu::FindSwitchState(item->getEvent(), item->getSlotName(), &state);
option.fCell = [self createSwitch:(BOOL)state];
break;
case SkOSMenu::kTriState_Type:
SkOSMenu::FindTriState(item->getEvent(), item->getSlotName(), &tristate);
option.fCell = [self createTriState:[self triStateToNSState:tristate]];
break;
case SkOSMenu::kTextField_Type:
SkOSMenu::FindText(item->getEvent(),item->getSlotName(), &str);
option.fCell = [self createTextField:[NSString stringWithUTF8String:str.c_str()]];
break;
default:
break;
}
}
[fItems addObject:option];
[option release];
@ -118,8 +133,14 @@
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
int columnIndex = [tableView columnWithIdentifier:[tableColumn identifier]];
if (columnIndex == 0)
return [NSString stringWithUTF8String:((SkOptionItem*)[fItems objectAtIndex:row]).fItem->getLabel()];
if (columnIndex == 0) {
const SkOSMenu::Item* item = ((SkOptionItem*)[fItems objectAtIndex:row]).fItem;
NSString* label = [NSString stringWithUTF8String:item->getLabel()];
if (fShowKeys)
return [NSString stringWithFormat:@"%@ (%c)", label, item->getKeyEquivalent()];
else
return label;
}
else
return nil;
}
@ -151,7 +172,6 @@
[cell setFloatValue:[storedCell floatValue]];
break;
case SkOSMenu::kSwitch_Type:
[cell setTitle:storedCell.title];
[cell setState:[(NSButtonCell*)storedCell state]];
break;
case SkOSMenu::kTextField_Type:
@ -159,7 +179,6 @@
[cell setStringValue:[storedCell stringValue]];
break;
case SkOSMenu::kTriState_Type:
[cell setTitle:storedCell.title];
[cell setState:[(NSButtonCell*)storedCell state]];
break;
default:
@ -226,19 +245,6 @@
return cell;
}
- (NSCell*)createSegmented:(NSArray*)items current:(int)index {
NSSegmentedCell* cell = [[[NSSegmentedCell alloc] init] autorelease];
[cell setSegmentStyle:NSSegmentStyleSmallSquare];
[cell setSegmentCount:[items count]];
NSUInteger i = 0;
for (NSString* label in items) {
[cell setLabel:label forSegment:i];
++i;
}
[cell setSelectedSegment:index];
return cell;
}
- (NSCell*)createSlider:(float)value min:(float)min max:(float)max {
NSSliderCell* cell = [[[NSSliderCell alloc] init] autorelease];
[cell setFloatValue:value];
@ -249,8 +255,8 @@
- (NSCell*)createSwitch:(BOOL)state {
NSButtonCell* cell = [[[NSButtonCell alloc] init] autorelease];
[cell setTitle:(state) ? @"On" : @"Off"];
[cell setState:state];
[cell setTitle:@""];
[cell setButtonType:NSSwitchButton];
return cell;
}
@ -265,15 +271,10 @@
- (NSCell*)createTriState:(NSCellStateValue)state {
NSButtonCell* cell = [[[NSButtonCell alloc] init] autorelease];
if (NSOnState == state)
[cell setTitle:@"On"];
else if (NSOffState == state)
[cell setTitle:@"Off"];
else
[cell setTitle:@"Mixed"];
[cell setAllowsMixedState:TRUE];
[cell setTitle:@""];
[cell setState:(NSInteger)state];
[cell setButtonType:NSSwitchButton];
return cell;
}
@end
@end

View File

@ -2,6 +2,7 @@
int main(int argc, char *argv[])
{
signal(SIGPIPE, SIG_IGN);
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = NSApplicationMain(argc, (const char **)argv);
[pool release];

View File

@ -0,0 +1,250 @@
#include "SampleCode.h"
#include "SkView.h"
#include "SkCanvas.h"
#include "SkGPipe.h"
#include "SkSockets.h"
#include "SkNetPipeController.h"
#include "SkCornerPathEffect.h"
#include "SkColorPalette.h"
#include "SkOSMenu.h"
#define MAX_READ_PER_FRAME 5
class DrawingClientView : public SampleView {
public:
DrawingClientView() {
fSocket = NULL;
fTotalBytesRead = 0;
fPalette = new SkColorPalette;
fPalette->setSize(100, 300);
fPalette->setVisibleP(true);
this->attachChildToFront(fPalette);
fPalette->unref();
fBrushSize = SkFloatToScalar(2.5);
fAA = false;
fPaletteVisible = true;
fSync = false;
fVector = false;
}
~DrawingClientView() {
if (fSocket) {
delete fSocket;
}
fData.reset();
fBuffer.reset();
}
virtual void requestMenu(SkOSMenu* menu) {
menu->setTitle("Drawing Client");
menu->appendTextField("Server IP", "Server IP", this->getSinkID(), "IP address or hostname");
menu->appendSwitch("Vector", "Vector", this->getSinkID(), fVector);
menu->appendSlider("Brush Size", "Brush Size", this->getSinkID(), 1.0, 100.0, fBrushSize);
menu->appendSwitch("Anti-Aliasing", "AA", this->getSinkID(), fAA);
menu->appendSwitch("Show Color Palette", "Palette", this->getSinkID(), fPaletteVisible);
menu->appendSwitch("Sync", "Sync", this->getSinkID(), fSync);
menu->appendAction("Clear", this->getSinkID());
}
protected:
static void readData(int cid, const void* data, size_t size,
SkSocket::DataType type, void* context) {
DrawingClientView* view = (DrawingClientView*)context;
view->onRead(cid, data, size, type);
}
void onRead(int cid, const void* data, size_t size, SkSocket::DataType type) {
if (size > 0) {
fBuffer.reset();
if (type == SkSocket::kPipeReplace_type)
fBuffer.append(size, (const char*)data);
else if (type == SkSocket::kPipeAppend_type)
fData.append(size, (const char*)data);
else {
//other types of data
}
}
}
bool onQuery(SkEvent* evt) {
if (SampleCode::TitleQ(*evt)) {
SampleCode::TitleR(evt, "Drawing Client");
return true;
}
return this->INHERITED::onQuery(evt);
}
bool onEvent(const SkEvent& evt) {;
if (SkOSMenu::FindSliderValue(&evt, "Brush Size", &fBrushSize))
return true;
SkString s;
if (SkOSMenu::FindText(&evt, "Server IP", &s)) {
if (NULL != fSocket) {
delete fSocket;
}
fSocket = new SkTCPClient(s.c_str(), 40000);
fSocket->connectToServer();
fSocket->suspendWrite();
SkDebugf("Connecting to %s\n", s.c_str());
fData.reset();
fBuffer.reset();
this->inval(NULL);
return true;
}
if (SkOSMenu::FindSwitchState(&evt, "AA", &fAA) ||
SkOSMenu::FindSwitchState(&evt, "Sync", &fSync))
return true;
if (SkOSMenu::FindSwitchState(&evt, "Vector", &fVector)) {
this->clearBitmap();
return true;
}
if (SkOSMenu::FindAction(&evt, "Clear")) {
this->clear();
return true;
}
if (SkOSMenu::FindSwitchState(&evt, "Palette", &fPaletteVisible)) {
fPalette->setVisibleP(fPaletteVisible);
return true;
}
return this->INHERITED::onEvent(evt);
}
virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y) {
return new Click(this);
}
virtual bool onClick(SkView::Click* click) {
switch (click->fState) {
case SkView::Click::kDown_State:
fCurrLine.moveTo(click->fCurr);
fType = SkSocket::kPipeReplace_type;
if (fSocket)
fSocket->resumeWrite();
break;
case SkView::Click::kMoved_State:
fCurrLine.lineTo(click->fCurr);
break;
case SkView::Click::kUp_State:
fType = SkSocket::kPipeAppend_type;
break;
default:
break;
}
return true;
}
virtual void onDrawContent(SkCanvas* canvas) {
if (fSocket) {
if (fSocket->isConnected()) {
if (fSync) {
int count = 0;
while (fSocket->readPacket(readData, this) > 0 &&
count < MAX_READ_PER_FRAME)
++count;
}
else
fSocket->readPacket(readData, this);
}
else
fSocket->connectToServer();
}
size_t bytesRead = 0;
SkCanvas bufferCanvas(fBase);
SkCanvas* tempCanvas;
while (fTotalBytesRead < fData.count()) {
if (fVector)
tempCanvas = canvas;
else
tempCanvas = &bufferCanvas;
SkGPipeReader reader(tempCanvas);
SkGPipeReader::Status status = reader.playback(fData.begin() + fTotalBytesRead,
fData.count() - fTotalBytesRead,
&bytesRead);
SkASSERT(SkGPipeReader::kError_Status != status);
fTotalBytesRead += bytesRead;
}
if (fVector)
fTotalBytesRead = 0;
else
canvas->drawBitmap(fBase, 0, 0, NULL);
size_t totalBytesRead = 0;
while (totalBytesRead < fBuffer.count()) {
SkGPipeReader reader(canvas);
reader.playback(fBuffer.begin() + totalBytesRead,
fBuffer.count() - totalBytesRead,
&bytesRead);
totalBytesRead += bytesRead;
}
SkNetPipeController controller(canvas);
SkGPipeWriter writer;
SkCanvas* writerCanvas = writer.startRecording(&controller,
SkGPipeWriter::kCrossProcess_Flag);
//controller.disablePlayback();
SkPaint p;
p.setColor(fPalette->getColor());
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(fBrushSize);
p.setStrokeCap(SkPaint::kRound_Cap);
p.setStrokeJoin(SkPaint::kRound_Join);
p.setAntiAlias(fAA);
p.setPathEffect(new SkCornerPathEffect(55))->unref();
writerCanvas->drawPath(fCurrLine, p);
writer.endRecording();
controller.writeToSocket(fSocket, fType);
if (fType == SkSocket::kPipeAppend_type && fSocket) {
fSocket->suspendWrite();
fCurrLine.reset();
}
this->inval(NULL);
}
virtual void onSizeChange() {
this->INHERITED::onSizeChange();
fPalette->setLoc(this->width()-100, 0);
fBase.setConfig(SkBitmap::kARGB_8888_Config, this->width(), this->height());
fBase.allocPixels(NULL);
this->clearBitmap();
}
private:
void clear() {
fData.reset();
fBuffer.reset();
fCurrLine.reset();
fTotalBytesRead = 0;
this->clearBitmap();
}
void clearBitmap() {
fTotalBytesRead = 0;
fBase.eraseColor(fBGColor);
}
SkTDArray<char> fData;
SkTDArray<char> fBuffer;
SkBitmap fBase;
SkPath fCurrLine;
SkTCPClient* fSocket;
SkSocket::DataType fType;
SkColorPalette* fPalette;
bool fPaletteVisible;
size_t fTotalBytesRead;
SkScalar fBrushSize;
bool fAA;
bool fSync;
bool fVector;
typedef SampleView INHERITED;
};
///////////////////////////////////////////////////////////////////////////////
static SkView* MyFactory() { return new DrawingClientView; }
static SkViewRegister reg(MyFactory);

View File

@ -0,0 +1,200 @@
#include "SampleCode.h"
#include "SkView.h"
#include "SkCanvas.h"
#include "SkGPipe.h"
#include "SkSockets.h"
#include "SkNetPipeController.h"
#include "SkCornerPathEffect.h"
#include "SkOSMenu.h"
#include <map>
class DrawingServerView : public SampleView {
public:
DrawingServerView(){
fServer = new SkTCPServer(40000);
fServer->suspendWrite();
fTotalBytesRead = fTotalBytesWritten = 0;
fVector = true;
}
~DrawingServerView() {
delete fServer;
fData.reset();
fBuffer.reset();
fClientMap.clear();
}
virtual void requestMenu(SkOSMenu* menu) {
menu->setTitle("Drawing Server");
menu->appendAction("Clear", this->getSinkID());
menu->appendSwitch("Vector", "Vector", this->getSinkID(), fVector);
}
protected:
static void readData(int cid, const void* data, size_t size,
SkSocket::DataType type, void* context) {
DrawingServerView* view = (DrawingServerView*)context;
view->onRead(cid, data, size, type);
}
void onRead(int cid, const void* data, size_t size, SkSocket::DataType type) {
if (NULL == data && size <= 0)
return;
ClientState* cs;
std::map<int, ClientState*>::iterator it = fClientMap.find(cid);
if (it == fClientMap.end()) { //New client
cs = new ClientState;
cs->bufferBase = 0;
cs->bufferSize = 0;
fClientMap[cid] = cs;
}
else {
cs = it->second;
}
if (type == SkSocket::kPipeReplace_type) {
fBuffer.remove(cs->bufferBase, cs->bufferSize);
for (it = fClientMap.begin(); it != fClientMap.end(); ++it) {
if (cid == it->first)
continue;
else {
if (it->second->bufferBase > cs->bufferBase) {
it->second->bufferBase -= cs->bufferSize;
SkASSERT(it->second->bufferBase >= 0);
}
}
}
cs->bufferBase = fBuffer.count();
cs->bufferSize = size;
fBuffer.append(size, (const char*)data);
}
else if (type == SkSocket::kPipeAppend_type) {
fData.append(size, (const char*)data);
fServer->resumeWrite();
fServer->writePacket(fData.begin() + fTotalBytesWritten,
fData.count() - fTotalBytesWritten,
SkSocket::kPipeAppend_type);
fTotalBytesWritten = fData.count();
fServer->suspendWrite();
//this->clearBitmap();
}
else {
//other types of data
}
}
// overrides from SkEventSink
bool onQuery(SkEvent* evt) {
if (SampleCode::TitleQ(*evt)) {
SampleCode::TitleR(evt, "Drawing Server");
return true;
}
return this->INHERITED::onQuery(evt);
}
bool onEvent(const SkEvent& evt) {
if (SkOSMenu::FindAction(&evt, "Clear")) {
this->clear();
return true;
}
if (SkOSMenu::FindSwitchState(&evt, "Vector", &fVector)) {
this->clearBitmap();
return true;
}
return this->INHERITED::onEvent(evt);
}
virtual void onDrawContent(SkCanvas* canvas) {
if (fCurrMatrix != canvas->getTotalMatrix()) {
fTotalBytesRead = 0;
fCurrMatrix = canvas->getTotalMatrix();
}
fServer->acceptConnections();
if (fServer->readPacket(readData, this) > 0) {
fServer->resumeWrite();
}
else {
fServer->suspendWrite();
}
size_t bytesRead;
SkCanvas bufferCanvas(fBase);
SkCanvas* tempCanvas;
while (fTotalBytesRead < fData.count()) {
if (fVector)
tempCanvas = canvas;
else
tempCanvas = &bufferCanvas;
SkGPipeReader reader(tempCanvas);
SkGPipeReader::Status stat = reader.playback(fData.begin() + fTotalBytesRead,
fData.count() - fTotalBytesRead,
&bytesRead);
SkASSERT(SkGPipeReader::kError_Status != stat);
fTotalBytesRead += bytesRead;
if (SkGPipeReader::kDone_Status == stat) {}
}
if (fVector)
fTotalBytesRead = 0;
else
canvas->drawBitmap(fBase, 0, 0, NULL);
size_t totalBytesRead = 0;
while (totalBytesRead < fBuffer.count()) {
SkGPipeReader reader(canvas);
reader.playback(fBuffer.begin() + totalBytesRead,
fBuffer.count() - totalBytesRead,
&bytesRead);
totalBytesRead += bytesRead;
}
fServer->writePacket(fBuffer.begin(), fBuffer.count(),
SkSocket::kPipeReplace_type);
this->inval(NULL);
}
virtual void onSizeChange() {
this->INHERITED::onSizeChange();
fBase.setConfig(SkBitmap::kARGB_8888_Config, this->width(), this->height());
fBase.allocPixels(NULL);
this->clearBitmap();
}
private:
void clear() {
fData.reset();
fBuffer.reset();
fTotalBytesRead = fTotalBytesWritten = 0;
fClientMap.clear();
this->clearBitmap();
}
void clearBitmap() {
fTotalBytesRead = 0;
fBase.eraseColor(fBGColor);
}
struct ClientState {
int bufferBase;
int bufferSize;
};
std::map<int, ClientState*> fClientMap;
SkTDArray<char> fData;
SkTDArray<char> fBuffer;
size_t fTotalBytesRead;
size_t fTotalBytesWritten;
SkMatrix fCurrMatrix;
SkBitmap fBase;
bool fVector;
SkTCPServer* fServer;
typedef SampleView INHERITED;
};
///////////////////////////////////////////////////////////////////////////////
static SkView* MyFactory() { return new DrawingServerView; }
static SkViewRegister reg(MyFactory);

View File

@ -16,9 +16,12 @@ SkColorPalette::SkColorPalette() {
fGradientRect = SkRect::MakeWH(SkIntToScalar(100), SkIntToScalar(100));
fSelected = 0;
fCurrColor = 0xFF000000;
for (int i = 0; i < PaletteSlots; ++i) {
fColors[i] = 0xFF000000;
}
fColors[0] = SK_ColorWHITE;
fColors[1] = SK_ColorBLACK;
fColors[2] = SK_ColorRED;
fColors[3] = SK_ColorGREEN;
fColors[4] = SK_ColorBLUE;
}
bool SkColorPalette::onEvent(const SkEvent& evt) {
@ -26,24 +29,27 @@ bool SkColorPalette::onEvent(const SkEvent& evt) {
}
void SkColorPalette::onDraw(SkCanvas* canvas) {
canvas->drawColor(0xFFEEEEEE);
canvas->drawColor(SK_ColorWHITE);
SkPaint paint;
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStrokeAndFill_Style);
canvas->translate(PalettePadding, PalettePadding);
for (int i = 0; i < PaletteSlots; ++i) {
if (fSelected == i) {
paint.setStrokeWidth(SkIntToScalar(3));
}
else {
paint.setStrokeWidth(0);
paint.setStrokeWidth(1);
}
paint.setStyle(SkPaint::kStroke_Style);
paint.setColor(SK_ColorBLACK);
canvas->drawRect(fSlotRect, paint);
paint.setStyle(SkPaint::kFill_Style);
paint.setColor(fColors[i]);
canvas->drawRect(fSlotRect, paint);
canvas->translate(0, fSlotRect.height() + PalettePadding);
}
paint.setStrokeWidth(0);

View File

@ -0,0 +1,110 @@
#include "SampleCode.h"
#include "SkView.h"
#include "SkCanvas.h"
#include "SkGradientShader.h"
#include "SkGPipe.h"
#include "SkSockets.h"
#include "SkOSMenu.h"
#define MAX_READS_PER_FRAME 5
class NetPipeReaderView : public SampleView {
public:
NetPipeReaderView() {
fSocket = NULL;
fSync = false;
}
~NetPipeReaderView() {
if (fSocket) {
delete fSocket;
}
fDataArray.reset();
}
virtual void requestMenu(SkOSMenu* menu) {
menu->setTitle("Net Pipe Reader");
menu->appendTextField("Server IP", "Server IP", this->getSinkID(),
"IP address");
menu->appendSwitch("Sync", "Sync", this->getSinkID(), fSync);
}
protected:
static void readData(int cid, const void* data, size_t size,
SkSocket::DataType type, void* context) {
NetPipeReaderView* view = (NetPipeReaderView*)context;
view->onRead(data, size);
}
void onRead(const void* data, size_t size) {
if (size > 0)
fDataArray.append(size, (const char*)data);
}
bool onQuery(SkEvent* evt) {
if (SampleCode::TitleQ(*evt)) {
SampleCode::TitleR(evt, "Net Pipe Reader");
return true;
}
return this->INHERITED::onQuery(evt);
}
bool onEvent(const SkEvent& evt) {;
SkString s;
if (SkOSMenu::FindText(&evt, "Server IP", &s)) {
if (NULL != fSocket) {
delete fSocket;
}
fSocket = new SkTCPClient(s.c_str());
fSocket->connectToServer();
SkDebugf("Connecting to %s\n", s.c_str());
return true;
}
if (SkOSMenu::FindSwitchState(&evt, "Sync", &fSync))
return true;
return this->INHERITED::onEvent(evt);
}
void onDrawContent(SkCanvas* canvas) {
if (NULL == fSocket)
return;
if (fSocket->isConnected()) {
int dataToRemove = fDataArray.count();
if (fSync) {
int numreads = 0;
while (fSocket->readPacket(readData, this) > 0 &&
numreads < MAX_READS_PER_FRAME) {
fDataArray.remove(0, dataToRemove);
dataToRemove = fDataArray.count();
++numreads;
}
}
else {
if (fSocket->readPacket(readData, this) > 0)
fDataArray.remove(0, dataToRemove);
}
}
else
fSocket->connectToServer();
SkGPipeReader reader(canvas);
size_t bytesRead;
SkGPipeReader::Status fStatus = reader.playback(fDataArray.begin(),
fDataArray.count(),
&bytesRead);
SkASSERT(SkGPipeReader::kError_Status != fStatus);
this->inval(NULL);
}
private:
bool fSync;
SkTDArray<char> fDataArray;
SkTCPClient* fSocket;
typedef SampleView INHERITED;
};
///////////////////////////////////////////////////////////////////////////////
static SkView* MyFactory() { return new NetPipeReaderView; }
static SkViewRegister reg(MyFactory);

View File

@ -1,4 +1,3 @@
/*
* Copyright 2011 Google Inc.
*
@ -20,8 +19,6 @@ SkSocket::SkSocket() {
fReadSuspended = false;
fWriteSuspended = false;
fSockfd = this->createSocket();
fTimeout.tv_sec = 0;
fTimeout.tv_usec = 0;
}
SkSocket::~SkSocket() {
@ -31,7 +28,13 @@ SkSocket::~SkSocket() {
int SkSocket::createSocket() {
int sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0) {
//SkDebugf("ERROR opening socket\n");
SkDebugf("ERROR opening socket\n");
return -1;
}
int reuse = 1;
if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(int)) < 0) {
SkDebugf("error: %s\n", strerror(errno));
return -1;
}
#ifdef NONBLOCKING_SOCKETS
@ -46,8 +49,9 @@ void SkSocket::closeSocket(int sockfd) {
if (!fReady)
return;
//SkDebugf("Closed fd:%d\n", sockfd);
shutdown(sockfd, 2); //stop sending/receiving
close(sockfd);
//SkDebugf("Closed fd:%d\n", sockfd);
if (FD_ISSET(sockfd, &fMasterSet)) {
FD_CLR(sockfd, &fMasterSet);
@ -56,10 +60,8 @@ void SkSocket::closeSocket(int sockfd) {
fMaxfd -= 1;
}
}
if (0 == fMaxfd) {
if (0 == fMaxfd)
fConnected = false;
//SkDebugf("all connections closed\n");
}
}
void SkSocket::onFailedConnection(int sockfd) {
@ -77,9 +79,10 @@ void SkSocket::addToMasterSet(int sockfd) {
fMaxfd = sockfd;
}
int SkSocket::readPacket(void (*onRead)(const void*, size_t, int, DataType,
int SkSocket::readPacket(void (*onRead)(int, const void*, size_t, DataType,
void*), void* context) {
if (!fConnected || !fReady || NULL == onRead || fReadSuspended)
if (!fConnected || !fReady || NULL == onRead || NULL == context
|| fReadSuspended)
return -1;
int totalBytesRead = 0;
@ -139,9 +142,9 @@ int SkSocket::readPacket(void (*onRead)(const void*, size_t, int, DataType,
failure = true;
break;
}
//SkDebugf("read packet(done:%d, bytes:%d) from fd:%d in %d attempts\n",
//SkDebugf("read packet(done:%d, bytes:%d) from fd:%d in %d tries\n",
// h.done, h.bytes, fSockfd, attempts);
stream.write(packet + HEADER_SIZE, h.bytes);\
stream.write(packet + HEADER_SIZE, h.bytes);
bytesReadInPacket = 0;
attempts = 0;
bytesReadInTransfer += h.bytes;
@ -156,7 +159,7 @@ int SkSocket::readPacket(void (*onRead)(const void*, size_t, int, DataType,
if (bytesReadInTransfer > 0) {
SkData* data = stream.copyToData();
SkASSERT(data->size() == bytesReadInTransfer);
onRead(data->data(), data->size(), i, h.type, context);
onRead(i, data->data(), data->size(), h.type, context);
data->unref();
totalBytesRead += bytesReadInTransfer;
@ -206,7 +209,7 @@ int SkSocket::writePacket(void* data, size_t size, DataType type) {
#ifdef NONBLOCKING_SOCKETS
else if (errno == EWOULDBLOCK || errno == EAGAIN) {
if (bytesWrittenInPacket > 0 || bytesWrittenInTransfer > 0)
continue; //incomplete packet or frame, keep tring
continue; //incomplete packet or frame, keep trying
else
break; //client not available, skip current transfer
}
@ -220,10 +223,8 @@ int SkSocket::writePacket(void* data, size_t size, DataType type) {
}
bytesWrittenInPacket += retval;
if (bytesWrittenInPacket < PACKET_SIZE) {
//SkDebugf("Wrote %d/%d\n", bytesWrittenInPacket, PACKET_SIZE);
continue; //incomplete packet, keep tring
}
if (bytesWrittenInPacket < PACKET_SIZE)
continue; //incomplete packet, keep trying
SkASSERT(bytesWrittenInPacket == PACKET_SIZE);
//SkDebugf("wrote to packet(done:%d, bytes:%d) to fd:%d in %d tries\n",
@ -233,15 +234,14 @@ int SkSocket::writePacket(void* data, size_t size, DataType type) {
attempts = 0;
}
if (failure) {
//SkDebugf("Failed to write to fd:%d, terminating connection\n", i);
if (failure)
this->onFailedConnection(i);
}
totalBytesWritten += bytesWrittenInTransfer;
}
return totalBytesWritten;
}
////////////////////////////////////////////////////////////////////////////////
SkTCPServer::SkTCPServer(int port) {
sockaddr_in serverAddr;
@ -250,33 +250,32 @@ SkTCPServer::SkTCPServer(int port) {
serverAddr.sin_port = htons(port);
if (bind(fSockfd, (sockaddr*)&serverAddr, sizeof(serverAddr)) < 0) {
//SkDebugf("ERROR on binding\n");
SkDebugf("ERROR on binding: %s\n", strerror(errno));
fReady = false;
}
}
SkTCPServer::~SkTCPServer() {
this->disconnectAllConnections();
this->disconnectAll();
}
int SkTCPServer::acceptIncomingConnections() {
int SkTCPServer::acceptConnections() {
if (!fReady)
return -1;
// if (fConnected)
// return 0;
listen(fSockfd, MAX_CLIENTS);
////SkDebugf("Accepting Incoming connections\n");
listen(fSockfd, MAX_WAITING_CLIENTS);
int newfd;
for (int i = 0; i < MAX_CLIENTS; ++i) {
for (int i = 0; i < MAX_WAITING_CLIENTS; ++i) {
#ifdef NONBLOCKING_SOCKETS
fd_set workingSet;
FD_ZERO(&workingSet);
FD_SET(fSockfd, &workingSet);
int sel = select(fSockfd + 1, &workingSet, NULL, NULL, &fTimeout);
timeval timeout;
timeout.tv_sec = 0;
timeout.tv_usec = 0;
int sel = select(fSockfd + 1, &workingSet, NULL, NULL, &timeout);
if (sel < 0) {
//SkDebugf("select() failed with error %s\n", strerror(errno));
SkDebugf("select() failed with error %s\n", strerror(errno));
continue;
}
if (sel == 0) //select() timed out
@ -286,10 +285,10 @@ int SkTCPServer::acceptIncomingConnections() {
socklen_t clientLen = sizeof(clientAddr);
newfd = accept(fSockfd, (struct sockaddr*)&clientAddr, &clientLen);
if (newfd< 0) {
//SkDebugf("accept() failed with error %s\n", strerror(errno));
SkDebugf("accept() failed with error %s\n", strerror(errno));
continue;
}
//SkDebugf("New incoming connection - %d\n", newfd);
SkDebugf("New incoming connection - %d\n", newfd);
fConnected = true;
#ifdef NONBLOCKING_SOCKETS
this->setNonBlocking(newfd);
@ -300,12 +299,10 @@ int SkTCPServer::acceptIncomingConnections() {
}
int SkTCPServer::disconnectAllConnections() {
////SkDebugf("disconnecting server\n");
int SkTCPServer::disconnectAll() {
if (!fConnected || !fReady)
return -1;
for (int i = 0; i <= fMaxfd; ++i)
{
for (int i = 0; i <= fMaxfd; ++i) {
if (FD_ISSET(i, &fMasterSet))
this->closeSocket(i);
}
@ -331,7 +328,7 @@ SkTCPClient::SkTCPClient(const char* hostname, int port) {
}
}
void SkTCPClient::onFailedConnection(int sockfd) {
void SkTCPClient::onFailedConnection(int sockfd) { //cleanup and recreate socket
SkASSERT(sockfd == fSockfd);
this->closeSocket(fSockfd);
fSockfd = this->createSocket();
@ -358,6 +355,6 @@ int SkTCPClient::connectToServer() {
}
}
fConnected = true;
//SkDebugf("Succesfully reached server\n");
SkDebugf("Succesfully reached server\n");
return 0;
}

View File

@ -1,4 +1,3 @@
/*
* Copyright 2011 Google Inc.
*
@ -12,19 +11,15 @@
#include <sys/socket.h>
#include "SkTypes.h"
#include "SkStream.h"
/* PACKET and HEADER Format */
#define PACKET_SIZE 1024
#define HEADER_SIZE 20
#define CONTENT_SIZE 1004
#define DEFAULT_PORT 15555
#define MAX_WAITING_CLIENTS 3
#define NONBLOCKING_SOCKETS
#ifdef NONBLOCKING_SOCKETS
#define MAX_CLIENTS 3
#else
#define MAX_CLIENTS 1
#endif
class SkSocket {
public:
@ -44,7 +39,9 @@ public:
kString_type,
kInt_type
};
/*
bool isConnected() { return fConnected; }
/**
* Write data to the socket. Data is a pointer to the beginning of the data
* to be sent and dataSize specifies the number of bytes to send. This
* method will spread the data across multiple packets if the data can't all
@ -54,29 +51,40 @@ public:
* was an error during the transfer, in which case the method returns -1.
* For blocking sockets, write will block indefinitely if the socket at the
* other end of the connection doesn't receive any data.
* NOTE: This method guarantees that all of the data will be sent unless
* there was an error, so it might block temporarily when the write buffer
* is full
*/
int writePacket(void* data, size_t size, DataType type = kPipeAppend_type);
/*
/**
* Read a logical packet from socket. The data read will be stored
* sequentially in the dataArray. This method will keep running until all
* the data in a logical chunk has been read (assembling multiple partial
* packets if necessary) and return the number of bytes successfully read,
* unless there was an error, in which case the method returns -1. NOTE: For
* unless there was an error, in which case the method returns -1. \For
* nonblocking sockets, read will return 0 if there's nothing to read. For
* blocking sockets, read will block indefinitely if the socket doesn't
* receive any data.
* once
* NOTE: This method guarantees that all the data in a logical packet will
* be read so there might be temporary delays if it's waiting for parts of a
* packet
*/
int readPacket(void (*onRead)(const void* data, size_t size,int cid,
int readPacket(void (*onRead)(int cid, const void* data, size_t size,
DataType type, void*), void* context);
// Suspend network transfers until resume() is called. Leaves all
// connections in tact.
/**
* Suspend network transfers until resume() is called. Leaves all
* connections in tact.
*/
void suspendAll() { fReadSuspended = fWriteSuspended = true; }
// Resume all network transfers.
/**
* Resume all network transfers.
*/
void resumeAll() { fReadSuspended = fWriteSuspended = false; }
// Other helper functions
/**
* Other helper functions
*/
void suspendRead() { fReadSuspended = true; }
void resumeRead() { fReadSuspended = false; }
void suspendWrite() { fWriteSuspended = true; }
@ -89,22 +97,34 @@ protected:
DataType type;
};
// Create a socket and return its file descriptor. Returns -1 on failure
/**
* Create a socket and return its file descriptor. Returns -1 on failure
*/
int createSocket();
// Close the socket specifies by the socket file descriptor passed in. Will
// update fMaxfd
/**
* Close the socket specified by the socket file descriptor argument. Will
* update fMaxfd and working set properly
*/
void closeSocket(int sockfd);
// called when a broken or terminated connection has been detected. Closes
// the socket file descriptor and removes it from the master set by default.
// Override to handle broken connections differently
/**
* Called when a broken or terminated connection has been detected. Closes
* the socket file descriptor and removes it from the master set by default.
* Override to handle broken connections differently
*/
virtual void onFailedConnection(int sockfd);
// set the socket specified by the socket file descriptor as nonblocking
/**
* Set the socket specified by the socket file descriptor as nonblocking
*/
void setNonBlocking(int sockfd);
// add the socket specified by the socket file descriptor to the master
// file descriptor set, which is used to in the select() to detect new data
// or connections
/**
* Add the socket specified by the socket file descriptor to the master
* file descriptor set, which is used to in the select() to detect new data
* or connections
*/
void addToMasterSet(int sockfd);
bool fConnected;
@ -114,32 +134,37 @@ protected:
int fMaxfd;
int fPort;
int fSockfd;
// fMasterSet contains all the file descriptors to be used for read/write.
// For clients, this will only contain fSockfd. For servers, this will
// contain all the file descriptors associated with established connections
// to clients
/**
* fMasterSet contains all the file descriptors to be used for read/write.
* For clients, this only contains the client socket. For servers, this
* contains all the file descriptors associated with established connections
* to clients
*/
fd_set fMasterSet;
timeval fTimeout;
};
/*
* TCP server. Can accept simultaneous connections to multiple SkTCPClients and
* read/write data back and forth using read/writePacket calls. Port number can
* be specified, but make sure that the clients use the same port for connections
* be specified, but make sure that client/server use the same port
*/
class SkTCPServer : public SkSocket {
public:
SkTCPServer(int port = DEFAULT_PORT);
~SkTCPServer();
// accept any incoming connections to the server, will only accept a limited
// number of clients (specified by MAX_CLIENTS) at a time. Returns -1 on
// error. For blocking sockets, this method will block until a client has
// connected
int acceptIncomingConnections();
/**
* Accept any incoming connections to the server, will accept 1 connection
* at a time. Returns -1 on error. For blocking sockets, this method will
* block until a client calls connectToServer()
*/
int acceptConnections();
// disconnect all connections to clients. Returns -1 on error
int disconnectAllConnections();
/**
* Disconnect all connections to clients. Returns -1 on error
*/
int disconnectAll();
private:
typedef SkSocket INHERITED;
};
@ -153,15 +178,17 @@ class SkTCPClient : public SkSocket {
public:
SkTCPClient(const char* hostname, int port = DEFAULT_PORT);
// Connect to server. Returns -1 on error or failure. Make sure to call this
// before any read/write operation to make sure that a connection is
// is established or is still open and reconnect to server if necessary. For
// blocking sockets, this method will block until the connection is accepted
// by the server.
/**
* Connect to server. Returns -1 on error or failure. Call this to connect
* or reconnect to the server. For blocking sockets, this method will block
* until the connection is accepted by the server.
*/
int connectToServer();
// Client needs to recreate the socket when a connection is broken because
// connect can only be called successfully once.
protected:
/**
* Client needs to recreate the socket when a connection is broken because
* connect can only be called successfully once.
*/
virtual void onFailedConnection(int sockfd);
private:
sockaddr_in fServerAddr;

View File

@ -2,9 +2,9 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1060</int>
<string key="IBDocument.SystemVersion">10J3250</string>
<string key="IBDocument.SystemVersion">10K540</string>
<string key="IBDocument.InterfaceBuilderVersion">851</string>
<string key="IBDocument.AppKitVersion">1038.35</string>
<string key="IBDocument.AppKitVersion">1038.36</string>
<string key="IBDocument.HIToolboxVersion">461.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
@ -12,7 +12,9 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="632"/>
<integer value="533"/>
<integer value="24"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@ -1326,6 +1328,33 @@
<object class="NSCustomView" id="322594744">
<reference key="NSNextResponder" ref="439893737"/>
<int key="NSvFlags">274</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSButton" id="215613538">
<reference key="NSNextResponder" ref="322594744"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{362, 312}, {96, 32}}</string>
<reference key="NSSuperview" ref="322594744"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="406327166">
<int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">134217728</int>
<string key="NSContents">Button</string>
<object class="NSFont" key="NSSupport" id="109605427">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">13</double>
<int key="NSfFlags">1044</int>
</object>
<reference key="NSControlView" ref="215613538"/>
<int key="NSButtonFlags">-2038284033</int>
<int key="NSButtonFlags2">129</int>
<string key="NSAlternateContents"/>
<string key="NSKeyEquivalent"/>
<int key="NSPeriodicDelay">200</int>
<int key="NSPeriodicInterval">25</int>
</object>
</object>
</object>
<string key="NSFrameSize">{480, 360}</string>
<reference key="NSSuperview" ref="439893737"/>
<string key="NSClassName">SkNSView</string>
@ -1343,6 +1372,194 @@
<object class="NSCustomObject" id="755631768">
<string key="NSClassName">NSFontManager</string>
</object>
<object class="NSCustomView" id="758604943">
<reference key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSScrollView" id="1038370525">
<reference key="NSNextResponder" ref="758604943"/>
<int key="NSvFlags">274</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSClipView" id="250930136">
<reference key="NSNextResponder" ref="1038370525"/>
<int key="NSvFlags">2304</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSTableView" id="429436769">
<reference key="NSNextResponder" ref="250930136"/>
<int key="NSvFlags">256</int>
<string key="NSFrameSize">{241, 301}</string>
<reference key="NSSuperview" ref="250930136"/>
<bool key="NSEnabled">YES</bool>
<object class="_NSCornerView" key="NSCornerView">
<nil key="NSNextResponder"/>
<int key="NSvFlags">-2147483392</int>
<string key="NSFrame">{{224, 0}, {16, 17}}</string>
</object>
<object class="NSMutableArray" key="NSTableColumns">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSTableColumn" id="691918008">
<double key="NSWidth">100</double>
<double key="NSMinWidth">40</double>
<double key="NSMaxWidth">1000</double>
<object class="NSTableHeaderCell" key="NSHeaderCell">
<int key="NSCellFlags">75628096</int>
<int key="NSCellFlags2">2048</int>
<string key="NSContents"/>
<object class="NSFont" key="NSSupport" id="26">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">11</double>
<int key="NSfFlags">3100</int>
</object>
<object class="NSColor" key="NSBackgroundColor" id="805714581">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC4zMzMzMzI5ODU2AA</bytes>
</object>
<object class="NSColor" key="NSTextColor" id="372600372">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">headerTextColor</string>
<object class="NSColor" key="NSColor" id="1032326875">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MAA</bytes>
</object>
</object>
</object>
<object class="NSTextFieldCell" key="NSDataCell" id="241301801">
<int key="NSCellFlags">337772096</int>
<int key="NSCellFlags2">2048</int>
<string key="NSContents">Text Cell</string>
<reference key="NSSupport" ref="109605427"/>
<reference key="NSControlView" ref="429436769"/>
<object class="NSColor" key="NSBackgroundColor" id="598476436">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">controlBackgroundColor</string>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC42NjY2NjY2ODY1AA</bytes>
</object>
</object>
<object class="NSColor" key="NSTextColor" id="1018211721">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">controlTextColor</string>
<reference key="NSColor" ref="1032326875"/>
</object>
</object>
<int key="NSResizingMask">3</int>
<bool key="NSIsResizeable">YES</bool>
<bool key="NSIsEditable">YES</bool>
<reference key="NSTableView" ref="429436769"/>
</object>
<object class="NSTableColumn" id="394988372">
<double key="NSWidth">135</double>
<double key="NSMinWidth">40</double>
<double key="NSMaxWidth">1000</double>
<object class="NSTableHeaderCell" key="NSHeaderCell">
<int key="NSCellFlags">75628096</int>
<int key="NSCellFlags2">2048</int>
<string key="NSContents"/>
<reference key="NSSupport" ref="26"/>
<reference key="NSBackgroundColor" ref="805714581"/>
<reference key="NSTextColor" ref="372600372"/>
</object>
<object class="NSTextFieldCell" key="NSDataCell" id="878937020">
<int key="NSCellFlags">337772096</int>
<int key="NSCellFlags2">2048</int>
<string key="NSContents">Text Cell</string>
<reference key="NSSupport" ref="109605427"/>
<reference key="NSControlView" ref="429436769"/>
<reference key="NSBackgroundColor" ref="598476436"/>
<reference key="NSTextColor" ref="1018211721"/>
</object>
<int key="NSResizingMask">3</int>
<bool key="NSIsResizeable">YES</bool>
<bool key="NSIsEditable">YES</bool>
<reference key="NSTableView" ref="429436769"/>
</object>
</object>
<double key="NSIntercellSpacingWidth">3</double>
<double key="NSIntercellSpacingHeight">2</double>
<object class="NSColor" key="NSBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
</object>
<object class="NSColor" key="NSGridColor">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">gridColor</string>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC41AA</bytes>
</object>
</object>
<double key="NSRowHeight">17</double>
<int key="NSTvFlags">-700448768</int>
<reference key="NSDelegate"/>
<reference key="NSDataSource"/>
<int key="NSGridStyleMask">1</int>
<int key="NSColumnAutoresizingStyle">4</int>
<int key="NSDraggingSourceMaskForLocal">15</int>
<int key="NSDraggingSourceMaskForNonLocal">0</int>
<bool key="NSAllowsTypeSelect">YES</bool>
<int key="NSTableViewDraggingDestinationStyle">0</int>
</object>
</object>
<string key="NSFrame">{{1, 1}, {241, 301}}</string>
<reference key="NSSuperview" ref="1038370525"/>
<reference key="NSNextKeyView" ref="429436769"/>
<reference key="NSDocView" ref="429436769"/>
<reference key="NSBGColor" ref="598476436"/>
<int key="NScvFlags">4</int>
</object>
<object class="NSScroller" id="617550661">
<reference key="NSNextResponder" ref="1038370525"/>
<int key="NSvFlags">-2147483392</int>
<string key="NSFrame">{{317, 1}, {15, 574}}</string>
<reference key="NSSuperview" ref="1038370525"/>
<reference key="NSTarget" ref="1038370525"/>
<string key="NSAction">_doScroller:</string>
<double key="NSPercent">0.95370370149612427</double>
</object>
<object class="NSScroller" id="977018641">
<reference key="NSNextResponder" ref="1038370525"/>
<int key="NSvFlags">-2147483392</int>
<string key="NSFrame">{{1, 263}, {157, 15}}</string>
<reference key="NSSuperview" ref="1038370525"/>
<int key="NSsFlags">1</int>
<reference key="NSTarget" ref="1038370525"/>
<string key="NSAction">_doScroller:</string>
<double key="NSPercent">0.98996657133102417</double>
</object>
</object>
<string key="NSFrameSize">{243, 303}</string>
<reference key="NSSuperview" ref="758604943"/>
<reference key="NSNextKeyView" ref="250930136"/>
<int key="NSsFlags">562</int>
<reference key="NSVScroller" ref="617550661"/>
<reference key="NSHScroller" ref="977018641"/>
<reference key="NSContentView" ref="250930136"/>
<bytes key="NSScrollAmts">QSAAAEEgAABBmAAAQZgAAA</bytes>
</object>
</object>
<string key="NSFrameSize">{243, 303}</string>
<reference key="NSSuperview"/>
<string key="NSClassName">NSView</string>
</object>
<object class="NSDrawer" id="764451088">
<nil key="NSNextResponder"/>
<string key="NSContentSize">{200, 100}</string>
<string key="NSMinContentSize">{0, 0}</string>
<string key="NSMaxContentSize">{10000, 10000}</string>
<int key="NSPreferredEdge">2</int>
<double key="NSLeadingOffset">0.0</double>
<double key="NSTrailingOffset">15</double>
<nil key="NSParentWindow"/>
<nil key="NSDelegate"/>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
@ -1907,14 +2124,6 @@
</object>
<int key="connectionID">493</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="1021"/>
<reference key="destination" ref="976324537"/>
</object>
<int key="connectionID">495</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">alignCenter:</string>
@ -2021,19 +2230,27 @@
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">fView</string>
<reference key="source" ref="972006081"/>
<reference key="destination" ref="322594744"/>
<string key="label">contentView</string>
<reference key="source" ref="764451088"/>
<reference key="destination" ref="758604943"/>
</object>
<int key="connectionID">535</int>
<int key="connectionID">542</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">toggle:</string>
<reference key="source" ref="764451088"/>
<reference key="destination" ref="215613538"/>
</object>
<int key="connectionID">649</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">window</string>
<reference key="source" ref="976324537"/>
<string key="label">parentWindow</string>
<reference key="source" ref="764451088"/>
<reference key="destination" ref="972006081"/>
</object>
<int key="connectionID">536</int>
<int key="connectionID">650</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
@ -3085,8 +3302,100 @@
<object class="IBObjectRecord">
<int key="objectID">533</int>
<reference key="object" ref="322594744"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="215613538"/>
</object>
<reference key="parent" ref="439893737"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">538</int>
<reference key="object" ref="758604943"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="1038370525"/>
</object>
<reference key="parent" ref="0"/>
<string key="objectName">Drawer Content View</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">539</int>
<reference key="object" ref="764451088"/>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">629</int>
<reference key="object" ref="1038370525"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="617550661"/>
<reference ref="977018641"/>
<reference ref="429436769"/>
</object>
<reference key="parent" ref="758604943"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">630</int>
<reference key="object" ref="617550661"/>
<reference key="parent" ref="1038370525"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">631</int>
<reference key="object" ref="977018641"/>
<reference key="parent" ref="1038370525"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">632</int>
<reference key="object" ref="429436769"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="691918008"/>
<reference ref="394988372"/>
</object>
<reference key="parent" ref="1038370525"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">634</int>
<reference key="object" ref="691918008"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="241301801"/>
</object>
<reference key="parent" ref="429436769"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">637</int>
<reference key="object" ref="241301801"/>
<reference key="parent" ref="691918008"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">635</int>
<reference key="object" ref="394988372"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="878937020"/>
</object>
<reference key="parent" ref="429436769"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">636</int>
<reference key="object" ref="878937020"/>
<reference key="parent" ref="394988372"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">646</int>
<reference key="object" ref="215613538"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="406327166"/>
</object>
<reference key="parent" ref="322594744"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">647</int>
<reference key="object" ref="406327166"/>
<reference key="parent" ref="215613538"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@ -3312,6 +3621,9 @@
<string>517.IBPluginDependency</string>
<string>533.IBPluginDependency</string>
<string>533.IBViewBoundsToFrameTransform</string>
<string>538.IBEditorWindowLastContentRect</string>
<string>538.IBPluginDependency</string>
<string>539.IBPluginDependency</string>
<string>56.IBPluginDependency</string>
<string>56.ImportedFromIB2</string>
<string>57.IBEditorWindowLastContentRect</string>
@ -3320,6 +3632,18 @@
<string>57.editorWindowContentRectSynchronizationRect</string>
<string>58.IBPluginDependency</string>
<string>58.ImportedFromIB2</string>
<string>629.IBPluginDependency</string>
<string>629.IBViewBoundsToFrameTransform</string>
<string>630.IBPluginDependency</string>
<string>631.IBPluginDependency</string>
<string>632.IBPluginDependency</string>
<string>634.IBPluginDependency</string>
<string>635.IBPluginDependency</string>
<string>636.IBPluginDependency</string>
<string>637.IBPluginDependency</string>
<string>646.IBPluginDependency</string>
<string>646.IBViewBoundsToFrameTransform</string>
<string>647.IBPluginDependency</string>
<string>72.IBPluginDependency</string>
<string>72.ImportedFromIB2</string>
<string>73.IBPluginDependency</string>
@ -3404,7 +3728,7 @@
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{547, 180}, {254, 283}}</string>
<string>{{559, 374}, {254, 283}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{187, 434}, {243, 243}}</string>
@ -3449,17 +3773,17 @@
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{654, 239}, {194, 73}}</string>
<string>{{719, 584}, {194, 73}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{525, 802}, {197, 73}}</string>
<string>{{380, 836}, {489, 20}}</string>
<string>{{366, 657}, {485, 20}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{74, 862}</string>
<string>{{6, 978}, {478, 20}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{604, 269}, {231, 43}}</string>
<string>{{669, 614}, {231, 43}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{475, 832}, {234, 43}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@ -3478,16 +3802,16 @@
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{358, 214}, {480, 360}}</string>
<string>{{83, 418}, {480, 360}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{358, 214}, {480, 360}}</string>
<string>{{83, 418}, {480, 360}}</string>
<integer value="1"/>
<string>{{33, 99}, {480, 360}}</string>
<string>{3.40282e+38, 3.40282e+38}</string>
<string>{0, 0}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{591, 420}, {83, 43}}</string>
<string>{{603, 614}, {83, 43}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{523, 2}, {178, 283}}</string>
@ -3537,7 +3861,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{725, 289}, {246, 23}}</string>
<string>{{790, 634}, {221, 23}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@ -3570,15 +3894,34 @@
<object class="NSAffineTransform">
<bytes key="NSTransformStruct">AULIAABDAgAAA</bytes>
</object>
<string>{{136, 964}, {243, 303}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{286, 129}, {275, 183}}</string>
<string>{{378, 474}, {250, 183}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{23, 794}, {245, 183}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSAffineTransform">
<bytes key="NSTransformStruct">P4AAAL+AAAAAAAAAxBNAAA</bytes>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSAffineTransform">
<bytes key="NSTransformStruct">P4AAAL+AAABDhgAAw6sAAA</bytes>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
@ -3594,7 +3937,7 @@
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{452, 109}, {196, 203}}</string>
<string>{{517, 454}, {196, 203}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{145, 474}, {199, 203}}</string>
@ -3622,7 +3965,7 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">536</int>
<int key="maxID">650</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@ -3630,9 +3973,20 @@
<object class="IBPartialClassDescription">
<string key="className">SampleWindow</string>
<string key="superclassName">SkNSWindow</string>
<object class="NSMutableDictionary" key="outlets">
<string key="NS.key.0">fView</string>
<string key="NS.object.0">SkNSView</string>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
<string key="NS.key.0">fView</string>
<object class="IBToOneOutletInfo" key="NS.object.0">
<string key="name">fView</string>
<string key="candidateClassName">SkNSView</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">SampleWindow.h</string>
<string key="minorKey">../../experimental/SimpleCocoaApp/SampleWindow.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
@ -3651,7 +4005,7 @@
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">SimpleCocoaAppDelegate.h</string>
<string key="minorKey">../../experimental/SimpleCocoaApp/SimpleCocoaAppDelegate.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
@ -3659,31 +4013,28 @@
<string key="superclassName">NSView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">SkNSView.h</string>
<string key="minorKey">../../experimental/SimpleCocoaApp/SkNSView.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">SkNSWindow</string>
<string key="superclassName">NSWindow</string>
<object class="NSMutableDictionary" key="outlets">
<string key="NS.key.0">fView</string>
<string key="NS.object.0">SkNSView</string>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
<string key="NS.key.0">fView</string>
<object class="IBToOneOutletInfo" key="NS.object.0">
<string key="name">fView</string>
<string key="candidateClassName">SkNSView</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">SkNSWindow.h</string>
<string key="minorKey">../../experimental/SimpleCocoaApp/SkNSWindow.h</string>
</object>
</object>
</object>
<object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">NSActionCell</string>
<string key="superclassName">NSCell</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">AppKit.framework/Headers/NSActionCell.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSApplication</string>
<string key="superclassName">NSResponder</string>
@ -3735,6 +4086,30 @@
<string key="minorKey">AppKit.framework/Headers/NSBrowser.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSButton</string>
<string key="superclassName">NSControl</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">AppKit.framework/Headers/NSButton.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSButtonCell</string>
<string key="superclassName">NSActionCell</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">AppKit.framework/Headers/NSButtonCell.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSCell</string>
<string key="superclassName">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">AppKit.framework/Headers/NSCell.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSControl</string>
<string key="superclassName">NSView</string>
@ -3872,6 +4247,14 @@
<string key="minorKey">AppKit.framework/Headers/NSDocumentController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSDrawer</string>
<string key="superclassName">NSResponder</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier" id="716270263">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">AppKit.framework/Headers/NSDrawer.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSFontManager</string>
<string key="superclassName">NSObject</string>
@ -3880,14 +4263,6 @@
<string key="minorKey">AppKit.framework/Headers/NSFontManager.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSFormatter</string>
<string key="superclassName">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Foundation.framework/Headers/NSFormatter.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSMatrix</string>
<string key="superclassName">NSControl</string>
@ -4032,133 +4407,7 @@
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Foundation.framework/Headers/NSArchiver.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Foundation.framework/Headers/NSClassDescription.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Foundation.framework/Headers/NSError.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Foundation.framework/Headers/NSFileManager.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Foundation.framework/Headers/NSKeyValueCoding.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Foundation.framework/Headers/NSKeyValueObserving.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Foundation.framework/Headers/NSKeyedArchiver.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Foundation.framework/Headers/NSObject.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Foundation.framework/Headers/NSObjectScripting.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Foundation.framework/Headers/NSPortCoder.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Foundation.framework/Headers/NSRunLoop.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Foundation.framework/Headers/NSScriptClassDescription.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Foundation.framework/Headers/NSScriptKeyValueCoding.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Foundation.framework/Headers/NSScriptObjectSpecifiers.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Foundation.framework/Headers/NSScriptWhoseTests.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Foundation.framework/Headers/NSThread.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Foundation.framework/Headers/NSURL.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Foundation.framework/Headers/NSURLConnection.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Foundation.framework/Headers/NSURLDownload.h</string>
<string key="minorKey">PrintCore.framework/Headers/PDEPluginInterface.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
@ -4176,6 +4425,30 @@
<string key="minorKey">AppKit.framework/Headers/NSResponder.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSScrollView</string>
<string key="superclassName">NSView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">AppKit.framework/Headers/NSScrollView.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSScroller</string>
<string key="superclassName">NSControl</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">AppKit.framework/Headers/NSScroller.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSTableColumn</string>
<string key="superclassName">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">AppKit.framework/Headers/NSTableColumn.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSTableView</string>
<string key="superclassName">NSControl</string>
@ -4189,6 +4462,14 @@
<string key="minorKey">AppKit.framework/Headers/NSText.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSTextFieldCell</string>
<string key="superclassName">NSActionCell</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">AppKit.framework/Headers/NSTextFieldCell.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSTextView</string>
<string key="superclassName">NSText</string>
@ -4222,10 +4503,7 @@
</object>
<object class="IBPartialClassDescription">
<string key="className">NSWindow</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">AppKit.framework/Headers/NSDrawer.h</string>
</object>
<reference key="sourceIdentifier" ref="716270263"/>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSWindow</string>
@ -4246,16 +4524,12 @@
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
<integer value="1060" key="NS.object.0"/>
</object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string>
<integer value="3000" key="NS.object.0"/>
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<string key="IBDocument.LastKnownRelativeProjectPath">../SimpleCocoaApp.xcodeproj</string>
<string key="IBDocument.LastKnownRelativeProjectPath">../../../out/gyp/SimpleCocoaApp.xcodeproj</string>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<object class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
<bool key="EncodedWithXMLCoder">YES</bool>

View File

@ -2,7 +2,6 @@
#include "SkEvent.h"
#define SkEventClass @"SkEvenClass"
@implementation SkEventNotifier
//Overwritten from NSObject
- (id)init {
self = [super init];
if (self) {
@ -44,9 +43,12 @@
@end
////////////////////////////////////////////////////////////////////////////////
void SkEvent::SignalNonEmptyQueue() {
//post a SkEventClass event to the default notification center
[[NSNotificationCenter defaultCenter] postNotificationName:SkEventClass
object:nil];
//post a SkEventClass event to the default notification queue
NSNotification* notification = [NSNotification notificationWithName:SkEventClass object:nil];
[[NSNotificationQueue defaultQueue] enqueueNotification:notification
postingStyle:NSPostWhenIdle
coalesceMask:NSNotificationNoCoalescing
forModes:nil];
}
void SkEvent::SignalQueueTimer(SkMSec delay) {

View File

@ -1,18 +0,0 @@
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#import <UIKit/UIKit.h>
@interface SkAlertPrompt : UIAlertView {
UITextField *textField;
}
@property (nonatomic, retain) UITextField *textField;
- (NSString*)enteredText;
@end

View File

@ -1,49 +0,0 @@
//
// SkAlertPrompt.m
// iOSSampleApp
//
// Created by Yang Su on 7/6/11.
// Copyright 2011 Google Inc.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#import "SkAlertPrompt.h"
@implementation SkAlertPrompt
@synthesize textField;
- (id)initWithTitle:(NSString *)title
message:(NSString *)message
delegate:(id)delegate
cancelButtonTitle:(NSString *)cancelButtonTitle
otherButtonTitles:(NSString *)okayButtonTitle,... {
if (self = [super initWithTitle:title
message:message
delegate:delegate
cancelButtonTitle:cancelButtonTitle
otherButtonTitles:okayButtonTitle, nil]) {
self.textField = [[UITextField alloc]
initWithFrame:CGRectMake(12, 45, 260, 25)];
[self.textField setBackgroundColor:[UIColor whiteColor]];
textField.borderStyle = UITextBorderStyleLine;
[self addSubview:self.textField];
}
return self;
}
- (void)show {
[textField becomeFirstResponder];
[super show];
}
- (NSString *)enteredText {
return textField.text;
}
- (void)dealloc {
[textField release];
[super dealloc];
}
@end

View File

@ -36,7 +36,7 @@
- (UITableViewCell*)createSlider:(NSString*)title min:(float)min max:(float)max default:(float)value;
- (UITableViewCell*)createSwitch:(NSString*)title default:(BOOL)state;
- (UITableViewCell*)createTriState:(NSString*)title default:(int)index;
- (UITableViewCell*)createTextField:(NSString*)title default:(const char*)value;
- (UITableViewCell*)createTextField:(NSString*)title default:(NSString*)value;
- (UITableViewCell*)createList:(NSString*)title default:(NSString*)value;
@end

View File

@ -70,22 +70,22 @@
const SkOSMenu::Item* item = menu->getItem(i);
NSString* title = [NSString stringWithUTF8String:item->getLabel()];
int index = 0;
NSArray* optionstrs = nil;
if (SkOSMenu::kList_Type == item->getType()) {
int value = 0;
SkOptionListItem* List = [[SkOptionListItem alloc] init];
//List.fCmdID = item->fOSCmd;
//List.getEvent() = item->getEvent();
List.fItem = item;
List.fOptions = [[SkOptionListController alloc] initWithStyle:UITableViewStyleGrouped];
NSArray* optionstrs = [[NSString stringWithUTF8String:item->getEvent()->findString(SkOSMenu::List_Items_Str)]
componentsSeparatedByString:[NSString stringWithUTF8String:SkOSMenu::Delimiter]];
for (NSString* optionstr in optionstrs) {
[List.fOptions addOption:optionstr];
}
item->getEvent()->findS32(item->getSlotName(), &index);
List.fOptions.fSelectedIndex = index;
int count = 0;
SkOSMenu::FindListItemCount(item->getEvent(), &count);
SkString options[count];
SkOSMenu::FindListItems(item->getEvent(), options);
for (int i = 0; i < count; ++i)
[List.fOptions addOption:[NSString stringWithUTF8String:options[i].c_str()]];
SkOSMenu::FindListIndex(item->getEvent(), item->getSlotName(), &value);
List.fOptions.fSelectedIndex = value;
List.fCell = [self createList:title
default:[List.fOptions getSelectedOption]];
List.fOptions.fParentCell = List.fCell;
@ -95,32 +95,36 @@
else {
SkOptionItem* option = [[SkOptionItem alloc] init];
option.fItem = item;
bool state = false;
SkString str;
SkOSMenu::TriState tristate;
switch (item->getType()) {
case SkOSMenu::kAction_Type:
option.fCell = [self createAction:title];
break;
case SkOSMenu::kSwitch_Type:
item->getEvent()->findBool(item->getSlotName(), &state);
SkOSMenu::FindSwitchState(item->getEvent(), item->getSlotName(), &state);
option.fCell = [self createSwitch:title default:(BOOL)state];
break;
case SkOSMenu::kSlider_Type:
SkScalar min, max, value;
item->getEvent()->findScalar(SkOSMenu::Slider_Min_Scalar, &min);
item->getEvent()->findScalar(SkOSMenu::Slider_Max_Scalar, &max);
item->getEvent()->findScalar(item->getSlotName(), &value);
SkOSMenu::FindSliderValue(item->getEvent(), item->getSlotName(), &value);
SkOSMenu::FindSliderMin(item->getEvent(), &min);
SkOSMenu::FindSliderMax(item->getEvent(), &max);
option.fCell = [self createSlider:title
min:min
max:max
default:value];
break;
case SkOSMenu::kTriState_Type:
item->getEvent()->findS32(item->getSlotName(), &index);
option.fCell = [self createTriState:title default:index];
SkOSMenu::FindTriState(item->getEvent(), item->getSlotName(), &tristate);
option.fCell = [self createTriState:title default:(int)tristate];
break;
case SkOSMenu::kTextField_Type:
SkOSMenu::FindText(item->getEvent(), item->getSlotName(), &str);
option.fCell = [self createTextField:title
default:item->getEvent()->findString(item->getSlotName())];
default:[NSString stringWithUTF8String:str.c_str()]];
break;
default:
break;
@ -225,7 +229,7 @@
}
- (UITableViewCell*)createTextField:(NSString*)title
default:(const char*)value {
default:(NSString*)value {
UITableViewCell* cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleValue1
reuseIdentifier:nil] autorelease];
@ -236,7 +240,7 @@
textField.adjustsFontSizeToFitWidth = YES;
textField.textAlignment = UITextAlignmentRight;
textField.textColor = cell.detailTextLabel.textColor;
textField.placeholder = [NSString stringWithUTF8String:value];
textField.placeholder = value;
textField.returnKeyType = UIReturnKeyDone;
[textField addTarget:self
action:@selector(valueChanged:)
@ -280,7 +284,7 @@
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath];
id item = [fItems objectAtIndex:indexPath.row];
id item = [fItems objectAtIndex:[self convertPathToIndex:indexPath]];
if ([item isKindOfClass:[SkOptionListItem class]]) {
SkOptionListItem* list = (SkOptionListItem*)item;

View File

@ -1,7 +1,6 @@
#import "SkAlertPrompt.h"
#import "SkUIDetailViewController.h"
#include "SampleApp.h"
#include "SkApplication.h"
#include "SkCGUtils.h"
#include "SkData.h"
#include "SkOSMenu.h"
@ -19,10 +18,23 @@
[self createButtons];
UISwipeGestureRecognizer* swipe = [[UISwipeGestureRecognizer alloc]
initWithTarget:self
action:@selector(handleSwipe:)];
[self.navigationController.navigationBar addGestureRecognizer:swipe];
[swipe release];
swipe = [[UISwipeGestureRecognizer alloc]
initWithTarget:self
action:@selector(handleSwipe:)];
swipe.direction = UISwipeGestureRecognizerDirectionLeft;
[self.navigationController.navigationBar addGestureRecognizer:swipe];
[swipe release];
fOptionsController = [[SkOptionsTableViewController alloc]
initWithStyle:UITableViewStyleGrouped];
fSkUIView.fOptionsDelegate = fOptionsController;
[fOptionsController registerMenus:fWind->getMenus()];
}
- (void)createButtons {
@ -62,6 +74,13 @@
[toolbar release];
}
- (void)handleSwipe:(UISwipeGestureRecognizer *)sender {
if (UISwipeGestureRecognizerDirectionRight == sender.direction)
fWind->previousSample();
else
fWind->nextSample();
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES; // Overriden to allow auto rotation for any direction
}
@ -71,7 +90,6 @@
[fOptionsButton release];
[fPopOverController release];
[fOptionsController release];
application_term();
[super dealloc];
}

View File

@ -15,7 +15,8 @@
#include "SkMatrix.h"
#include "FlingState.h"
#include "SampleApp.h"
#include "SkiOSDeviceManager.h"
class SkiOSDeviceManager;
class SkOSWindow;
class SkEvent;
struct FPSState;
@ -30,7 +31,7 @@ struct FPSState;
@interface SkUIView : UIView {
BOOL fRedrawRequestPending;
struct {
EAGLContext* fContext;
GLuint fRenderbuffer;

View File

@ -15,71 +15,82 @@
#include "GrGLInterface.h"
#include "SkGpuDevice.h"
#include "SkCGUtils.h"
SkiOSDeviceManager::SkiOSDeviceManager() {
fGrContext = NULL;
fGrRenderTarget = NULL;
usingGL = false;
}
SkiOSDeviceManager::~SkiOSDeviceManager() {
SkSafeUnref(fGrContext);
SkSafeUnref(fGrRenderTarget);
}
void SkiOSDeviceManager::init(SampleWindow* win) {
win->attachGL();
if (NULL == fGrContext) {
#ifdef USE_GL_1
fGrContext = GrContext::Create(kOpenGL_Fixed_GrEngine, NULL);
#else
fGrContext = GrContext::Create(kOpenGL_Shaders_GrEngine, NULL);
#endif
}
fGrRenderTarget = SkGpuDevice::Current3DApiRenderTarget();
if (NULL == fGrContext) {
SkDebugf("Failed to setup 3D");
win->detachGL();
}
}
bool SkiOSDeviceManager::supportsDeviceType(SampleWindow::DeviceType dType) {
switch (dType) {
case SampleWindow::kRaster_DeviceType:
case SampleWindow::kPicture_DeviceType: // fallthru
return true;
case SampleWindow::kGPU_DeviceType:
return NULL != fGrContext;
default:
return false;
}
}
bool SkiOSDeviceManager::prepareCanvas(SampleWindow::DeviceType dType,
SkCanvas* canvas,
SampleWindow* win) {
if (SampleWindow::kGPU_DeviceType == dType) {
canvas->setDevice(new SkGpuDevice(fGrContext, fGrRenderTarget))->unref();
usingGL = true;
}
else {
//The clip needs to be applied with a device attached to the canvas
canvas->setBitmapDevice(win->getBitmap());
class SkiOSDeviceManager : public SampleWindow::DeviceManager {
public:
SkiOSDeviceManager() {
fGrContext = NULL;
fGrRenderTarget = NULL;
usingGL = false;
}
return true;
}
void SkiOSDeviceManager::publishCanvas(SampleWindow::DeviceType dType,
SkCanvas* canvas,
SampleWindow* win) {
if (SampleWindow::kGPU_DeviceType == dType) {
fGrContext->flush();
virtual ~SkiOSDeviceManager() {
SkSafeUnref(fGrContext);
SkSafeUnref(fGrRenderTarget);
}
else {
//CGContextRef cg = UIGraphicsGetCurrentContext();
//SkCGDrawBitmap(cg, win->getBitmap(), 0, 0);
virtual void init(SampleWindow* win) {
win->attachGL();
if (NULL == fGrContext) {
#ifdef USE_GL_1
fGrContext = GrContext::Create(kOpenGL_Fixed_GrEngine, NULL);
#else
fGrContext = GrContext::Create(kOpenGL_Shaders_GrEngine, NULL);
#endif
}
fGrRenderTarget = SkGpuDevice::Current3DApiRenderTarget();
if (NULL == fGrContext) {
SkDebugf("Failed to setup 3D");
win->detachGL();
}
}
virtual bool supportsDeviceType(SampleWindow::DeviceType dType) {
switch (dType) {
case SampleWindow::kRaster_DeviceType:
case SampleWindow::kPicture_DeviceType: // fallthru
return true;
case SampleWindow::kGPU_DeviceType:
return NULL != fGrContext;
default:
return false;
}
}
win->presentGL();
}
virtual bool prepareCanvas(SampleWindow::DeviceType dType,
SkCanvas* canvas,
SampleWindow* win) {
if (SampleWindow::kGPU_DeviceType == dType) {
canvas->setDevice(new SkGpuDevice(fGrContext, fGrRenderTarget))->unref();
usingGL = true;
}
else {
//The clip needs to be applied with a device attached to the canvas
canvas->setBitmapDevice(win->getBitmap());
usingGL = false;
}
return true;
}
virtual void publishCanvas(SampleWindow::DeviceType dType,
SkCanvas* canvas,
SampleWindow* win) {
if (SampleWindow::kGPU_DeviceType == dType) {
fGrContext->flush();
}
else {
//CGContextRef cg = UIGraphicsGetCurrentContext();
//SkCGDrawBitmap(cg, win->getBitmap(), 0, 0);
}
win->presentGL();
}
virtual void windowSizeChanged(SampleWindow* win) {}
bool isUsingGL() { return usingGL; }
virtual GrContext* getGrContext() { return fGrContext; }
private:
bool usingGL;
GrContext* fGrContext;
GrRenderTarget* fGrRenderTarget;
};
////////////////////////////////////////////////////////////////////////////////
@implementation SkUIView
@ -90,17 +101,8 @@ void SkiOSDeviceManager::publishCanvas(SampleWindow::DeviceType dType,
#include "SkEvent.h"
#include "SkWindow.h"
static float gScreenScale = 1;
#define kREDRAW_UIVIEW_GL "sk_redraw_uiview_gl_iOS"
static const float SCALE_FOR_ZOOM_LENS = 4.0;
#define Y_OFFSET_FOR_ZOOM_LENS 200
#define SIZE_FOR_ZOOM_LENS 250
static const float MAX_ZOOM_SCALE = 4.0;
static const float MIN_ZOOM_SCALE = 2.0 / MAX_ZOOM_SCALE;
extern bool gDoTraceDraw;
#define DO_TRACE_DRAW_MAX 100
@ -171,6 +173,16 @@ static FPSState gFPS;
- (id)initWithMyDefaults {
fRedrawRequestPending = false;
fFPSState = new FPSState;
//Add gesture recognizer for single taps. Taps on the right half of the view
//will cause SampleApp to go to the next sample, taps on the left will go to
//the previous sample
UITapGestureRecognizer* tap = [[UITapGestureRecognizer alloc]
initWithTarget:self
action:@selector(handleTap:)];
[self addGestureRecognizer:tap];
[tap release];
#ifdef USE_GL_1
fGL.fContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
#else
@ -227,6 +239,7 @@ static FPSState gFPS;
fWind = new SampleWindow(self, NULL, NULL, fDevManager);
application_init();
fWind->resize(self.frame.size.width, self.frame.size.height, SKWIND_CONFIG);
return self;
}
@ -258,11 +271,6 @@ static FPSState gFPS;
- (void)layoutSubviews {
int W, H;
gScreenScale = [UIScreen mainScreen].scale;
if ([self respondsToSelector:@selector(setContentScaleFactor:)]) {
self.contentScaleFactor = gScreenScale;
}
// Allocate color buffer backing based on the current layer size
glBindRenderbuffer(GL_RENDERBUFFER, fGL.fRenderbuffer);
@ -400,6 +408,15 @@ static FPSState gFPS;
}
}
- (void)handleTap:(UISwipeGestureRecognizer *)sender {
// CGPoint loc = [sender locationInView:self];
// if (loc.x > self.bounds.size.width/2)
// ((SampleWindow*)fWind)->nextSample();
// else
// ((SampleWindow*)fWind)->previousSample();
}
///////////////////////////////////////////////////////////////////////////////
- (void)setSkTitle:(const char *)title {

View File

@ -1,36 +0,0 @@
#ifndef SkiOSDeviceManager_DEFINED
#define SkiOSDeviceManager_DEFINED
#include "SampleApp.h"
#include "SkCanvas.h"
#include "GrContext.h"
#include "GrGLInterface.h"
#include "SkGpuDevice.h"
#include "SkCGUtils.h"
#include "GrContext.h"
class SkiOSDeviceManager : public SampleWindow::DeviceManager {
public:
SkiOSDeviceManager();
virtual ~SkiOSDeviceManager();
virtual void init(SampleWindow* win);
virtual bool supportsDeviceType(SampleWindow::DeviceType dType);
virtual bool prepareCanvas(SampleWindow::DeviceType dType,
SkCanvas* canvas,
SampleWindow* win);
virtual void publishCanvas(SampleWindow::DeviceType dType,
SkCanvas* canvas,
SampleWindow* win);
virtual void windowSizeChanged(SampleWindow* win) {}
bool isUsingGL() { return usingGL; }
virtual GrContext* getGrContext() { return fGrContext; }
private:
bool usingGL;
GrContext* fGrContext;
GrRenderTarget* fGrRenderTarget;
};
#endif

View File

@ -429,23 +429,25 @@
260EF18513AFD62E0064D447 /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 260EF18413AFD62E0064D447 /* CoreText.framework */; };
260EF2B013AFDBD30064D447 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
263BE75813CCC7BF00CCE991 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 263BE75713CCC7BF00CCE991 /* QuartzCore.framework */; };
26591EB913EB16EB000DA8A8 /* TransitionView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26591EB813EB16EB000DA8A8 /* TransitionView.cpp */; };
265C7DE313D75752008329F6 /* SkOptionListController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 265C7DE213D75752008329F6 /* SkOptionListController.mm */; };
265C816C13D77860008329F6 /* SampleDrawingClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 265C816A13D77860008329F6 /* SampleDrawingClient.cpp */; };
2662AB7013BD067900CDE7E9 /* SkiOSSampleApp-Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 2662AB6F13BD067900CDE7E9 /* SkiOSSampleApp-Debug.xcconfig */; };
2662AB7613BD0C0D00CDE7E9 /* SkiOSSampleApp-Release.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 2662AB7513BD0C0D00CDE7E9 /* SkiOSSampleApp-Release.xcconfig */; };
2662AB7813BD0C1E00CDE7E9 /* SkiOSSampleApp-Base.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 2662AB7713BD0C1E00CDE7E9 /* SkiOSSampleApp-Base.xcconfig */; };
2663AC9413D5D8D400C20488 /* SkOptionsTableViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2663AC9313D5D8D400C20488 /* SkOptionsTableViewController.mm */; };
26677D6613B4C548009319B8 /* SkData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26677D6513B4C548009319B8 /* SkData.cpp */; };
26811E7913DEFAE8001A1609 /* SkBitSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26811E7813DEFAE8001A1609 /* SkBitSet.cpp */; };
26811E8613DEFC33001A1609 /* SampleDrawingServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 265C816B13D77860008329F6 /* SampleDrawingServer.cpp */; };
268F31FE13CDE72D003A1EF2 /* SkSockets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268F31FA13CDE726003A1EF2 /* SkSockets.cpp */; };
268C50D613F022820003FF9A /* SkColorPalette.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268C50D213F022820003FF9A /* SkColorPalette.cpp */; };
268C50D713F022820003FF9A /* SkNetPipeController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268C50D413F022820003FF9A /* SkNetPipeController.cpp */; };
268C50DA13F022AF0003FF9A /* SampleDrawingClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268C50D813F022AF0003FF9A /* SampleDrawingClient.cpp */; };
268C50DB13F022AF0003FF9A /* SampleDrawingServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268C50D913F022AF0003FF9A /* SampleDrawingServer.cpp */; };
268C50DF13F0230C0003FF9A /* SampleNetPipeReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268C50DC13F0230C0003FF9A /* SampleNetPipeReader.cpp */; };
268C50E013F0230C0003FF9A /* SkSockets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268C50DD13F0230C0003FF9A /* SkSockets.cpp */; };
26962B2313CDF6A00039B1FB /* SkOSFile_iOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 260EE8BB13AFA7790064D447 /* SkOSFile_iOS.mm */; };
26962C8013CE256E0039B1FB /* SkUIDetailViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 26962C7913CE256E0039B1FB /* SkUIDetailViewController.mm */; };
26962C8113CE256E0039B1FB /* SkUIRootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 26962C7B13CE256E0039B1FB /* SkUIRootViewController.mm */; };
26962CA413CE265C0039B1FB /* SkOSWindow_iOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 26962CA313CE265C0039B1FB /* SkOSWindow_iOS.mm */; };
26962CAB13CE268A0039B1FB /* SampleApp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26962CA913CE268A0039B1FB /* SampleApp.cpp */; };
26962CEC13CE293A0039B1FB /* SkColorPalette.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26962CE813CE293A0039B1FB /* SkColorPalette.cpp */; };
26962CED13CE293A0039B1FB /* SkNetPipeController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26962CEA13CE293A0039B1FB /* SkNetPipeController.cpp */; };
26962D4F13CE2D780039B1FB /* GrGLDefaultInterface_iOS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26962D4E13CE2D780039B1FB /* GrGLDefaultInterface_iOS.cpp */; };
26A8AFF313E05D7000A3C111 /* GrResourceCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26A8AFF113E05D7000A3C111 /* GrResourceCache.cpp */; };
26E0E40A13B4E67800866555 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 260EE9D113AFA7850064D447 /* OpenGLES.framework */; };
@ -1325,10 +1327,9 @@
260EE9D113AFA7850064D447 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; };
260EF18413AFD62E0064D447 /* CoreText.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreText.framework; path = System/Library/Frameworks/CoreText.framework; sourceTree = SDKROOT; };
263BE75713CCC7BF00CCE991 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
26591EB813EB16EB000DA8A8 /* TransitionView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TransitionView.cpp; sourceTree = "<group>"; };
265C7DE113D75752008329F6 /* SkOptionListController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SkOptionListController.h; path = Shared/SkOptionListController.h; sourceTree = "<group>"; };
265C7DE213D75752008329F6 /* SkOptionListController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = SkOptionListController.mm; path = Shared/SkOptionListController.mm; sourceTree = "<group>"; };
265C816A13D77860008329F6 /* SampleDrawingClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SampleDrawingClient.cpp; sourceTree = "<group>"; };
265C816B13D77860008329F6 /* SampleDrawingServer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SampleDrawingServer.cpp; sourceTree = "<group>"; };
2662AB6F13BD067900CDE7E9 /* SkiOSSampleApp-Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "SkiOSSampleApp-Debug.xcconfig"; sourceTree = "<group>"; };
2662AB7513BD0C0D00CDE7E9 /* SkiOSSampleApp-Release.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "SkiOSSampleApp-Release.xcconfig"; sourceTree = "<group>"; };
2662AB7713BD0C1E00CDE7E9 /* SkiOSSampleApp-Base.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "SkiOSSampleApp-Base.xcconfig"; sourceTree = "<group>"; };
@ -1336,11 +1337,17 @@
2663AC9313D5D8D400C20488 /* SkOptionsTableViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = SkOptionsTableViewController.mm; path = Shared/SkOptionsTableViewController.mm; sourceTree = "<group>"; };
26677D6413B4C53E009319B8 /* SkData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SkData.h; path = core/SkData.h; sourceTree = "<group>"; };
26677D6513B4C548009319B8 /* SkData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SkData.cpp; path = core/SkData.cpp; sourceTree = "<group>"; };
266CB66113CF56E30011139A /* SkiOSDeviceManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SkiOSDeviceManager.h; path = Shared/SkiOSDeviceManager.h; sourceTree = "<group>"; };
26811E7813DEFAE8001A1609 /* SkBitSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SkBitSet.cpp; path = ../../src/pdf/SkBitSet.cpp; sourceTree = SOURCE_ROOT; };
26811E7A13DEFAF7001A1609 /* SkBitSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SkBitSet.h; path = ../../include/pdf/SkBitSet.h; sourceTree = SOURCE_ROOT; };
268F31FA13CDE726003A1EF2 /* SkSockets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SkSockets.cpp; path = ../SkSockets.cpp; sourceTree = "<group>"; };
268F31FB13CDE726003A1EF2 /* SkSockets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SkSockets.h; path = ../SkSockets.h; sourceTree = "<group>"; };
268C50D213F022820003FF9A /* SkColorPalette.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SkColorPalette.cpp; path = ../DrawingBoard/SkColorPalette.cpp; sourceTree = SOURCE_ROOT; };
268C50D313F022820003FF9A /* SkColorPalette.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SkColorPalette.h; path = ../DrawingBoard/SkColorPalette.h; sourceTree = SOURCE_ROOT; };
268C50D413F022820003FF9A /* SkNetPipeController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SkNetPipeController.cpp; path = ../DrawingBoard/SkNetPipeController.cpp; sourceTree = SOURCE_ROOT; };
268C50D513F022820003FF9A /* SkNetPipeController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SkNetPipeController.h; path = ../DrawingBoard/SkNetPipeController.h; sourceTree = SOURCE_ROOT; };
268C50D813F022AF0003FF9A /* SampleDrawingClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SampleDrawingClient.cpp; path = ../DrawingBoard/SampleDrawingClient.cpp; sourceTree = SOURCE_ROOT; };
268C50D913F022AF0003FF9A /* SampleDrawingServer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SampleDrawingServer.cpp; path = ../DrawingBoard/SampleDrawingServer.cpp; sourceTree = SOURCE_ROOT; };
268C50DC13F0230C0003FF9A /* SampleNetPipeReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SampleNetPipeReader.cpp; path = ../Networking/SampleNetPipeReader.cpp; sourceTree = SOURCE_ROOT; };
268C50DD13F0230C0003FF9A /* SkSockets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SkSockets.cpp; path = ../Networking/SkSockets.cpp; sourceTree = SOURCE_ROOT; };
268C50DE13F0230C0003FF9A /* SkSockets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SkSockets.h; path = ../Networking/SkSockets.h; sourceTree = SOURCE_ROOT; };
26962C7813CE256E0039B1FB /* SkUIDetailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SkUIDetailViewController.h; path = Shared/SkUIDetailViewController.h; sourceTree = "<group>"; };
26962C7913CE256E0039B1FB /* SkUIDetailViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = SkUIDetailViewController.mm; path = Shared/SkUIDetailViewController.mm; sourceTree = "<group>"; };
26962C7A13CE256E0039B1FB /* SkUIRootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SkUIRootViewController.h; path = Shared/SkUIRootViewController.h; sourceTree = "<group>"; };
@ -1351,10 +1358,6 @@
26962CA513CE26730039B1FB /* SkOSWindow_iOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SkOSWindow_iOS.h; path = ../../include/views/SkOSWindow_iOS.h; sourceTree = SOURCE_ROOT; };
26962CA913CE268A0039B1FB /* SampleApp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SampleApp.cpp; path = ../../samplecode/SampleApp.cpp; sourceTree = SOURCE_ROOT; };
26962CAA13CE268A0039B1FB /* SampleApp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SampleApp.h; path = ../../samplecode/SampleApp.h; sourceTree = SOURCE_ROOT; };
26962CE813CE293A0039B1FB /* SkColorPalette.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SkColorPalette.cpp; path = Shared/DrawingBoard/SkColorPalette.cpp; sourceTree = "<group>"; };
26962CE913CE293A0039B1FB /* SkColorPalette.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SkColorPalette.h; path = Shared/DrawingBoard/SkColorPalette.h; sourceTree = "<group>"; };
26962CEA13CE293A0039B1FB /* SkNetPipeController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SkNetPipeController.cpp; path = Shared/DrawingBoard/SkNetPipeController.cpp; sourceTree = "<group>"; };
26962CEB13CE293A0039B1FB /* SkNetPipeController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SkNetPipeController.h; path = Shared/DrawingBoard/SkNetPipeController.h; sourceTree = "<group>"; };
26962D4E13CE2D780039B1FB /* GrGLDefaultInterface_iOS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GrGLDefaultInterface_iOS.cpp; path = ../../gpu/src/ios/GrGLDefaultInterface_iOS.cpp; sourceTree = SOURCE_ROOT; };
26A8AFF113E05D7000A3C111 /* GrResourceCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GrResourceCache.cpp; sourceTree = "<group>"; };
26A8AFF213E05D7000A3C111 /* GrResourceCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GrResourceCache.h; sourceTree = "<group>"; };
@ -1456,8 +1459,7 @@
260E002313B11F5B0064D447 /* samplecode */ = {
isa = PBXGroup;
children = (
265C816A13D77860008329F6 /* SampleDrawingClient.cpp */,
265C816B13D77860008329F6 /* SampleDrawingServer.cpp */,
26591EB813EB16EB000DA8A8 /* TransitionView.cpp */,
260E002413B11F5B0064D447 /* ClockFaceView.cpp */,
260E002513B11F5B0064D447 /* OverView.cpp */,
260E002613B11F5B0064D447 /* SampleAARects.cpp */,
@ -2715,7 +2717,6 @@
children = (
26FB98D113D0C87000ACBEA0 /* SkUIView.h */,
26FB98D213D0C87000ACBEA0 /* SkUIView.mm */,
266CB66113CF56E30011139A /* SkiOSDeviceManager.h */,
26962D4E13CE2D780039B1FB /* GrGLDefaultInterface_iOS.cpp */,
26962CA513CE26730039B1FB /* SkOSWindow_iOS.h */,
26962CA313CE265C0039B1FB /* SkOSWindow_iOS.mm */,
@ -2740,10 +2741,12 @@
26962CE713CE29120039B1FB /* DrawingBoard */ = {
isa = PBXGroup;
children = (
26962CE813CE293A0039B1FB /* SkColorPalette.cpp */,
26962CE913CE293A0039B1FB /* SkColorPalette.h */,
26962CEA13CE293A0039B1FB /* SkNetPipeController.cpp */,
26962CEB13CE293A0039B1FB /* SkNetPipeController.h */,
268C50D813F022AF0003FF9A /* SampleDrawingClient.cpp */,
268C50D913F022AF0003FF9A /* SampleDrawingServer.cpp */,
268C50D213F022820003FF9A /* SkColorPalette.cpp */,
268C50D313F022820003FF9A /* SkColorPalette.h */,
268C50D413F022820003FF9A /* SkNetPipeController.cpp */,
268C50D513F022820003FF9A /* SkNetPipeController.h */,
);
name = DrawingBoard;
sourceTree = "<group>";
@ -2751,8 +2754,9 @@
26F67B2A13CB3564005DDCD2 /* Networking */ = {
isa = PBXGroup;
children = (
268F31FA13CDE726003A1EF2 /* SkSockets.cpp */,
268F31FB13CDE726003A1EF2 /* SkSockets.h */,
268C50DC13F0230C0003FF9A /* SampleNetPipeReader.cpp */,
268C50DD13F0230C0003FF9A /* SkSockets.cpp */,
268C50DE13F0230C0003FF9A /* SkSockets.h */,
);
name = Networking;
sourceTree = "<group>";
@ -3339,27 +3343,29 @@
26F548E913B91980007CC564 /* SkBitmapProcState_opts_arm.cpp in Sources */,
26F548EC13B91980007CC564 /* SkBlitRow_opts_none.cpp in Sources */,
26F548ED13B91980007CC564 /* SkUtils_opts_none.cpp in Sources */,
268F31FE13CDE72D003A1EF2 /* SkSockets.cpp in Sources */,
26962B2313CDF6A00039B1FB /* SkOSFile_iOS.mm in Sources */,
26962C8013CE256E0039B1FB /* SkUIDetailViewController.mm in Sources */,
26962C8113CE256E0039B1FB /* SkUIRootViewController.mm in Sources */,
26962CA413CE265C0039B1FB /* SkOSWindow_iOS.mm in Sources */,
26962CAB13CE268A0039B1FB /* SampleApp.cpp in Sources */,
26962CEC13CE293A0039B1FB /* SkColorPalette.cpp in Sources */,
26962CED13CE293A0039B1FB /* SkNetPipeController.cpp in Sources */,
26962D4F13CE2D780039B1FB /* GrGLDefaultInterface_iOS.cpp in Sources */,
26FB98D313D0C87000ACBEA0 /* SkUIView.mm in Sources */,
2663AC9413D5D8D400C20488 /* SkOptionsTableViewController.mm in Sources */,
265C7DE313D75752008329F6 /* SkOptionListController.mm in Sources */,
265C816C13D77860008329F6 /* SampleDrawingClient.cpp in Sources */,
26811E7913DEFAE8001A1609 /* SkBitSet.cpp in Sources */,
26811E8613DEFC33001A1609 /* SampleDrawingServer.cpp in Sources */,
26A8AFF313E05D7000A3C111 /* GrResourceCache.cpp in Sources */,
26FB125E13E70310001AFF6D /* SkEventNotifier.mm in Sources */,
26FB129313E704AE001AFF6D /* GrGLTexture.cpp in Sources */,
26FB129413E704B0001AFF6D /* GrContext.cpp in Sources */,
26FB12B013E70D3B001AFF6D /* GrGLRenderTarget.cpp in Sources */,
26FB12B413E70D51001AFF6D /* GrRenderTarget.cpp in Sources */,
26591EB913EB16EB000DA8A8 /* TransitionView.cpp in Sources */,
268C50D613F022820003FF9A /* SkColorPalette.cpp in Sources */,
268C50D713F022820003FF9A /* SkNetPipeController.cpp in Sources */,
268C50DA13F022AF0003FF9A /* SampleDrawingClient.cpp in Sources */,
268C50DB13F022AF0003FF9A /* SampleDrawingServer.cpp in Sources */,
268C50DF13F0230C0003FF9A /* SampleNetPipeReader.cpp in Sources */,
268C50E013F0230C0003FF9A /* SkSockets.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -3397,7 +3403,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 2662AB6F13BD067900CDE7E9 /* SkiOSSampleApp-Debug.xcconfig */;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_OPTIMIZATION_LEVEL = 0;

View File

@ -53,6 +53,7 @@
'../samplecode/SampleDegenerateTwoPtRadials.cpp',
'../samplecode/SampleDither.cpp',
'../samplecode/SampleDitherBitmap.cpp',
'../samplecode/SampleDrawBitmap.cpp',
'../samplecode/SampleDrawLooper.cpp',
'../samplecode/SampleEffects.cpp',
'../samplecode/SampleEmboss.cpp',
@ -117,6 +118,24 @@
# Dependencies for the pipe code in SampleApp
'../src/pipe/SkGPipeRead.cpp',
'../src/pipe/SkGPipeWrite.cpp',
# DrawingBoard
'../experimental/DrawingBoard/SkColorPalette.h',
'../experimental/DrawingBoard/SkColorPalette.cpp',
'../experimental/DrawingBoard/SkNetPipeController.h',
'../experimental/DrawingBoard/SkNetPipeController.cpp',
'../experimental/DrawingBoard/SampleDrawingClient.cpp',
'../experimental/DrawingBoard/SampleDrawingServer.cpp',
# Networking
'../experimental/Networking/SampleNetPipeReader.cpp',
'../experimental/Networking/SkSockets.cpp',
'../experimental/Networking/SkSockets.h',
# Transition
'../src/utils/SkInterpolator.cpp',
'../include/utils/SkInterpolator.h',
'../samplecode/TransitionView.cpp',
],
'sources!': [
'../samplecode/SampleSkLayer.cpp', #relies on SkMatrix44 which doesn't compile
@ -163,14 +182,12 @@
'../experimental/CocoaSampleApp/SampleAppDelegate.mm',
'../experimental/CocoaSampleApp/SkNSView.h',
'../experimental/CocoaSampleApp/SkNSView.mm',
'../experimental/CocoaSampleApp/SkOSWindow_Mac.h',
'../experimental/CocoaSampleApp/SkOSWindow_Mac.mm',
'../experimental/CocoaSampleApp/SkOptionsTableView.h',
'../experimental/CocoaSampleApp/SkOptionsTableView.mm',
'../experimental/CocoaSampleApp/SkOSWindow_Mac.h',
'../experimental/CocoaSampleApp/SkOSWindow_Mac.mm',
'../experimental/CocoaSampleApp/SkTextFieldCell.h',
'../experimental/CocoaSampleApp/SkTextFieldCell.m',
'../experimental/SkSockets.h',
'../experimental/SkSockets.cpp',
'../experimental/SkEventNotifier.h',
'../experimental/SkEventNotifier.mm',
],
@ -181,6 +198,10 @@
'$(SDKROOT)/System/Library/Frameworks/QuartzCore.framework',
'$(SDKROOT)/System/Library/Frameworks/OpenGL.framework',
],
'libraries!': [
'$(SDKROOT)/System/Library/Frameworks/Carbon.framework',
'$(SDKROOT)/System/Library/Frameworks/AGL.framework',
],
},
'xcode_settings' : {
'INFOPLIST_FILE' : '../experimental/CocoaSampleApp/SampleApp-Info.plist',
@ -189,48 +210,6 @@
'../experimental/CocoaSampleApp/SampleApp.xib',
],
}],
[ 'skia_os == "ios"', {
# TODO: This doesn't build properly yet, but it's getting there.
'sources!': [
'../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',
'../experimental/iOSSampleApp/iOSSampleApp_Prefix.pch',
'../experimental/iOSSampleApp/Shared/main.m',
'../experimental/iOSSampleApp/iPad/AppDelegate_iPad.mm',
'../experimental/iOSSampleApp/iPad/SkUISplitViewController.mm',
'../experimental/iOSSampleApp/iPhone/AppDelegate_iPhone.mm',
'../experimental/iOSSampleApp/iPhone/SkUINavigationController.mm',
'../src/utils/ios/SkOSWindow_iOS.mm',
'../src/utils/ios/SkImageDecoder_iOS.mm',
'../src/utils/ios/SkStream_NSData.mm',
'../src/utils/ios/SkOSFile_iOS.mm',
'../src/utils/mac/SkCreateCGImageRef.cpp',
'../experimental/iOSSampleApp/SkiOSSampleApp-Debug.xcconfig',
'../experimental/iOSSampleApp/SkiOSSampleApp-Release.xcconfig',
],
'include_dirs' : [
'../experimental/iOSSampleApp',
'../experimental/iOSSampleApp/iPad',
'../experimental/iOSSampleApp/iPhone',
'../include/utils/ios',
'../../gpu/include',
],
'xcode_config_file': '../experimental/iOSSampleApp/SkiOSSampleApp-Base.xcconfig',
'mac_bundle_resources' : [
'../experimental/iOSSampleApp/iPad/MainWindow_iPad.xib',
'../experimental/iOSSampleApp/iPhone/MainWindow_iPhone.xib',
],
}],
],
'msvs_settings': {
'VCLinkerTool': {

View File

@ -21,7 +21,7 @@ SkOSWindow::~SkOSWindow() {
void SkOSWindow::onHandleInval(const SkIRect& r) {
if (!fInvalEventIsPending) {
fInvalEventIsPending = true;
(new SkEvent(kINVAL_UIVIEW_EventType))->post(this->getSinkID());
(new SkEvent(kINVAL_UIVIEW_EventType, this->getSinkID()))->post();
}
}