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

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: Fix shutdown issue 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
« no previous file with comments | « ui/gl/async_pixel_transfer_delegate.h ('k') | ui/gl/async_pixel_transfer_delegate_stub.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 fcad1eb9a29909d9a69e996b9c1f4a0b75188d77..e96611aef25f9c93df2b54ff6027d4f3d646707d 100644
--- a/ui/gl/async_pixel_transfer_delegate_android.cc
+++ b/ui/gl/async_pixel_transfer_delegate_android.cc
@@ -159,8 +159,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,
@@ -251,7 +250,7 @@ class TransferStateInternal
}
protected:
- friend class base::RefCountedThreadSafe<TransferStateInternal>;
+ friend class base::RefCounted<TransferStateInternal>;
friend class AsyncPixelTransferDelegateAndroid;
static void DeleteTexture(GLuint id) {
@@ -330,7 +329,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,
@@ -360,6 +360,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(
@@ -444,19 +450,23 @@ AsyncPixelTransferState*
use_image_preserved));
}
-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) {
« no previous file with comments | « ui/gl/async_pixel_transfer_delegate.h ('k') | ui/gl/async_pixel_transfer_delegate_stub.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698