1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef UI_GL_ASYNC_TASK_DELEGATE_IDLE_H_
6 #define UI_GL_ASYNC_TASK_DELEGATE_IDLE_H_
11 #include "base/callback.h"
12 #include "ui/gl/async_pixel_transfer_delegate.h"
16 class TransferStateInternalIdle
;
17 class ScopedSafeSharedMemory
;
19 // Class which handles async pixel transfers in a platform
21 class AsyncPixelTransferDelegateIdle
: public AsyncPixelTransferDelegate
,
22 public base::SupportsWeakPtr
<AsyncPixelTransferDelegateIdle
> {
24 static scoped_ptr
<AsyncPixelTransferDelegate
>
25 Create(gfx::GLContext
* context
);
27 AsyncPixelTransferDelegateIdle();
28 virtual ~AsyncPixelTransferDelegateIdle();
30 // implement AsyncPixelTransferDelegate:
31 virtual bool BindCompletedAsyncTransfers() OVERRIDE
;
32 virtual void AsyncNotifyCompletion(
33 const AsyncMemoryParams
& mem_params
,
34 const CompletionCallback
& callback
) OVERRIDE
;
35 virtual void AsyncTexImage2D(
36 AsyncPixelTransferState
* transfer_state
,
37 const AsyncTexImage2DParams
& tex_params
,
38 const AsyncMemoryParams
& mem_params
,
39 const base::Closure
& bind_callback
) OVERRIDE
;
40 virtual void AsyncTexSubImage2D(
41 AsyncPixelTransferState
* transfer_state
,
42 const AsyncTexSubImage2DParams
& tex_params
,
43 const AsyncMemoryParams
& mem_params
) OVERRIDE
;
44 virtual void WaitForTransferCompletion(
45 AsyncPixelTransferState
* transfer_state
) OVERRIDE
;
46 virtual uint32
GetTextureUploadCount() OVERRIDE
;
47 virtual base::TimeDelta
GetTotalTextureUploadTime() OVERRIDE
;
48 virtual bool ProcessMorePendingTransfers() OVERRIDE
;
49 virtual bool NeedsProcessMorePendingTransfers() OVERRIDE
;
53 Task(uint64 transfer_id
, const base::Closure
& task
);
56 // This is non-zero if pixel transfer task.
62 void ProcessNotificationTasks();
64 // implement AsyncPixelTransferDelegate:
65 virtual AsyncPixelTransferState
*
66 CreateRawPixelTransferState(
68 const AsyncTexImage2DParams
& define_params
) OVERRIDE
;
70 void PerformNotifyCompletion(
71 AsyncMemoryParams mem_params
,
72 ScopedSafeSharedMemory
* safe_shared_memory
,
73 const CompletionCallback
& callback
);
74 void PerformAsyncTexImage2D(
75 AsyncTexImage2DParams tex_params
,
76 AsyncMemoryParams mem_params
,
77 const base::Closure
& bind_callback
,
78 ScopedSafeSharedMemory
* safe_shared_memory
,
80 void PerformAsyncTexSubImage2D(
81 AsyncTexSubImage2DParams tex_params
,
82 AsyncMemoryParams mem_params
,
83 ScopedSafeSharedMemory
* safe_shared_memory
,
86 int texture_upload_count_
;
87 base::TimeDelta total_texture_upload_time_
;
89 std::list
<Task
> tasks_
;
91 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferDelegateIdle
);
96 #endif // UI_GL_ASYNC_TASK_DELEGATE_IDLE_H_