| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/gl/gl_context_nsview.h" | 5 #include "ui/gl/gl_context_nsview.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #import <AppKit/NSOpenGL.h> | 9 #import <AppKit/NSOpenGL.h> |
| 10 #import <AppKit/NSView.h> | 10 #import <AppKit/NSView.h> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 bool GLContextNSView::Initialize(GLSurface* surface, | 25 bool GLContextNSView::Initialize(GLSurface* surface, |
| 26 GpuPreference gpu_preference) { | 26 GpuPreference gpu_preference) { |
| 27 DCHECK(!context_) << "NSGLContext was previously initialized."; | 27 DCHECK(!context_) << "NSGLContext was previously initialized."; |
| 28 gpu_preference_ = gpu_preference; | 28 gpu_preference_ = gpu_preference; |
| 29 | 29 |
| 30 std::vector<NSOpenGLPixelFormatAttribute> attributes; | 30 std::vector<NSOpenGLPixelFormatAttribute> attributes; |
| 31 attributes.push_back(NSOpenGLPFAAccelerated); | 31 attributes.push_back(NSOpenGLPFAAccelerated); |
| 32 attributes.push_back(NSOpenGLPFADoubleBuffer); | 32 attributes.push_back(NSOpenGLPFADoubleBuffer); |
| 33 attributes.push_back(0); | 33 attributes.push_back(0); |
| 34 | 34 |
| 35 scoped_nsobject<NSOpenGLPixelFormat> pixel_format; | 35 base::scoped_nsobject<NSOpenGLPixelFormat> pixel_format; |
| 36 pixel_format.reset([[NSOpenGLPixelFormat alloc] | 36 pixel_format.reset([[NSOpenGLPixelFormat alloc] |
| 37 initWithAttributes:&attributes.front()]); | 37 initWithAttributes:&attributes.front()]); |
| 38 if (!pixel_format) { | 38 if (!pixel_format) { |
| 39 LOG(ERROR) << "NSOpenGLPixelFormat initWithAttributes failed."; | 39 LOG(ERROR) << "NSOpenGLPixelFormat initWithAttributes failed."; |
| 40 return false; | 40 return false; |
| 41 } | 41 } |
| 42 | 42 |
| 43 context_.reset([[NSOpenGLContext alloc] initWithFormat:pixel_format | 43 context_.reset([[NSOpenGLContext alloc] initWithFormat:pixel_format |
| 44 shareContext:nil]); | 44 shareContext:nil]); |
| 45 if (!context_) { | 45 if (!context_) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 DCHECK(interval == 0 || interval == 1); | 90 DCHECK(interval == 0 || interval == 1); |
| 91 GLint swap = interval; | 91 GLint swap = interval; |
| 92 [context_ setValues:&swap forParameter:NSOpenGLCPSwapInterval]; | 92 [context_ setValues:&swap forParameter:NSOpenGLCPSwapInterval]; |
| 93 } | 93 } |
| 94 | 94 |
| 95 void GLContextNSView::FlushBuffer() { | 95 void GLContextNSView::FlushBuffer() { |
| 96 [context_ flushBuffer]; | 96 [context_ flushBuffer]; |
| 97 } | 97 } |
| 98 | 98 |
| 99 } // namespace gfx | 99 } // namespace gfx |
| OLD | NEW |