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