gfx/skia/trunk/src/views/mac/SkOSWindow_Mac.mm

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/src/views/mac/SkOSWindow_Mac.mm	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,80 @@
     1.4 +/*
     1.5 + * Copyright 2011 Google Inc.
     1.6 + *
     1.7 + * Use of this source code is governed by a BSD-style license that can be
     1.8 + * found in the LICENSE file.
     1.9 + */
    1.10 +
    1.11 +#if defined(SK_BUILD_FOR_MAC)
    1.12 +
    1.13 +#import  <Cocoa/Cocoa.h>
    1.14 +#include "SkOSWindow_Mac.h"
    1.15 +#include "SkOSMenu.h"
    1.16 +#include "SkTypes.h"
    1.17 +#include "SkWindow.h"
    1.18 +#import  "SkNSView.h"
    1.19 +#import  "SkEventNotifier.h"
    1.20 +#define  kINVAL_NSVIEW_EventType "inval-nsview"
    1.21 +
    1.22 +SK_COMPILE_ASSERT(SK_SUPPORT_GPU, not_implemented_for_non_gpu_build);
    1.23 +
    1.24 +SkOSWindow::SkOSWindow(void* hWnd) : fHWND(hWnd) {
    1.25 +    fInvalEventIsPending = false;
    1.26 +    fGLContext = NULL;
    1.27 +    fNotifier = [[SkEventNotifier alloc] init];
    1.28 +}
    1.29 +SkOSWindow::~SkOSWindow() {
    1.30 +    [(SkEventNotifier*)fNotifier release];
    1.31 +}
    1.32 +
    1.33 +void SkOSWindow::onHandleInval(const SkIRect& r) {
    1.34 +    if (!fInvalEventIsPending) {
    1.35 +        fInvalEventIsPending = true;
    1.36 +        (new SkEvent(kINVAL_NSVIEW_EventType, this->getSinkID()))->post();
    1.37 +    }
    1.38 +}
    1.39 +
    1.40 +bool SkOSWindow::onEvent(const SkEvent& evt) {
    1.41 +    if (evt.isType(kINVAL_NSVIEW_EventType)) {
    1.42 +        fInvalEventIsPending = false;
    1.43 +        const SkIRect& r = this->getDirtyBounds();
    1.44 +        [(SkNSView*)fHWND postInvalWithRect:&r];
    1.45 +        [(NSOpenGLContext*)fGLContext update];
    1.46 +        return true;
    1.47 +    }
    1.48 +    if ([(SkNSView*)fHWND onHandleEvent:evt]) {
    1.49 +        return true;
    1.50 +    }
    1.51 +    return this->INHERITED::onEvent(evt);
    1.52 +}
    1.53 +
    1.54 +bool SkOSWindow::onDispatchClick(int x, int y, Click::State state, void* owner,
    1.55 +                                 unsigned modi) {
    1.56 +    return this->INHERITED::onDispatchClick(x, y, state, owner, modi);
    1.57 +}
    1.58 +
    1.59 +void SkOSWindow::onSetTitle(const char title[]) {
    1.60 +    [(SkNSView*)fHWND setSkTitle:title];
    1.61 +}
    1.62 +
    1.63 +void SkOSWindow::onAddMenu(const SkOSMenu* menu) {
    1.64 +    [(SkNSView*)fHWND onAddMenu:menu];
    1.65 +}
    1.66 +
    1.67 +void SkOSWindow::onUpdateMenu(const SkOSMenu* menu) {
    1.68 +    [(SkNSView*)fHWND onUpdateMenu:menu];
    1.69 +}
    1.70 +
    1.71 +bool SkOSWindow::attach(SkBackEndTypes attachType, int sampleCount, AttachmentInfo* info) {
    1.72 +    return [(SkNSView*)fHWND attach:attachType withMSAASampleCount:sampleCount andGetInfo:info];
    1.73 +}
    1.74 +
    1.75 +void SkOSWindow::detach() {
    1.76 +    [(SkNSView*)fHWND detach];
    1.77 +}
    1.78 +
    1.79 +void SkOSWindow::present() {
    1.80 +    [(SkNSView*)fHWND present];
    1.81 +}
    1.82 +
    1.83 +#endif

mercurial