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 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" | 5 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <string> | 10 #include <string> |
(...skipping 25 matching lines...) Expand all Loading... |
36 } | 36 } |
37 | 37 |
38 WGC3Denum type; | 38 WGC3Denum type; |
39 scoped_array<char> source; | 39 scoped_array<char> source; |
40 scoped_array<char> log; | 40 scoped_array<char> log; |
41 scoped_array<char> translated_source; | 41 scoped_array<char> translated_source; |
42 bool is_valid; | 42 bool is_valid; |
43 }; | 43 }; |
44 | 44 |
45 WebGraphicsContext3DInProcessImpl::WebGraphicsContext3DInProcessImpl( | 45 WebGraphicsContext3DInProcessImpl::WebGraphicsContext3DInProcessImpl( |
46 gfx::PluginWindowHandle window) | 46 gfx::PluginWindowHandle window, |
| 47 gfx::GLShareGroup* share_group) |
47 : initialized_(false), | 48 : initialized_(false), |
48 render_directly_to_web_view_(false), | 49 render_directly_to_web_view_(false), |
49 is_gles2_(false), | 50 is_gles2_(false), |
50 have_ext_framebuffer_object_(false), | 51 have_ext_framebuffer_object_(false), |
51 have_ext_framebuffer_multisample_(false), | 52 have_ext_framebuffer_multisample_(false), |
52 have_angle_framebuffer_multisample_(false), | 53 have_angle_framebuffer_multisample_(false), |
53 texture_(0), | 54 texture_(0), |
54 fbo_(0), | 55 fbo_(0), |
55 depth_stencil_buffer_(0), | 56 depth_stencil_buffer_(0), |
56 cached_width_(0), | 57 cached_width_(0), |
57 cached_height_(0), | 58 cached_height_(0), |
58 multisample_fbo_(0), | 59 multisample_fbo_(0), |
59 multisample_depth_stencil_buffer_(0), | 60 multisample_depth_stencil_buffer_(0), |
60 multisample_color_buffer_(0), | 61 multisample_color_buffer_(0), |
61 bound_fbo_(0), | 62 bound_fbo_(0), |
62 bound_texture_(0), | 63 bound_texture_(0), |
63 copy_texture_to_parent_texture_fbo_(0), | 64 copy_texture_to_parent_texture_fbo_(0), |
64 #ifdef FLIP_FRAMEBUFFER_VERTICALLY | 65 #ifdef FLIP_FRAMEBUFFER_VERTICALLY |
65 scanline_(0), | 66 scanline_(0), |
66 #endif | 67 #endif |
67 fragment_compiler_(0), | 68 fragment_compiler_(0), |
68 vertex_compiler_(0), | 69 vertex_compiler_(0), |
69 window_(window) { | 70 window_(window), |
| 71 share_group_(share_group) { |
70 } | 72 } |
71 | 73 |
72 WebGraphicsContext3DInProcessImpl::~WebGraphicsContext3DInProcessImpl() { | 74 WebGraphicsContext3DInProcessImpl::~WebGraphicsContext3DInProcessImpl() { |
73 if (!initialized_) | 75 if (!initialized_) |
74 return; | 76 return; |
75 | 77 |
76 makeContextCurrent(); | 78 makeContextCurrent(); |
77 | 79 |
78 if (attributes_.antialias) { | 80 if (attributes_.antialias) { |
79 glDeleteRenderbuffersEXT(1, &multisample_color_buffer_); | 81 glDeleteRenderbuffersEXT(1, &multisample_color_buffer_); |
(...skipping 27 matching lines...) Expand all Loading... |
107 bool WebGraphicsContext3DInProcessImpl::initialize( | 109 bool WebGraphicsContext3DInProcessImpl::initialize( |
108 WebGraphicsContext3D::Attributes attributes, | 110 WebGraphicsContext3D::Attributes attributes, |
109 WebView* webView, | 111 WebView* webView, |
110 bool render_directly_to_web_view) { | 112 bool render_directly_to_web_view) { |
111 if (!gfx::GLSurface::InitializeOneOff()) | 113 if (!gfx::GLSurface::InitializeOneOff()) |
112 return false; | 114 return false; |
113 | 115 |
114 render_directly_to_web_view_ = render_directly_to_web_view; | 116 render_directly_to_web_view_ = render_directly_to_web_view; |
115 gfx::GLShareGroup* share_group = 0; | 117 gfx::GLShareGroup* share_group = 0; |
116 | 118 |
117 if (!render_directly_to_web_view) { | |
118 // Pick up the compositor's context to share resources with. | |
119 WebGraphicsContext3D* view_context = webView ? | |
120 webView->graphicsContext3D() : NULL; | |
121 if (view_context) { | |
122 WebGraphicsContext3DInProcessImpl* contextImpl = | |
123 static_cast<WebGraphicsContext3DInProcessImpl*>(view_context); | |
124 share_group = contextImpl->gl_context_->share_group(); | |
125 } else { | |
126 // The compositor's context didn't get created | |
127 // successfully, so conceptually there is no way we can | |
128 // render successfully to the WebView. | |
129 render_directly_to_web_view_ = false; | |
130 } | |
131 } | |
132 | |
133 is_gles2_ = gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2; | 119 is_gles2_ = gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2; |
134 | 120 |
135 if (window_ != gfx::kNullPluginWindow) { | 121 if (window_ != gfx::kNullPluginWindow) { |
| 122 share_group = share_group_; |
136 gl_surface_ = gfx::GLSurface::CreateViewGLSurface(false, window_); | 123 gl_surface_ = gfx::GLSurface::CreateViewGLSurface(false, window_); |
137 } else { | 124 } else { |
| 125 if (!render_directly_to_web_view) { |
| 126 // Pick up the compositor's context to share resources with. |
| 127 WebGraphicsContext3D* view_context = webView ? |
| 128 webView->graphicsContext3D() : NULL; |
| 129 if (view_context) { |
| 130 WebGraphicsContext3DInProcessImpl* contextImpl = |
| 131 static_cast<WebGraphicsContext3DInProcessImpl*>(view_context); |
| 132 share_group = contextImpl->gl_context_->share_group(); |
| 133 } else { |
| 134 // The compositor's context didn't get created |
| 135 // successfully, so conceptually there is no way we can |
| 136 // render successfully to the WebView. |
| 137 render_directly_to_web_view_ = false; |
| 138 } |
| 139 } |
138 // This implementation always renders offscreen regardless of | 140 // This implementation always renders offscreen regardless of |
139 // whether render_directly_to_web_view is true. Both DumpRenderTree | 141 // whether render_directly_to_web_view is true. Both DumpRenderTree |
140 // and test_shell paint first to an intermediate offscreen buffer | 142 // and test_shell paint first to an intermediate offscreen buffer |
141 // and from there to the window, and WebViewImpl::paint already | 143 // and from there to the window, and WebViewImpl::paint already |
142 // correctly handles the case where the compositor is active but | 144 // correctly handles the case where the compositor is active but |
143 // the output needs to go to a WebCanvas. | 145 // the output needs to go to a WebCanvas. |
144 gl_surface_ = gfx::GLSurface::CreateOffscreenGLSurface(false, | 146 gl_surface_ = gfx::GLSurface::CreateOffscreenGLSurface(false, |
145 gfx::Size(1, 1)); | 147 gfx::Size(1, 1)); |
146 } | 148 } |
147 | 149 |
(...skipping 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1673 if (length > 1) { | 1675 if (length > 1) { |
1674 entry->translated_source.reset(new char[length]); | 1676 entry->translated_source.reset(new char[length]); |
1675 ShGetObjectCode(compiler, entry->translated_source.get()); | 1677 ShGetObjectCode(compiler, entry->translated_source.get()); |
1676 } | 1678 } |
1677 entry->is_valid = true; | 1679 entry->is_valid = true; |
1678 return true; | 1680 return true; |
1679 } | 1681 } |
1680 | 1682 |
1681 } // namespace gpu | 1683 } // namespace gpu |
1682 } // namespace webkit | 1684 } // namespace webkit |
OLD | NEW |