OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/gl/async_pixel_transfer_delegate_android.h" | 5 #include "ui/gl/async_pixel_transfer_delegate_android.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 // doing the first upload (or the texture remains black). | 214 // doing the first upload (or the texture remains black). |
215 // A fence after image creation didn't always work, but glFinish | 215 // A fence after image creation didn't always work, but glFinish |
216 // seems to always work, and this only happens on the upload thread. | 216 // seems to always work, and this only happens on the upload thread. |
217 if (wait_for_egl_images_) { | 217 if (wait_for_egl_images_) { |
218 TRACE_EVENT0("gpu", "glFinish"); | 218 TRACE_EVENT0("gpu", "glFinish"); |
219 glFinish(); | 219 glFinish(); |
220 } | 220 } |
221 } | 221 } |
222 | 222 |
223 void WaitForLastUpload() { | 223 void WaitForLastUpload() { |
224 if (!wait_for_uploads_) | 224 // This glFinish is just a safe-guard for if uploads have some |
225 return; | 225 // GPU action that needs to occur. We could use fences and try |
226 | 226 // to do this less often. However, on older drivers fences are |
227 // This fence is basically like calling glFinish, which is fine on | 227 // not always reliable (eg. Mali-400 just blocks forever). |
228 // the upload thread if uploads occur on the CPU. We may want to delay | 228 if (wait_for_uploads_) { |
229 // blocking on this fence if this causes any stalls. | 229 TRACE_EVENT0("gpu", "glFinish"); |
230 | 230 glFinish(); |
231 TRACE_EVENT0("gpu", "eglWaitSync"); | 231 } |
232 EGLDisplay display = eglGetCurrentDisplay(); | |
233 EGLSyncKHR fence = eglCreateSyncKHR(display, EGL_SYNC_FENCE_KHR, NULL); | |
234 EGLint flags = EGL_SYNC_FLUSH_COMMANDS_BIT_KHR; | |
235 EGLTimeKHR time = EGL_FOREVER_KHR; | |
236 eglClientWaitSyncKHR(display, fence, flags, time); | |
237 eglDestroySyncKHR(display, fence); | |
238 } | 232 } |
239 | 233 |
240 protected: | 234 protected: |
241 friend class base::RefCountedThreadSafe<TransferStateInternal>; | 235 friend class base::RefCountedThreadSafe<TransferStateInternal>; |
242 friend class AsyncPixelTransferDelegateAndroid; | 236 friend class AsyncPixelTransferDelegateAndroid; |
243 | 237 |
244 static void DeleteTexture(GLuint id) { | 238 static void DeleteTexture(GLuint id) { |
245 glDeleteTextures(1, &id); | 239 glDeleteTextures(1, &id); |
246 } | 240 } |
247 | 241 |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 data); | 757 data); |
764 } | 758 } |
765 texture_upload_count_++; | 759 texture_upload_count_++; |
766 total_texture_upload_time_ += base::TimeTicks::HighResNow() - begin_time; | 760 total_texture_upload_time_ += base::TimeTicks::HighResNow() - begin_time; |
767 | 761 |
768 DCHECK(CHECK_GL()); | 762 DCHECK(CHECK_GL()); |
769 return true; | 763 return true; |
770 } | 764 } |
771 | 765 |
772 } // namespace gfx | 766 } // namespace gfx |
OLD | NEW |