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 #include "webkit/plugins/ppapi/ppb_surface_3d_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_surface_3d_impl.h" |
6 | 6 |
7 #include "gpu/command_buffer/client/gles2_implementation.h" | 7 #include "gpu/command_buffer/client/gles2_implementation.h" |
8 #include "gpu/command_buffer/common/command_buffer.h" | 8 #include "gpu/command_buffer/common/command_buffer.h" |
9 #include "ppapi/c/dev/ppb_graphics_3d_dev.h" | 9 #include "ppapi/c/dev/ppb_graphics_3d_dev.h" |
10 #include "webkit/plugins/ppapi/common.h" | 10 #include "webkit/plugins/ppapi/common.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 if (context == context_) | 100 if (context == context_) |
101 return true; | 101 return true; |
102 | 102 |
103 // Unbind from the current context. | 103 // Unbind from the current context. |
104 if (context_) { | 104 if (context_) { |
105 context_->platform_context()->SetSwapBuffersCallback(NULL); | 105 context_->platform_context()->SetSwapBuffersCallback(NULL); |
106 } | 106 } |
107 if (context) { | 107 if (context) { |
108 // Resize the backing texture to the size of the instance when it is bound. | 108 // Resize the backing texture to the size of the instance when it is bound. |
109 // TODO(alokp): This should be the responsibility of plugins. | 109 // TODO(alokp): This should be the responsibility of plugins. |
110 const gfx::Size& size = instance()->position().size(); | 110 gpu::gles2::GLES2Implementation* impl = context->gles2_impl(); |
111 context->gles2_impl()->ResizeCHROMIUM(size.width(), size.height()); | 111 if (impl) { |
| 112 const gfx::Size& size = instance()->position().size(); |
| 113 impl->ResizeCHROMIUM(size.width(), size.height()); |
| 114 } |
112 | 115 |
113 context->platform_context()->SetSwapBuffersCallback( | 116 context->platform_context()->SetSwapBuffersCallback( |
114 NewCallback(this, &PPB_Surface3D_Impl::OnSwapBuffers)); | 117 NewCallback(this, &PPB_Surface3D_Impl::OnSwapBuffers)); |
115 } | 118 } |
116 context_ = context; | 119 context_ = context; |
117 return true; | 120 return true; |
118 } | 121 } |
119 | 122 |
120 bool PPB_Surface3D_Impl::SwapBuffers(PP_CompletionCallback callback) { | 123 bool PPB_Surface3D_Impl::SwapBuffers(PP_CompletionCallback callback) { |
121 if (!context_) | 124 if (!context_) |
122 return false; | 125 return false; |
123 | 126 |
124 if (swap_callback_.func) { | 127 if (swap_callback_.func) { |
125 // Already a pending SwapBuffers that hasn't returned yet. | 128 // Already a pending SwapBuffers that hasn't returned yet. |
126 return false; | 129 return false; |
127 } | 130 } |
128 | 131 |
129 swap_callback_ = callback; | 132 swap_callback_ = callback; |
130 context_->gles2_impl()->SwapBuffers(); | 133 gpu::gles2::GLES2Implementation* impl = context_->gles2_impl(); |
| 134 if (impl) { |
| 135 context_->gles2_impl()->SwapBuffers(); |
| 136 } |
131 return true; | 137 return true; |
132 } | 138 } |
133 | 139 |
134 void PPB_Surface3D_Impl::ViewInitiatedPaint() { | 140 void PPB_Surface3D_Impl::ViewInitiatedPaint() { |
135 if (swap_callback_.func) { | 141 if (swap_callback_.func) { |
136 swap_initiated_ = true; | 142 swap_initiated_ = true; |
137 } | 143 } |
138 } | 144 } |
139 | 145 |
140 void PPB_Surface3D_Impl::ViewFlushedPaint() { | 146 void PPB_Surface3D_Impl::ViewFlushedPaint() { |
(...skipping 13 matching lines...) Expand all Loading... |
154 } | 160 } |
155 | 161 |
156 void PPB_Surface3D_Impl::OnSwapBuffers() { | 162 void PPB_Surface3D_Impl::OnSwapBuffers() { |
157 if (bound_to_instance_) | 163 if (bound_to_instance_) |
158 instance()->CommitBackingTexture(); | 164 instance()->CommitBackingTexture(); |
159 } | 165 } |
160 | 166 |
161 } // namespace ppapi | 167 } // namespace ppapi |
162 } // namespace webkit | 168 } // namespace webkit |
163 | 169 |
OLD | NEW |