OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // This file implements the ViewGLContext and PbufferGLContext classes. | 5 // This file implements the ViewGLContext and PbufferGLContext classes. |
6 | 6 |
7 #include "app/gfx/gl/gl_context.h" | 7 #include "app/gfx/gl/gl_context.h" |
8 | 8 |
9 #include <GL/osmesa.h> | 9 #include <GL/osmesa.h> |
10 | 10 |
(...skipping 29 matching lines...) Expand all Loading... |
40 | 40 |
41 // Initializes the GL context. | 41 // Initializes the GL context. |
42 bool Initialize(bool multisampled); | 42 bool Initialize(bool multisampled); |
43 | 43 |
44 virtual void Destroy(); | 44 virtual void Destroy(); |
45 virtual bool MakeCurrent(); | 45 virtual bool MakeCurrent(); |
46 virtual bool IsCurrent(); | 46 virtual bool IsCurrent(); |
47 virtual bool IsOffscreen(); | 47 virtual bool IsOffscreen(); |
48 virtual bool SwapBuffers(); | 48 virtual bool SwapBuffers(); |
49 virtual gfx::Size GetSize(); | 49 virtual gfx::Size GetSize(); |
| 50 virtual void SetSize(gfx::Size size); |
50 virtual void* GetHandle(); | 51 virtual void* GetHandle(); |
51 virtual void SetSwapInterval(int interval); | 52 virtual void SetSwapInterval(int interval); |
52 | 53 |
53 private: | 54 private: |
54 gfx::PluginWindowHandle window_; | 55 gfx::PluginWindowHandle window_; |
55 GLContextHandle context_; | 56 GLContextHandle context_; |
56 | 57 |
57 DISALLOW_COPY_AND_ASSIGN(ViewGLContext); | 58 DISALLOW_COPY_AND_ASSIGN(ViewGLContext); |
58 }; | 59 }; |
59 | 60 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 return true; | 309 return true; |
309 } | 310 } |
310 | 311 |
311 gfx::Size ViewGLContext::GetSize() { | 312 gfx::Size ViewGLContext::GetSize() { |
312 XWindowAttributes attributes; | 313 XWindowAttributes attributes; |
313 Display* display = x11_util::GetXDisplay(); | 314 Display* display = x11_util::GetXDisplay(); |
314 XGetWindowAttributes(display, window_, &attributes); | 315 XGetWindowAttributes(display, window_, &attributes); |
315 return gfx::Size(attributes.width, attributes.height); | 316 return gfx::Size(attributes.width, attributes.height); |
316 } | 317 } |
317 | 318 |
| 319 void ViewGLContext::SetSize(gfx::Size size) { |
| 320 // Need to flush the GL commands in flight so that the resize operation |
| 321 // doesn't damage the backbuffer. |
| 322 glFinish(); |
| 323 |
| 324 GLContext::SetSize(size); |
| 325 } |
| 326 |
318 void* ViewGLContext::GetHandle() { | 327 void* ViewGLContext::GetHandle() { |
319 return context_; | 328 return context_; |
320 } | 329 } |
321 | 330 |
322 void ViewGLContext::SetSwapInterval(int interval) { | 331 void ViewGLContext::SetSwapInterval(int interval) { |
323 DCHECK(IsCurrent()); | 332 DCHECK(IsCurrent()); |
324 if (HasExtension("GLX_EXT_swap_control") && glXSwapIntervalEXT) { | 333 if (HasExtension("GLX_EXT_swap_control") && glXSwapIntervalEXT) { |
325 Display* display = x11_util::GetXDisplay(); | 334 Display* display = x11_util::GetXDisplay(); |
326 glXSwapIntervalEXT(display, window_, interval); | 335 glXSwapIntervalEXT(display, window_, interval); |
327 } | 336 } |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 } | 810 } |
802 case kGLImplementationMockGL: | 811 case kGLImplementationMockGL: |
803 return new StubGLContext; | 812 return new StubGLContext; |
804 default: | 813 default: |
805 NOTREACHED(); | 814 NOTREACHED(); |
806 return NULL; | 815 return NULL; |
807 } | 816 } |
808 } | 817 } |
809 | 818 |
810 } // namespace gfx | 819 } // namespace gfx |
OLD | NEW |