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 #if defined(ENABLE_GPU) | 5 #if defined(ENABLE_GPU) |
6 | 6 |
7 #include "chrome/renderer/webgraphicscontext3d_command_buffer_impl.h" | 7 #include "chrome/renderer/webgraphicscontext3d_command_buffer_impl.h" |
8 | 8 |
9 #include <GLES2/gl2.h> | 9 #include <GLES2/gl2.h> |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 bound_fbo_(0) { | 21 bound_fbo_(0) { |
22 } | 22 } |
23 | 23 |
24 WebGraphicsContext3DCommandBufferImpl:: | 24 WebGraphicsContext3DCommandBufferImpl:: |
25 ~WebGraphicsContext3DCommandBufferImpl() { | 25 ~WebGraphicsContext3DCommandBufferImpl() { |
26 if (context_) { | 26 if (context_) { |
27 ggl::DestroyContext(context_); | 27 ggl::DestroyContext(context_); |
28 } | 28 } |
29 } | 29 } |
30 | 30 |
| 31 // TODO(vangelis): Properly implement this method once the upstream WebKit |
| 32 // changes have landed. |
| 33 bool WebGraphicsContext3DCommandBufferImpl::initialize( |
| 34 WebGraphicsContext3D::Attributes attributes, |
| 35 WebKit::WebView*) { |
| 36 return initialize(attributes); |
| 37 } |
| 38 |
31 bool WebGraphicsContext3DCommandBufferImpl::initialize( | 39 bool WebGraphicsContext3DCommandBufferImpl::initialize( |
32 WebGraphicsContext3D::Attributes attributes) { | 40 WebGraphicsContext3D::Attributes attributes) { |
33 RenderThread* render_thread = RenderThread::current(); | 41 RenderThread* render_thread = RenderThread::current(); |
34 if (!render_thread) | 42 if (!render_thread) |
35 return false; | 43 return false; |
36 GpuChannelHost* host = render_thread->EstablishGpuChannelSync(); | 44 GpuChannelHost* host = render_thread->EstablishGpuChannelSync(); |
37 if (!host) | 45 if (!host) |
38 return false; | 46 return false; |
39 DCHECK(host->ready()); | 47 DCHECK(host->ready()); |
40 context_ = ggl::CreateOffscreenContext(host, NULL, gfx::Size(1, 1)); | 48 context_ = ggl::CreateOffscreenContext(host, NULL, gfx::Size(1, 1)); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 case GL_FLOAT: | 82 case GL_FLOAT: |
75 return sizeof(GLfloat); | 83 return sizeof(GLfloat); |
76 } | 84 } |
77 return 0; | 85 return 0; |
78 } | 86 } |
79 | 87 |
80 bool WebGraphicsContext3DCommandBufferImpl::isGLES2Compliant() { | 88 bool WebGraphicsContext3DCommandBufferImpl::isGLES2Compliant() { |
81 return true; | 89 return true; |
82 } | 90 } |
83 | 91 |
| 92 unsigned int WebGraphicsContext3DCommandBufferImpl::getPlatformTextureId() { |
| 93 DCHECK(context_); |
| 94 return ggl::GetParentTextureId(context_); |
| 95 } |
| 96 |
| 97 void WebGraphicsContext3DCommandBufferImpl::prepareTexture() { |
| 98 // Copies the contents of the off-screen render target into the texture |
| 99 // used by the compositor. |
| 100 ggl::SwapBuffers(context_); |
| 101 } |
| 102 |
84 void WebGraphicsContext3DCommandBufferImpl::reshape(int width, int height) { | 103 void WebGraphicsContext3DCommandBufferImpl::reshape(int width, int height) { |
85 cached_width_ = width; | 104 cached_width_ = width; |
86 cached_height_ = height; | 105 cached_height_ = height; |
87 makeContextCurrent(); | 106 makeContextCurrent(); |
88 | 107 |
89 ggl::ResizeOffscreenContext(context_, gfx::Size(width, height)); | 108 ggl::ResizeOffscreenContext(context_, gfx::Size(width, height)); |
90 | 109 |
91 // Force a SwapBuffers to get the framebuffer to resize, even though | 110 // Force a SwapBuffers to get the framebuffer to resize, even though |
92 // we aren't directly rendering from the back buffer yet. | 111 // we aren't directly rendering from the back buffer yet. |
93 ggl::SwapBuffers(context_); | 112 ggl::SwapBuffers(context_); |
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 glDeleteShader(shader); | 815 glDeleteShader(shader); |
797 } | 816 } |
798 | 817 |
799 void WebGraphicsContext3DCommandBufferImpl::deleteTexture(unsigned texture) { | 818 void WebGraphicsContext3DCommandBufferImpl::deleteTexture(unsigned texture) { |
800 makeContextCurrent(); | 819 makeContextCurrent(); |
801 glDeleteTextures(1, &texture); | 820 glDeleteTextures(1, &texture); |
802 } | 821 } |
803 | 822 |
804 #endif // defined(ENABLE_GPU) | 823 #endif // defined(ENABLE_GPU) |
805 | 824 |
OLD | NEW |