| 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" | |
| 19 #include "ui/gfx/native_widget_types.h" | 18 #include "ui/gfx/native_widget_types.h" |
| 20 #include "ui/gfx/size.h" | 19 #include "ui/gfx/size.h" |
| 21 | 20 |
| 22 class GpuChannelHost; | 21 class GpuChannelHost; |
| 23 class MessageLoop; | 22 class MessageLoop; |
| 24 class CommandBufferProxy; | 23 class CommandBufferProxy; |
| 25 class GURL; | 24 class GURL; |
| 26 class TransportTextureHost; | 25 class TransportTextureHost; |
| 27 | 26 |
| 28 namespace gpu { | 27 namespace gpu { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // same thread as the parent. A child RendererGLContext may not outlive its | 117 // same thread as the parent. A child RendererGLContext may not outlive its |
| 119 // parent. attrib_list must be NULL or a NONE-terminated list of | 118 // parent. attrib_list must be NULL or a NONE-terminated list of |
| 120 // attribute/value pairs. | 119 // attribute/value pairs. |
| 121 static RendererGLContext* CreateOffscreenContext( | 120 static RendererGLContext* CreateOffscreenContext( |
| 122 GpuChannelHost* channel, | 121 GpuChannelHost* channel, |
| 123 const gfx::Size& size, | 122 const gfx::Size& size, |
| 124 const char* allowed_extensions, | 123 const char* allowed_extensions, |
| 125 const int32* attrib_list, | 124 const int32* attrib_list, |
| 126 const GURL& active_url); | 125 const GURL& active_url); |
| 127 | 126 |
| 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 | |
| 156 // Sets the parent context. If any parent textures have been created for | 127 // Sets the parent context. If any parent textures have been created for |
| 157 // another parent, it is important to delete them before changing the parent. | 128 // another parent, it is important to delete them before changing the parent. |
| 158 bool SetParent(RendererGLContext* parent); | 129 bool SetParent(RendererGLContext* parent); |
| 159 | 130 |
| 160 // Resize an offscreen frame buffer. The resize occurs on the next call to | 131 // Resize an offscreen frame buffer. The resize occurs on the next call to |
| 161 // SwapBuffers. This is to avoid waiting until all pending GL calls have been | 132 // SwapBuffers. This is to avoid waiting until all pending GL calls have been |
| 162 // executed by the GPU process. Everything rendered up to the call to | 133 // executed by the GPU process. Everything rendered up to the call to |
| 163 // SwapBuffers will be lost. A lost RendererGLContext will be reported if the | 134 // SwapBuffers will be lost. A lost RendererGLContext will be reported if the |
| 164 // resize fails. | 135 // resize fails. |
| 165 void ResizeOffscreen(const gfx::Size& size); | 136 void ResizeOffscreen(const gfx::Size& size); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 int32 transfer_buffer_id_; | 205 int32 transfer_buffer_id_; |
| 235 gpu::gles2::GLES2Implementation* gles2_implementation_; | 206 gpu::gles2::GLES2Implementation* gles2_implementation_; |
| 236 gfx::Size size_; | 207 gfx::Size size_; |
| 237 Error last_error_; | 208 Error last_error_; |
| 238 int frame_number_; | 209 int frame_number_; |
| 239 | 210 |
| 240 DISALLOW_COPY_AND_ASSIGN(RendererGLContext); | 211 DISALLOW_COPY_AND_ASSIGN(RendererGLContext); |
| 241 }; | 212 }; |
| 242 | 213 |
| 243 #endif // CONTENT_RENDERER_GPU_RENDERER_GL_CONTEXT_H_ | 214 #endif // CONTENT_RENDERER_GPU_RENDERER_GL_CONTEXT_H_ |
| OLD | NEW |