1 #import <UIKit/UIKit.h> 2 #include "SkCanvas.h" 3 #include "SkGraphics.h" 4 #import "SkEventNotifier.h" 5 #include "SkOSMenu.h" 6 #include "SkTime.h" 7 #include "SkTypes.h" 8 #import "SkUIView.h" 9 #include "SkWindow.h" 10 11 #define kINVAL_UIVIEW_EventType "inval-uiview" 12 13 SkOSWindow::SkOSWindow(void* hWnd) : fHWND(hWnd) { 14 fInvalEventIsPending = false; 15 fNotifier = [[SkEventNotifier alloc] init]; 16 } 17 SkOSWindow::~SkOSWindow() { 18 [(SkEventNotifier*)fNotifier release]; 19 } 20 21 void SkOSWindow::onHandleInval(const SkIRect& r) { 22 if (!fInvalEventIsPending) { 23 fInvalEventIsPending = true; 24 (new SkEvent(kINVAL_UIVIEW_EventType, this->getSinkID()))->post(); 25 } 26 } 27 28 bool SkOSWindow::onEvent(const SkEvent& evt) { 29 if (evt.isType(kINVAL_UIVIEW_EventType)) { 30 fInvalEventIsPending = false; 31 const SkIRect& r = this->getDirtyBounds(); 32 [(SkUIView*)fHWND postInvalWithRect:&r]; 33 return true; 34 } 35 if ([(SkUIView*)fHWND onHandleEvent:evt]) { 36 return true; 37 } 38 return this->INHERITED::onEvent(evt); 39 } 40 41 void SkOSWindow::onSetTitle(const char title[]) { 42 [(SkUIView*)fHWND setSkTitle:title]; 43 } 44 45 void SkOSWindow::onAddMenu(const SkOSMenu* menu) { 46 [(SkUIView*)fHWND onAddMenu:menu]; 47 } 48 49 void SkOSWindow::onUpdateMenu(SkOSMenu* menu) { 50 [(SkUIView*)fHWND onUpdateMenu:menu]; 51 } 52 53 bool SkOSWindow::attach(SkBackEndTypes /* attachType */, 54 int /* msaaSampleCount */, 55 AttachmentInfo* info) { 56 [(SkUIView*)fHWND getAttachmentInfo:info]; 57 bool success = true; 58 return success; 59 } 60 61 void SkOSWindow::detach() {} 62 63 void SkOSWindow::present() { 64 } 65