CCEAGLView-ios.mm 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. /*
  2. ===== IMPORTANT =====
  3. This is sample code demonstrating API, technology or techniques in development.
  4. Although this sample code has been reviewed for technical accuracy, it is not
  5. final. Apple is supplying this information to help you plan for the adoption of
  6. the technologies and programming interfaces described herein. This information
  7. is subject to change, and software implemented based on this sample code should
  8. be tested with final operating system software and final documentation. Newer
  9. versions of this sample code may be provided with future seeds of the API or
  10. technology. For information about updates to this and other developer
  11. documentation, view the New & Updated sidebars in subsequent documentation
  12. seeds.
  13. =====================
  14. File: EAGLView.m
  15. Abstract: Convenience class that wraps the CAEAGLLayer from CoreAnimation into a
  16. UIView subclass.
  17. Version: 1.3
  18. Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
  19. ("Apple") in consideration of your agreement to the following terms, and your
  20. use, installation, modification or redistribution of this Apple software
  21. constitutes acceptance of these terms. If you do not agree with these terms,
  22. please do not use, install, modify or redistribute this Apple software.
  23. In consideration of your agreement to abide by the following terms, and subject
  24. to these terms, Apple grants you a personal, non-exclusive license, under
  25. Apple's copyrights in this original Apple software (the "Apple Software"), to
  26. use, reproduce, modify and redistribute the Apple Software, with or without
  27. modifications, in source and/or binary forms; provided that if you redistribute
  28. the Apple Software in its entirety and without modifications, you must retain
  29. this notice and the following text and disclaimers in all such redistributions
  30. of the Apple Software.
  31. Neither the name, trademarks, service marks or logos of Apple Inc. may be used
  32. to endorse or promote products derived from the Apple Software without specific
  33. prior written permission from Apple. Except as expressly stated in this notice,
  34. no other rights or licenses, express or implied, are granted by Apple herein,
  35. including but not limited to any patent rights that may be infringed by your
  36. derivative works or by other works in which the Apple Software may be
  37. incorporated.
  38. The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
  39. WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
  40. WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  41. PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
  42. COMBINATION WITH YOUR PRODUCTS.
  43. IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
  44. CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  45. GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  46. ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR
  47. DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF
  48. CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
  49. APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  50. Copyright (C) 2008 Apple Inc. All Rights Reserved.
  51. */
  52. #import "platform/ios/CCEAGLView-ios.h"
  53. #import <QuartzCore/QuartzCore.h>
  54. #include "scripting/js-bindings/event/EventDispatcher.h"
  55. #include "platform/ios/OpenGL_Internal-ios.h"
  56. #include "platform/CCApplication.h"
  57. #include "base/ccMacros.h"
  58. #include "ui/edit-box/EditBox.h"
  59. namespace
  60. {
  61. GLenum pixelformat2glenum(NSString* str)
  62. {
  63. if ([str isEqualToString:kEAGLColorFormatRGB565])
  64. return GL_RGB565;
  65. else
  66. return GL_RGBA8_OES;
  67. }
  68. }
  69. //CLASS IMPLEMENTATIONS:
  70. #define MAX_TOUCH_COUNT 10
  71. @interface CCEAGLView (Private)
  72. @end
  73. @implementation CCEAGLView
  74. + (Class) layerClass
  75. {
  76. return [CAEAGLLayer class];
  77. }
  78. + (id) viewWithFrame:(CGRect)frame pixelFormat:(NSString*)format depthFormat:(GLuint)depth preserveBackbuffer:(BOOL)retained sharegroup:(EAGLSharegroup*)sharegroup multiSampling:(BOOL)multisampling numberOfSamples:(unsigned int)samples
  79. {
  80. return [[[self alloc]initWithFrame:frame pixelFormat:format depthFormat:depth preserveBackbuffer:retained sharegroup:sharegroup multiSampling:multisampling numberOfSamples:samples] autorelease];
  81. }
  82. - (id) initWithFrame:(CGRect)frame pixelFormat:(NSString*)format depthFormat:(GLuint)depth preserveBackbuffer:(BOOL)retained sharegroup:(EAGLSharegroup*)sharegroup multiSampling:(BOOL)sampling numberOfSamples:(unsigned int)nSamples;
  83. {
  84. if((self = [super initWithFrame:frame]))
  85. {
  86. _pixelformatString = format;
  87. _pixelformat = pixelformat2glenum(_pixelformatString);
  88. _depthFormat = depth;
  89. // Multisampling doc: https://developer.apple.com/library/content/documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/WorkingwithEAGLContexts/WorkingwithEAGLContexts.html#//apple_ref/doc/uid/TP40008793-CH103-SW4
  90. _multisampling = sampling;
  91. _requestedSamples = nSamples;
  92. _preserveBackbuffer = retained;
  93. _sharegroup = sharegroup;
  94. _isReady = FALSE;
  95. _needToPreventTouch = FALSE;
  96. #if GL_EXT_discard_framebuffer == 1
  97. _discardFramebufferSupported = YES;
  98. #else
  99. _discardFramebufferSupported = NO;
  100. #endif
  101. if ([self respondsToSelector:@selector(setContentScaleFactor:)])
  102. self.contentScaleFactor = [[UIScreen mainScreen] scale];
  103. _touchIds = 0;
  104. for (int i = 0; i < 10; ++i)
  105. _touches[i] = nil;
  106. [self setupGLContext];
  107. }
  108. return self;
  109. }
  110. - (void) dealloc
  111. {
  112. if (_defaultColorBuffer)
  113. {
  114. glDeleteRenderbuffers(1, &_defaultColorBuffer);
  115. _defaultColorBuffer = 0;
  116. }
  117. if (_defaultDepthBuffer)
  118. {
  119. glDeleteRenderbuffers(1, &_defaultDepthBuffer);
  120. _defaultDepthBuffer = 0;
  121. }
  122. if (_defaultFramebuffer)
  123. {
  124. glDeleteFramebuffers(1, &_defaultFramebuffer);
  125. _defaultFramebuffer = 0;
  126. }
  127. if (_msaaColorBuffer)
  128. {
  129. glDeleteRenderbuffers(1, &_msaaColorBuffer);
  130. _msaaColorBuffer = 0;
  131. }
  132. if (_msaaDepthBuffer)
  133. {
  134. glDeleteRenderbuffers(1, &_msaaDepthBuffer);
  135. _msaaDepthBuffer = 0;
  136. }
  137. if (_msaaFramebuffer)
  138. {
  139. glDeleteFramebuffers(1, &_msaaFramebuffer);
  140. _msaaFramebuffer = 0;
  141. }
  142. if ([EAGLContext currentContext] == _context)
  143. [EAGLContext setCurrentContext:nil];
  144. if (_context)
  145. {
  146. [_context release];
  147. _context = nil;
  148. }
  149. [super dealloc];
  150. }
  151. - (void) layoutSubviews
  152. {
  153. // On some devices with iOS13, `[_context renderbufferStorage:GL_RENDERBUFFER fromDrawable:(CAEAGLLayer *)self.layer]`
  154. // will return false if lock screen when running application, which make framebuffer in invalid state.
  155. // FIXME: do binding framebuffer in other place?
  156. UIApplicationState state = [[UIApplication sharedApplication] applicationState];
  157. if (state == UIApplicationStateBackground)
  158. return;
  159. glBindFramebuffer(GL_FRAMEBUFFER, _defaultFramebuffer);
  160. if (_defaultColorBuffer)
  161. {
  162. glBindRenderbuffer(GL_RENDERBUFFER, _defaultColorBuffer);
  163. if(! [_context renderbufferStorage:GL_RENDERBUFFER fromDrawable:(CAEAGLLayer *)self.layer])
  164. {
  165. NSLog(@"failed to call context");
  166. return;
  167. }
  168. }
  169. int backingWidth = 0;
  170. int backingHeight = 0;
  171. glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &backingWidth);
  172. glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &backingHeight);
  173. if (_defaultDepthBuffer)
  174. {
  175. glBindRenderbuffer(GL_RENDERBUFFER, _defaultDepthBuffer);
  176. glRenderbufferStorage(GL_RENDERBUFFER, _depthFormat, backingWidth, backingHeight);
  177. }
  178. if (_multisampling)
  179. {
  180. glBindFramebuffer(GL_FRAMEBUFFER, _msaaFramebuffer);
  181. if (_msaaColorBuffer)
  182. {
  183. glBindRenderbuffer(GL_RENDERBUFFER, _msaaColorBuffer);
  184. glRenderbufferStorageMultisampleAPPLE(GL_RENDERBUFFER, _requestedSamples, _pixelformat, backingWidth, backingHeight);
  185. }
  186. if (_msaaDepthBuffer)
  187. {
  188. glBindRenderbuffer(GL_RENDERBUFFER, _msaaDepthBuffer);
  189. glRenderbufferStorageMultisampleAPPLE(GL_RENDERBUFFER, _requestedSamples, _depthFormat, backingWidth, backingHeight);
  190. }
  191. }
  192. else
  193. {
  194. glBindRenderbuffer(GL_RENDERBUFFER, _defaultColorBuffer);
  195. }
  196. CHECK_GL_ERROR();
  197. GLenum error;
  198. if( (error=glCheckFramebufferStatus(GL_FRAMEBUFFER)) != GL_FRAMEBUFFER_COMPLETE)
  199. NSLog(@"Failed to make complete framebuffer object 0x%X", error);
  200. _isReady = TRUE;
  201. }
  202. - (BOOL) isReady
  203. {
  204. return _isReady;
  205. }
  206. -(void) setPreventTouchEvent:(BOOL) flag
  207. {
  208. _needToPreventTouch = flag;
  209. }
  210. -(EAGLContext*) getContext
  211. {
  212. return _context;
  213. }
  214. - (void) setupGLContext
  215. {
  216. CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
  217. eaglLayer.opaque = YES;
  218. eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
  219. [NSNumber numberWithBool:_preserveBackbuffer], kEAGLDrawablePropertyRetainedBacking,
  220. _pixelformatString, kEAGLDrawablePropertyColorFormat, nil];
  221. if(! _sharegroup)
  222. {
  223. _context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
  224. if (!_context)
  225. _context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
  226. }
  227. else
  228. {
  229. _context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3 sharegroup:_sharegroup];
  230. if (!_context)
  231. _context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2 sharegroup:_sharegroup];
  232. }
  233. if (!_context || ![EAGLContext setCurrentContext:_context] )
  234. {
  235. NSLog(@"Can not crate GL context.");
  236. return;
  237. }
  238. if (![self createFrameBuffer])
  239. return;
  240. if (![self createAndAttachColorBuffer])
  241. return;
  242. [self createAndAttachDepthBuffer];
  243. }
  244. - (BOOL) createFrameBuffer
  245. {
  246. if (!_context)
  247. return FALSE;
  248. glGenFramebuffers(1, &_defaultFramebuffer);
  249. if (0 == _defaultFramebuffer)
  250. {
  251. NSLog(@"Can not create default frame buffer.");
  252. return FALSE;
  253. }
  254. if (_multisampling)
  255. {
  256. glGenFramebuffers(1, &_msaaFramebuffer);
  257. if (0 == _msaaFramebuffer)
  258. {
  259. NSLog(@"Can not create multi sampling frame buffer");
  260. _multisampling = FALSE;
  261. }
  262. }
  263. return TRUE;
  264. }
  265. - (BOOL) createAndAttachColorBuffer
  266. {
  267. if (0 == _defaultFramebuffer)
  268. return FALSE;
  269. glBindFramebuffer(GL_FRAMEBUFFER, _defaultFramebuffer);
  270. glGenRenderbuffers(1, &_defaultColorBuffer);
  271. if (0 == _defaultColorBuffer)
  272. {
  273. NSLog(@"Can not create default color buffer.");
  274. return FALSE;
  275. }
  276. glBindRenderbuffer(GL_RENDERBUFFER, _defaultColorBuffer);
  277. glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, _defaultColorBuffer);
  278. CHECK_GL_ERROR();
  279. if (!_multisampling || (0 == _msaaFramebuffer))
  280. return TRUE;
  281. glBindFramebuffer(GL_FRAMEBUFFER, _msaaFramebuffer);
  282. glGenRenderbuffers(1, &_msaaColorBuffer);
  283. if (0 == _msaaColorBuffer)
  284. {
  285. NSLog(@"Can not create multi sampling color buffer.");
  286. // App can work without multi sampleing.
  287. return TRUE;
  288. }
  289. glBindRenderbuffer(GL_RENDERBUFFER, _msaaColorBuffer);
  290. glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, _msaaColorBuffer);
  291. CHECK_GL_ERROR();
  292. return TRUE;
  293. }
  294. - (BOOL) createAndAttachDepthBuffer
  295. {
  296. if (0 == _defaultFramebuffer || 0 == _depthFormat)
  297. return FALSE;
  298. glBindFramebuffer(GL_FRAMEBUFFER, _defaultFramebuffer);
  299. glGenRenderbuffers(1, &_defaultDepthBuffer);
  300. if (0 == _defaultDepthBuffer)
  301. {
  302. NSLog(@"Can not create default depth buffer.");
  303. return FALSE;
  304. }
  305. glBindRenderbuffer(GL_RENDERBUFFER, _defaultDepthBuffer);
  306. glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, _defaultDepthBuffer);
  307. CHECK_GL_ERROR();
  308. if (GL_DEPTH24_STENCIL8_OES == _depthFormat ||
  309. GL_DEPTH_STENCIL_OES == _depthFormat)
  310. glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, _defaultDepthBuffer);
  311. CHECK_GL_ERROR();
  312. if (!_multisampling || (0 == _msaaFramebuffer))
  313. return TRUE;
  314. glBindFramebuffer(GL_FRAMEBUFFER, _msaaFramebuffer);
  315. glGenRenderbuffers(1, &_msaaDepthBuffer);
  316. if (0 == _msaaDepthBuffer)
  317. {
  318. NSLog(@"Can not create multi sampling depth buffer.");
  319. return TRUE;
  320. }
  321. glBindRenderbuffer(GL_RENDERBUFFER, _msaaDepthBuffer);
  322. glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, _msaaDepthBuffer);
  323. CHECK_GL_ERROR();
  324. if (GL_DEPTH24_STENCIL8_OES == _depthFormat ||
  325. GL_DEPTH_STENCIL_OES == _depthFormat)
  326. glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, _msaaDepthBuffer);
  327. CHECK_GL_ERROR();
  328. return TRUE;
  329. }
  330. - (void) swapBuffers
  331. {
  332. // IMPORTANT:
  333. // - preconditions
  334. // -> context_ MUST be the OpenGL context
  335. // -> renderbuffer_ must be the RENDER BUFFER
  336. if (_multisampling)
  337. {
  338. /* Resolve from msaaFramebuffer to resolveFramebuffer */
  339. //glDisable(GL_SCISSOR_TEST);
  340. glBindFramebuffer(GL_READ_FRAMEBUFFER_APPLE, _msaaFramebuffer);
  341. glBindFramebuffer(GL_DRAW_FRAMEBUFFER_APPLE, _defaultFramebuffer);
  342. glResolveMultisampleFramebufferAPPLE();
  343. }
  344. CHECK_GL_ERROR();
  345. if (_discardFramebufferSupported)
  346. {
  347. if (_multisampling)
  348. {
  349. if (_depthFormat)
  350. {
  351. GLenum attachments[] = {GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTACHMENT};
  352. glDiscardFramebufferEXT(GL_READ_FRAMEBUFFER_APPLE, 2, attachments);
  353. }
  354. else
  355. {
  356. GLenum attachments[] = {GL_COLOR_ATTACHMENT0};
  357. glDiscardFramebufferEXT(GL_READ_FRAMEBUFFER_APPLE, 1, attachments);
  358. }
  359. }
  360. else if (_depthFormat)
  361. {
  362. // not MSAA
  363. GLenum attachments[] = { GL_DEPTH_ATTACHMENT};
  364. glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, attachments);
  365. }
  366. CHECK_GL_ERROR();
  367. }
  368. glBindRenderbuffer(GL_RENDERBUFFER, _defaultColorBuffer);
  369. if(![_context presentRenderbuffer:GL_RENDERBUFFER])
  370. NSLog(@"cocos2d: Failed to swap renderbuffer in %s\n", __FUNCTION__);
  371. #if COCOS2D_DEBUG
  372. CHECK_GL_ERROR();
  373. #endif
  374. // We can safely re-bind the framebuffer here, since this will be the
  375. // 1st instruction of the new main loop
  376. if(_multisampling)
  377. glBindFramebuffer(GL_FRAMEBUFFER, _msaaFramebuffer);
  378. }
  379. // Pass the touches to the superview
  380. #pragma mark CCEAGLView - Touch Delegate
  381. namespace
  382. {
  383. int getUnusedID(unsigned int& touchIDs)
  384. {
  385. int i;
  386. unsigned int temp = touchIDs;
  387. for (i = 0; i < 10; i++) {
  388. if (! (temp & 0x00000001))
  389. {
  390. touchIDs |= (1 << i);
  391. return i;
  392. }
  393. temp >>= 1;
  394. }
  395. // all bits are used
  396. return -1;
  397. }
  398. void resetTouchID(unsigned int& touchIDs, int index)
  399. {
  400. touchIDs &= ((1 << index) ^ 0xffffffff);
  401. }
  402. cocos2d::TouchInfo createTouchInfo(int index, UITouch* touch, float contentScaleFactor)
  403. {
  404. uint8_t deviceRatio = cocos2d::Application::getInstance()->getDevicePixelRatio();
  405. // TouchInfo should located in UI coordinate system, not GL pixels
  406. // It will be converted to display position later in View.convertToLocationInView
  407. cocos2d::TouchInfo touchInfo;
  408. touchInfo.index = index;
  409. touchInfo.x = [touch locationInView: [touch view]].x / deviceRatio;
  410. touchInfo.y = [touch locationInView: [touch view]].y / deviceRatio;
  411. return touchInfo;
  412. }
  413. void deliverTouch(cocos2d::TouchEvent& touchEvent,
  414. NSSet* touches,
  415. UITouch** internalTouches,
  416. float contentScaleFactor,
  417. bool reset,
  418. unsigned int& touchIds)
  419. {
  420. for (UITouch *touch in touches)
  421. {
  422. for (int i = 0; i < MAX_TOUCH_COUNT; ++i)
  423. {
  424. if (touch == internalTouches[i])
  425. {
  426. if (reset)
  427. {
  428. internalTouches[i] = nil;
  429. resetTouchID(touchIds, i);
  430. }
  431. touchEvent.touches.push_back(createTouchInfo(i, touch, contentScaleFactor));
  432. }
  433. }
  434. }
  435. if (!touchEvent.touches.empty())
  436. cocos2d::EventDispatcher::dispatchTouchEvent(touchEvent);
  437. }
  438. }
  439. - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
  440. {
  441. // When editbox is editing, should prevent glview to handle touch events.
  442. if (_needToPreventTouch)
  443. {
  444. cocos2d::EditBox::complete();
  445. return;
  446. }
  447. cocos2d::TouchEvent touchEvent;
  448. touchEvent.type = cocos2d::TouchEvent::Type::BEGAN;
  449. for (UITouch *touch in touches) {
  450. int index = getUnusedID(_touchIds);
  451. if (-1 == index)
  452. return;
  453. _touches[index] = touch;
  454. touchEvent.touches.push_back(createTouchInfo(index, touch, self.contentScaleFactor));
  455. }
  456. if (!touchEvent.touches.empty())
  457. cocos2d::EventDispatcher::dispatchTouchEvent(touchEvent);
  458. }
  459. - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
  460. {
  461. cocos2d::TouchEvent touchEvent;
  462. touchEvent.type = cocos2d::TouchEvent::Type::MOVED;
  463. deliverTouch(touchEvent, touches, _touches, self.contentScaleFactor, false, _touchIds);
  464. }
  465. - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
  466. {
  467. cocos2d::TouchEvent touchEvent;
  468. touchEvent.type = cocos2d::TouchEvent::Type::ENDED;
  469. deliverTouch(touchEvent, touches, _touches, self.contentScaleFactor, true, _touchIds);
  470. }
  471. - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
  472. {
  473. cocos2d::TouchEvent touchEvent;
  474. touchEvent.type = cocos2d::TouchEvent::Type::CANCELLED;
  475. deliverTouch(touchEvent, touches, _touches, self.contentScaleFactor, true, _touchIds);
  476. }
  477. @end