| 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 API is consistent with other OpenGL setup APIs like window's WGL | 5 // This API is consistent with other OpenGL setup APIs like window's WGL |
| 6 // and pepper's PGL. This API is used to manage OpenGL contexts in the Chrome | 6 // and pepper's PGL. This API is used to manage OpenGL contexts in the Chrome |
| 7 // renderer process in a way that is consistent with other platforms. It is | 7 // renderer process in a way that is consistent with other platforms. It is |
| 8 // a C style API to ease porting of existing OpenGL software to Chrome. | 8 // a C style API to ease porting of existing OpenGL software to Chrome. |
| 9 | 9 |
| 10 #ifndef CHROME_RENDERER_GGL_GGL_H_ | 10 #ifndef CHROME_RENDERER_GGL_GGL_H_ |
| 11 #define CHROME_RENDERER_GGL_GGL_H_ | 11 #define CHROME_RENDERER_GGL_GGL_H_ |
| 12 | 12 |
| 13 #include "gfx/native_widget_types.h" |
| 14 #include "gfx/size.h" |
| 15 |
| 13 class GpuChannelHost; | 16 class GpuChannelHost; |
| 14 | 17 |
| 15 namespace ggl { | 18 namespace ggl { |
| 16 | 19 |
| 17 class Context; | 20 class Context; |
| 18 | 21 |
| 19 // These are the same error codes as used by EGL. | 22 // These are the same error codes as used by EGL. |
| 20 enum Error { | 23 enum Error { |
| 21 SUCCESS = 0x3000, | 24 SUCCESS = 0x3000, |
| 22 NOT_INITIALIZED = 0x3001, | 25 NOT_INITIALIZED = 0x3001, |
| 23 BAD_CONTEXT = 0x3006, | 26 BAD_CONTEXT = 0x3006, |
| 24 CONTEXT_LOST = 0x300E | 27 CONTEXT_LOST = 0x300E |
| 25 }; | 28 }; |
| 26 | 29 |
| 27 // Initialize the GGL library. This must have completed before any other GGL | 30 // Initialize the GGL library. This must have completed before any other GGL |
| 28 // functions are invoked. | 31 // functions are invoked. |
| 29 bool Initialize(); | 32 bool Initialize(); |
| 30 | 33 |
| 31 // Terminate the GGL library. This must be called after any other GGL functions | 34 // Terminate the GGL library. This must be called after any other GGL functions |
| 32 // have completed. | 35 // have completed. |
| 33 bool Terminate(); | 36 bool Terminate(); |
| 34 | 37 |
| 35 // Create A GGL context for an offscreen 1 x 1 pbuffer. | 38 // Create a GGL context that renders directly to a view. |
| 36 Context* CreateContext(GpuChannelHost* channel); | 39 Context* CreateViewContext(GpuChannelHost* channel, gfx::NativeViewId view); |
| 40 |
| 41 // Create a GGL context that renders to an offscreen frame buffer. If parent is |
| 42 // not NULL, that context can access a copy of the created |
| 43 // context's frame buffer that is updated every time SwapBuffers is called. It |
| 44 // is not as general as shared contexts in other implementations of OpenGL. If |
| 45 // parent is not NULL, it must be used on the same thread as the parent. A child |
| 46 // context may not outlive its parent. |
| 47 Context* CreateOffscreenContext(GpuChannelHost* channel, |
| 48 Context* parent, |
| 49 const gfx::Size& size); |
| 50 |
| 51 // Resize an offscreen frame buffer. The resize occurs on the next call to |
| 52 // SwapBuffers. This is to avoid waiting until all pending GL calls have been |
| 53 // executed by the GPU process. Everything rendered up to the call to |
| 54 // SwapBuffers will be lost. A lost context will be reported if the resize |
| 55 // fails. |
| 56 void ResizeOffscreenContext(Context* context, const gfx::Size& size); |
| 57 |
| 58 // For an offscreen frame buffer context, return the texture ID with |
| 59 // respect to the parent context. Returns zero if context does not have a |
| 60 // parent. |
| 61 uint32 GetParentTextureId(Context* context); |
| 37 | 62 |
| 38 // Set the current GGL context for the calling thread. | 63 // Set the current GGL context for the calling thread. |
| 39 bool MakeCurrent(Context* context); | 64 bool MakeCurrent(Context* context); |
| 40 | 65 |
| 41 // Get the calling thread's current GGL context. | 66 // Get the calling thread's current GGL context. |
| 42 Context* GetCurrentContext(); | 67 Context* GetCurrentContext(); |
| 43 | 68 |
| 44 // Display everything that has been rendered since the last call. | 69 // For a view context, display everything that has been rendered since the |
| 70 // last call. For an offscreen context, resolve everything that has been |
| 71 // rendered since the last call to a copy that can be accessed by the parent |
| 72 // context. |
| 45 bool SwapBuffers(); | 73 bool SwapBuffers(); |
| 46 | 74 |
| 47 // Destroy the given GGL context. | 75 // Destroy the given GGL context. |
| 48 bool DestroyContext(Context* context); | 76 bool DestroyContext(Context* context); |
| 49 | 77 |
| 50 // Return the current GGL error. | 78 // Return the current GGL error. |
| 51 Error GetError(); | 79 Error GetError(); |
| 52 | 80 |
| 53 } // namespace ggl | 81 } // namespace ggl |
| 54 | 82 |
| 55 #endif // CHROME_RENDERER_GGL_GGL_H_ | 83 #endif // CHROME_RENDERER_GGL_GGL_H_ |
| OLD | NEW |