757ebd20ef
Reason for revert: breaking the Chrome deps roll. http://build.chromium.org/p/chromium.linux/builders/Linux%20GN%20%28dbg%29/builds/839/steps/compile/logs/stdio Original issue's description: > Rename kPMColor_SkColorType to kN32_SkColorType. > > The new name better represents what this flag means. > > BUG=skia:2384 > > Committed: http://code.google.com/p/skia/source/detail?r=14117 R=reed@google.com, scroggo@google.com TBR=reed@google.com, scroggo@google.com NOTREECHECKS=true NOTRY=true BUG=skia:2384 Author: bensong@google.com Review URL: https://codereview.chromium.org/234243002 git-svn-id: http://skia.googlecode.com/svn/trunk@14144 2bbb7eff-a529-9590-31e7-b0007b416f81
116 lines
2.9 KiB
Plaintext
116 lines
2.9 KiB
Plaintext
#import "SkUIView.h"
|
|
#include "SkCanvas.h"
|
|
#include "SkCGUtils.h"
|
|
@implementation SkUIView
|
|
|
|
@synthesize fWind, fTitleItem, fOptionsDelegate;
|
|
|
|
- (id)initWithDefaults {
|
|
fWind = NULL;
|
|
return self;
|
|
}
|
|
|
|
- (id)initWithCoder:(NSCoder*)coder {
|
|
if ((self = [super initWithCoder:coder])) {
|
|
self = [self initWithDefaults];
|
|
[self setUpWindow];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (id)initWithFrame:(CGRect)frame {
|
|
if (self = [super initWithFrame:frame]) {
|
|
self = [self initWithDefaults];
|
|
[self setUpWindow];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)setUpWindow {
|
|
if (NULL != fWind) {
|
|
fWind->setVisibleP(true);
|
|
fWind->resize(self.frame.size.width, self.frame.size.height,
|
|
kPMColor_SkColorType);
|
|
}
|
|
}
|
|
|
|
- (void)dealloc {
|
|
delete fWind;
|
|
[fTitleItem release];
|
|
[super dealloc];
|
|
}
|
|
|
|
- (void)forceRedraw {
|
|
[self drawInRaster];
|
|
}
|
|
|
|
- (void)drawInRaster {
|
|
SkCanvas canvas(fWind->getBitmap());
|
|
fWind->draw(&canvas);
|
|
CGImageRef cgimage = SkCreateCGImageRef(fWind->getBitmap());
|
|
self.layer.contents = (id)cgimage;
|
|
CGImageRelease(cgimage);
|
|
}
|
|
|
|
//Gesture Handlers
|
|
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
|
|
for (UITouch *touch in touches) {
|
|
CGPoint loc = [touch locationInView:self];
|
|
fWind->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];
|
|
fWind->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];
|
|
fWind->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];
|
|
fWind->handleClick(loc.x, loc.y, SkView::Click::kUp_State, touch);
|
|
}
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
- (void)setSkTitle:(const char *)title {
|
|
if (fTitleItem) {
|
|
fTitleItem.title = [NSString stringWithUTF8String:title];
|
|
}
|
|
}
|
|
|
|
- (BOOL)onHandleEvent:(const SkEvent&)evt {
|
|
return false;
|
|
}
|
|
|
|
- (void)getAttachmentInfo:(SkOSWindow::AttachmentInfo*)info {
|
|
// we don't have a GL context.
|
|
info->fSampleCount = 0;
|
|
info->fStencilBits = 0;
|
|
}
|
|
|
|
#include "SkOSMenu.h"
|
|
- (void)onAddMenu:(const SkOSMenu*)menu {
|
|
[self.fOptionsDelegate view:self didAddMenu:menu];
|
|
}
|
|
- (void)onUpdateMenu:(SkOSMenu*)menu {
|
|
[self.fOptionsDelegate view:self didUpdateMenu:menu];
|
|
}
|
|
|
|
- (void)postInvalWithRect:(const SkIRect*)r {
|
|
[self performSelector:@selector(drawInRaster) withObject:nil afterDelay:0];
|
|
[self setNeedsDisplay];
|
|
}
|
|
|
|
@end
|