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

Unified Diff: ui/gl/async_pixel_transfer_delegate_android.cc

Issue 12213073: Re-land: Mark async texture uploads as completed from the upload thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Keep replies. Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: ui/gl/async_pixel_transfer_delegate_android.cc
diff --git a/ui/gl/async_pixel_transfer_delegate_android.cc b/ui/gl/async_pixel_transfer_delegate_android.cc
index 68c329f162ab4df9febe1f351f73ba2e492a8f55..7997926587a68c6d6cc160c07281c3b3798b4e2e 100644
--- a/ui/gl/async_pixel_transfer_delegate_android.cc
+++ b/ui/gl/async_pixel_transfer_delegate_android.cc
@@ -133,8 +133,7 @@ base::MessageLoopProxy* transfer_message_loop_proxy() {
// Class which holds async pixel transfers state (EGLImage).
// The EGLImage is accessed by either thread, but everything
// else accessed only on the main thread.
-class TransferStateInternal
- : public base::RefCountedThreadSafe<TransferStateInternal> {
+class TransferStateInternal : public base::RefCounted<TransferStateInternal> {
public:
explicit TransferStateInternal(GLuint texture_id,
bool wait_for_uploads,
@@ -234,7 +233,7 @@ class TransferStateInternal
}
protected:
- friend class base::RefCountedThreadSafe<TransferStateInternal>;
+ friend class base::RefCounted<TransferStateInternal>;
friend class AsyncPixelTransferDelegateAndroid;
static void DeleteTexture(GLuint id) {
@@ -313,7 +312,8 @@ class AsyncPixelTransferDelegateAndroid
// implement AsyncPixelTransferDelegate:
virtual void AsyncNotifyCompletion(
- const base::Closure& task) OVERRIDE;
+ const AsyncMemoryParams& mem_params,
+ const CompletionCallback& callback) OVERRIDE;
virtual void AsyncTexImage2D(
AsyncPixelTransferState* state,
const AsyncTexImage2DParams& tex_params,
@@ -343,6 +343,12 @@ class AsyncPixelTransferDelegateAndroid
AsyncTexSubImage2DParams tex_params,
base::SharedMemory* shared_memory,
uint32 shared_memory_data_offset);
+ static void PerformNotifyCompletion(
+ base::SharedMemory* shared_memory,
+ uint32 shared_memory_size,
+ uint32 shared_memory_data_offset,
+ uint32 shared_memory_data_size,
+ const CompletionCallback& callback);
// Returns true if a work-around was used.
bool WorkAroundAsyncTexImage2D(
@@ -422,19 +428,23 @@ AsyncPixelTransferState*
wait_for_egl_images));
}
-namespace {
-// Dummy function to measure completion on
-// the upload thread.
-void NoOp() {}
-} // namespace
-
void AsyncPixelTransferDelegateAndroid::AsyncNotifyCompletion(
- const base::Closure& task) {
- // Post a no-op task to the upload thread followed
- // by a reply to the callback. The reply will then occur after
- // all async transfers are complete.
- transfer_message_loop_proxy()->PostTaskAndReply(FROM_HERE,
- base::Bind(&NoOp), task);
+ const AsyncMemoryParams& mem_params,
+ const CompletionCallback& callback) {
+ DCHECK(mem_params.shared_memory);
+ DCHECK_LE(mem_params.shm_data_offset + mem_params.shm_data_size,
+ mem_params.shm_size);
+ // Post a PerformNotifyCompletion task to the upload thread. This task
+ // will run after all async transfers are complete.
+ transfer_message_loop_proxy()->PostTask(
+ FROM_HERE,
+ base::Bind(&AsyncPixelTransferDelegateAndroid::PerformNotifyCompletion,
+ base::Owned(DuplicateSharedMemory(mem_params.shared_memory,
+ mem_params.shm_size)),
+ mem_params.shm_size,
+ mem_params.shm_data_offset,
+ mem_params.shm_data_size,
+ callback));
}
void AsyncPixelTransferDelegateAndroid::AsyncTexImage2D(
@@ -660,6 +670,20 @@ void AsyncPixelTransferDelegateAndroid::PerformAsyncTexSubImage2D(
state->last_transfer_time_ = base::TimeTicks::HighResNow() - begin_time;
}
+void AsyncPixelTransferDelegateAndroid::PerformNotifyCompletion(
+ base::SharedMemory* shared_memory,
+ uint32 shared_memory_size,
+ uint32 shared_memory_data_offset,
+ uint32 shared_memory_data_size,
+ const CompletionCallback& callback) {
+ TRACE_EVENT0("gpu", "PerformNotifyCompletion");
+ gfx::AsyncMemoryParams mem_params;
+ mem_params.shared_memory = shared_memory;
+ mem_params.shm_size = shared_memory_size;
+ mem_params.shm_data_offset = shared_memory_data_offset;
+ mem_params.shm_data_size = shared_memory_data_size;
+ callback.Run(mem_params);
+}
namespace {
bool IsPowerOfTwo (unsigned int x) {

Powered by Google App Engine
This is Rietveld 408576698