| 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 137 |
| 138 swap_callback_ = callback; | 138 swap_callback_ = callback; |
| 139 gpu::gles2::GLES2Implementation* impl = context_->gles2_impl(); | 139 gpu::gles2::GLES2Implementation* impl = context_->gles2_impl(); |
| 140 if (impl) { | 140 if (impl) { |
| 141 context_->gles2_impl()->SwapBuffers(); | 141 context_->gles2_impl()->SwapBuffers(); |
| 142 } | 142 } |
| 143 return PP_ERROR_WOULDBLOCK; | 143 return PP_ERROR_WOULDBLOCK; |
| 144 } | 144 } |
| 145 | 145 |
| 146 void PPB_Surface3D_Impl::ViewInitiatedPaint() { | 146 void PPB_Surface3D_Impl::ViewInitiatedPaint() { |
| 147 if (swap_callback_.func) { | |
| 148 swap_initiated_ = true; | |
| 149 } | |
| 150 } | 147 } |
| 151 | 148 |
| 152 void PPB_Surface3D_Impl::ViewFlushedPaint() { | 149 void PPB_Surface3D_Impl::ViewFlushedPaint() { |
| 153 if (swap_initiated_ && swap_callback_.func) { | 150 if (swap_initiated_ && swap_callback_.func) { |
| 154 // We must clear swap_callback_ before issuing the callback. It will be | 151 // We must clear swap_callback_ before issuing the callback. It will be |
| 155 // common for the plugin to issue another SwapBuffers in response to the | 152 // common for the plugin to issue another SwapBuffers in response to the |
| 156 // callback, and we don't want to think that a callback is already pending. | 153 // callback, and we don't want to think that a callback is already pending. |
| 157 PP_CompletionCallback callback = PP_BlockUntilComplete(); | 154 PP_CompletionCallback callback = PP_BlockUntilComplete(); |
| 158 std::swap(callback, swap_callback_); | 155 std::swap(callback, swap_callback_); |
| 159 swap_initiated_ = false; | 156 swap_initiated_ = false; |
| 160 PP_RunCompletionCallback(&callback, PP_OK); | 157 PP_RunCompletionCallback(&callback, PP_OK); |
| 161 } | 158 } |
| 162 } | 159 } |
| 163 | 160 |
| 164 unsigned int PPB_Surface3D_Impl::GetBackingTextureId() { | 161 unsigned int PPB_Surface3D_Impl::GetBackingTextureId() { |
| 165 return context_ ? context_->platform_context()->GetBackingTextureId() : 0; | 162 return context_ ? context_->platform_context()->GetBackingTextureId() : 0; |
| 166 } | 163 } |
| 167 | 164 |
| 168 void PPB_Surface3D_Impl::OnSwapBuffers() { | 165 void PPB_Surface3D_Impl::OnSwapBuffers() { |
| 169 if (bound_to_instance_) | 166 if (bound_to_instance_) { |
| 170 instance()->CommitBackingTexture(); | 167 instance()->CommitBackingTexture(); |
| 168 swap_initiated_ = true; |
| 169 } else if (swap_callback_.func) { |
| 170 // If we're off-screen, no need to trigger compositing so run the callback |
| 171 // immediately. |
| 172 PP_CompletionCallback callback = PP_BlockUntilComplete(); |
| 173 std::swap(callback, swap_callback_); |
| 174 swap_initiated_ = false; |
| 175 PP_RunCompletionCallback(&callback, PP_OK); |
| 176 } |
| 171 } | 177 } |
| 172 | 178 |
| 173 } // namespace ppapi | 179 } // namespace ppapi |
| 174 } // namespace webkit | 180 } // namespace webkit |
| 175 | 181 |
| OLD | NEW |