Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /*
2 * Copyright 2011 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
8 #if defined(SK_BUILD_FOR_MAC)
10 #import <Cocoa/Cocoa.h>
11 #include "SkOSWindow_Mac.h"
12 #include "SkOSMenu.h"
13 #include "SkTypes.h"
14 #include "SkWindow.h"
15 #import "SkNSView.h"
16 #import "SkEventNotifier.h"
17 #define kINVAL_NSVIEW_EventType "inval-nsview"
19 SK_COMPILE_ASSERT(SK_SUPPORT_GPU, not_implemented_for_non_gpu_build);
21 SkOSWindow::SkOSWindow(void* hWnd) : fHWND(hWnd) {
22 fInvalEventIsPending = false;
23 fGLContext = NULL;
24 fNotifier = [[SkEventNotifier alloc] init];
25 }
26 SkOSWindow::~SkOSWindow() {
27 [(SkEventNotifier*)fNotifier release];
28 }
30 void SkOSWindow::onHandleInval(const SkIRect& r) {
31 if (!fInvalEventIsPending) {
32 fInvalEventIsPending = true;
33 (new SkEvent(kINVAL_NSVIEW_EventType, this->getSinkID()))->post();
34 }
35 }
37 bool SkOSWindow::onEvent(const SkEvent& evt) {
38 if (evt.isType(kINVAL_NSVIEW_EventType)) {
39 fInvalEventIsPending = false;
40 const SkIRect& r = this->getDirtyBounds();
41 [(SkNSView*)fHWND postInvalWithRect:&r];
42 [(NSOpenGLContext*)fGLContext update];
43 return true;
44 }
45 if ([(SkNSView*)fHWND onHandleEvent:evt]) {
46 return true;
47 }
48 return this->INHERITED::onEvent(evt);
49 }
51 bool SkOSWindow::onDispatchClick(int x, int y, Click::State state, void* owner,
52 unsigned modi) {
53 return this->INHERITED::onDispatchClick(x, y, state, owner, modi);
54 }
56 void SkOSWindow::onSetTitle(const char title[]) {
57 [(SkNSView*)fHWND setSkTitle:title];
58 }
60 void SkOSWindow::onAddMenu(const SkOSMenu* menu) {
61 [(SkNSView*)fHWND onAddMenu:menu];
62 }
64 void SkOSWindow::onUpdateMenu(const SkOSMenu* menu) {
65 [(SkNSView*)fHWND onUpdateMenu:menu];
66 }
68 bool SkOSWindow::attach(SkBackEndTypes attachType, int sampleCount, AttachmentInfo* info) {
69 return [(SkNSView*)fHWND attach:attachType withMSAASampleCount:sampleCount andGetInfo:info];
70 }
72 void SkOSWindow::detach() {
73 [(SkNSView*)fHWND detach];
74 }
76 void SkOSWindow::present() {
77 [(SkNSView*)fHWND present];
78 }
80 #endif