aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils/mac
diff options
context:
space:
mode:
authorGravatar yangsu@google.com <yangsu@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-08-08 18:38:58 +0000
committerGravatar yangsu@google.com <yangsu@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-08-08 18:38:58 +0000
commit42fd1e94bbc43ddb28df39c64efaf1883e303c4e (patch)
treee77d70a28da7454c30f9f8aa4b53410b398e6247 /src/utils/mac
parentc71174da7aa45de5efc60cf8fb26789f2d690f3e (diff)
CocoaSampleApp no longer depends on SkOSWindow_Mac.h
./gyp_skia now builds CocoaSampleApp on Mac http://codereview.appspot.com/4810084/ git-svn-id: http://skia.googlecode.com/svn/trunk@2063 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/utils/mac')
-rw-r--r--src/utils/mac/SkOSWindow_Mac_Cocoa.mm66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/utils/mac/SkOSWindow_Mac_Cocoa.mm b/src/utils/mac/SkOSWindow_Mac_Cocoa.mm
new file mode 100644
index 0000000000..f9eb10e325
--- /dev/null
+++ b/src/utils/mac/SkOSWindow_Mac_Cocoa.mm
@@ -0,0 +1,66 @@
+#import <Cocoa/Cocoa.h>
+#include "SkOSWindow_Mac_Cocoa.h"
+#include "SkOSMenu.h"
+#include "SkTypes.h"
+#include "SkWindow.h"
+#import "SkNSView.h"
+#import "SkEventNotifier.h"
+#define kINVAL_NSVIEW_EventType "inval-nsview"
+
+SkOSWindow::SkOSWindow(void* hWnd) : fHWND(hWnd) {
+ fInvalEventIsPending = false;
+ fGLContext = NULL;
+ fNotifier = [[SkEventNotifier alloc] init];
+}
+SkOSWindow::~SkOSWindow() {
+ [(SkEventNotifier*)fNotifier release];
+}
+
+void SkOSWindow::onHandleInval(const SkIRect& r) {
+ if (!fInvalEventIsPending) {
+ fInvalEventIsPending = true;
+ (new SkEvent(kINVAL_NSVIEW_EventType, this->getSinkID()))->post();
+ }
+}
+
+bool SkOSWindow::onEvent(const SkEvent& evt) {
+ if (evt.isType(kINVAL_NSVIEW_EventType)) {
+ fInvalEventIsPending = false;
+ const SkIRect& r = this->getDirtyBounds();
+ [(SkNSView*)fHWND postInvalWithRect:&r];
+ [(NSOpenGLContext*)fGLContext update];
+ return true;
+ }
+ if ([(SkNSView*)fHWND onHandleEvent:evt]) {
+ return true;
+ }
+ return this->INHERITED::onEvent(evt);
+}
+
+bool SkOSWindow::onDispatchClick(int x, int y, Click::State state, void* owner) {
+ return this->INHERITED::onDispatchClick(x, y, state, owner);
+}
+
+void SkOSWindow::onSetTitle(const char title[]) {
+ [(SkNSView*)fHWND setSkTitle:title];
+}
+
+void SkOSWindow::onAddMenu(const SkOSMenu* menu) {
+ [(SkNSView*)fHWND onAddMenu:menu];
+}
+
+void SkOSWindow::onUpdateMenu(const SkOSMenu* menu) {
+ [(SkNSView*)fHWND onUpdateMenu:menu];
+}
+
+bool SkOSWindow::attachGL() {
+ [(SkNSView*)fHWND attachGL];
+}
+
+void SkOSWindow::detachGL() {
+ [(SkNSView*)fHWND detachGL];
+}
+
+void SkOSWindow::presentGL() {
+ [(SkNSView*)fHWND presentGL];
+} \ No newline at end of file