gfx/skia/trunk/src/views/ios/SkOSWindow_iOS.mm

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/src/views/ios/SkOSWindow_iOS.mm	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,64 @@
     1.4 +#import <UIKit/UIKit.h>
     1.5 +#include "SkCanvas.h"
     1.6 +#include "SkGraphics.h"
     1.7 +#import "SkEventNotifier.h"
     1.8 +#include "SkOSMenu.h"
     1.9 +#include "SkTime.h"
    1.10 +#include "SkTypes.h"
    1.11 +#import "SkUIView.h"
    1.12 +#include "SkWindow.h"
    1.13 +
    1.14 +#define kINVAL_UIVIEW_EventType "inval-uiview"
    1.15 +
    1.16 +SkOSWindow::SkOSWindow(void* hWnd) : fHWND(hWnd) {
    1.17 +    fInvalEventIsPending = false;
    1.18 +    fNotifier = [[SkEventNotifier alloc] init];
    1.19 +}
    1.20 +SkOSWindow::~SkOSWindow() {
    1.21 +    [(SkEventNotifier*)fNotifier release];
    1.22 +}
    1.23 +
    1.24 +void SkOSWindow::onHandleInval(const SkIRect& r) {
    1.25 +    if (!fInvalEventIsPending) {
    1.26 +        fInvalEventIsPending = true;
    1.27 +        (new SkEvent(kINVAL_UIVIEW_EventType, this->getSinkID()))->post();
    1.28 +    }
    1.29 +}
    1.30 +
    1.31 +bool SkOSWindow::onEvent(const SkEvent& evt) {
    1.32 +    if (evt.isType(kINVAL_UIVIEW_EventType)) {
    1.33 +        fInvalEventIsPending = false;
    1.34 +        const SkIRect& r = this->getDirtyBounds();
    1.35 +        [(SkUIView*)fHWND postInvalWithRect:&r];
    1.36 +        return true;
    1.37 +    }
    1.38 +    if ([(SkUIView*)fHWND onHandleEvent:evt]) {
    1.39 +        return true;
    1.40 +    }
    1.41 +    return this->INHERITED::onEvent(evt);
    1.42 +}
    1.43 +
    1.44 +void SkOSWindow::onSetTitle(const char title[]) {
    1.45 +    [(SkUIView*)fHWND setSkTitle:title];
    1.46 +}
    1.47 +
    1.48 +void SkOSWindow::onAddMenu(const SkOSMenu* menu) {
    1.49 +    [(SkUIView*)fHWND onAddMenu:menu];
    1.50 +}
    1.51 +
    1.52 +void SkOSWindow::onUpdateMenu(SkOSMenu* menu) {
    1.53 +    [(SkUIView*)fHWND onUpdateMenu:menu];
    1.54 +}
    1.55 +
    1.56 +bool SkOSWindow::attach(SkBackEndTypes /* attachType */,
    1.57 +                        int /* msaaSampleCount */,
    1.58 +                        AttachmentInfo* info) {
    1.59 +    [(SkUIView*)fHWND getAttachmentInfo:info];
    1.60 +    bool success = true;
    1.61 +    return success;
    1.62 +}
    1.63 +
    1.64 +void SkOSWindow::detach() {}
    1.65 +
    1.66 +void SkOSWindow::present() {
    1.67 +}

mercurial