OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 RendererGLContexts in the | 6 // and pepper's PGL. This API is used to manage OpenGL RendererGLContexts in the |
7 // Chrome renderer process in a way that is consistent with other platforms. | 7 // Chrome renderer process in a way that is consistent with other platforms. |
8 | 8 |
9 #ifndef CONTENT_RENDERER_GPU_RENDERER_GL_CONTEXT_H_ | 9 #ifndef CONTENT_RENDERER_GPU_RENDERER_GL_CONTEXT_H_ |
10 #define CONTENT_RENDERER_GPU_RENDERER_GL_CONTEXT_H_ | 10 #define CONTENT_RENDERER_GPU_RENDERER_GL_CONTEXT_H_ |
11 #pragma once | 11 #pragma once |
12 | 12 |
13 #include "base/callback_old.h" | 13 #include "base/callback_old.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 18 #include "gpu/command_buffer/common/constants.h" |
18 #include "ui/gfx/native_widget_types.h" | 19 #include "ui/gfx/native_widget_types.h" |
19 #include "ui/gfx/size.h" | 20 #include "ui/gfx/size.h" |
20 | 21 |
21 class GpuChannelHost; | 22 class GpuChannelHost; |
22 class MessageLoop; | 23 class MessageLoop; |
23 class CommandBufferProxy; | 24 class CommandBufferProxy; |
24 class GURL; | 25 class GURL; |
25 class TransportTextureHost; | 26 class TransportTextureHost; |
26 | 27 |
27 namespace gpu { | 28 namespace gpu { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 // same thread as the parent. A child RendererGLContext may not outlive its | 118 // same thread as the parent. A child RendererGLContext may not outlive its |
118 // parent. attrib_list must be NULL or a NONE-terminated list of | 119 // parent. attrib_list must be NULL or a NONE-terminated list of |
119 // attribute/value pairs. | 120 // attribute/value pairs. |
120 static RendererGLContext* CreateOffscreenContext( | 121 static RendererGLContext* CreateOffscreenContext( |
121 GpuChannelHost* channel, | 122 GpuChannelHost* channel, |
122 const gfx::Size& size, | 123 const gfx::Size& size, |
123 const char* allowed_extensions, | 124 const char* allowed_extensions, |
124 const int32* attrib_list, | 125 const int32* attrib_list, |
125 const GURL& active_url); | 126 const GURL& active_url); |
126 | 127 |
| 128 // Map a resource from an external context into this context. The source |
| 129 // context need not be in the same share group from the client's point of |
| 130 // view, allowing safe sharing between an "untrusted" context, like Pepper |
| 131 // and a compositor context. |
| 132 // |
| 133 // Currently only texture resources are supported. TODO(apatrick): generalize |
| 134 // this as appropriate. |
| 135 // |
| 136 // To unmap a previously mapped external resource, delete it in the |
| 137 // destination context group. This will not delete the underlying texture |
| 138 // object, just disassociate it with the id in the destination context group. |
| 139 // |
| 140 // The lifetime of the external resource is managed by the context group it |
| 141 // was originally created in. When the last context in that group is destroyed |
| 142 // the resource becomes invalid in all other context groups it is mapped into. |
| 143 bool MapExternalResource(gpu::resource_type::ResourceType resource_type, |
| 144 uint32 resource_source_id, |
| 145 RendererGLContext* source_context, |
| 146 uint32 resource_dest_id); |
| 147 |
| 148 // TODO(apatrick): this is a workaround until the parent / child relationship |
| 149 // between contexts is removed. MapExternalResource has no such restrictions |
| 150 // on the relationship between contexts. Use it instead. |
| 151 bool MapExternalResourceToParent( |
| 152 gpu::resource_type::ResourceType resource_type, |
| 153 uint32 resource_source_id, |
| 154 uint32 resource_dest_id); |
| 155 |
127 // Sets the parent context. If any parent textures have been created for | 156 // Sets the parent context. If any parent textures have been created for |
128 // another parent, it is important to delete them before changing the parent. | 157 // another parent, it is important to delete them before changing the parent. |
129 bool SetParent(RendererGLContext* parent); | 158 bool SetParent(RendererGLContext* parent); |
130 | 159 |
131 // Resize an offscreen frame buffer. The resize occurs on the next call to | 160 // Resize an offscreen frame buffer. The resize occurs on the next call to |
132 // SwapBuffers. This is to avoid waiting until all pending GL calls have been | 161 // SwapBuffers. This is to avoid waiting until all pending GL calls have been |
133 // executed by the GPU process. Everything rendered up to the call to | 162 // executed by the GPU process. Everything rendered up to the call to |
134 // SwapBuffers will be lost. A lost RendererGLContext will be reported if the | 163 // SwapBuffers will be lost. A lost RendererGLContext will be reported if the |
135 // resize fails. | 164 // resize fails. |
136 void ResizeOffscreen(const gfx::Size& size); | 165 void ResizeOffscreen(const gfx::Size& size); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 int32 transfer_buffer_id_; | 234 int32 transfer_buffer_id_; |
206 gpu::gles2::GLES2Implementation* gles2_implementation_; | 235 gpu::gles2::GLES2Implementation* gles2_implementation_; |
207 gfx::Size size_; | 236 gfx::Size size_; |
208 Error last_error_; | 237 Error last_error_; |
209 int frame_number_; | 238 int frame_number_; |
210 | 239 |
211 DISALLOW_COPY_AND_ASSIGN(RendererGLContext); | 240 DISALLOW_COPY_AND_ASSIGN(RendererGLContext); |
212 }; | 241 }; |
213 | 242 |
214 #endif // CONTENT_RENDERER_GPU_RENDERER_GL_CONTEXT_H_ | 243 #endif // CONTENT_RENDERER_GPU_RENDERER_GL_CONTEXT_H_ |
OLD | NEW |