aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/iOSSampleApp
diff options
context:
space:
mode:
authorGravatar yangsu@google.com <yangsu@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-07-17 14:44:55 +0000
committerGravatar yangsu@google.com <yangsu@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-07-17 14:44:55 +0000
commit22db8af525ef1eb01eefe7ac255019ec69484db9 (patch)
tree77d194d47ff8198352fd4d18db1665f977f06c6b /experimental/iOSSampleApp
parentc5aeccd8ba0ca51b03512ad5d473adeee82cb6f8 (diff)
Removed old files in iOSSampleApp
git-svn-id: http://skia.googlecode.com/svn/trunk@1880 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'experimental/iOSSampleApp')
-rw-r--r--experimental/iOSSampleApp/SkAlertPrompt.h19
-rw-r--r--experimental/iOSSampleApp/SkAlertPrompt.m47
-rw-r--r--experimental/iOSSampleApp/SkIOSNotifier.h7
-rw-r--r--experimental/iOSSampleApp/SkIOSNotifier.mm58
-rw-r--r--experimental/iOSSampleApp/SkUIDetailViewController.h32
-rw-r--r--experimental/iOSSampleApp/SkUIDetailViewController.mm124
-rw-r--r--experimental/iOSSampleApp/SkUIRootViewController.h15
-rw-r--r--experimental/iOSSampleApp/SkUIRootViewController.mm64
-rw-r--r--experimental/iOSSampleApp/SkUIView_shell.h18
-rw-r--r--experimental/iOSSampleApp/SkUIView_shell.mm88
-rw-r--r--experimental/iOSSampleApp/SkUIView_withSkUIContainerView.h20
-rw-r--r--experimental/iOSSampleApp/SkUIView_withSkUIContainerView.mm145
12 files changed, 0 insertions, 637 deletions
diff --git a/experimental/iOSSampleApp/SkAlertPrompt.h b/experimental/iOSSampleApp/SkAlertPrompt.h
deleted file mode 100644
index 36053a99f6..0000000000
--- a/experimental/iOSSampleApp/SkAlertPrompt.h
+++ /dev/null
@@ -1,19 +0,0 @@
-//
-// SkAlertPrompt.h
-// iOSSampleApp
-//
-// Created by Yang Su on 7/6/11.
-// Copyright 2011 Google Inc. All rights reserved.
-//
-
-#import <UIKit/UIKit.h>
-
-
-@interface SkAlertPrompt : UIAlertView {
- UITextField *textField;
-}
-@property (nonatomic, retain) UITextField *textField;
-
-- (NSString*)enteredText;
-
-@end
diff --git a/experimental/iOSSampleApp/SkAlertPrompt.m b/experimental/iOSSampleApp/SkAlertPrompt.m
deleted file mode 100644
index 5156b10e53..0000000000
--- a/experimental/iOSSampleApp/SkAlertPrompt.m
+++ /dev/null
@@ -1,47 +0,0 @@
-//
-// SkAlertPrompt.m
-// iOSSampleApp
-//
-// Created by Yang Su on 7/6/11.
-// Copyright 2011 Google Inc. All rights reserved.
-//
-
-#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
diff --git a/experimental/iOSSampleApp/SkIOSNotifier.h b/experimental/iOSSampleApp/SkIOSNotifier.h
deleted file mode 100644
index 755ed458ef..0000000000
--- a/experimental/iOSSampleApp/SkIOSNotifier.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#import <Foundation/Foundation.h>
-
-@interface SkIOSNotifier : NSObject
-- (void)receiveSkEvent:(NSNotification*)notification;
-+ (void)postTimedSkEvent:(NSTimeInterval)ti;
-+ (void)timerFireMethod:(NSTimer*)theTimer;
-@end
diff --git a/experimental/iOSSampleApp/SkIOSNotifier.mm b/experimental/iOSSampleApp/SkIOSNotifier.mm
deleted file mode 100644
index 5c2bc55f45..0000000000
--- a/experimental/iOSSampleApp/SkIOSNotifier.mm
+++ /dev/null
@@ -1,58 +0,0 @@
-#import "SkIOSNotifier.h"
-#import "SkEvent.h"
-#define SkEventClass @"SkEvenClass"
-@implementation SkIOSNotifier
-//Overwritten from NSObject
-- (id)init {
- self = [super init];
- if (self) {
- //Register as an observer for SkEventClass events and call
- //receiveSkEvent: upon receiving the event
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(receiveSkEvent:)
- name:SkEventClass
- object:nil];
- }
- return self;
-}
-
-- (void)dealloc {
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- [super dealloc];
-}
-
--(BOOL) acceptsFirstResponder {
- return YES;
-}
-
-//SkEvent Handers
-- (void)receiveSkEvent:(NSNotification *)notification {
- if(SkEvent::ProcessEvent())
- SkEvent::SignalNonEmptyQueue();
-}
-
-+ (void)postTimedSkEvent:(NSTimeInterval)timeInterval {
- [NSTimer scheduledTimerWithTimeInterval:timeInterval target:self
- selector:@selector(timerFireMethod:)
- userInfo:nil repeats:NO];
-}
-
-+ (void)timerFireMethod:(NSTimer*)theTimer {
- SkEvent::ServiceQueueTimer();
-}
-
-@end
-////////////////////////////////////////////////////////////////////////////////
-void SkEvent::SignalNonEmptyQueue() {
- //post a SkEventClass event to the default notification center
- [[NSNotificationCenter defaultCenter] postNotificationName:SkEventClass
- object:nil];
-}
-
-void SkEvent::SignalQueueTimer(SkMSec delay) {
- if (delay) {
- //Convert to seconds
- NSTimeInterval ti = delay/(float)SK_MSec1;
- [SkIOSNotifier postTimedSkEvent:ti];
- }
-}
diff --git a/experimental/iOSSampleApp/SkUIDetailViewController.h b/experimental/iOSSampleApp/SkUIDetailViewController.h
deleted file mode 100644
index eba1b6ee70..0000000000
--- a/experimental/iOSSampleApp/SkUIDetailViewController.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#import <UIKit/UIKit.h>
-#import "SkUIRootViewController.h"
-#import "SkUIView_shell.h"
-
-class SampleWindow;
-class SkData;
-@interface SkUIDetailViewController : UIViewController {
-@private
- UINavigationBar* fNavigationBar;
- UIBarButtonItem* fPrintButton;
- SkData* fData;
- SkUIView_shell* fSkUIView;
- SampleWindow* fWind;
-}
-@property (nonatomic, retain) IBOutlet UINavigationBar *fNavigationBar;
-@property (nonatomic, retain) IBOutlet UIBarButtonItem* fPrintButton;
-
-//Instance methods
-- (void)redraw;
-- (void)populateRoot:(SkUIRootViewController*)root;
-- (void)goToItem:(NSUInteger)index;
-
-//UI actions
-- (IBAction)printContent:(id)sender;
-- (IBAction)usePipe:(id)sender;
-- (IBAction)enterServerIP:(id)sender;
-
-//SplitView popover management
-- (void)showRootPopoverButtonItem:(UIBarButtonItem *)barButtonItem;
-- (void)invalidateRootPopoverButtonItem:(UIBarButtonItem *)barButtonItem;
-
-@end
diff --git a/experimental/iOSSampleApp/SkUIDetailViewController.mm b/experimental/iOSSampleApp/SkUIDetailViewController.mm
deleted file mode 100644
index f19ce76219..0000000000
--- a/experimental/iOSSampleApp/SkUIDetailViewController.mm
+++ /dev/null
@@ -1,124 +0,0 @@
-#import "SkAlertPrompt.h"
-#import "SkUIDetailViewController.h"
-#include "SampleApp.h"
-#include "SkApplication.h"
-#include "SkCGUtils.h"
-#include "SkData.h"
-#include "SkWindow.h"
-
-@implementation SkUIDetailViewController
-@synthesize fNavigationBar, fPrintButton;
-
-//Overwritten from UIViewController
-- (void)viewDidLoad {
- [super viewDidLoad];
-
- fSkUIView = (SkUIView_shell*)self.view;
- fSkUIView.fTitle = fNavigationBar.topItem;
-
- application_init();
- fWind = (SampleWindow*)create_sk_window(self.view, NULL, NULL);
- CGSize s = self.view.bounds.size;
- fWind->resize(s.width, s.height);
- [fSkUIView setSkWindow:(SkOSWindow*)fWind];
-
- [NSTimer scheduledTimerWithTimeInterval:0.001 target:self
- selector:@selector(redraw) userInfo:nil
- repeats:YES];
-}
-
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
- return YES; // Overriden to allow auto rotation for any direction
-}
-
-- (void)dealloc {
- [fNavigationBar release];
- [fPrintButton release];
- application_term();
- delete fWind;
- [super dealloc];
-}
-
-//Instance Methods
-- (void)redraw {
- [self.view setNeedsDisplay];
-}
-
-- (void)populateRoot:(SkUIRootViewController*)rootVC {
- for (int i = 0; i < fWind->sampleCount(); ++i) {
- [rootVC addItem:[NSString stringWithUTF8String:fWind->getSampleTitle(i).c_str()]];
- }
-}
-
-- (void)goToItem:(NSUInteger)index {
- fWind->goToSample(index);
-}
-
-//UI actions
-- (IBAction)usePipe:(id)sender {
- //fWind->togglePipe();
-}
-
-- (IBAction)printContent:(id)sender {
- UIPrintInteractionController *controller = [UIPrintInteractionController sharedPrintController];
- UIPrintInfo *printInfo = [UIPrintInfo printInfo];
- printInfo.jobName = @"Skia iOS SampleApp";
- printInfo.duplex = UIPrintInfoDuplexLongEdge;
- printInfo.outputType = UIPrintInfoOutputGeneral;
- fWind->saveToPdf();
- [self.view drawRect:self.view.bounds];
- fData = fWind->getPDFData();
- NSData* data = [NSData dataWithBytesNoCopy:(void*)fData->data() length:fData->size()];
- controller.printInfo = printInfo;
- controller.printingItem = data;
- //Add ref because data pointer retains a pointer to data
- fData->ref();
-
- void (^SkCompletionHandler)(UIPrintInteractionController *, BOOL, NSError *) =
- ^(UIPrintInteractionController *pic, BOOL completed, NSError *error) {
- fData->unref();
- if (!completed && error)
- NSLog(@"FAILED! due to error in domain %@ with error code %u",
- error.domain, error.code);
- };
-
- if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
- [controller presentFromBarButtonItem:fPrintButton animated:YES
- completionHandler:SkCompletionHandler];
- } else {
- [controller presentAnimated:YES completionHandler:SkCompletionHandler];
- }
-}
-
-- (IBAction)enterServerIP:(id)sender {
- SkAlertPrompt *prompt = [[SkAlertPrompt alloc] initWithTitle:@"Enter Server IP:"
- message:@"\n"
- delegate:self
- cancelButtonTitle:@"Cancel"
- otherButtonTitles:@"Enter", nil];
- // show the dialog box
- [prompt show];
- [prompt release];
-}
-
-// manage popup
-- (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex
-{
- if (buttonIndex != [alertView cancelButtonIndex])
- {
- NSString *entered = [(SkAlertPrompt*)alertView enteredText];
- //fWind->setServerIP([entered UTF8String]);
- }
-}
-//Popover Management
-- (void)showRootPopoverButtonItem:(UIBarButtonItem *)barButtonItem {
- // Add the popover button to the left navigation item.
- [fNavigationBar.topItem setLeftBarButtonItem:barButtonItem animated:NO];
-}
-
-
-- (void)invalidateRootPopoverButtonItem:(UIBarButtonItem *)barButtonItem {
- // Remove the popover button.
- [fNavigationBar.topItem setLeftBarButtonItem:nil animated:NO];
-}
-@end
diff --git a/experimental/iOSSampleApp/SkUIRootViewController.h b/experimental/iOSSampleApp/SkUIRootViewController.h
deleted file mode 100644
index 4ea5d16a8a..0000000000
--- a/experimental/iOSSampleApp/SkUIRootViewController.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#import <UIKit/UIKit.h>
-
-@interface SkUIRootViewController : UITableViewController <UITableViewDataSource> {
-@private
- UIPopoverController *popoverController;
- UIBarButtonItem *popoverButtonItem;
- NSMutableArray* fSamples;
-}
-@property (nonatomic, retain) UIPopoverController *popoverController;
-@property (nonatomic, retain) UIBarButtonItem *popoverButtonItem;
-
-- (void)initSamples;
-- (void)addItem:(NSString*)anItem;
-
-@end
diff --git a/experimental/iOSSampleApp/SkUIRootViewController.mm b/experimental/iOSSampleApp/SkUIRootViewController.mm
deleted file mode 100644
index b0b22e6f0b..0000000000
--- a/experimental/iOSSampleApp/SkUIRootViewController.mm
+++ /dev/null
@@ -1,64 +0,0 @@
-#import "SkUIRootViewController.h"
-#import "SkUISplitViewController.h"
-@implementation SkUIRootViewController
-@synthesize popoverController, popoverButtonItem;
-
-//Overwritten from UIViewController
-- (void)viewDidLoad {
- [super viewDidLoad];
- self.contentSizeForViewInPopover = CGSizeMake(200, self.view.bounds.size.height);
-}
-
-- (void)viewDidUnload {
- [super viewDidUnload];
- self.popoverButtonItem = nil;
-}
-
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
- return YES;
-}
-
-- (void)dealloc {
- [popoverController release];
- [popoverButtonItem release];
- [fSamples release];
- [super dealloc];
-}
-
-
-//Table View Delegate Methods
-- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- // Return the number of sections.
- return 1;
-}
-
-- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- // Return the number of rows in the section.
- return [fSamples count];
-}
-
-- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-
- static NSString *CellIdentifier = @"Cell";
-
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
- if (cell == nil) {
- cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
- reuseIdentifier:CellIdentifier] autorelease];
- }
-
- cell.textLabel.text = [fSamples objectAtIndex:indexPath.row];
- return cell;
-}
-
-//Instance methods
-- (void)addItem:(NSString*)anItem {
- [fSamples addObject:anItem];
-}
-
-- (void)initSamples {
- fSamples = [[NSMutableArray alloc] init];
-}
-
-@end
-
diff --git a/experimental/iOSSampleApp/SkUIView_shell.h b/experimental/iOSSampleApp/SkUIView_shell.h
deleted file mode 100644
index d23143f90d..0000000000
--- a/experimental/iOSSampleApp/SkUIView_shell.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#import <UIKit/UIKit.h>
-#include "SkEvent.h"
-
-class SkOSWindow;
-class SkIRect;
-@interface SkUIView_shell : UIView {
-@private
- UINavigationItem* fTitle;
- SkOSWindow* fSkWind;
-}
-@property(nonatomic, retain) UINavigationItem* fTitle;
-
-- (void)setSkWindow:(SkOSWindow*)anSkWindow;
-- (void)setSkTitle:(const char*)title;
-- (void)postInvalWithRect:(const SkIRect*)rectOrNil;
-- (BOOL)onHandleEvent:(const SkEvent&)event;
-
-@end
diff --git a/experimental/iOSSampleApp/SkUIView_shell.mm b/experimental/iOSSampleApp/SkUIView_shell.mm
deleted file mode 100644
index 7fe35d79d3..0000000000
--- a/experimental/iOSSampleApp/SkUIView_shell.mm
+++ /dev/null
@@ -1,88 +0,0 @@
-#include "SkCanvas.h"
-#include "SkCGUtils.h"
-#include "SkEvent.h"
-#include "SkOSWindow_iOS.h"
-#include "SkView.h"
-#import "SkUIView_shell.h"
-
-@implementation SkUIView_shell
-@synthesize fTitle;
-
-//Overwritten from UIView
-- (void)layoutSubviews {
- [super layoutSubviews];
- CGSize s = self.bounds.size;
- fSkWind->resize(s.width, s.height);
-}
-
-- (void)drawRect:(CGRect)rect {
- //TODO -- check if our UIView is backed by a CALayer, and possibly use
- //skia's gpu backend
- if (fSkWind != nil) {
- SkCanvas canvas;
- SkIRect dirtyRect = SkIRect::MakeWH(rect.size.width, rect.size.height);
- fSkWind->update(&dirtyRect, &canvas);
-
- CGImageRef cgimage = SkCreateCGImageRef(fSkWind->getBitmap());
- [[UIImage imageWithCGImage:cgimage] drawAtPoint:CGPointMake(0, 44)];
- CGImageRelease(cgimage);
- }
-}
-
-- (void)dealloc {
- [fTitle release];
- [super dealloc];
-}
-
-//Instance methods
-- (void)setSkWindow:(SkOSWindow*)anSkWindow {
- fSkWind = anSkWindow;
-}
-
-//Handlers for SkOSWindow
-- (void)setSkTitle:(const char *)title {
- fTitle.title = [NSString stringWithUTF8String:title];
-}
-
-- (BOOL)onHandleEvent:(const SkEvent&)event {
- return false;
-}
-
-- (void)postInvalWithRect:(const SkIRect*)rect {
- if (rect) {
- [self setNeedsDisplayInRect:CGRectMake(rect->fLeft, rect->fTop,
- rect->width(), rect->height())];
- } else {
- [self setNeedsDisplay];
- }
-}
-
-//Gesture Handlers
-- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
- for (UITouch *touch in touches) {
- CGPoint loc = [touch locationInView:self];
- fSkWind->handleClick(loc.x, loc.y, SkView::Click::kDown_State, touch);
- }
-}
-
-- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
- for (UITouch *touch in touches) {
- CGPoint loc = [touch locationInView:self];
- fSkWind->handleClick(loc.x, loc.y, SkView::Click::kMoved_State, touch);
- }
-}
-
-- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
- for (UITouch *touch in touches) {
- CGPoint loc = [touch locationInView:self];
- fSkWind->handleClick(loc.x, loc.y, SkView::Click::kUp_State, touch);
- }
-}
-
-- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
- for (UITouch *touch in touches) {
- CGPoint loc = [touch locationInView:self];
- fSkWind->handleClick(loc.x, loc.y, SkView::Click::kUp_State, touch);
- }
-}
-@end
diff --git a/experimental/iOSSampleApp/SkUIView_withSkUIContainerView.h b/experimental/iOSSampleApp/SkUIView_withSkUIContainerView.h
deleted file mode 100644
index b63636d66b..0000000000
--- a/experimental/iOSSampleApp/SkUIView_withSkUIContainerView.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#import <UIKit/UIKit.h>
-
-
-@interface SkUIView_withSkUIContainerView : UIView {
- SkUIContainerView* fView;
- UINavigationItem* fTitle;
-@private
- CGPoint fOffset, fCenter;
- CGFloat fScale, fRotation;
-}
-
-@property(assign) CGPoint fOffset, fCenter;
-@property(assign) CGFloat fScale, fRotation;
-@property(retain) UINavigationItem* fTitle;
-- (void)resetTransformations;
-- (void)addSkView:(SkView*)aView;
-- (void)setSkTitle:(const char*)title;
-- (void)postInvalWithRect:(const SkIRect*)rectOrNil;
-- (BOOL)onHandleEvent:(const SkEvent&)event;
-@end
diff --git a/experimental/iOSSampleApp/SkUIView_withSkUIContainerView.mm b/experimental/iOSSampleApp/SkUIView_withSkUIContainerView.mm
deleted file mode 100644
index 39f62488c3..0000000000
--- a/experimental/iOSSampleApp/SkUIView_withSkUIContainerView.mm
+++ /dev/null
@@ -1,145 +0,0 @@
-#import "SkView.h"
-#import "SkMatrix.h"
-#import "SkCanvas.h"
-
-class SkUIContainerView : public SkView {
-public:
- SkUIContainerView(UIView* parent){
- fParent = parent;
- fMatrix.reset();
- }
- ~SkUIContainerView() {
- [fParent release];
- }
- void setBeforeChildMatrix(const SkMatrix& m) {fMatrix = m;}
-
-protected:
- virtual bool handleInval(const SkRect*) {
- [fParent setNeedsDisplay];
- return true;
- }
- virtual void beforeChild(SkView* child, SkCanvas* canvas) {
- canvas->concat(fMatrix);
- }
- virtual void onSizeChange() {
- this->INHERITED::onSizeChange();
- SkView::F2BIter iter(this);
- SkView* view = iter.next();
- while (view) {
- view->setSize(this->width(), this->height());
- view = iter.next();
- }
- }
-
-private:
- UIView* fParent;
- SkMatrix fMatrix;
-
- typedef SkView INHERITED;
-};
-////////////////////////////////////////////////////////////////////////////////
-#import "SkCGUtils.h"
-#import "SkEvent.h"
-#import "SkUIView_withSkUIContainerView.h"
-
-@implementation SkUIView_withSkUIContainerView
-@synthesize fOffset, fCenter, fScale, fRotation, fTitle;
-
-- (id)initWithFrame:(CGRect)frame {
- self = [super initWithFrame:frame];
- if (self) {
- // Initialization code.
- fView = new SkUIContainerView(self);
- fView->setVisibleP(true);
- fView->setSize(frame.size.width, frame.size.height);
- [self resetTransformations];
- }
- return self;
-}
-
-- (id)initWithCoder:(NSCoder *)decoder {
- self = [super initWithCoder:decoder];
- if (self) {
- // Initialization code.
- fView = new SkUIContainerView(self);
- fView->setVisibleP(true);
- CGSize s = self.bounds.size;
- fView->setSize(s.width, s.height);
- [self resetTransformations];
- }
- return self;
-}
-
-- (void)dealloc {
- [fTitle release];
- delete fView;
- [super dealloc];
-}
-
-- (void)layoutSubviews {
- CGSize s = self.bounds.size;
- fView->setSize(s.width, s.height);
-}
-
-- (void)drawRect:(CGRect)rect {
- //TODO -- check if our UIView is backed by a CALayer, and possibly use
- //skia's gpu backend
- if (fView != nil) {
- SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, fView->width(),
- fView->height());
- bitmap.allocPixels();
- SkCanvas canvas(bitmap);
-
- //Apply view transformations so they can be applied to individual
- //child views without affecting the parent's clip/matrix
- SkMatrix matrix;
- matrix.setTranslate(fOffset.x + fCenter.x, fOffset.y + fCenter.y);
- matrix.preRotate(fRotation);
- matrix.preScale(fScale, fScale);
- matrix.preTranslate(-fCenter.x, -fCenter.y);
- fView->setBeforeChildMatrix(matrix);
-
- fView->draw(&canvas);
-
- //Draw bitmap
- CGImageRef cgimage = SkCreateCGImageRef(bitmap);
- [[UIImage imageWithCGImage:cgimage] drawAtPoint:CGPointMake(0, 44)];
- CGImageRelease(cgimage);
- }
-}
-
-- (void)addSkView:(SkView*)aView {
- SkASSERT(fView);
- fView->attachChildToFront(aView);
-}
-
-- (void)resetTransformations {
- fOffset = CGPointMake(0, 0);
- fCenter = CGPointMake(fView->width() / 2.0, fView->height() / 2.0);
- fRotation = 0;
- fScale = 1.0;
-}
-
-- (void)setSkTitle:(const char*)title{
- if (fTitle) {
- fTitle.title = [NSString stringWithUTF8String:title];
- }
-}
-
-- (void)postInvalWithRect:(const SkIRect*)rectOrNil{
- if (rectOrNil) {
- CGRect r = CGRectMake(rectOrNil->fLeft, rectOrNil->fTop,
- rectOrNil->width(), rectOrNil->height());
- [self setNeedsDisplayInRect:r];
- }
- else {
- [self setNeedsDisplay];
- }
-}
-
-- (BOOL)onHandleEvent:(const SkEvent&)event{
- [self setNeedsDisplay];
- return YES;
-}
-@end \ No newline at end of file