Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Side by Side Diff: ui/gl/async_pixel_transfer_delegate_android.cc

Issue 12040049: gpu: Implement idle async pixel transfers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add DCHECKs to ensure idle async uploads are only used with GL_TEXTURE_2D target Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gl/async_pixel_transfer_delegate.h ('k') | ui/gl/async_pixel_transfer_delegate_idle.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <list> 7 #include <list>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 void DoFullTexSubImage2D(const AsyncTexImage2DParams& tex_params, void* data) { 106 void DoFullTexSubImage2D(const AsyncTexImage2DParams& tex_params, void* data) {
107 glTexSubImage2D( 107 glTexSubImage2D(
108 GL_TEXTURE_2D, tex_params.level, 108 GL_TEXTURE_2D, tex_params.level,
109 0, 0, tex_params.width, tex_params.height, 109 0, 0, tex_params.width, tex_params.height,
110 tex_params.format, tex_params.type, data); 110 tex_params.format, tex_params.type, data);
111 } 111 }
112 112
113 // Gets the address of the data from shared memory. 113 // Gets the address of the data from shared memory.
114 void* GetAddress(SharedMemory* shared_memory, uint32 shm_data_offset) { 114 void* GetAddress(SharedMemory* shared_memory, uint32 shm_data_offset) {
115 // Memory bounds have already been validated, so there 115 // Memory bounds have already been validated, so there
116 // is just DCHECKS here. 116 // are just DCHECKS here.
117 CHECK(shared_memory); 117 CHECK(shared_memory);
118 CHECK(shared_memory->memory()); 118 CHECK(shared_memory->memory());
119 return static_cast<int8*>(shared_memory->memory()) + shm_data_offset; 119 return static_cast<int8*>(shared_memory->memory()) + shm_data_offset;
120 } 120 }
121 121
122 class TransferThread : public base::Thread { 122 class TransferThread : public base::Thread {
123 public: 123 public:
124 TransferThread() : base::Thread(kAsyncTransferThreadName) { 124 TransferThread() : base::Thread(kAsyncTransferThreadName) {
125 Start(); 125 Start();
126 } 126 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 205
206 void BindTransfer() { 206 void BindTransfer() {
207 TRACE_EVENT2("gpu", "BindAsyncTransfer glEGLImageTargetTexture2DOES", 207 TRACE_EVENT2("gpu", "BindAsyncTransfer glEGLImageTargetTexture2DOES",
208 "width", define_params_.width, 208 "width", define_params_.width,
209 "height", define_params_.height); 209 "height", define_params_.height);
210 DCHECK(texture_id_); 210 DCHECK(texture_id_);
211 DCHECK_NE(EGL_NO_IMAGE_KHR, egl_image_); 211 DCHECK_NE(EGL_NO_IMAGE_KHR, egl_image_);
212 212
213 // We can only change the active texture and unit 0, 213 // We can only change the active texture and unit 0,
214 // as that is all that will be restored. 214 // as that is all that will be restored.
215 glActiveTexture(GL_TEXTURE0);
216 glBindTexture(GL_TEXTURE_2D, texture_id_); 215 glBindTexture(GL_TEXTURE_2D, texture_id_);
217 glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, egl_image_); 216 glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, egl_image_);
218 bind_callback_.Run(); 217 bind_callback_.Run();
219 218
220 DCHECK(CHECK_GL()); 219 DCHECK(CHECK_GL());
221 } 220 }
222 221
223 void CreateEglImage(GLuint texture_id) { 222 void CreateEglImage(GLuint texture_id) {
224 TRACE_EVENT0("gpu", "eglCreateImageKHR"); 223 TRACE_EVENT0("gpu", "eglCreateImageKHR");
225 DCHECK(texture_id); 224 DCHECK(texture_id);
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 const AsyncMemoryParams& mem_params, 376 const AsyncMemoryParams& mem_params,
378 const base::Closure& bind_callback) OVERRIDE; 377 const base::Closure& bind_callback) OVERRIDE;
379 virtual void AsyncTexSubImage2D( 378 virtual void AsyncTexSubImage2D(
380 AsyncPixelTransferState* state, 379 AsyncPixelTransferState* state,
381 const AsyncTexSubImage2DParams& tex_params, 380 const AsyncTexSubImage2DParams& tex_params,
382 const AsyncMemoryParams& mem_params) OVERRIDE; 381 const AsyncMemoryParams& mem_params) OVERRIDE;
383 virtual void WaitForTransferCompletion( 382 virtual void WaitForTransferCompletion(
384 AsyncPixelTransferState* state) OVERRIDE; 383 AsyncPixelTransferState* state) OVERRIDE;
385 virtual uint32 GetTextureUploadCount() OVERRIDE; 384 virtual uint32 GetTextureUploadCount() OVERRIDE;
386 virtual base::TimeDelta GetTotalTextureUploadTime() OVERRIDE; 385 virtual base::TimeDelta GetTotalTextureUploadTime() OVERRIDE;
386 virtual bool ProcessMorePendingTransfers() OVERRIDE;
387 virtual bool NeedsProcessMorePendingTransfers() OVERRIDE;
387 388
388 private: 389 private:
389 // implement AsyncPixelTransferDelegate: 390 // implement AsyncPixelTransferDelegate:
390 virtual AsyncPixelTransferState* 391 virtual AsyncPixelTransferState*
391 CreateRawPixelTransferState(GLuint texture_id, 392 CreateRawPixelTransferState(GLuint texture_id,
392 const AsyncTexImage2DParams& define_params) OVERRIDE; 393 const AsyncTexImage2DParams& define_params) OVERRIDE;
393 394
394 static void PerformNotifyCompletion( 395 static void PerformNotifyCompletion(
395 AsyncMemoryParams mem_params, 396 AsyncMemoryParams mem_params,
396 ScopedSafeSharedMemory* safe_shared_memory, 397 ScopedSafeSharedMemory* safe_shared_memory,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 // creation on the main thread as a work-around. 477 // creation on the main thread as a work-around.
477 bool wait_for_creation = is_qualcomm_; 478 bool wait_for_creation = is_qualcomm_;
478 479
479 // Qualcomm has a race when using image_preserved=FALSE, 480 // Qualcomm has a race when using image_preserved=FALSE,
480 // which can result in black textures even after the first upload. 481 // which can result in black textures even after the first upload.
481 // Since using FALSE is mainly for performance (to avoid layout changes), 482 // Since using FALSE is mainly for performance (to avoid layout changes),
482 // but Qualcomm itself doesn't seem to get any performance benefit, 483 // but Qualcomm itself doesn't seem to get any performance benefit,
483 // we just using image_preservedd=TRUE on Qualcomm as a work-around. 484 // we just using image_preservedd=TRUE on Qualcomm as a work-around.
484 bool use_image_preserved = is_qualcomm_ || is_imagination_; 485 bool use_image_preserved = is_qualcomm_ || is_imagination_;
485 486
486 return static_cast<AsyncPixelTransferState*>( 487 return new AsyncTransferStateAndroid(texture_id,
487 new AsyncTransferStateAndroid(texture_id, 488 define_params,
488 define_params, 489 wait_for_uploads,
489 wait_for_uploads, 490 wait_for_creation,
490 wait_for_creation, 491 use_image_preserved);
491 use_image_preserved));
492 } 492 }
493 493
494 bool AsyncPixelTransferDelegateAndroid::BindCompletedAsyncTransfers() { 494 bool AsyncPixelTransferDelegateAndroid::BindCompletedAsyncTransfers() {
495 bool texture_dirty = false; 495 bool texture_dirty = false;
496 while(!pending_allocations_.empty()) { 496 while(!pending_allocations_.empty()) {
497 if (!pending_allocations_.front().get()) { 497 if (!pending_allocations_.front().get()) {
498 pending_allocations_.pop_front(); 498 pending_allocations_.pop_front();
499 continue; 499 continue;
500 } 500 }
501 scoped_refptr<TransferStateInternal> state = 501 scoped_refptr<TransferStateInternal> state =
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 return texture_upload_stats_->GetStats(NULL); 651 return texture_upload_stats_->GetStats(NULL);
652 } 652 }
653 653
654 base::TimeDelta AsyncPixelTransferDelegateAndroid::GetTotalTextureUploadTime() { 654 base::TimeDelta AsyncPixelTransferDelegateAndroid::GetTotalTextureUploadTime() {
655 CHECK(texture_upload_stats_); 655 CHECK(texture_upload_stats_);
656 base::TimeDelta total_texture_upload_time; 656 base::TimeDelta total_texture_upload_time;
657 texture_upload_stats_->GetStats(&total_texture_upload_time); 657 texture_upload_stats_->GetStats(&total_texture_upload_time);
658 return total_texture_upload_time; 658 return total_texture_upload_time;
659 } 659 }
660 660
661 bool AsyncPixelTransferDelegateAndroid::ProcessMorePendingTransfers() {
662 return false;
663 }
664
665 bool AsyncPixelTransferDelegateAndroid::NeedsProcessMorePendingTransfers() {
666 return false;
667 }
668
669
661 namespace { 670 namespace {
662 void SetGlParametersForEglImageTexture() { 671 void SetGlParametersForEglImageTexture() {
663 // These params are needed for EGLImage creation to succeed on several 672 // These params are needed for EGLImage creation to succeed on several
664 // Android devices. I couldn't find this requirement in the EGLImage 673 // Android devices. I couldn't find this requirement in the EGLImage
665 // extension spec, but several devices fail without it. 674 // extension spec, but several devices fail without it.
666 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 675 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
667 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 676 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
668 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 677 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
669 } 678 }
670 } // namespace 679 } // namespace
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 if (texture_upload_stats_) { 897 if (texture_upload_stats_) {
889 texture_upload_stats_->AddUpload( 898 texture_upload_stats_->AddUpload(
890 base::TimeTicks::HighResNow() - begin_time); 899 base::TimeTicks::HighResNow() - begin_time);
891 } 900 }
892 901
893 DCHECK(CHECK_GL()); 902 DCHECK(CHECK_GL());
894 return true; 903 return true;
895 } 904 }
896 905
897 } // namespace gfx 906 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/async_pixel_transfer_delegate.h ('k') | ui/gl/async_pixel_transfer_delegate_idle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698