OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "gpu/command_buffer/service/async_pixel_transfer_manager_egl.h" | 5 #include "gpu/command_buffer/service/async_pixel_transfer_manager_egl.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 163 |
164 bool TransferIsInProgress() { | 164 bool TransferIsInProgress() { |
165 return !transfer_completion_.IsSignaled(); | 165 return !transfer_completion_.IsSignaled(); |
166 } | 166 } |
167 | 167 |
168 void BindTransfer() { | 168 void BindTransfer() { |
169 TRACE_EVENT2("gpu", "BindAsyncTransfer glEGLImageTargetTexture2DOES", | 169 TRACE_EVENT2("gpu", "BindAsyncTransfer glEGLImageTargetTexture2DOES", |
170 "width", define_params_.width, | 170 "width", define_params_.width, |
171 "height", define_params_.height); | 171 "height", define_params_.height); |
172 DCHECK(texture_id_); | 172 DCHECK(texture_id_); |
173 DCHECK_NE(EGL_NO_IMAGE_KHR, egl_image_); | 173 if (EGL_NO_IMAGE_KHR == egl_image_) |
| 174 return; |
174 | 175 |
175 glBindTexture(GL_TEXTURE_2D, texture_id_); | 176 glBindTexture(GL_TEXTURE_2D, texture_id_); |
176 glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, egl_image_); | 177 glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, egl_image_); |
177 bind_callback_.Run(); | 178 bind_callback_.Run(); |
178 | 179 |
179 DCHECK(CHECK_GL()); | 180 DCHECK(CHECK_GL()); |
180 } | 181 } |
181 | 182 |
182 void CreateEglImage(GLuint texture_id) { | 183 void CreateEglImage(GLuint texture_id) { |
183 TRACE_EVENT0("gpu", "eglCreateImageKHR"); | 184 TRACE_EVENT0("gpu", "eglCreateImageKHR"); |
(...skipping 12 matching lines...) Expand all Loading... |
196 EGL_IMAGE_PRESERVED_KHR, image_preserved, | 197 EGL_IMAGE_PRESERVED_KHR, image_preserved, |
197 EGL_NONE | 198 EGL_NONE |
198 }; | 199 }; |
199 egl_image_ = eglCreateImageKHR( | 200 egl_image_ = eglCreateImageKHR( |
200 egl_display, | 201 egl_display, |
201 egl_context, | 202 egl_context, |
202 egl_target, | 203 egl_target, |
203 egl_buffer, | 204 egl_buffer, |
204 egl_attrib_list); | 205 egl_attrib_list); |
205 | 206 |
206 DCHECK_NE(EGL_NO_IMAGE_KHR, egl_image_); | 207 DLOG_IF(ERROR, EGL_NO_IMAGE_KHR == egl_image_) |
| 208 << "eglCreateImageKHR failed"; |
207 } | 209 } |
208 | 210 |
209 void CreateEglImageOnUploadThread() { | 211 void CreateEglImageOnUploadThread() { |
210 CreateEglImage(thread_texture_id_); | 212 CreateEglImage(thread_texture_id_); |
211 } | 213 } |
212 | 214 |
213 void CreateEglImageOnMainThreadIfNeeded() { | 215 void CreateEglImageOnMainThreadIfNeeded() { |
214 if (egl_image_ == EGL_NO_IMAGE_KHR) { | 216 if (egl_image_ == EGL_NO_IMAGE_KHR) { |
215 CreateEglImage(texture_id_); | 217 CreateEglImage(texture_id_); |
216 if (wait_for_creation_) { | 218 if (wait_for_creation_) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 ScopedSafeSharedMemory* safe_shared_memory, | 254 ScopedSafeSharedMemory* safe_shared_memory, |
253 scoped_refptr<AsyncPixelTransferUploadStats> texture_upload_stats) { | 255 scoped_refptr<AsyncPixelTransferUploadStats> texture_upload_stats) { |
254 TRACE_EVENT2("gpu", | 256 TRACE_EVENT2("gpu", |
255 "PerformAsyncTexImage", | 257 "PerformAsyncTexImage", |
256 "width", | 258 "width", |
257 tex_params.width, | 259 tex_params.width, |
258 "height", | 260 "height", |
259 tex_params.height); | 261 tex_params.height); |
260 DCHECK(!thread_texture_id_); | 262 DCHECK(!thread_texture_id_); |
261 DCHECK_EQ(0, tex_params.level); | 263 DCHECK_EQ(0, tex_params.level); |
262 DCHECK_EQ(EGL_NO_IMAGE_KHR, egl_image_); | 264 if (EGL_NO_IMAGE_KHR == egl_image_) { |
| 265 MarkAsCompleted(); |
| 266 return; |
| 267 } |
263 | 268 |
264 void* data = | 269 void* data = |
265 AsyncPixelTransferDelegate::GetAddress(safe_shared_memory, mem_params); | 270 AsyncPixelTransferDelegate::GetAddress(safe_shared_memory, mem_params); |
266 | 271 |
267 base::TimeTicks begin_time; | 272 base::TimeTicks begin_time; |
268 if (texture_upload_stats.get()) | 273 if (texture_upload_stats.get()) |
269 begin_time = base::TimeTicks::HighResNow(); | 274 begin_time = base::TimeTicks::HighResNow(); |
270 | 275 |
271 { | 276 { |
272 TRACE_EVENT0("gpu", "glTexImage2D no data"); | 277 TRACE_EVENT0("gpu", "glTexImage2D no data"); |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 | 765 |
761 AsyncPixelTransferDelegate* | 766 AsyncPixelTransferDelegate* |
762 AsyncPixelTransferManagerEGL::CreatePixelTransferDelegateImpl( | 767 AsyncPixelTransferManagerEGL::CreatePixelTransferDelegateImpl( |
763 gles2::TextureRef* ref, | 768 gles2::TextureRef* ref, |
764 const AsyncTexImage2DParams& define_params) { | 769 const AsyncTexImage2DParams& define_params) { |
765 return new AsyncPixelTransferDelegateEGL( | 770 return new AsyncPixelTransferDelegateEGL( |
766 &shared_state_, ref->service_id(), define_params); | 771 &shared_state_, ref->service_id(), define_params); |
767 } | 772 } |
768 | 773 |
769 } // namespace gpu | 774 } // namespace gpu |
OLD | NEW |