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 |
11 #include "app/gfx/gl/gl_bindings.h" | 11 #include "app/gfx/gl/gl_bindings.h" |
12 #include "app/gfx/gl/gl_context_egl.h" | 12 #include "app/gfx/gl/gl_context_egl.h" |
13 #include "app/gfx/gl/gl_context_osmesa.h" | 13 #include "app/gfx/gl/gl_context_osmesa.h" |
14 #include "app/gfx/gl/gl_context_stub.h" | 14 #include "app/gfx/gl/gl_context_stub.h" |
15 #include "app/gfx/gl/gl_implementation.h" | 15 #include "app/gfx/gl/gl_implementation.h" |
16 #include "app/x11_util.h" | 16 #include "app/x11_util.h" |
17 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
18 #include "base/logging.h" | 18 #include "base/logging.h" |
19 #include "base/scoped_ptr.h" | 19 #include "base/scoped_ptr.h" |
20 #include "chrome/common/child_thread.h" | |
21 #include "chrome/common/gpu_messages.h" | |
20 | 22 |
21 namespace gfx { | 23 namespace gfx { |
22 | 24 |
23 typedef GLXContext GLContextHandle; | 25 typedef GLXContext GLContextHandle; |
24 typedef GLXPbuffer PbufferHandle; | 26 typedef GLXPbuffer PbufferHandle; |
25 | 27 |
26 class BaseLinuxGLContext : public GLContext { | 28 class BaseLinuxGLContext : public GLContext { |
27 public: | 29 public: |
28 virtual std::string GetExtensions(); | 30 virtual std::string GetExtensions(); |
29 }; | 31 }; |
(...skipping 10 matching lines...) Expand all Loading... | |
40 | 42 |
41 // Initializes the GL context. | 43 // Initializes the GL context. |
42 bool Initialize(bool multisampled); | 44 bool Initialize(bool multisampled); |
43 | 45 |
44 virtual void Destroy(); | 46 virtual void Destroy(); |
45 virtual bool MakeCurrent(); | 47 virtual bool MakeCurrent(); |
46 virtual bool IsCurrent(); | 48 virtual bool IsCurrent(); |
47 virtual bool IsOffscreen(); | 49 virtual bool IsOffscreen(); |
48 virtual bool SwapBuffers(); | 50 virtual bool SwapBuffers(); |
49 virtual gfx::Size GetSize(); | 51 virtual gfx::Size GetSize(); |
52 virtual void SetSize(gfx::Size size); | |
50 virtual void* GetHandle(); | 53 virtual void* GetHandle(); |
51 virtual void SetSwapInterval(int interval); | 54 virtual void SetSwapInterval(int interval); |
52 | 55 |
53 private: | 56 private: |
54 gfx::PluginWindowHandle window_; | 57 gfx::PluginWindowHandle window_; |
55 GLContextHandle context_; | 58 GLContextHandle context_; |
56 | 59 |
57 DISALLOW_COPY_AND_ASSIGN(ViewGLContext); | 60 DISALLOW_COPY_AND_ASSIGN(ViewGLContext); |
58 }; | 61 }; |
59 | 62 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 return true; | 311 return true; |
309 } | 312 } |
310 | 313 |
311 gfx::Size ViewGLContext::GetSize() { | 314 gfx::Size ViewGLContext::GetSize() { |
312 XWindowAttributes attributes; | 315 XWindowAttributes attributes; |
313 Display* display = x11_util::GetXDisplay(); | 316 Display* display = x11_util::GetXDisplay(); |
314 XGetWindowAttributes(display, window_, &attributes); | 317 XGetWindowAttributes(display, window_, &attributes); |
315 return gfx::Size(attributes.width, attributes.height); | 318 return gfx::Size(attributes.width, attributes.height); |
316 } | 319 } |
317 | 320 |
321 void ViewGLContext::SetSize(gfx::Size size) { | |
322 // Need to flush the GL commands in flight so that the resize operation | |
323 // doesn't damage the backbuffer. | |
324 glFinish(); | |
325 | |
326 ChildThread* gpu_thread = ChildThread::current(); | |
327 bool result = false; | |
328 gpu_thread->Send( | |
329 new GpuHostMsg_ResizeXID(window_, size.width(), size.height(), &result)); | |
Ken Russell (switch to Gerrit)
2010/11/22 22:49:52
This violates a large number of abstraction barrie
jonathan.backer
2010/11/23 16:41:13
Done. Thanks for catching this. I used your callba
| |
330 } | |
331 | |
318 void* ViewGLContext::GetHandle() { | 332 void* ViewGLContext::GetHandle() { |
319 return context_; | 333 return context_; |
320 } | 334 } |
321 | 335 |
322 void ViewGLContext::SetSwapInterval(int interval) { | 336 void ViewGLContext::SetSwapInterval(int interval) { |
323 DCHECK(IsCurrent()); | 337 DCHECK(IsCurrent()); |
324 if (HasExtension("GLX_EXT_swap_control") && glXSwapIntervalEXT) { | 338 if (HasExtension("GLX_EXT_swap_control") && glXSwapIntervalEXT) { |
325 Display* display = x11_util::GetXDisplay(); | 339 Display* display = x11_util::GetXDisplay(); |
326 glXSwapIntervalEXT(display, window_, interval); | 340 glXSwapIntervalEXT(display, window_, interval); |
327 } | 341 } |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
801 } | 815 } |
802 case kGLImplementationMockGL: | 816 case kGLImplementationMockGL: |
803 return new StubGLContext; | 817 return new StubGLContext; |
804 default: | 818 default: |
805 NOTREACHED(); | 819 NOTREACHED(); |
806 return NULL; | 820 return NULL; |
807 } | 821 } |
808 } | 822 } |
809 | 823 |
810 } // namespace gfx | 824 } // namespace gfx |
OLD | NEW |