Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: src/views/mac/SkNSView.mm

Issue 1184143011: nibless mac, visual bench working on mac (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix HelloWorld compile on windows Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/views/mac/SkNSView.h ('k') | src/views/mac/SkOSWindow_Mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #import "SkNSView.h" 8 #import "SkNSView.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkSurface.h" 10 #include "SkSurface.h"
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 loc.y = -loc.y; 322 loc.y = -loc.y;
323 #endif 323 #endif
324 fWind->handleClick((int) loc.x, (int) loc.y, 324 fWind->handleClick((int) loc.x, (int) loc.y,
325 SkView::Click::kUp_State, self, modi); 325 SkView::Click::kUp_State, self, modi);
326 } 326 }
327 } 327 }
328 328
329 /////////////////////////////////////////////////////////////////////////////// 329 ///////////////////////////////////////////////////////////////////////////////
330 #include <OpenGL/OpenGL.h> 330 #include <OpenGL/OpenGL.h>
331 331
332 namespace { 332 static CGLContextObj createGLContext(int msaaSampleCount) {
333 CGLContextObj createGLContext(int msaaSampleCount) {
334 GLint major, minor; 333 GLint major, minor;
335 CGLGetVersion(&major, &minor); 334 CGLGetVersion(&major, &minor);
336 335
337 static const CGLPixelFormatAttribute attributes[] = { 336 static const CGLPixelFormatAttribute attributes[] = {
338 kCGLPFAStencilSize, (CGLPixelFormatAttribute) 8, 337 kCGLPFAStencilSize, (CGLPixelFormatAttribute) 8,
339 kCGLPFAAccelerated, 338 kCGLPFAAccelerated,
340 kCGLPFADoubleBuffer, 339 kCGLPFADoubleBuffer,
341 (CGLPixelFormatAttribute)0 340 (CGLPixelFormatAttribute)0
342 }; 341 };
343 342
(...skipping 18 matching lines...) Expand all
362 } 361 }
363 CGLContextObj ctx; 362 CGLContextObj ctx;
364 CGLCreateContext(format, NULL, &ctx); 363 CGLCreateContext(format, NULL, &ctx);
365 CGLDestroyPixelFormat(format); 364 CGLDestroyPixelFormat(format);
366 365
367 static const GLint interval = 1; 366 static const GLint interval = 1;
368 CGLSetParameter(ctx, kCGLCPSwapInterval, &interval); 367 CGLSetParameter(ctx, kCGLCPSwapInterval, &interval);
369 CGLSetCurrentContext(ctx); 368 CGLSetCurrentContext(ctx);
370 return ctx; 369 return ctx;
371 } 370 }
372 }
373 371
374 - (void)viewDidMoveToWindow { 372 - (void)viewDidMoveToWindow {
375 [super viewDidMoveToWindow]; 373 [super viewDidMoveToWindow];
376 374
377 //Attaching view to fGLContext requires that the view to be part of a window , 375 //Attaching view to fGLContext requires that the view to be part of a window ,
378 //and that the NSWindow instance must have a CoreGraphics counterpart (or 376 //and that the NSWindow instance must have a CoreGraphics counterpart (or
379 //it must NOT be deferred or should have been on screen at least once) 377 //it must NOT be deferred or should have been on screen at least once)
380 if ([fGLContext view] != self && nil != self.window) { 378 if ([fGLContext view] != self && nil != self.window) {
381 [fGLContext setView:self]; 379 [fGLContext setView:self];
382 } 380 }
(...skipping 30 matching lines...) Expand all
413 - (void)detach { 411 - (void)detach {
414 [fGLContext release]; 412 [fGLContext release];
415 fGLContext = nil; 413 fGLContext = nil;
416 } 414 }
417 415
418 - (void)present { 416 - (void)present {
419 if (nil != fGLContext) { 417 if (nil != fGLContext) {
420 [fGLContext flushBuffer]; 418 [fGLContext flushBuffer];
421 } 419 }
422 } 420 }
421
422 - (void)setVSync:(bool)enable {
423 if (fGLContext) {
424 GLint interval = enable ? 1 : 0;
425 CGLContextObj ctx = (CGLContextObj)[fGLContext CGLContextObj];
426 CGLSetParameter(ctx, kCGLCPSwapInterval, &interval);
427 }
428 }
423 @end 429 @end
OLDNEW
« no previous file with comments | « src/views/mac/SkNSView.h ('k') | src/views/mac/SkOSWindow_Mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698