Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Side by Side Diff: chrome/renderer/ggl/ggl.h

Issue 6673090: Move core renderer subdirectories to content. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | chrome/renderer/ggl/ggl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
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
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.
9
10 #ifndef CHROME_RENDERER_GGL_GGL_H_
11 #define CHROME_RENDERER_GGL_GGL_H_
12 #pragma once
13
14 #include "base/callback.h"
15 #include "ui/gfx/native_widget_types.h"
16 #include "ui/gfx/size.h"
17
18 class GpuChannelHost;
19 class MessageLoop;
20 class CommandBufferProxy;
21
22 namespace gpu {
23 namespace gles2 {
24 class GLES2Implementation;
25 }
26 }
27
28 namespace media {
29 class VideoDecodeContext;
30 class VideoDecodeEngine;
31 }
32
33 namespace ggl {
34
35 class Context;
36
37 // These are the same error codes as used by EGL.
38 enum Error {
39 SUCCESS = 0x3000,
40 NOT_INITIALIZED = 0x3001,
41 BAD_ATTRIBUTE = 0x3004,
42 BAD_CONTEXT = 0x3006,
43 CONTEXT_LOST = 0x300E
44 };
45
46 // Context configuration attributes. These are the same as used by EGL.
47 // Attributes are matched using a closest fit algorithm.
48 const int32 GGL_ALPHA_SIZE = 0x3021;
49 const int32 GGL_BLUE_SIZE = 0x3022;
50 const int32 GGL_GREEN_SIZE = 0x3023;
51 const int32 GGL_RED_SIZE = 0x3024;
52 const int32 GGL_DEPTH_SIZE = 0x3025;
53 const int32 GGL_STENCIL_SIZE = 0x3026;
54 const int32 GGL_SAMPLES = 0x3031;
55 const int32 GGL_SAMPLE_BUFFERS = 0x3032;
56 const int32 GGL_NONE = 0x3038; // Attrib list = terminator
57
58 // Initialize the GGL library. This must have completed before any other GGL
59 // functions are invoked.
60 bool Initialize();
61
62 // Terminate the GGL library. This must be called after any other GGL functions
63 // have completed.
64 bool Terminate();
65
66 // Create a GGL context that renders directly to a view. The view and the
67 // associated window must not be destroyed until the returned context has been
68 // destroyed, otherwise the GPU process might attempt to render to an invalid
69 // window handle.
70 //
71 // NOTE: on Mac OS X, this entry point is only used to set up the
72 // accelerated compositor's output. On this platform, we actually pass
73 // a gfx::PluginWindowHandle in place of the gfx::NativeViewId,
74 // because the facility to allocate a fake PluginWindowHandle is
75 // already in place. We could add more entry points and messages to
76 // allocate both fake PluginWindowHandles and NativeViewIds and map
77 // from fake NativeViewIds to PluginWindowHandles, but this seems like
78 // unnecessary complexity at the moment.
79 //
80 // The render_view_id is currently also only used on Mac OS X.
81 // TODO(kbr): clean up the arguments to this function and make them
82 // more cross-platform.
83 Context* CreateViewContext(GpuChannelHost* channel,
84 int render_view_id,
85 const char* allowed_extensions,
86 const int32* attrib_list);
87
88 #if defined(OS_MACOSX)
89 // On Mac OS X only, view contexts actually behave like offscreen contexts, and
90 // require an explicit resize operation which is slightly different from that
91 // of offscreen contexts.
92 void ResizeOnscreenContext(Context* context, const gfx::Size& size);
93 #endif
94
95 // Create a GGL context that renders to an offscreen frame buffer. If parent is
96 // not NULL, that context can access a copy of the created
97 // context's frame buffer that is updated every time SwapBuffers is called. It
98 // is not as general as shared contexts in other implementations of OpenGL. If
99 // parent is not NULL, it must be used on the same thread as the parent. A child
100 // context may not outlive its parent. attrib_list must be NULL or a
101 // GGL_NONE-terminated list of attribute/value pairs.
102 Context* CreateOffscreenContext(GpuChannelHost* channel,
103 Context* parent,
104 const gfx::Size& size,
105 const char* allowed_extensions,
106 const int32* attrib_list);
107
108 // Resize an offscreen frame buffer. The resize occurs on the next call to
109 // SwapBuffers. This is to avoid waiting until all pending GL calls have been
110 // executed by the GPU process. Everything rendered up to the call to
111 // SwapBuffers will be lost. A lost context will be reported if the resize
112 // fails.
113 void ResizeOffscreenContext(Context* context, const gfx::Size& size);
114
115 // For an offscreen frame buffer context, return the texture ID with
116 // respect to the parent context. Returns zero if context does not have a
117 // parent.
118 uint32 GetParentTextureId(Context* context);
119
120 // Create a new texture in the parent's context. Returns zero if context
121 // does not have a parent.
122 uint32 CreateParentTexture(Context* context, const gfx::Size& size);
123
124 // Deletes a texture in the parent's context.
125 void DeleteParentTexture(Context* context, uint32 texture);
126
127 // Provides a callback that will be invoked when SwapBuffers has completed
128 // service side.
129 void SetSwapBuffersCallback(Context* context, Callback0::Type* callback);
130
131 void SetContextLostCallback(Context* context, Callback0::Type* callback);
132
133 // Set the current GGL context for the calling thread.
134 bool MakeCurrent(Context* context);
135
136 // For a view context, display everything that has been rendered since the
137 // last call. For an offscreen context, resolve everything that has been
138 // rendered since the last call to a copy that can be accessed by the parent
139 // context.
140 bool SwapBuffers(Context* context);
141
142 // Destroy the given GGL context.
143 bool DestroyContext(Context* context);
144
145 // Create a hardware video decode engine corresponding to the context.
146 media::VideoDecodeEngine* CreateVideoDecodeEngine(Context* context);
147
148 // Create a hardware video decode context to pair with the hardware video
149 // decode engine. It can also be used with a software decode engine.
150 //
151 // Set |hardware_decoder| to true if this context is for a hardware video
152 // engine. |message_loop| is where the decode context should run on.
153 media::VideoDecodeContext* CreateVideoDecodeContext(Context* context,
154 MessageLoop* message_loop,
155 bool hardware_decoder);
156
157 // TODO(gman): Remove this
158 void DisableShaderTranslation(Context* context);
159
160 // Allows direct access to the GLES2 implementation so a context
161 // can be used without making it current.
162 gpu::gles2::GLES2Implementation* GetImplementation(Context* context);
163
164 // Return the current GGL error.
165 Error GetError(Context* context);
166
167 // Return true if GPU process reported context lost or there was a problem
168 // communicating with the GPU process.
169 bool IsCommandBufferContextLost(Context* context);
170
171 CommandBufferProxy* GetCommandBufferProxy(Context* context);
172
173 } // namespace ggl
174
175 #endif // CHROME_RENDERER_GGL_GGL_H_
OLDNEW
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | chrome/renderer/ggl/ggl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698