OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 } | 108 } |
109 | 109 |
110 | 110 |
111 | 111 |
112 | 112 |
113 /* Called by the CAOpenGLLayer implementation when a rendering context | 113 /* Called by the CAOpenGLLayer implementation when a rendering context |
114 * is needed by the layer. Should return an OpenGL context with | 114 * is needed by the layer. Should return an OpenGL context with |
115 * renderers from pixel format 'pixelFormat'. The default implementation | 115 * renderers from pixel format 'pixelFormat'. The default implementation |
116 * allocates a new context with a null share context. */ | 116 * allocates a new context with a null share context. */ |
117 - (CGLContextObj)copyCGLContextForPixelFormat:(CGLPixelFormatObj)pixelFormat { | 117 - (CGLContextObj)copyCGLContextForPixelFormat:(CGLPixelFormatObj)pixelFormat { |
118 CGLContextObj share_context = obj_->GetFullscreenShareContext(); | 118 if (glContext_ == NULL) { |
119 DCHECK(share_context); | 119 CGLContextObj share_context = obj_->GetFullscreenShareContext(); |
120 if (CGLCreateContext(pixelFormat, share_context, &glContext_) != | 120 DCHECK(share_context); |
121 kCGLNoError) { | 121 if (CGLCreateContext(pixelFormat, share_context, &glContext_) != |
122 glContext_ = [super copyCGLContextForPixelFormat:pixelFormat]; | 122 kCGLNoError) { |
| 123 glContext_ = [super copyCGLContextForPixelFormat:pixelFormat]; |
| 124 } |
| 125 obj_->SetMacCGLContext(glContext_); |
| 126 created_context_ = true; |
123 } | 127 } |
124 obj_->SetMacCGLContext(glContext_); | |
125 created_context_ = true; | |
126 return glContext_; | 128 return glContext_; |
127 } | 129 } |
128 | 130 |
129 /* | 131 /* |
130 - (CGLPixelFormatObj)copyCGLPixelFormatForDisplayMask:(uint32_t)mask { | 132 - (CGLPixelFormatObj)copyCGLPixelFormatForDisplayMask:(uint32_t)mask { |
131 return [super copyCGLPixelFormatForDisplayMask:mask]; | 133 return [super copyCGLPixelFormatForDisplayMask:mask]; |
132 }*/ | 134 }*/ |
133 | 135 |
134 | 136 |
135 #define PFA(number) static_cast<CGLPixelFormatAttribute>(number) | 137 #define PFA(number) static_cast<CGLPixelFormatAttribute>(number) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 return glContext_; | 184 return glContext_; |
183 } | 185 } |
184 | 186 |
185 - (void)setWidth:(int)width height:(int)height { | 187 - (void)setWidth:(int)width height:(int)height { |
186 width_ = width; | 188 width_ = width; |
187 height_ = height; | 189 height_ = height; |
188 was_resized_ = true; | 190 was_resized_ = true; |
189 } | 191 } |
190 | 192 |
191 @end | 193 @end |
OLD | NEW |